Flashing elf file in internal + external memory in STM32CubeIde
- January 20, 2023
- 9 replies
- 7850 views
I've successfully created a custom flash loader for the STM32H7A3ZIT6Q with the MT25TL256 dual-quad NOR FLASH. I can erase, program and read the external memory in STM32CubeProgrammer with a dummy file. Flashing an elf file with external flash data fails.
Memory mapping also works in my STM32CubeIDE project. The project has some dummy data in the external flash section. It shows up in the Build Analyzer. I can export the external memory section to a bin file, which I can manually flash with STM32CubeProgrammer. If I debug my application I can see the dummy variable is correctly initialized and in the right location.
I use the following post-build command to export my bin file:
arm-none-eabi-objcopy.exe -O binary --only-section=.textqspi "${BuildArtifactFileBaseName}.elf" textqspi.binI've added my flash loader to a new launch file and I get the following output:
STMicroelectronics ST-LINK GDB server. Version 7.1.0
Copyright (c) 2022, STMicroelectronics. All rights reserved.
Starting server with the following options:
Persistent Mode : Disabled
Logging Level : 1
Listen Port Number : 61234
Status Refresh Delay : 15s
Verbose Mode : Disabled
SWD Debug : Enabled
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
Failed to initialize external memorySTM32CubeProgrogrammer gives the following error if I select external flash column on the right before clicking on Start Programming:
16:52:39:365 : r ap 0 @0x1FF13FFE 0x00000004 bytes Data 0xFFFF0091
16:52:39:844 : Memory Programming ...
16:52:39:844 : Opening and parsing file: IDE-Prothese-base.elf
16:52:39:854 : File : IDE-Prothese-base.elf
16:52:39:854 : Size : 1.81 MB
16:52:39:854 : Address : 0x08000000
16:52:39:854 : Erasing Segment <0> Address <0x08000000> Size <1901070>Bytes
16:52:39:854 : Erasing memory corresponding to segment 0:
16:52:39:854 : Memory erase...
16:52:39:856 : halt ap 0
16:52:39:856 : w ap 0 reg 15 PC (0x24000000)
16:52:39:856 : w ap 0 reg 17 MSP (0x24000500)
16:52:39:856 : w ap 0 reg 16 xPSR (0x01000000)
16:52:39:859 : w ap 0 @0x24001140 0x00000200 bytes Data 0x00000000
16:52:39:859 : w ap 0 @0x24000000 0x00000004 bytes Data 0x0000BE00
16:52:39:861 : w ap 0 @0x24000004 0x00000D10 bytes Data 0x8F4FF3BF
16:52:39:861 : Erasing internal memory sectors [0 232]
16:52:39:861 : Init flashloader...
16:52:39:861 : halt ap 0
16:52:39:862 : w ap 0 reg 0 R0 0x00000001
16:52:39:863 : w ap 0 reg 1 R1 0x00000000
16:52:39:863 : w ap 0 reg 2 R2 0x00000000
16:52:39:864 : w ap 0 reg 3 R3 0x00000000
16:52:39:864 : w ap 0 reg 4 R4 0x00000000
16:52:39:864 : w ap 0 reg 5 R5 0x00000000
16:52:39:864 : w ap 0 reg 6 R6 0x00000000
16:52:39:864 : w ap 0 reg 7 R7 0x00000000
16:52:39:864 : w ap 0 reg 8 R8 0x00000000
16:52:39:864 : w ap 0 reg 9 R9 0x00000000
16:52:39:864 : w ap 0 reg 10 R10 0x00000000
16:52:39:864 : w ap 0 reg 11 R11 0x00000000
16:52:39:865 : w ap 0 reg 12 R12 0x00000000
16:52:39:865 : w ap 0 reg 13 SP 0x00000000
16:52:39:865 : w ap 0 reg 14 LR 0x24000001
16:52:39:866 : w ap 0 reg 15 PC 0x2400000B
16:52:39:866 : w ap 0 reg 16 xPSR 0x01000000
16:52:39:866 : w ap 0 reg 17 MSP 0x24001110
16:52:39:866 : w ap 0 reg 18 PSP 0x00000000
16:52:39:866 : run ap 0
16:52:39:866 : halt ap 0
16:52:39:866 : r ap 0 reg 0 R0 0x00000001
16:52:39:866 : Loader sector erase...
16:52:39:867 : w ap 0 reg 0 R0 0x08000000
16:52:39:867 : w ap 0 reg 1 R1 0x081D0000
16:52:39:867 : w ap 0 reg 2 R2 0x00000002
16:52:39:868 : w ap 0 reg 3 R3 0x00000000
16:52:39:868 : w ap 0 reg 4 R4 0x00000000
16:52:39:868 : w ap 0 reg 5 R5 0x00000000
16:52:39:868 : w ap 0 reg 6 R6 0x00000000
16:52:39:869 : w ap 0 reg 7 R7 0x00000000
16:52:39:869 : w ap 0 reg 8 R8 0x00000000
16:52:39:869 : w ap 0 reg 9 R9 0x00000000
16:52:39:869 : w ap 0 reg 10 R10 0x00000000
16:52:39:869 : w ap 0 reg 11 R11 0x00000000
16:52:39:869 : w ap 0 reg 12 R12 0x00000000
16:52:39:869 : w ap 0 reg 13 SP 0x00000000
16:52:39:870 : w ap 0 reg 14 LR 0x24000001
16:52:39:870 : w ap 0 reg 15 PC 0x2400086B
16:52:39:870 : w ap 0 reg 16 xPSR 0x01000000
16:52:39:870 : w ap 0 reg 17 MSP 0x24001110
16:52:39:870 : w ap 0 reg 18 PSP 0x00000000
16:52:39:870 : run ap 0
16:52:40:417 : halt ap 0
16:52:40:417 : r ap 0 reg 0 R0 0x00000000
16:52:40:418 : r ap 0 reg 16 xPSR 0x80000003
16:52:40:418 : Error: failed to erase memory
16:52:40:441 : Error: failed to erase memory
16:52:40:441 : r ap 0 @0x1FF13FFE 0x00000004 bytes Data 0xFFFF0091
16:52:41:411 : r ap 0 @0x1FF13FFE 0x00000004 bytes Data 0xFFFF0091
16:52:42:417 : r ap 0 @0x1FF13FFE 0x00000004 bytes Data 0xFFFF0091
16:52:43:421 : r ap 0 @0x1FF13FFE 0x00000004 bytes Data 0xFFFF0091I've tried different versions of STM32CubeIDE. 1.11.0 and 1.10.0. Both cannot flash my elf file.
How do I get STM32CubeIDE to flash my elf file in external memory too?
