From Thingy53 to custom board

Hi community,

I`m trying to develop a custom board with nRF5340, now comes the question how to flash it?

The application was developed with the Thingy53. On Thingy53 the bootloader mode is activated by cycling the power during press the button SW2(P1.14).

we also want to use another pin for activating the bootloader mode, therefore we also need to customize the bootloader.

so my questions are: 

1. how to customize/develop the bootloader?

2. Is it possible to use another pin for activating the bootloader mode?

3. how to flash the custom bootloader?

Thanks in advance

Danny

Parents
  • Hi AHaug,

    thanks for replying me.

    I go throgh the lessons again, It´s more about DFU. not about how to flash the Bootloader in a empty nRF5340.

    My understanding is like this, please correct me, if I´m wrong.

    The MCUboot(Bootloader) will be  automatically compiled if CONFIG_BOOTLOADER_MCUBOOT=y is set in the project conf file. 

    the Bootload can be found under project_name\build\mcuboot\zephyr\zephyr.hex

    I tried to use the Programmer from nRF Connect for Desktop to flash this hex file inito thingy53, but failed as followed:

    11:33:15.271
    Error: Failed with exit code 1. One or more program tasks failed. Message: Failed, [mcuBoot] Unable to parse MCUBoot image file. Unable to parse image header: invalid magic value.
    11:33:15.271
    MCUboot DFU failed with error: Error: Failed with exit code 1. One or more program tasks failed. Message: Failed, [mcuBoot] Unable to parse MCUBoot image file. Unable to parse image header: invalid magic value.
    11:33:15.271
    Error: Failed with exit code 1. One or more program tasks failed. Message: Failed, [mcuBoot] Unable to parse MCUBoot image file. Unable to parse image header: invalid magic value.
    In the Exercise 2 of Lesson 8, 
    Until here not explained what is built and flashed? If only the Application, then it´s also not what i`m looking for. 
    Again, I want to know how to flash the Bootloader in an empty nRF5340.
  • danny0007 said:
    The MCUboot(Bootloader) will be  automatically compiled if CONFIG_BOOTLOADER_MCUBOOT=y is set in the project conf file. 

    This is correct, for multi image builds such as a build including MCUboot/bootloader and an app, you must also make sure that you meet the conditions mentioned in the multi-image builds documentation as well as this one specifically mentioned for the nrf5340.

    Do note that there will be changes w.r.t the parent/child support in upstream Zephyr so there might be some changes when sysbuild is introduced in 2.7.0/later releases of NCS.

    danny0007 said:
    the Bootload can be found under project_name\build\mcuboot\zephyr\zephyr.hex

    This is also correct

    danny0007 said:
    I tried to use the Programmer from nRF Connect for Desktop to flash this hex file inito thingy53, but failed as followed

    I assume that you've seen the working with the Thingy:53, but in case you haven't here's another two link that you should have a look at https://docs.nordicsemi.com/bundle/ncs-2.7.0-rc2/page/nrf/device_guides/nrf53/thingy53_application_guide.html and https://docs.nordicsemi.com/bundle/ncs-2.7.0-rc2/page/nrf/gsg_guides/thingy53_gs.html 

    Are you following this guide when programming the bootloader through nRF Connect for Desktop? https://docs.nordicsemi.com/bundle/ncs-2.7.0-rc2/page/nrf/gsg_guides/thingy53_gs.html#getting_started_with_precompiled_firmware_samples 

    danny0007 said:
    Until here not explained what is built and flashed?

    Thats right. When building all of the components are built as a default to ensure that versions and signings are matching. You can choose to set up the build system/configure your project so that you only build MCUboot or the application, but then you will have to manually sign all of the images with the same key to ensure that they are compatible with each other.

    danny0007 said:
    Again, I want to know how to flash the Bootloader in an empty nRF5340.

    Could you try using nrfjprog -f NRF53 --sectorerase --program mcuboot/zephyr/zephyr.hex --verify on a DK if you have one available to verify that this works on the 53 DK and then try to use this command on the Thingy through the DK?

    Kind regards,
    Andreas

  • Hi,

    danny0007 said:

    I'm not quite sure this answers what you're asking since this is simply the procedure for how to update the bootloader and not how to program it. In other words this is a different topic than programming the bootloader

    danny0007 said:
    then my question will be how can I do the very first flash for a blank nRF5340? 
    danny0007 said:
    I want to reflash the blue area, not the red and green area.

    This is explained in the links I've sent you in my previous replies. Copy pasting what I previously wrote once more:

    I assume that you've seen the working with the Thingy:53, but in case you haven't here's another two link that you should have a look at https://docs.nordicsemi.com/bundle/ncs-2.7.0-rc2/page/nrf/device_guides/nrf53/thingy53_application_guide.html and https://docs.nordicsemi.com/bundle/ncs-2.7.0-rc2/page/nrf/gsg_guides/thingy53_gs.html 

    Are you following this guide when programming the bootloader through nRF Connect for Desktop? https://docs.nordicsemi.com/bundle/ncs-2.7.0-rc2/page/nrf/gsg_guides/thingy53_gs.html#getting_started_with_precompiled_firmware_samples 

    Could you try using nrfjprog -f NRF53 --sectorerase --program mcuboot/zephyr/zephyr.hex --verify.

    Kind regards,
    Andreas

  • Hi Andreas,

    Thanks for replying me.

    we have developed our application on Thingy, so I think this is clear.

    This link describes two ways for updating firmware:
    1. Firmware update using MCUboot bootloader

    This we have done many times through USB with nRF connect for Desktop, works fine for uns, no questions. we mostly flash our dfu_application.zip file. The OTA also works fine. 

    2. Firmware update using external debug probe

    this we have never done, because we don´t have DK or Jlink in hand. We just assume that a blank nRF5340 can aslo be programmed through USB with nRF connect for Desktop. Our PCB only with USB interface is on the way to us. Now we´re not sure, if it´s possible to program the  mcuboot/zephyr/zephyr.hex just through USB. Tried on Thingy failed as above said.

    nrfjprog -f NRF53 --sectorerase --program mcuboot/zephyr/zephyr.hex --verify

    we never used this command, don´t know under which conditions it will be used. 
    After googling, find out: 

    • nrfjprog executable - tool for programming through SEGGER J-LINK programmers and debuggers

    that means the  mcuboot/zephyr/zephyr.hex can only be flashed with J-LINK or DK, it also means a blank nRF5340 can only be flshed with J-LINK or DK. is this correct? If Yes, we need to deesign a new PCB. this is the answer I have been seeking for.

    best regards

    Danny

  • danny0007 said:

    This link describes two ways for updating firmware:
    1. Firmware update using MCUboot bootloader

    This we have done many times through USB with nRF connect for Desktop, works fine for uns, no questions. we mostly flash our dfu_application.zip file. The OTA also works fine. 

    2. Firmware update using external debug probe

    this we have never done, because we don´t have DK or Jlink in hand. We just assume that a blank nRF5340 can aslo be programmed through USB with nRF connect for Desktop. Our PCB only with USB interface is on the way to us. Now we´re not sure, if it´s possible to program the  mcuboot/zephyr/zephyr.hex just through USB. Tried on Thingy failed as above said.

    Thank you for verifying.

    danny0007 said:
    we never used this command, don´t know under which conditions it will be used. 

    https://docs.nordicsemi.com/bundle/ug_nrf_cltools/page/UG/cltools/nrf_nrfjprogexe.html 

    nrfjprog, which will be replaced with nrfutil (same usage as nrfjprog) is what is used under the hood when programming SoCs in VS Code

    danny0007 said:
    that means the  mcuboot/zephyr/zephyr.hex can only be flashed with J-LINK or DK, it also means a blank nRF5340 can only be flshed with J-LINK or DK. is this correct? If Yes, we need to deesign a new PCB. this is the answer I have been seeking for.

    Yes, if you don't have a bootloader already present on the board, or you're not able to enter bootloader mode for said bootloader in place, then the only way you can program in the bootloader is with J-Link or through a DK/programmer. 

    Here's a description from another guide w.r.t how to program through SWD:

    ----

    To program a System on Chip (SoC) with Serial Wire Debug (SWD), you will need a debug probe like the J-Link External Debug Probe. Here are the steps:

    1. Install the https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/develop/flash_debug/host-tools.html#jlink-debug-host-tools and make sure they are in your search path.

    2. The board can be programmed using the [J-Link External Debug Probe](docs.nordicsemi.com/.../probes.html, provided the onboard debug circuit’s SWD signals are isolated from the MCU.

    3. To do so, ensure that jumpers J9 and J10 are **off** (they are on by default when the board ships from the factory). The external probe’s 20 pin connector can then be connected to J2 to program the SOC.

    For nRF5340 SoC, the required connections for nRF5340 DK v2 are as follows:

    | DK (programmer)P19 or P20 | Target boardSoC | Comments |
    | --- | --- | --- |
    | SWD CLK | SWDCLK | |
    | SWD IO | SWDIO | |
    | GND | GND | |
    | VTG | VDD | If using P20 |
    | SWD0 SEL | GND | If using P19 |
    | VDD nRF | VDD | If powering the external board from the DK |
    | RESET | RESET | Optional |

    If you have a bricked chip, you can perform "nrfjprog --eraseall" command to erase all and "nrfjprog --program new.hex --verify" to program a new image with the https://www.nordicsemi.com/Products/Development-tools/nRF-Command-Line-Tools 

     Programming Custom nRF5340 Board Using nRF5340 Development Kit  

    ---

    Kind regards,
    Andreas

  • Thinks a lot!

    That answers my original questons. Have a nice day.

  • Happy to help! 

    As always please feel free to open new cases for new queries

    Kind regards,
    Andreas

Reply Children
No Data
Related