This goes over how to setup a development environment for embedded programming on macOS systems, specifically for the ARM Cortex STM32WB55 board (but probably applies generally for other boards with minor adjustments).
-
Follow this guide to setup the workfolder: https://gist.github.com/csukuangfj/bfe2be78eda3a24a5164005b1092c94b
I will add more detailed steps in this guide at a later time, as well as prerequisites for this setup.
-
Copy
/Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/SVD/STM32WB55_CM4.svd
(or the SVD that's appropriate for your specific board) to the root of your workfolder. -
Run:
ln -sv /Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin/STM32_Programmer_CLI /usr/local/bin/
-
Set up the following files in Visual Studio Code (adapt per your specific project name and folder structure):
settings.json
:launch.json
:{ "version": "0.2.0", "configurations": [ { "name": "ST-Link", "cwd": "${workspaceRoot}/build", "executable": "HelloWorld.elf", "request": "launch", "type": "cortex-debug", "servertype": "stutil", "serverpath": "st-util", "device": "STM32WB55", "interface": "swd", "gdbTarget": ":4242", "runToMain": true, "preLaunchTask": "build", "svdFile": "${workspaceRoot}/STM32WB55_CM4.svd", "swoConfig": {} } ] }
tasks.json
:{ "version": "2.0.0", "tasks": [ { "label": "build", "type": "shell", "command": "make -j", "options": { "cwd": "${workspaceFolder}" }, "presentation": { "clear": true }, "group": { "kind": "build", "isDefault": true }, "problemMatcher": { "base": "$gcc", "fileLocation": [ "autoDetect", "${workspaceFolder}" ] } }, { "label": "flash_fw", "type": "shell", "command": "st-flash write ./build/*.bin 0x08000000", "options": { "cwd": "${workspaceFolder}" }, "presentation": { "clear": true }, "problemMatcher": { "base": "$gcc", "fileLocation": [ "autoDetect", "${workspaceFolder}" ] } } ] }
c_cpp_properties.json
:{ "version": 4, "configurations": [ { "name": "STM32WB55", "includePath": [ "${workspaceFolder}/**", "${workspaceFolder}/../STM32CubeWB/Drivers", ], "defines": [ "USE_HAL_DRIVER", "STM32WB55xx" ], "intelliSenseMode": "gcc-arm", "compilerPath": "arm-none-eabi-gcc", "compilerArgs": [ "-mcpu=cortex-m4", "-mthumb" ], "cStandard": "c11" } ] }
-
Start the wireless stack:
STM32_Programmer_CLI -c port=swd -startfus STM32_Programmer_CLI -c port=swd mode=UR -fwupgrade stm32wb5x_Zigbee_FFD_fw.bin 0x080A2000 firstinstall=0
Find deviceL: ls -all /dev/*usb*
Run screen command: screen /dev/tty.usbmodem143303 115200