This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is't possible to change app start address from prebuild binary file?

Hi,
Usually we set FLASH_START macro to indicate application start address,
I do like to consult is't possible to change the FLASH_START from prebuild binary file without rebuild?

I'm trying to implement dual boot, that is, 2 different application are programed to 2 address of flash,
then boot to one of them depending on bootloader choice,

For example, app1 start from 0x27000, app2 start from 0x8d000,
I set FLASH_START=0x27000 for app1,
FLASH_START=0x8d000 for app2,
then build hex files and program them to flash.

That works but I need to decide application start address before compiling,
I hope the start address can be set by bootloader dynamically,
if application is programed to address of app1, set it to 0x27000, otherwise 0x8d000,
is't possible?

Thanks~

Parents
  • Hi,

    It is possible to change the start address of the HEX-file using objcopy:

    arm-none-eabi-objcopy --change-addresses <address> <input_file>.hex <output_file>.hex

    However, I'm not sure if the application will work correctly if moved this way. You may try it out in your device.

    Best regards,
    Jørgen

  • Hi Jørgen,

    Thank you for the reply, exactly arm-none-eabi-objcopy can change the image placement,
    then I did some experimentation,

    Build image demos_27000.hex with FLASH_START=0x27000,

    Change generated hex file address to 0x8d000, named 27000_to_8d000.hex

    arm-none-eabi-objcopy --change-address 0x66000 demos_27000.hex 27000_to_8d000.hex
    (0x66000 + 0x27000 = 0x8d000)

    Write 2 hex files to nRF52840, then seems it can boot to both 0x27000 and 0x8d000,

    BUT,
    If I erase the image of 0x27000 from nRF52840, keep others,
    then it can't boot to image of 0x8d000, the 27000_to_8d000.hex anymore.

    I did one more experimentation,
    Build an image with FLASH_START=0x00000, then change its address to 0x8d000, named 00000_to_8d000.hex,

    arm-none-eabi-objcopy --change-address 0x8d000 demos_00000.hex 00000_to_8d000.hex

    Then write original demos_27000.hex and 00000_to_8d000.hex to nRF52840,
    this time, 0x27000 can boot normally, but 0x8d000, the 00000_to_8d000.hex can't,

    I guess that should be something such like vector table or somethings
    are indicated with FLASH_START during compiling,
    so even I changed where the image to be writen, image still can't work.

    By the way, my arm-none-eabi-objcopy version is 2.34

    arm-none-eabi-objcopy --version
    GNU objcopy (2.34-4ubuntu1+13ubuntu1) 2.34
    Copyright (C) 2020 Free Software Foundation, Inc.
    This program is free software; you may redistribute it under the terms of
    the GNU General Public License version 3 or (at your option) any later version.
    This program has absolutely no warranty.

    And, if build image with FLASH_START=0x8d000,
    it can boot even image of 0x27000 has been erased.

    Thanks~

Reply
  • Hi Jørgen,

    Thank you for the reply, exactly arm-none-eabi-objcopy can change the image placement,
    then I did some experimentation,

    Build image demos_27000.hex with FLASH_START=0x27000,

    Change generated hex file address to 0x8d000, named 27000_to_8d000.hex

    arm-none-eabi-objcopy --change-address 0x66000 demos_27000.hex 27000_to_8d000.hex
    (0x66000 + 0x27000 = 0x8d000)

    Write 2 hex files to nRF52840, then seems it can boot to both 0x27000 and 0x8d000,

    BUT,
    If I erase the image of 0x27000 from nRF52840, keep others,
    then it can't boot to image of 0x8d000, the 27000_to_8d000.hex anymore.

    I did one more experimentation,
    Build an image with FLASH_START=0x00000, then change its address to 0x8d000, named 00000_to_8d000.hex,

    arm-none-eabi-objcopy --change-address 0x8d000 demos_00000.hex 00000_to_8d000.hex

    Then write original demos_27000.hex and 00000_to_8d000.hex to nRF52840,
    this time, 0x27000 can boot normally, but 0x8d000, the 00000_to_8d000.hex can't,

    I guess that should be something such like vector table or somethings
    are indicated with FLASH_START during compiling,
    so even I changed where the image to be writen, image still can't work.

    By the way, my arm-none-eabi-objcopy version is 2.34

    arm-none-eabi-objcopy --version
    GNU objcopy (2.34-4ubuntu1+13ubuntu1) 2.34
    Copyright (C) 2020 Free Software Foundation, Inc.
    This program is free software; you may redistribute it under the terms of
    the GNU General Public License version 3 or (at your option) any later version.
    This program has absolutely no warranty.

    And, if build image with FLASH_START=0x8d000,
    it can boot even image of 0x27000 has been erased.

    Thanks~

Children
No Data
Related