Installing stm32-sine using SWD  [SOLVED]

Post Reply
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Installing stm32-sine using SWD

Post 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?
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Installing stm32-sine using SWD

Post 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
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Installing stm32-sine using SWD  [SOLVED]

Post by johu »

Or just use the hex file as it's got the address in it
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Installing stm32-sine using SWD

Post by catphish »

Successfully tested using the following command on Linux:

Code: Select all

sudo st-flash write stm32_sine.bin 0x08001000
davefiddes
Posts: 211
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 14 times
Been thanked: 35 times

Re: Installing stm32-sine using SWD

Post 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"
            ]
        },
Post Reply