Author Topic: Storing data in flash of micro at a specific place  (Read 1008 times)

0 Members and 1 Guest are viewing this topic.

Offline BoscoeTopic starter

  • Frequent Contributor
  • **
  • Posts: 276
Storing data in flash of micro at a specific place
« on: January 10, 2019, 10:31:49 pm »
Hi all,

I'm currently developing a product with a bootloader and an application program to go with it. For ease in production I would like to include the application binary into the C code of the bootloader to create one binary of bootloader + preinstalled application. I'm not sure how to do this as I need to store the application at a specific flash address - not just where the bootloader finishes. I'm using an STM32L052 micro.

Thanks
 

Offline lucazader

  • Regular Contributor
  • *
  • Posts: 221
  • Country: au
Re: Storing data in flash of micro at a specific place
« Reply #1 on: January 10, 2019, 10:35:44 pm »
A simple way (so long as you are doing using flash read out protection etc):
Program the bootloader and application as you normally would. to their respective locations.
Then read out the flash and save to a bin/hex file. (use stlink utility or stmcubeprogrammer).
 

Offline bson

  • Supporter
  • ****
  • Posts: 2270
  • Country: us
Re: Storing data in flash of micro at a specific place
« Reply #2 on: January 11, 2019, 12:44:40 am »
Build the bootloader and application as two separate images relocated to their respective load address, and then combine the images.  In a format like extended tekhex this is trivial since each record has a load address, you just need to make sure the only launch address remaining is that of the boot loader.

If you need them to be able to refer to each other using symbols, then you need to compile either or the other with a different psect prefix and handle section relocation in the link script.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: Storing data in flash of micro at a specific place
« Reply #3 on: January 11, 2019, 04:47:08 am »
How about just changing the Flash start address in the linker script.  In fact, you could create a .section for the bootloader code and just add the bootloader.o file to the list of files.  ld will handle the details.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf