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

printk() on blinky example not working on UART0 for NS build

Hello all,

Having a smallish problem seeing printk() output on my board.  My board is an NRF9160 PCA10090 inspired board.  Long story short, I can't see printk() stuff showing up on UART0 when I build the NS version of the board.  The other non-NS version is fine.  I'm using 1.2.0.

The details.

Our board is very similar to the PCA10090.  LEDs on different GPIO, and UART0 on different pins.  I copied the ncs\v1.2.0\zephyr\samples\basic\blinky folder to my desktop and placed two files in there named nrf9160_pca10090.overlay and nrf9160_pca10090ns.overlay.  They are identical.  Here's the contents:

&uart0 {
  status = "ok";
  current-speed = <115200>;
  tx-pin = <19>;
  rx-pin = <18>;
};

&uart2 {
  status = "ok";
  current-speed = <9600>;
  tx-pin = <11>;
  rx-pin = <10>;
};

I've also modified the code to wiggle one of my LED pins, and give me a little printk() action as it does.  My main.c is modified like this:

	while (1) {
		/* Set pin to HIGH/LOW every 1 second */
		gpio_pin_write(dev, 5, cnt % 2);
		cnt++;
		k_sleep(SLEEP_TIME);
        printk("Count is: %d\n",cnt);
	}

Now if I do the following, it works:

File -> Open nRF Connect SDK Project (CMakeLists.txt is Desktop/blinky/CMakeLists.txt, Board Directory is ncs/v1.2.0/zephyr/boards/arm/nrf9160_pca10090, Board Name is nrf9160_pca10090, Build directory is the default Desktop/blinky/build_nerf9160_pca10090.  Check [X] Clean Build Directory).  Click Go.  Then click Debug->Go.  My LED blinks, and the count shows up on UART0 on pins 18/19.  All is well, so I'm pretty sure my .overlay files are ok.

But do the same thing, except for set Board Name to nrf9160_pca10090ns, and it doesn't work.  LED blinks, so I know I'm running, but no printk() on the uart.  

Anyone know why?

Thanks,

BoredBSEE

Parents
  • My collegue says that this is caused by the SPM.

    you should add the following in the CMakeLists.txt file, just below the cmake_minimum_required() line:

    if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/spm.conf")
      set(spm_CONF_FILE
        prj.conf
        ${CMAKE_CURRENT_LIST_DIR}/spm.conf
      )
    endif()
     
    if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/mcuboot.conf")
      set(mcuboot_CONF_FILE
        prj.conf
        ${CMAKE_CURRENT_LIST_DIR}/mcuboot.conf
      )
    endif()
     
    if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${BOARD}.overlay")
      set(mcuboot_DTC_OVERLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${BOARD}.overlay")
      set(spm_DTC_OVERLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${BOARD}.overlay")
    endif(

    Can you please give it a try.

  • Thank you!  This fixed the problem perfectly.  I now have serial output on the NS build, worked like a charm.  Tell your colleague thank you as well.

    Small point - there is a missing end parenthesis on your code block.  I only mention it just in case someone else needs this.  Line 18 should be "endif ()".

    Again, many thanks.

    BoredBSEE

Reply Children
No Data
Related