2026-01-09 6:36 AM
I am using STM32CubeMX 6.16.1 to generate project with external Flash loader for STM32N6. When I generate for STM32CubeIDE and build the extmemloader then STM32CubeProgrammer can parse it (the .elf renamed to .stldr). But when I generate CMake project and build with vscode (with STM32 extensions) then STM32CubeProgrammer fails to parse. Compiler/linker removes the StorageInfo structure from output completely. I fooled it to keep it. Now it doesn't fail immediately, but still can't parse any info either.
Here's the CubeProgrammer EL list view. First is vscode built loader, second is Eclipse built:
I compared the ELF files, Map files, compiler and linker flags. There are plenty of differences and I haven't figured out what exactly causes it. I changed the flags but nothing helped. I noticed vscode uses GCC 14 and STM32CubeIDE uses GCC 13 but tricking vscode to use GCC 13 didn't solve it either.
2026-02-01 12:14 PM
Hi Mikk!
I am also struggling building external loaders with vscode and CMake. However, I have some mitigated sucess loading them in CubeProgrammer. Here is what I learned for now:
In the linker script used for building the external loader (probably linker.ld), it is stated that a segment is generated for device info
/* linker.ld */
...
/* Generate 2 segment for Loader code and device info */
PHDRS {Loader PT_LOAD ; SgInfo PT_LOAD ; }
...This segment is populated with the `Dev_Inf.o` object, indeed containing all the device information. So first, make sure you haven't renamed the `Dev_Inf.c` file, otherwise the object name won't match with the one declared in the linker script.
Then, I had an other hassle. Apparently, and I did not spend much time finding why, when generating a code for CMake with CubeMX (and maybe fiddling a bit with the CMake files...) the output objects are not suffixed with .o, but keep the original file name (with .c) and are suffixed with .obj.
Thus I had to replace in the linker script:
/* linker.ld */
...
.Dev_info :
{
KEEP(*Dev_Inf.o ( .rodata* ))
} :SgInfo
...by:
/* linker.ld */
...
.Dev_info :
{
KEEP(*Dev_Inf.c.obj ( .rodata* ))
} :SgInfo
...
Now my external loader shows with the right attributes in CubeProgrammer.
(And I can use it... kind of, it reads well my NOR flash, but then says that it does not, and I can't make it write on it...)
Hope this helps!