Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nrf5_drv_uart build failed #60

Open
ildar opened this issue Aug 6, 2020 · 3 comments
Open

nrf5_drv_uart build failed #60

ildar opened this issue Aug 6, 2020 · 3 comments

Comments

@ildar
Copy link

ildar commented Aug 6, 2020

info: ci/examples/ble_peripheral/ble_app_blinky, SDK 16.0.0
command:

cmake . -D NRF5_SDK_PATH=/tmp/nRF5_SDK -D NRF5_TARGET=nrf52832 -D NRF5_SOFTDEVICE_VARIANT=s132 && make

[ 66%] Building C object CMakeFiles/nrf5_drv_uart.dir/tmp/nRF5_SDK/integration/nrfx/legacy/nrf_drv_uart.c.o
In file included from /tmp/nRF5_SDK/integration/nrfx/legacy/nrf_drv_uart.c:41:
/tmp/nRF5_SDK/integration/nrfx/legacy/nrf_drv_uart.h:122:13: error: unknown type name 'nrf_uarte_baudrate_t'
     typedef nrf_uarte_baudrate_t        nrf_uart_baudrate_t;
             ^~~~~~~~~~~~~~~~~~~~
/tmp/nRF5_SDK/integration/nrfx/legacy/nrf_drv_uart.h:127:13: error: unknown type name 'nrf_uarte_error_mask_t'
     typedef nrf_uarte_error_mask_t      nrf_uart_error_mask_t;
             ^~~~~~~~~~~~~~~~~~~~~~
/tmp/nRF5_SDK/integration/nrfx/legacy/nrf_drv_uart.h:130:13: error: unknown type name 'nrf_uarte_hwfc_t'
     typedef nrf_uarte_hwfc_t            nrf_uart_hwfc_t;
             ^~~~~~~~~~~~~~~~
/tmp/nRF5_SDK/integration/nrfx/legacy/nrf_drv_uart.h:133:13: error: unknown type name 'nrf_uarte_parity_t'
     typedef nrf_uarte_parity_t          nrf_uart_parity_t;
             ^~~~~~~~~~~~~~~~~~
/tmp/nRF5_SDK/integration/nrfx/legacy/nrf_drv_uart.h:134:13: error: unknown type name 'nrf_uarte_task_t'
     typedef nrf_uarte_task_t            nrf_uart_task_t;
             ^~~~~~~~~~~~~~~~
/tmp/nRF5_SDK/integration/nrfx/legacy/nrf_drv_uart.h:135:13: error: unknown type name 'nrf_uarte_event_t'
     typedef nrf_uarte_event_t           nrf_uart_event_t;
             ^~~~~~~~~~~~~~~~~
/tmp/nRF5_SDK/integration/nrfx/legacy/nrf_drv_uart.c: In function 'nrf_drv_uart_init':
/tmp/nRF5_SDK/integration/nrfx/legacy/nrf_drv_uart.c:124:27: warning: variable 'config' set but not used [-Wunused-but-set-variable]
     nrf_drv_uart_config_t config = *p_config;
                           ^~~~~~
make[2]: *** [CMakeFiles/nrf5_drv_uart.dir/build.make:82: CMakeFiles/nrf5_drv_uart.dir/tmp/nRF5_SDK/integration/nrfx/legacy/nrf_drv_uart.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1454: CMakeFiles/nrf5_drv_uart.dir/all] Error 2
make: *** [Makefile:103: all] Error 2
@borys-jelenski-polidea
Copy link
Contributor

Hi! I'm afraid that calling CMake with just

cmake . -D NRF5_SDK_PATH=/tmp/nRF5_SDK -D NRF5_TARGET=nrf52832 -D NRF5_SOFTDEVICE_VARIANT=s132 && make

won't work. There are few problems with that:

  • Consider creating a CMake binary directory separate from the source directory.
  • You need to set the CMAKE_TOOLCHAIN_FILE and TOOLCHAIN_PREFIX variables in order to use a proper toolchain.
  • The official nRF5 examples are meant for boards, not targets per se. It would be better to pass NRF5_BOARD=pca10040 instead of NRF5_TARGET=nrf52832, the target will be deduced from the board. Thing is, nRF5 examples use the Board Support Package library (nrf5_bsp) which relies on compile definitions related to the board.
  • The compile errors you got are most likely due to incorrect entries in the sdk_config.h. Since you did not specify the NRF5_SDKCONFIG_PATH, the generic SDK configuration file was used which won't work in this case. You need to use the sdk_config.h file meant for the ble_peripheral/ble_app_blinky example for the pca10040 board.
  • Finally, you need to use the right linker script for the example and the board, otherwise it won't work after being loaded into the board. You can point to a linker script by setting the NRF5_LINKER_SCRIPT variable.

Assuming you're running CMake from the ci/examples/ble_peripheral/ble_app_blinky directory, the command line would look more or less like this (you need to adjust the paths for your system, of course):

cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=../../../../cmake/arm-none-eabi.cmake -D TOOLCHAIN_PREFIX=D:/tools/gcc-arm-none-eabi-9-2019-q4-major-win32 -DNRF5_SDK_PATH=D:/tools/nRF5SDK160098a08e2 -DNRF5_BOARD=pca10040 -DNRF5_SOFTDEVICE_VARIANT=s132 -DNRF5_SDKCONFIG_PATH=D:/tools/nRF5SDK160098a08e2/examples/ble_peripheral/ble_app_blinky/pca10040/s132/config -DNRF5_LINKER_SCRIPT=D:/tools/nRF5SDK160098a08e2/examples/ble_peripheral/ble_app_blinky/pca10040/s132/armgcc/ble_app_blinky_gcc_nrf52.ld -G "Unix Makefiles"

@ildar
Copy link
Author

ildar commented Aug 6, 2020 via email

@borys-jelenski-polidea
Copy link
Contributor

borys-jelenski-polidea commented Aug 7, 2020

Glad to help.

Actually, you can specify NRF5_SDK_PATH (and some other variables) in CMakeLists.txt. The important thing is that it must occur before including the nrf5 module, for example:

# ...

set(NRF5_SDK_PATH "D:/tools/nRF5SDK160098a08e2" CACHE PATH "" FORCE)

list(APPEND CMAKE_MODULE_PATH "../cmake")
include("nrf5")

# ...

If it works for you - that's OK but I wouldn't recommend doing that in production. By setting configuration variables in the command line your CMakeLists.txt can be more universal so you can keep it unchanged for building for multiple targets, SDK versions etc.

BTW. You can build examples more easily if you setup the CI locally and run some scripts. Go the ci/scripts directory and run prepare.sh. It's going to download and install some dependencies, check it out and make sure it's OK for you. After that, you can just type:

./build_example.sh --example=ble_peripheral/ble_app_blinky --sdk_version=16.0.0 --board=pca10040 --sd_variant=s132

That will configure and build the example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants