STM32 bootloader and linker question
First to say, I have read the documentation about the linker and explored some of the xml files, but I am still befuddled about what I am trying to do here! Next to say I have never even looked at a linker file before so am rather unsure of what I have read up in the Crossworks reference manual.
I have FreeRTOS running in an STM32F103RB. I need to shift where that starts executing from 0x8000000 to 0x8000800 freeing up space in the first 2k to have my little boot loader which will read a new image FreeRTOS has placed in external SPI flash and programme it into internal flash, starting at 0x8000800.(I might need a little more than 2k, but let's assume that's all I need for the time being!)
The reference manual talks about the xml files and specifically the Section Placement file. In my project manager in Linker Options this is claimed to be $(StudioDir)/targets/section_placement.xml but this file does not exist!
I found a memory map file: $(TargetsDir)/ST_STM32F10x/ST_STM32F103RB_MemoryMap.xml which is here:
.rowley_associates_limited/CrossWorks for ARM/packages/targets/STM32/STM32F103RB_MemoryMap.xml
And this does seem to partially indicate it is defining flash here:
<MemorySegment size="0x20000" access="ReadOnly" name="FLASH" start="0x08000000"/>
The size is wrong though.
This post:
http://rowley.zendesk.com/entries/509423-create-a-programsection-in-flash-not-working
Also talks about this section placement file.
One other thing that I am unclear of: when I have sorted the above and my boot loader has finished either upgrading the code or jumping straight out because there is no software to upgrade, how do you get it to jump to 0x8000400 to start the FreeRTOS application?
Many thanks!
-
Talking to myself, but stumbled across this thing where you can right click on the project and import the memory map. then worked out how to actually edit it, changed the size of flash and the starting point. This does seem to rebuild the project with the elf file showing the vectors starting at 0x8000800, so that looks good. Seems I was under a total misapprehension about needing a linker file changing. Hopefully this will help other people in future.
-
No! I have finally gone back to doing this. Seems I am very close in that I can create a hex file with the program starting at 0x8003000, I have written a bootloader which starts at 0x8000000, runs below 0x8003000, quite clearly reprograms the flash with what is in the hex file starting at 0x8003000 in the repositioned "normal" program, I seem to be able to jump to 0x8003004 and yet it doesn't run the repositioned program that starts at 0x8003000. I have, I think, repositioned the vector table too. I must be very close! I'll post answers when I finally suss it.
-
Now I have sorted it. The programming worked just fine, but there was a flash LED sequence at the start that was getting optimised out in the release code. Previously, I'd just been running debug code in the target (non-bootloader program). So, it really is as simple as importing the xml file and changing start point and size.
Please sign in to leave a comment.
Comments
5 comments