Thursday, March 13, 2025

Q&A: How to create a blinky baremetal application on STM32F407G-DISC1 using STM32CubeMX and Keil μVision

Q: How to create a blinky baremetal application on STM32F407G-DISC1 using STM32CubeMX and Keil μVision


Answer: Blinking an LED is the equivalent to creating a "Hello World" application to verify the IDE/tool/compiler are installed correctly on general purpose computers. We will be using STM32CubeMX and Keil μVision targetting STM32F407G-DISC for this exercise.

Pre-requisite:
- Hardware: STM32F407G-DISC
  • Part#: STM32F407G-DISC1
  • Vendor: STMicroelectronics
  • Board name: STM32F407G-DISC1
  • Description: DISCOVERY STM32F407/STM32F417
  • CPU: ARM® Cortex®-M4-based MCU with FPU
  • Frequency: 168 MHz
  • SRAM: 192KB
  • Flash: 1MB
- Host: Windows 10 LTSC 2021
- Keil μVision already installed
- STM32CubeMX installed
- STSW-LINK009 USB Driver Installed


Step 0: On corporate environment with SSL inspection in place, add the corporate root CA certificate
PS C:\> C:\Users\u1\AppData\Local\Programs\STM32CubeMX\jre\bin\keytool.exe  -trustcacerts -cacerts -importcert -file C:\tmp\CorpRCA.cer -alias corp-v1 -storepass changeit
Notes:
- Change u1 to the correct user and/or path
- Chnage location to corporate certificate - CorpRCA.cer

Step 1: Open Keil uVision Pack Installer

Step 2: Install STM32F407G-DISC1 board support package (BSP)
Installing BSP will bring the License Agrement for Board Support Package (BSP), Device Family Pack (DFP) and Arm's Common Microcontroller Software Interface Standard (CMSIS) driver for STM32, hit on Next button everytime it shows up. Close Pack Installer once installation is complete.

Step 3: Create new Keil uVision project
Search for STM32F407, and then select STM32F407GTx in the treeview and hit on OK.
In Manage Run-Time Environment window, expand on Device | CubeMX. Then select the checkbox and hit on Resolve. Hit on OK to bring another window.
Do click on Start CubeMX. This should bring up STM32CubeMX - this can take awhile to load for the first time.

Step 4: Configure GPIO in STM32CubeMX
In System Core, click on drop down arrow and select GPIO.
Zoom into Pinout view, select pin PD12 and then GPIO Output as pin type.
From the previous step, change User Label to LD4 [Green Led]. The options will be explained in future blogs.
Save the project
Click on Generate Code
Click on Yes for the missing firmware package
You will need to login to ST to download the firmware.
Below shows I am logging in to ST. You may have to create an account as needed.
Accept License Agreement and hit on Finish button. The download and extraction may take awhile to complete.
Close the Code Generation dialog
Then exit the STM32CubeMX application.
Observe the code generated by STM32CubeMX as shown in Keil uVision
Now add code to blink LED4
See Github gist code below for the complete main.c

Step 5: Set Debug options
Do Project | Options for Target *
Select Debug tab, see @(1). Then ensure ST-Link Debugger is selected, see @(2). Then click on Settings, see @(3).
In Debug Adapater pane, ensure Unit is set to ST-LINK/V2-1. Then hit on OK, see @(2)
Finally, Build and Download to your target.

Installing STSW-LINK009 USB Driver

 STSW-LINK009 USB driver is for ST-LINK/V2, ST-LINK/V2-1, and STLINK-V3 boards and derivatives (STM8/STM32 Discovery kits, STM8/STM32 Evaluation boards, and STM32 Nucleo boards). It declares the USB interfaces provided by the ST-LINK to the system as ST Debug port, Virtual COM port, and ST Bridge interfaces.


  1. Download installer from https://www.st.com/en/development-tools/stsw-link009.html

  2. Extract en.stsw-link009.zip

  3. Run "C:\Installer\STM32F407G-DISC1\en.stsw-link009\stlink_winusb_install.bat" as administrator

  1. Welcome Device Driver Installation, click Next. 

  1. Install Universal Serial Bus driver


  1. At this point, you should now be able to plug-in your STM32F407G-DISC1


REF: DocMe: 01-Driver-Installation


Saturday, March 8, 2025

Installing STM32CubeMX on Windows 10

Installing STM32CubeMX on Windows 10



Pre-requisite:
- Host: Windows 10 LTSC 2021
- STM32CubeMX downloaded from https://www.st.com/en/development-tools/stm32cubemx.html, as of this writting, the version available is SetupSTM32CubeMX-6.14.0-Win.


Below shows installation screens for STM32CubeMX on Windows 10.

Sunday, February 16, 2025

Running Project 0 for LAUNCHXL2-RM46 development board

Running Project 0 for LAUNCHXL2-RM46 development board

Project 0 is simple example to verify that LAUNCHXL2-RM46 and the environment is working by blinking an LED.

Pre-requisite:
Tested on the following:
- Host: Windows 10 IoT LTSC 2021
- Code Composer Studio 9.3.x

Step 1. Clone git repo for Hecules examples.
PS C:\> mkdir c:\repo
PS C:\> cd c:\repo
PS C:\> git clone https://git.ti.com/git/hercules_examples/hercules_examples.git

Step 2. Import into Code Composer Studio 9.3.x.

Open CCS 9.3.x

Ensure CCS Edit perspective is active

Import Project 0
If your CCS 9.3.x looks like below, then you have to restore the view.
Click on Restore button to view Project Explorer
Below is the Project Explorer view that is needed
Inside Project Explorer area, right click and do Import | CSS Projects
Naviate to Project 0 inside the repo (C:\repo\hercules_examples\Launchpad\RM\RM46L8\Project_0)
Project 0 loaded
Step 3: Debug the project!
You should see lots of activities and in the Console Window (Windows | Show View | Console), a message shows "System Reset" and the LED should start blinking at this point.

References:
TI git repo site - https://git.ti.com/cgit/hercules_examples/hercules_examples/
My Project 0 repo - https://github.com/myLAUNCHXL2-RM46/Project0

Friday, January 31, 2025

Installing Texas Instruments Code Composer Studio IDE (CCS 20.x) for LAUNCHXL2-RM46 development kit on Windows 10

Installing Texas Instruments Code Composer Studio IDE (CCS 20.x) for LAUNCHXL2-RM46 development kit on Windows 10

Code Composer Studio is an integrated development environment (IDE) for TI's microcontrollers and processors. It is comprised of a rich suite of tools used to build, debug, analyze and optimize embedded applications

Pre-requisite:
- Host: Windows 10 LTSC 2021
- Code Composer Studio IDE installer downloaded from https://www.ti.com/tool/CCSTUDIO, as of this writting (01/31/2025), the version available is ccs_setup_20.0.2.00005.exe.


Below shows how to install the application.


Welcome screen - hit on Next button
License Agreement - Accept and hit Next
Pre-check before installation
Installation Directory - use default
Select Componets - Hercules Safety MCU
Ready to Install!
Some packages may fail to install - perform as instructed
Installation Complete!

Q&A: How to create a blinky baremetal application on STM32F407G-DISC1 using STM32CubeMX and Keil μVision

Q: How to create a blinky baremetal application on STM32F407G-DISC1 using STM32CubeMX and Keil μVision Answer: Blinking an LED is the equiv...