Generating binaries on vscode with prepended zeroed header to the image

Hello ,

I am using nrf Connect SDK v1.9.1 with nRF Connect extension for my application development.

With reference to the nordic documentation : https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/mcuboot/imgtool.html#incorporating-the-public-key-into-the-code:~:text=Zephyr%20build%20system%20will%20already%20prepended%20a%20zeroed%20header%20to%20the%20image

Please find as in below snap the binaries generated from vscode and nCS I am using, There is no padded zeroed header to my build binaries at 0x000000 (Right image below)

While the left image below is the binary i generated with just zephyr and no nCS. It clearly has zero padded header.

So my question is, How can I have zero padded header to binaries generated out of nCS..?
Can i use any config..?

Thanks,

Ubaid

  • Hi Ubaid,

    I will look into this and return with more information tomorrow.

    Regards,
    Sigurd Hellesvik

  • I will look into this and return with more information tomorrow.

    Yes please, 

    Thanks

  • Hi,

    I will assume the file you refer to is build/zephyr/app_update.bin.

    Our build system automatically generates this file.
    To see the command used to generate this file, you can build using CLI and add "-vvv" to the west command like this:

    west -vvv build -p -b nrf52840dk_nrf52840

    From my code, the generation looks like this:

    [19/24] cd /home/bruk/git/samples_for_nrf_connect_sdk/bootloader_samples/smp/mcuboot_smp_uart/build/modules/mcuboot && /home/bruk/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-objcopy --input-target=ihex --output-target=binary --gap-fill=0xff /home/bruk/git/samples_for_nrf_connect_sdk/bootloader_samples/smp/mcuboot_smp_uart/build/zephyr/mcuboot_primary_app.hex /home/bruk/git/samples_for_nrf_connect_sdk/bootloader_samples/smp/mcuboot_smp_uart/build/zephyr/app_to_sign.bin && /usr/bin/python3.10 /home/bruk/nrf_connect_sdk/bootloader/mcuboot/scripts/imgtool.py sign --key /home/bruk/nrf_connect_sdk/bootloader/mcuboot/root-ec-p256.pem --header-size 0x200 --align 4 --version 0.0.0+0 --pad-header --slot-size 0x7a000 /home/bruk/git/samples_for_nrf_connect_sdk/bootloader_samples/smp/mcuboot_smp_uart/build/zephyr/app_to_sign.bin /home/bruk/git/samples_for_nrf_connect_sdk/bootloader_samples/smp/mcuboot_smp_uart/build/zephyr/app_update.bin

    As you can see from this, imgtool generates the binary.

    You can try to generate app_update.bin manually from this command and then change arguments to your liking.

    Can you also send the contents of the partition_manager_report? Maybe the padding could be related to the partitions?

    west build -t partition_manager_report

    Regards,
    Sigurd Hellesvik

  • Hello ,

    Thanks for the info.

    The snap of comparision I attached is of zephyr.bin, Sorry I forgot to mention.

    While the left image below is the binary i generated with just zephyr and no nCS. It clearly has zero padded header.

    Now If I build simple LED code, on zephyr RTOS+eclipse, I am getting zero prepended "zephyr.bin".
    While for same code if I build on nRF Connect Extension on vscode, I am not getting zero prepended "zephyr.bin".

    So, I need to be able to build zero prepended "zephyr.bin" from nRF Connect Extension on vscode.

    I am attaching the partition file:

    app:
      address: 0xf200
      end_address: 0x70000
      region: flash_primary
      size: 0x60e00
    external_flash:
      address: 0x0
      end_address: 0x100000
      region: external_flash
      size: 0x100000
    mcuboot:
      address: 0x0
      end_address: 0xf000
      placement:
        before:
        - mcuboot_primary
      region: flash_primary
      size: 0xf000
    mcuboot_pad:
      address: 0xf000
      end_address: 0xf200
      placement:
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0xf000
      end_address: 0x6f000
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      size: 0x60000
      span: *id001
    mcuboot_primary_app:
      address: 0xf200
      end_address: 0x6f000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0x5fe00
      span: *id002
    mcuboot_secondary:
      address: 0x0
      device: IS25
      end_address: 0x60000
      placement:
        align:
          start: 0x4
      region: external_flash
      share_size:
      - mcuboot_primary
      size: 0x60000
    settings_storage:
      address: 0x70000
      end_address: 0x80000
      placement:
        before:
        - end
      region: flash_primary
      size: 0x10000
    sram_primary:
      address: 0x20000000
      end_address: 0x20020000
      region: sram_primary
      size: 0x20000
    

    Also, I have never used CLI build, please help me where I can fire the commands.

    Thanks,

  • Ubaid_M said:
    Also, I have never used CLI build, please help me where I can fire the commands.

    For VS Code, press the arrow beside the "+" sign in the terminal view.
    Then select "nRF Connect SDK". Now you should get a CLI below to type commands.

    Ubaid_M said:
    Now If I build simple LED code, on zephyr RTOS+eclipse, I am getting zero prepended "zephyr.bin".
    While for same code if I build on nRF Connect Extension on vscode, I am not getting zero prepended "zephyr.bin".

    Aha, so you want to get the Zero padding.

    Do you build with MCUboot for both projects?
    Do you see the same issue if you build without MCUboot for both projects?

    Regards,
    Sigurd Hellesvik

Related