Bootloader corruption

Hi,

I’m currently working on a stm32l073 cpu and i have written my own bootloader that starts at the following address : 0x08000000 and that is able to jump on a main application starting at 0x08008000. But if i want it to be working, i need to flash bootloader after my main application. Indeed, i have identified when i’m flashing my main application that the startup code is flashed at 0x08008000 as it should be but the flasher is also overwriting the bootloader area (0x08000000 <-> 0x08007FFF) with some bytes (indeed i can see “.ELF” string bytes (magic of elf file) written in 0x08000000 that is corrupting my bootloader binary and preventing it from booting).

I’m using linker file to indicate where my binaries need to be flashed. My bootloader and my main application are two distinct RIOT projects.

bootloader.ld :

MEMORY { rom (rx) : ORIGIN = 0x08000000, LENGTH = 32K ram (rwx) : ORIGIN = 0x20000000, LENGTH = 19K sh_ram (rwx): ORIGIN = 0x20004C00, LENGTH = 1K cpuid ® : ORIGIN = 0x1ff80050, LENGTH = 12 }

main_application.ld :

MEMORY { rom (rx) : ORIGIN = 0x08008000, LENGTH = 160K ram (rwx) : ORIGIN = 0x20000000, LENGTH = 19K sh_ram (rwx): ORIGIN = 0x20004C00, LENGTH = 1K cpuid ® : ORIGIN = 0x1ff80050, LENGTH = 12 }

Am i missing something ? Thank you in advance for your help !

Best regards,