[riot-users] How to flash at a specific address ?

Francisco Acosta francisco.acosta at inria.fr
Thu Mar 22 13:37:58 CET 2018


Hi,

Actually, you can override at runtime the size of your ROM with the variable ROM_LEN, and put the starting code at ROM_OFFSET. The cortex.ld linker script will take those values and replace them to produce the final ELF. Take a look at both cortexm.ld and Makefile.include at cpu/cortexm-common folder.

To produce a binary file either you add an extra rule like:

create-bin:
	$(OBJCOPY) -Obinary $(ELFFILE) $(BINFILE)

in one of your makefiles.

If you really want to use the make flash, then more modifications need to be done, depending which debugger are you using to flash.

You can always generate an ELF, it’s a bit more complicated but I did it in the past. You might take a look at (very old) [1] and [2].

Cheers!

Francisco Javier Acosta Padilla  
Research Engineer at INFINE team
Inria Saclay Ile-de-France

[1] https://github.com/kYc0o/RIOT/blob/487f8af6266387d7ea80fee5b06ab68674979d0d/cpu/stm32f1/ldscripts/stm32f103re-bootloader.ld
[2] https://github.com/kYc0o/RIOT/blob/487f8af6266387d7ea80fee5b06ab68674979d0d/examples/firmware_swapping/Makefile


On 22 March 2018 at 13:02:10, Aurélien Fillau (aurelien.fillau at gmail.com) wrote:
> Hi,
>  
> Thank you very much for your reply.
> Actually, i would like to continue using the following "make flash" target
> if possible. I'm calling a script by overiding PRE_FLASH_CHECK_SCRIPT
> variable. This script is adding some informations to my binary. i saw that
> i can flash HEX file by modifying this variable : "export IMAGE_FILE =
> $(HEXFILE)" but it seems that BIN file is not generated after compilation,
> only ELF and HEX files. With HEX file, there is no more corruption issue
> when i flash my main application. But unfortunatly, my script can only
> handles ELF or BIN file as input.
> So is it possible to generate a BIN file as output and flashing it by using
> "make flash" ?
>  
> Regards,
>  
> Aurélien
>  
> 2018-03-21 18:45 GMT+01:00 Francisco Acosta :
>  
> > Hi Aurélien,
> >
> > This is completely normal. Whenever you flash an ELF file the “not used”
> > ROM will become 0.
> >
> > What you might do is some magic to generate a “.o" file from your
> > bootloader ELF and link it in a single ELF file together with your
> > application.
> >
> > Or, you can flash everything as BIN, with openocd you can place it
> > wherever you want.
> >
> > I have already tried something like that in some of my PRs regarding OTA
> > and bootloader. You might look at them to have an example.
> >
> > Cheers,
> >
> > Francisco Javier Acosta Padilla
> > Research Engineer at INFINE team
> > Inria Saclay Ile-de-France
> >
> > On 21 March 2018 at 18:37:39, Aurélien Fillau (aurelien.fillau at gmail.com)
> > wrote:
> > > Hello,
> > >
> > > I'm currently working on a stm32l073 on a custom board. I'm writing an
> > > application where i need to use my own linker file because i need to put
> > > the application at a specific address. This application is starting at
> > > 0x08008000. Between 0x08000000 and 0x08008000, i have a bootloader in
> > > charge of booting on my application. But when i'm doing a "make flash",
> > the
> > > flasher is writing some code before 0x08008000 ... that is corrupting my
> > > bootloader. Indeed, when i dump the memory i can find the ELF magic
> > string
> > > and i don't know why the flasher is flashing some code before 0x08008000
> > > whereas it is specified in the linker file : rom (rx) : ORIGIN =
> > > 0x08008000 !!! Regarding the vector table, it is put at the right place.
> > If
> > > i want this to work i need to flash my bootloader after the application
> > ...
> > > If i'm missing something or if you have any idea on how to put an
> > > application at a specific address without corrupting the other
> > partitions,
> > > feel free to share :)
> > >
> > > Best regards,
> > >
> > > Aurélien
> > > _______________________________________________
> > > users mailing list
> > > users at riot-os.org
> > > https://lists.riot-os.org/mailman/listinfo/users
> > >
> >
> >
>  



More information about the users mailing list