Page 1 of 1

Installing stm32-sine using SWD

Posted: Sat Jan 07, 2023 12:16 am
by catphish
I've started making changes to the OI code and I'm finding the ESP8266 serial update process to be much too unreliable for doing frequent updates. Instead I'd like to flash the firmware with SWD using an ST-Link-V2. Is there a specific location in flash I should write the stm32-sine.bin file so that it works and doesn't erase the bootloader?

Re: Installing stm32-sine using SWD

Posted: Sat Jan 07, 2023 1:06 am
by catphish
I found the answer myself. Hopefully it will be as simple as supplying these values to my flashing software.

Bootloader should be loaded at 0x08000000
Firmware should be loaded at 0x08001000

Re: Installing stm32-sine using SWD  [SOLVED]

Posted: Sat Jan 07, 2023 9:51 am
by johu
Or just use the hex file as it's got the address in it

Re: Installing stm32-sine using SWD

Posted: Sun Jan 08, 2023 12:27 pm
by catphish
Successfully tested using the following command on Linux:

Code: Select all

sudo st-flash write stm32_sine.bin 0x08001000

Re: Installing stm32-sine using SWD

Posted: Sun Mar 12, 2023 3:50 pm
by davefiddes
I use the cortex-debug extension in VS Code which is a fancy wrapper around arm-none-eabi-gdb and openocd. You can achieve the same result with raw gdb if you are into that sort of thing with .gdbinit scripts. A nice GUI debugger is quite handy. I found that hacking the bootloder to disable the watchdog was required. Things can obviously go south if you start single stepping through time critical code...

You need to install openocd and arm-none-eabi-gdb separately on your system.

My config from launch.json looks like:

Code: Select all

        {
            "name": "Debug Sine",
            "cwd": "${workspaceFolder}",
            "executable": "./stm32_sine",
            "request": "launch",
            "type": "cortex-debug",
            "servertype": "openocd",
            "interface": "swd",
            "device": "STM32F103RB",
            "configFiles": [
                "interface/stlink.cfg",
                "target/stm32f1x.cfg"
            ],
            "runToEntryPoint": "main",
            "preRestartCommands": [
                "load",
                "add-symbol-file ./stm32_sine 0x08001000",
                "set remote hardware-breakpoint-limit 6",
                "set remote hardware-watchpoint-limit 4",
                "enable breakpoint",
                "monitor reset",
                "monitor arm semihosting enable",
                "set output-radix 16"
            ]
        },