Thanks @maxgerhardt, it’s working now. It required three changes outlined below. One of them, is updating the openocd binaries from 0.11.0+dev (2021-10-16-21:19) to 0.12.0-00017-gb153daa14 (2023-02-03-14:58) (these versions are on Windows). Will it be possible to upgrade the openocd version that platformio installs? I got my binaries from an installation of ST Cube IDE on widnows.
For the record, here are the three changes:
1. Include const int uxTopUsedPriority in the link.
Its name should be non C++ mangled and should have an actual address, not 0x0000000 which means it was not optimized out.
This is how it should look in the linker map file:
.rodata.uxTopUsedPriority
0x0800d9ac 0x4 .pio/build/weact_mini_h750vbtx/src/main.o
0x0800d9ac uxTopUsedPriority
I achieved that by having this in my main.cpp (should be simpler in a .c):
extern "C" {
extern const int uxTopUsedPriority;
__attribute__((used)) const int uxTopUsedPriority = configMAX_PRIORITIES - 1;
}
int main(void) {
printf("%p\n", &uxTopUsedPriority);
...
}
2. Append ‘-rtos auto’ to the relevant openocd configuration script.
in my case it’s the file
~/.platformio/packages/tool-openocd/scripts/target/stm32h7x.cfg
And the line after the change is
$_CHIPNAME.cpu0 configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0 -rtos auto
3. Replace the openocd binaries with newer ones.
To do this deleted all the files in the opencd bin directory and place instead the binaries of the newer version.
Open OCD bin directory:
~/.platformio/packages/tool-openocd/bin
The old files in my case (windowz)
-rwxr-xr-x 1 user 197121 397027 Oct 16 2021 libftdi1.dll
-rwxr-xr-x 1 user 197121 209885 Oct 16 2021 libusb-1.0.dll
-rwxr-xr-x 1 user 197121 4075008 Oct 16 2021 openocd.exe
The new files in my case (window):
-rwxr-xr-x 1 user 197121 1102386 May 31 11:10 libgcc_s_sjlj-1.dll
-rwxr-xr-x 1 user 197121 328493 May 31 11:10 libhidapi-0.dll
-rwxr-xr-x 1 user 197121 1159378 May 31 11:10 libjaylink-0.dll
-rwxr-xr-x 1 user 197121 1058321 May 31 11:10 libusb-1.0.dll
-rwxr-xr-x 1 user 197121 530510 May 31 11:10 libwinpthread-1.dll
-rwxr-xr-x 1 user 197121 5083837 May 31 11:10 openocd.exe
The binaries files I used are here temp_public/openocd_bin_windows at main · zapta/temp_public · GitHub . They were copied from a windows install of ST Cube IDE 1.12.1.
EDIT: Upgrading the openocd binaries result in these (seems to be harmless) warnings. Would be nice to upgradethe scripts as well.
Warn : DEPRECATED! use 'read_memory' not 'mem2array'
EDIT2: This also preserved the variable in the map and works:
extern "C" {
extern const int uxTopUsedPriority;
__attribute__((section(".rodata"))) const int uxTopUsedPriority = configMAX_PRIORITIES - 1;
}
In the map:
.rodata 0x0800b500 0xf .pio/build/weact_mini_h750vbtx/src/main.o
0x0800b508 uxTopUsedPriority