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

How to create a custom board file for the nRF9160

I am trying to create a custom board file in the ncs/zepher/boards directory for our nRF9160.

If I copy the nrf9160_pca10090 directory to a new nam eg. nrf9160_newboard it will compile and run just fine.

Then when i change the name of the files to nrf9160_newboard and change the references in each of the files to correspond to the new file names.

I was able to get the hello world example to compile and run as a nrf9160_newboard, but when I tried to compile as nrf9160_newboardns I get the following errors in spm.c

1> C:/ncs/nrf/subsys/spm/spm.c:129:2: error: 'NRF_SPU' undeclared (first use in this function); did you mean 'NRF_SPU_S'?
1> C:/ncs/nrf/subsys/spm/spm.c:129:2: note: each undeclared identifier is reported only once for each function it appears in
1> C:/ncs/nrf/subsys/spm/spm.c:160:3: error: 'NRF_SPU' undeclared (first use in this function); did you mean 'NRF_SPU_S'?
1> C:/ncs/nrf/subsys/spm/spm.c:207:3: error: 'NRF_SPU' undeclared (first use in this function); did you mean 'NRF_SPU_S'?
1> C:/ncs/nrf/subsys/spm/spm.c:224:21: error: 'NRF_SPU' undeclared (first use in this function); did you mean 'NRF_SPU_S'?
1> C:/ncs/nrf/subsys/spm/spm.c:262:3: error: 'NRF_SPU' undeclared (first use in this function); did you mean 'NRF_SPU_S'?
1> C:/ncs/nrf/subsys/spm/spm.c:293:24: error: 'NRF_UARTE2' undeclared (first use in this function); did you mean 'NRF_UARTE0'?
1> C:/ncs/nrf/subsys/spm/spm.c:93:23: note: in definition of macro 'NRFX_PERIPHERAL_ID_GET'
1> C:/ncs/nrf/subsys/spm/spm.c:293:3: note: in expansion of macro 'PERIPH'
1> C:/ncs/nrf/subsys/spm/spm.c:301:22: error: 'NRF_PWM1' undeclared (first use in this function); did you mean 'NRF_PWM0'?
1> C:/ncs/nrf/subsys/spm/spm.c:93:23: note: in definition of macro 'NRFX_PERIPHERAL_ID_GET'
1> C:/ncs/nrf/subsys/spm/spm.c:301:3: note: in expansion of macro 'PERIPH'
1> C:/ncs/nrf/subsys/spm/spm.c:302:22: error: 'NRF_PWM2' undeclared (first use in this function); did you mean 'NRF_PWM1'?
1> C:/ncs/nrf/subsys/spm/spm.c:93:23: note: in definition of macro 'NRFX_PERIPHERAL_ID_GET'
1> C:/ncs/nrf/subsys/spm/spm.c:302:3: note: in expansion of macro 'PERIPH'
1> C:/ncs/nrf/subsys/spm/spm.c:303:22: error: 'NRF_PWM3' undeclared (first use in this function); did you mean 'NRF_PWM2'?
1> C:/ncs/nrf/subsys/spm/spm.c:93:23: note: in definition of macro 'NRFX_PERIPHERAL_ID_GET'
1> C:/ncs/nrf/subsys/spm/spm.c:303:3: note: in expansion of macro 'PERIPH'
1> C:/ncs/nrf/subsys/spm/spm.c:321:3: error: 'NRF_SPU' undeclared (first use in this function); did you mean 'NRF_SPU_S'?
1> C:/ncs/nrf/subsys/spm/spm.c:321:10: error: 'const struct periph_cfg' has no member named 'GPIOPORT'
1> C:/ncs/nrf/subsys/spm/spm.c:321:23: error: 'const struct periph_cfg' has no member named 'PERM'
1> C:/ncs/nrf/subsys/spm/spm.c:321:3: warning: statement with no effect [-Wunused-value]
Build failed

i tried this using a grep replace function for 10090 on the new directory since I though I may have missed a line somewhere.

Is there a tutorial or set of directions on how to create new boards other than the one in Zephyr.

(Note: I did this before the introduction of the secure and non-secure versions of the board for section placement)

Parents
  • Have you remembered to set the Secure Partition Manager to your custom board too? It seems that the SPM example is still using the regular board. I would try opening the SPM example with that custom board, building & then go back to your example & trying that again.

  • On your advice I tried programming the SPM sample.

    When I first tried Programming SPM with the board set to nrf9160_newboard I did get the PWM and UART errors.

    Then I edited the device tree configuration, using the device tree tool, and changed that status of the peripherals that were giving me the errors.  The SPM sample then compiled.

    When I moved back to my hello world test I needed to edit the device tree for that project.  However the changes made in the device tree did not affect the errors when compiling.

  • I was able to flash and build a hello world nonsecure example with your custom board by executing these steps:


    • Placed the folder nrf9160_pca20190 into <..>/ncs/zephyr/boards/arm with all the files you provided
    • Added the following lines of code into <..>\ncs\zephyr\cmake\app\boilerplate.cmake:

    if(FIRST_BOILERPLATE_EXECUTION)
    .
    .
    else() # NOT FIRST_BOILERPLATE_EXECUTION
    .
    .
        set(BOARD nrf9160_pca20035)
        message("Changed board to secure nrf9160_pca20035 (NOT NS)")
      endif()
      
        if(${BOARD} STREQUAL nrf9160_pca20190ns)                     //Added this
        set(BOARD nrf9160_pca20190)                                  //Added this
        message("Changed board to secure nrf9160_pca20035 (NOT NS)") //Added this
      endif()                                                        //Added this
      
      unset(${IMAGE}DTC_OVERLAY_FILE)...
      .
      .
      .

    • Built and flashed the hello world sample by running the commands  "west build -b nrf9160_pca20190ns" and "west flash"

    I might have done some more changes that I have forgotten, but try to execute my steps and see if you are able to make it work.

    Best regards,

    Simon

  • Then I edited the device tree configuration, using the device tree tool, and changed that status of the peripherals that were giving me the errors.  The SPM sample then compiled.

    I'm stuck on this step, and trying to figure out which device tree tool you're talking about.  Can you please send me a pointer?

Reply Children
Related