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

Command line Make example project for nRF52 DK

I'm trying to build the "blinky" example found in nRF5_SDK_15.3.0_59ac345/examples/peripheral/blinky/pca10040e/blank/armgcc

Actually the pca10040e directory contains 'blank' and 'mbr' directories, I just went with blank but I've no idea what the difference is and which I should be using. I went with 'blank' and tried a 'make' command. Everything compiled but the linker is missing a library. I've installed both the  nRF5_SDK_15.3.0 and s132 packages but searching my machine and there's no occurrences of either libc_nano* or libg_nano. I'm not sure if those libs are target, as in Nordic nRF52 specific or arm specific, in which case they should have been installed with my arm-none-eabi-gcc packages?

/usr/lib64/gcc/arm-none-eabi/7/ld: cannot find -lc_nano
/usr/lib64/gcc/arm-none-eabi/7/ld: cannot find -lg_nano
/usr/lib64/gcc/arm-none-eabi/7/ld: cannot find -lc_nano

So should I be making in 'blank' or 'mbr' and where should I install libs from?

Parents
  • Hi,

    The library should be included in the toolchain. Did you download the toolchain from this site https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads

    This is how I would set up the toolchain on Linux

    1. Find the recommended toolchain release in the SDK release notes. Is GCC ARM Embedded 7.2018q2.update for SDK 15.3.0

    2. Download the pre-compiled version from ARM and move the extracted toolchain directory to /usr/local/ so it matches the path set in nRF5_SDK_15.3.0_59ac345/components/toolchain/gcc/Makefile.posix

    So should I be making in 'blank' or 'mbr' and where should I install libs from?

     Use "blank" if you intend to run the app without a bootloader. A typical memory layout with bootloader, app, and MBR would look like this: https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/lib_bootloader.html?cp=5_1_3_5_0_7#lib_bootloader_memory 

  • So I managed to build the blinky project from the command line. And flash it to the target dev board by copying the hex file to the mounted drive. I'll have to come back to that as if I designed by own board that's not how this would work. I have a JLink so I'd have to connect to the JTAG header and user a command line program to flash.

    I'll come back to that but for the moment if I wanted to create a template C project I've now got this script to pull necessary files from the blinky project. My question is that if I wanted instead to create an empty C++ project, what is required. I've tried changing the Makefile.common to specify -std=c++17 instead of -std=c99, and changing to $(CXX) but there's more to it then that as you need the standard library.

    #!/bin/bash
    
    SDK_ROOT=/home/john/Install/Nordic/nRF5SDK/nRF5_SDK_15.3.0_59ac345
    
    if [ $# -ne 1 ]; then
        echo "usage: $0 <target>"
        exit 1
    fi
    
    target=$1
    	
    if [ -f $target ]; then
        echo "Error - Target file exists"
        exit 2
    fi
    
    if [ -d $target ]; then
        echo "Error - Target directory exists"
        exit 2
    fi
    
    #
    # Create the target directory
    #
    mkdir -p $target/src
    
    #
    # Copy in Blinkey Makefile and Makefile.common
    #
    cp $SDK_ROOT/examples/peripheral/blinky/pca10040e/blank/armgcc/Makefile $target
    cp $SDK_ROOT/components/toolchain/gcc/Makefile.common $target
    
    sed -e "s/blinky_pca10040e/$target/" \
        -e "s;SDK_ROOT := ../../../../../..;SDK_ROOT := $SDK_ROOT;" \
        -e "s;PROJ_DIR := ../../..;PROJ_DIR := .;" \
        -e "s/blinky_gcc_nrf52.ld/gcc_nrf52.ld/" \
        -e 's;(PROJ_DIR);(PROJ_DIR)/src;' \
        -e 's;SDK_CONFIG_FILE := ../config/sdk_config.h;SDK_CONFIG_FILE := sdk_config.h;' \
        -e 's;$(TEMPLATE_PATH)/;;' \
        -e '/..\/config/d' \
        $target/Makefile > $target/Makefile.tmp
    
    rm $target/Makefile
    mv $target/Makefile.tmp $target/Makefile
     
    #
    # Copy in the linker script from blinkey project
    #
    cp $SDK_ROOT/examples/peripheral/blinky/pca10040e/blank/armgcc/blinky_gcc_nrf52.ld $target/gcc_nrf52.ld
    
    #
    # Populate the src directory with the config header file and a main
    cp $SDK_ROOT/examples/peripheral/blinky/pca10040e/blank/config/sdk_config.h $target/src
    
    echo "int main(int argc, char **argv){}" > $target/src/main.c
    

Reply
  • So I managed to build the blinky project from the command line. And flash it to the target dev board by copying the hex file to the mounted drive. I'll have to come back to that as if I designed by own board that's not how this would work. I have a JLink so I'd have to connect to the JTAG header and user a command line program to flash.

    I'll come back to that but for the moment if I wanted to create a template C project I've now got this script to pull necessary files from the blinky project. My question is that if I wanted instead to create an empty C++ project, what is required. I've tried changing the Makefile.common to specify -std=c++17 instead of -std=c99, and changing to $(CXX) but there's more to it then that as you need the standard library.

    #!/bin/bash
    
    SDK_ROOT=/home/john/Install/Nordic/nRF5SDK/nRF5_SDK_15.3.0_59ac345
    
    if [ $# -ne 1 ]; then
        echo "usage: $0 <target>"
        exit 1
    fi
    
    target=$1
    	
    if [ -f $target ]; then
        echo "Error - Target file exists"
        exit 2
    fi
    
    if [ -d $target ]; then
        echo "Error - Target directory exists"
        exit 2
    fi
    
    #
    # Create the target directory
    #
    mkdir -p $target/src
    
    #
    # Copy in Blinkey Makefile and Makefile.common
    #
    cp $SDK_ROOT/examples/peripheral/blinky/pca10040e/blank/armgcc/Makefile $target
    cp $SDK_ROOT/components/toolchain/gcc/Makefile.common $target
    
    sed -e "s/blinky_pca10040e/$target/" \
        -e "s;SDK_ROOT := ../../../../../..;SDK_ROOT := $SDK_ROOT;" \
        -e "s;PROJ_DIR := ../../..;PROJ_DIR := .;" \
        -e "s/blinky_gcc_nrf52.ld/gcc_nrf52.ld/" \
        -e 's;(PROJ_DIR);(PROJ_DIR)/src;' \
        -e 's;SDK_CONFIG_FILE := ../config/sdk_config.h;SDK_CONFIG_FILE := sdk_config.h;' \
        -e 's;$(TEMPLATE_PATH)/;;' \
        -e '/..\/config/d' \
        $target/Makefile > $target/Makefile.tmp
    
    rm $target/Makefile
    mv $target/Makefile.tmp $target/Makefile
     
    #
    # Copy in the linker script from blinkey project
    #
    cp $SDK_ROOT/examples/peripheral/blinky/pca10040e/blank/armgcc/blinky_gcc_nrf52.ld $target/gcc_nrf52.ld
    
    #
    # Populate the src directory with the config header file and a main
    cp $SDK_ROOT/examples/peripheral/blinky/pca10040e/blank/config/sdk_config.h $target/src
    
    echo "int main(int argc, char **argv){}" > $target/src/main.c
    

Children
No Data
Related