STM32 IDE specifying address to start at - Page 1
Forum section: electronics / general

author: Ario
author_rank: Regular Contributor
timestamp: March 28, 2021, 09:38:53 pm
content: Hi thereI have a project originally developed in keill ide. It contains a boot loader for modbus communications. How would I set up STM IDE and cubemx to only start writing to flash at a certain memory address? I would like to add code to the flash of the controller without wiping erasing the bootloader at the start of the memory space. Any advice and guidance would be appreciated!!I know the address where the boot loader stops at. I am not sure how to set up the STM IDE ( build on eclipse) to not write over the boot loader at the start of the flash memory. Any advice?Kind regards

author: AlfBaz
author_rank: Super Contributor
timestamp: March 29, 2021, 03:37:45 am
content: That depends. Are you now using gcc to compile the new code or Keil?If it's gcc then you have to look at the linker script. I'm betting Keil uses a linker script also.From what I can see here on Cube IDE with gcc, 2 linker scripts are provided. One for writing code to RAM and one for writing code to flash. GCC linker scripts have a *.ld file extension.Not sure where Cube IDE installs GNU ARM GCC but the documentation is available in ld.pdf if you download and install theGNU ARM Embedded Tool ChainOn windows its installed at "C:\Program Files (x86)\GNU Arm Embedded Toolchain\X XXXX-qX-update\share\doc\gcc-arm-none-eabi\pdf\ld.pdf"X XXXX-qX will be what ever the latest version is you downloadJust a word of warning however be careful the programmer doesn't do a full chip erase prior to writing your code to the appropriate place

author: Ario
author_rank: Regular Contributor
timestamp: March 29, 2021, 04:59:12 am
content: Thank you so much for the response!Will I be able to specify the address in the linker scipt? I am using GNU tools for STM, as a toolchain.

author: Ario
author_rank: Regular Contributor
timestamp: March 29, 2021, 05:21:32 am
content: Will this be the place to change the address of where to start flashing code?

author: AlfBaz
author_rank: Super Contributor
timestamp: March 29, 2021, 03:48:35 pm
content: It has been a long time since I have done anything with linker scripts and even then it was minor tweaking, possibly even debugging something, I can not remember. This is why I referred you to the manual as well as the warning that merely changing the address might not prevent erasing the entire flash before programming the code into your desired locationUnless others chime in with further advise I'll have to leave it to you to investigate.If you have a spare micro or dev board experiment with it. You can usually use a programming device to fill the flash with a specific pattern, then with adjustments to the linker script generate and reprogram that same micro. If you read it back and the pattern has been wiped out you will have more work to doSorry I couldn't help you any further

author: AlfBaz
author_rank: Super Contributor
timestamp: March 29, 2021, 03:52:03 pm
content: Reading back your original post, do you have any documentation on the original boot loader? It most likely has a way to load and flash the code itself and may very well give some hint as to what is required from a linker script for code compiled for its use

author: Ario
author_rank: Regular Contributor
timestamp: March 30, 2021, 05:42:33 am
content: Hi thank you so much, you already put me in the right direction. No documentation is available, only the code. So at least if something goes wrong I can redo the bootloader.