Author Topic: STM32 IDE specifying address to start at  (Read 3021 times)

0 Members and 1 Guest are viewing this topic.

Offline ArioTopic starter

  • Regular Contributor
  • *
  • Posts: 54
  • Country: za
STM32 IDE specifying address to start at
« on: March 28, 2021, 09:38:53 pm »
Hi there

I 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

« Last Edit: March 28, 2021, 09:41:10 pm by Ario »
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2183
  • Country: au
Re: STM32 IDE specifying address to start at
« Reply #1 on: March 29, 2021, 03:37:45 am »
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 the GNU ARM Embedded Tool Chain

On 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 download

Just 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
 

Offline ArioTopic starter

  • Regular Contributor
  • *
  • Posts: 54
  • Country: za
Re: STM32 IDE specifying address to start at
« Reply #2 on: March 29, 2021, 04:59:12 am »
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.
 

Offline ArioTopic starter

  • Regular Contributor
  • *
  • Posts: 54
  • Country: za
Re: STM32 IDE specifying address to start at
« Reply #3 on: March 29, 2021, 05:21:32 am »
Will this be the place to change the address of where to start flashing code?
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2183
  • Country: au
Re: STM32 IDE specifying address to start at
« Reply #4 on: March 29, 2021, 03:48:35 pm »
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 location

Unless 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 do

Sorry I couldn't help you any further
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2183
  • Country: au
Re: STM32 IDE specifying address to start at
« Reply #5 on: March 29, 2021, 03:52:03 pm »
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
 
The following users thanked this post: Ario

Offline ArioTopic starter

  • Regular Contributor
  • *
  • Posts: 54
  • Country: za
Re: STM32 IDE specifying address to start at
« Reply #6 on: March 30, 2021, 05:42:33 am »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf