2019년 10월 7일 월요일

Setup develop environment for Bluetooth SOC, nRF52840

1. Install Toolchain on debian testing(currently bulleseye)
# apt install libnewlib-dev libstdc++-arm-none-eabi-newlib libnewlib-arm-none-eabi gcc-arm-none-eabi binutils-arm-none-eabi

1.2. Verify the version of installed gcc
# arm-none-eabi-gcc --version
arm-none-eabi-gcc (15:7-2018-q2-6+b1) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907]
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

2. Download, and install the nRF5 SDK
Go to https://www.nordicsemi.com/Software-and-Tools/Software/nRF5-SDK/, and
download the latest verion of SDK at https://www.nordicsemi.com/-/media/Software-and-other-downloads/SDKs/nRF5/Binaries/nRF5SDK153059ac345.zip
Unzip nRF5SDK153059ac345.zip like as:
nRF5_SDK_15.3.0_59ac345
+- components
+- config
+- documentation
+- examples
+- external
+- external_tools
+- intergation
+- modules
+- license.txt
+- nRF5x_MDK_8_24_1_IAR_NordicLicense.msi
+- nRF5x_MDK_8_24_1_Keil4_NordicLicense.msi

At "$(SDK_ROOT)/components/toolchain/gcc" under SDK, there are several kinds of Makefile for Windows/Linux/MacOs.
Now, we should edit "Makefile.posix" in the case of Linux or MacOs like the below.

GNU_INSTALL_ROOT ?= /usr/local/gcc-arm-none-eabi-7-2018-q2-update/bin/
GNU_VERSION ?= 7.3.1
GNU_PREFIX ?= arm-none-eabi

into

GNU_INSTALL_ROOT ?= /usr/bin/
GNU_VERSION ?= 7.3.1
GNU_PREFIX ?= arm-none-eabi

2.1. Try to compile the example.
Under "$(SDK_ROOT)/examples/peripheral/blinkyPCA10056/blank/armgcc",
$ make
mkdir _build
cd _build && mkdir nrf52840_xxaa
Assembling file: gcc_startup_nrf52840.S
Compiling file: nrf_log_frontend.c
Compiling file: nrf_log_str_formatter.c
Compiling file: boards.c
Compiling file: app_error.c
Compiling file: app_error_handler_gcc.c
Compiling file: app_error_weak.c
Compiling file: app_util_platform.c
Compiling file: nrf_assert.c
Compiling file: nrf_atomic.c
Compiling file: nrf_balloc.c
Compiling file: nrf_fprintf.c
Compiling file: nrf_fprintf_format.c
Compiling file: nrf_memobj.c
Compiling file: nrf_ringbuf.c
Compiling file: nrf_strerror.c
Compiling file: nrfx_atomic.c
Compiling file: main.c
Compiling file: system_nrf52840.c
Linking target: _build/nrf52840_xxaa.out
   text       data        bss        dec        hex    filename
   2168        112        172       2452        994    _build/nrf52840_xxaa.out
Preparing: _build/nrf52840_xxaa.hex
Preparing: _build/nrf52840_xxaa.bin
DONE nrf52840_xxaa