This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Building a custom board in VS Code for nRF9160, and getting an error

I'm trying to build a custom board in VS Code to use with the nRF9160. I'm using a Thingy91, so I took the board file for that, and copied it into the project directory. (the board file I copied from is from C:\Users\<USERNAME>\ncs\v1.9.1\nrf\boards\arm\thingy91_nrf9160). The project I'm using is the AWS_IoT sample from Nordic.

I then renamed all the files so that "thingy91" was just replaced with "NCB". I followed all instructions that were in the Q&A (https://devzone.nordicsemi.com/f/nordic-q-a/68856/how-to-create-a-custom-board-for-nrf9160) and I followed the directions exactly as detailed in the webinar (https://webinars.nordicsemi.com/getting-started-with-custom-5).

So the custom board is now "NCB_nrf9160_ns" instead of "thingy91_nrf9160_ns".

I then programmed device using a J-Link.

However, programming the code onto the thingy91, the program fails to run, and I get this message on LTE Link Monitor (the last message with the "cancel startup", the software then stays in a while loop).

*** Booting Zephyr OS build v2.7.99-ncs1 ***
I: Starting bootloader
I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Swap type: none
I: Bootloader chainload address offset: 0xc000
I: Jumping to the first image slot
E: Protect mcuboot flash failed, cancel startup.

How do I get this working?

Thank you.

Parents Reply Children
  • Hello, sorry for the delayed answer. There is a one last file that you have to add here: 
    bootloader\mcuboot\boot\zephyr\boards\ncb_nrf9160.conf

    I tested on my side and got at first the same output as you, then I copied the thingy91_nrf9160.conf and renamed to the same name as custom board and now it runs as expected. 

    Let me know how it works for you.

    Kind regards,

    Øyvind

  • Thank you, that works!

    Is there a way to keep this file with the local project folder?

  • Yes, you can add it to a new folder called: child_image\ncb_nrf9160.conf

    Your project folder should look similar to this:

    boards\arm\ncb_nrf9160\board_nonsecure.c
    boards\arm\ncb_nrf9160\board_secure.c
    boards\arm\ncb_nrf9160\board.cmake
    boards\arm\ncb_nrf9160\CMakeLists.txt
    boards\arm\ncb_nrf9160\Kconfig
    boards\arm\ncb_nrf9160\Kconfig.board
    boards\arm\ncb_nrf9160\Kconfig.defconfig
    boards\arm\ncb_nrf9160\ncb_nrf9160_common.dts
    boards\arm\ncb_nrf9160\ncb_nrf9160_defconfig
    boards\arm\ncb_nrf9160\ncb_nrf9160_ns_defconfig
    boards\arm\ncb_nrf9160\ncb_nrf9160_ns.dts
    boards\arm\ncb_nrf9160\ncb_nrf9160_ns.yaml
    boards\arm\ncb_nrf9160\ncb_nrf9160_partition_conf.dts
    boards\arm\ncb_nrf9160\ncb_nrf9160.dts
    boards\arm\ncb_nrf9160\ncb_nrf9160.yaml
    boards\arm\ncb_nrf9160\pm_static.yml
    boards\arm\ncb_nrf9160\pre_dt_board.cmake
    
    child_image\ncb_nrf9160.conf
    
    src
    CMakeLists.txt
    Kconfig
    prj_qemu_x86.conf
    prj.conf
    README.rst
    sample.yaml

    That worked on my side. Let me know how it works for you.

    Kind regards,
    Øyvind

  • After moving the ncb_nrf9160.conf file into the child_image directory, the original problem happens again ("Protect mcuboot flash failed, cancel startup.").

    Also, I'm not sure if it's related, but I noticed there's one additional file I have that isn't in your list: boards/arm/ncb_nrf9160/nrf52840_reset.c.

  • JonnyMN said:
    Also, I'm not sure if it's related, but I noticed there's one additional file I have that isn't in your list: boards/arm/ncb_nrf9160/nrf52840_reset.c.

    No, this is fine if you have in your folder. Should not affect the message you get. 

    JonnyMN said:
    After moving the ncb_nrf9160.conf file into the child_image directory, the original problem happens again ("Protect mcuboot flash failed, cancel startup.").

    Sorry, you need to rename it to child_image\mcuboot.conf

    Let me know how that works for you. Remember to do a pristine build.

Related