polidea / cmake-nrf5x Goto Github PK
View Code? Open in Web Editor NEWcmake script for nRF5 series SoC
License: MIT License
cmake script for nRF5 series SoC
License: MIT License
We need to come up with a strategy to introduce versioning shortly. Currently, a lot of names and features are unstable, and we should communicate than through versioning. I can see the following steps required to achieve it:
Examples to cover:
Currently the code does not check whether or not nrfjprog
is actually included in PATH. One way to check if to see if nrfjprog.exe
is found using find_program()
There's also no gurantee that if a user defines a path for NRF5_NRFJPROG
that it is a valid path.
if(NOT NRF5_NRFJPROG)
# Check if nrfjprog command is recognised
find_program(NRFJPROG "nrfjprog")
if(NRFJPROG)
set(NRF5_NRFJPROG "nrfjprog" CACHE FILEPATH "" FORCE)
message(STATUS "Using nrfjprog utility available from PATH: ${NRF5_NRFJPROG}")
else()
message(FATAL_ERROR "Could no find nrfjprog utlity from PATH")
endif()
else()
message(STATUS "Using nrfjprog utility: ${NRF5_NRFJPROG}")
endif()
Move legacy driver target definitions from nrf5_nrfx.json
to nrf5_drv.json
.
I followed the example, it compiles, flashes both softdevice and firmware, but the Led1 that is supposed to be lit on the board is not and the ble is not broadcasting.
I also compiled the simple peripheral/blinky
example and it also does not work.
Am I missing something?
Thank you
Currently nrf5_validation.cmake
scripts do more than validation itself. Consider changing names of the function to reflect better what's going on.
Can anyone lead me in the right direction of creating an elf file and setting up with Cortex-Debug for VS Code?
There are examples in nRF5 SDK which rely on definitions found in bsp.h
file however, they do not require the bsp.c
to be compiled e.g. peripheral/uart
. Actually, such examples do not contain the configuration required (in sdk_config.h
) to compile the bsp.c
. The problem is, when the nrf5_bsp
target is linked in those examples, it cannot be built correctly.
The solution would be to create an interface target nrf5_bsp_defs
containing only the include directory for the bsp.h
file.
In most cases, creating a custom linker script is what the user wants. Let's display a warning when the linker script is used from the SDK and suggest copying it.
First of all, this is a question, not really an issue, but since you seem to have more knowledge for cmake files rather than me, I'd like to ask something. I have almost the same cmake file (customized yours for the NRF52) but when I try to build the project, I get the following error message:
mingw32-make.exe[2]: Leaving directory 'C:/Users/marcd/Google Drive/HBO ICT/Jaar 3/Stage/untitled4/cmake-build-debug'
process_begin: CreateProcess(NULL, nrfjprog -c 4000 --eraseall --program untitled4.hex --sectorerase, ...) failed.
mingw32-make.exe[1]: Leaving directory 'C:/Users/marcd/Google Drive/HBO ICT/Jaar 3/Stage/untitled4/cmake-build-debug'
make (e=2): The system cannot find the file specified.
mingw32-make.exe[2]: *** [CMakeFiles\flash_untitled4.dir\build.make:60: CMakeFiles/flash_untitled4] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:112: CMakeFiles/flash_untitled4.dir/all] Error 2
mingw32-make.exe: *** [Makefile:86: all] Error 2
It cannot create the process for some reason while I have nrfjprog
installed and added to path. Also I am running the FLASH_${EXECUTABLE_NAME}
, when I run the project. Do you have any suggestions?
Hi. nrf5_app_redirect module is missing, can you please include it in nrf5_app.cmake?
Hello,
I am trying to use this framework and all is good, build files, flash, etc. Tho only problem is that I am trying to print something with RTT of Jlink and I can't see the output print. could you help me with this?
this is my src file:
#include <stdbool.h>
#include <stdint.h>
#include "nrf_delay.h"
#include "bsp.h"
#include "nrf.h"
#include "system_nrf52.h"
#include "nrf_delay.h"
#include "sdk_config.h"
#define ENABLE_SWD 1
static const uint8_t leds_list[LEDS_NUMBER] = { 9, 7, LED_3, LED_4 };
int main(void)
{
/* Configure LED-pins as outputs. */
printf("yeah nene\n");
LEDS_CONFIGURE(LEDS_MASK);
while (true)
{
for (int i = 0; i < LEDS_NUMBER; i++)
{
LEDS_INVERT(1 << leds_list[i]);
printf("testing print CMAKE\n");
nrf_delay_ms(500);
}
}
}
It seems that Nordic restructured SDK directories and renamed some files, e.g. softdevice_handler.c is now called sdh.c ? And location of RTT files changed?
I don't expect anyone to fix this, just noting that users of the script might need to adjust for SDK versions other than 12.3 used by the script.
We can provide support for nRF51 once we cover nRF5 SDK 12.3.0.
Examples to cover:
In the nrf5_helpers.cmake
file, the pca10100
seems to be the only board which does not support SDK 16. Is there any reason for this? Could it be a mistake?
If I change line 71 to the following:
set(board_pca10100 nrf52833_xxaa BOARD_PCA10100 15.3.0 16.0.0)
I'm able to compile the blinky example just fine.
Examples to cover:
Hi,
There are some .cmake files that have some kind of indent problem. When you try to compile blinky example adding "nrf5_app_scheduler" as target link library (SDK 16) on Linux environment it throws the following error:
Scanning dependencies of target nrf5_mdk [100%] Building ASM object CMakeFiles/nrf5_mdk.dir/nRF5_SDK_16.0.0/modules/nrfx/mdk/gcc_startup_nrf52.S.obj [100%] Building C object CMakeFiles/nrf5_mdk.dir/nRF5_SDK_16.0.0/modules/nrfx/mdk/system_nrf52.c.obj [100%] Built target nrf5_mdk Scanning dependencies of target nrf5_boards [100%] Building C object CMakeFiles/nrf5_boards.dir/nRF5_SDK_16.0.0/components/boards/boards.c.obj [100%] Built target nrf5_boards Scanning dependencies of target nrf5_app_scheduler CMakeFiles/nrf5_app_scheduler.dir/depend.make:4: *** missing separator. Stop. make[1]: *** [CMakeFiles/Makefile2:5985: CMakeFiles/nrf5_app_scheduler.dir/all] Error 2 make: *** [Makefile:84: all] Error 2 stark@vm:~/workspace/cmake-nRF5x/build$
Afterwards, if you run again "make", it compiles. This error happens with many files of this project. I have idented all .cmake files but continues happening I do not know where is the problem.
Best regards
I've noticed that there haven't been any commits in two years. Wanted to check if there are any plans to develop this further.
Thanks!
Hello,
I am trying to use this framework and all is good, build files, flash, etc. Tho only problem is that I am trying to print something with RTT of Jlink and I can't see the output print. could you help me with this?
this is my src file:
#include <stdbool.h>
#include <stdint.h>
#include "nrf_delay.h"
#include "bsp.h"
#include "nrf.h"
#include "system_nrf52.h"
#include "nrf_delay.h"
#include "sdk_config.h"
#define ENABLE_SWD 1
static const uint8_t leds_list[LEDS_NUMBER] = { 9, 7, LED_3, LED_4 };
int main(void)
{
/* Configure LED-pins as outputs. */
printf("yeah nene\n");
LEDS_CONFIGURE(LEDS_MASK);
while (true)
{
for (int i = 0; i < LEDS_NUMBER; i++)
{
LEDS_INVERT(1 << leds_list[i]);
printf("testing print CMAKE\n");
nrf_delay_ms(500);
}
}
}
If blank
or mbr
will be specified as NRF5_SD_VARIANT
, running the flash_softdevice
target after a successful configuration will result in the nrfjprog reporting an error. This is due to the local_sd_hex_file_path
CMake variable which in case of blank and MBR variants will remain uninitialized (empty). This will result in composing of an incorrect command line for the nrfjprog.
i.e. defined as a variable to be used in command line:
cmake -D TOOLCHAIN_PREFIX=/usr ...
hello,
I follow your code. and I am using the clion IDE on Mac OS . now I am getting this error.
CMakeFiles/Blinky.dir/Users/atifshabbir/Development/SDK/components/toolchain/gcc/gcc_startup_nrf51.S.o:9:157: warning: null character(s) ignored
CMakeFiles/Blinky.dir/Users/atifshabbir/Development/SDK/components/toolchain/gcc/gcc_startup_nrf51.S.o:9:169: warning: null character(s) ignored
CMakeFiles/Blinky.dir/Users/atifshabbir/Development/SDK/components/toolchain/gcc/gcc_startup_nrf51.S.o: Assembler messages:
CMakeFiles/Blinky.dir/Users/atifshabbir/Development/SDK/components/toolchain/gcc/gcc_startup_nrf51.S.o:1: Error: junk at end of line, first unrecognized character valued 0x7f
CMakeFiles/Blinky.dir/Users/atifshabbir/Development/SDK/components/toolchain/gcc/gcc_startup_nrf51.S.o:2: Error: junk at end of line, first unrecognized character valued 0x3
CMakeFiles/Blinky.dir/Users/atifshabbir/Development/SDK/components/toolchain/gcc/gcc_startup_nrf51.S.o:3: Error: bad instruction `h�h'
CMakeFiles/Blinky.dir/Users/atifshabbir/Development/SDK/components/toolchain/gcc/gcc_startup_nrf51.S.o:4: Error: bad instruction `c�` H�h'
CMakeFiles/Blinky.dir/Users/atifshabbir/Development/SDK/components/toolchain/gcc/gcc_startup_nrf51.S.o:5: Error: bad instruction `c�J K�����'
CMakeFiles/Blinky.dir/Users/atifshabbir/Development/SDK/components/toolchain/gcc/gcc_startup_nrf51.S.o:5: Error: bad instruction `�x�p����������$�'
CMakeFiles/Blinky.dir/Users/atifshabbir/Development/SDK/components/toolchain/gcc/gcc_startup_nrf51.S.o:6: Error: junk at end of line, first unrecognized character is `:'
CMakeFiles/Blinky.dir/Users/atifshabbir/Development/SDK/components/toolchain/gcc/gcc_startup_nrf51.S.o:7: Error: junk at end of line, first unrecognized character is `4'
CMakeFiles/Blinky.dir/Users/atifshabbir/Development/SDK/components/toolchain/gcc/gcc_startup_nrf51.S.o:8: Error: junk at end of line, first unrecognized character valued 0x1
CMakeFiles/Blinky.dir/Users/atifshabbir/Development/SDK/components/toolchain/gcc/gcc_startup_nrf51.S.o:9: Error: junk at end of line, first unrecognized character valued 0x7
make[3]: *** [Blinky.out] Error 1
make[2]: *** [CMakeFiles/Blinky.dir/all] Error 2
make[1]: *** [CMakeFiles/Blinky.dir/rule] Error 2
make: *** [Blinky] Error 2
in the start he give me lot of warning but I just copy last two warning which is the same as previous warning. after then some error regarding the gcc_startup_nrf5.
thank you
Library definitions and examples should be adapted if needed so they can be build with the version 17.0.0 of the nRF5 SDK. After this change, version 16.0.0 and 17.0.0 should be used for building on the CI.
Redefinition of CMAKE_CXX_LINK_EXECUTABLE omits <LINK_LIBRARIES>. It should be:
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_C_COMPILER} <LINK_FLAGS> -lstdc++ -o <LINK_LIBRARIES>")
For example, without it, this fails with undefined references at link time:
add_library(bar STATIC IMPORTED)
set_target_properties( bar PROPERTIES IMPORTED_LOCATION /home/bootch/git/radioSoC/Debug52/bar.a )
nRF5x_addExecutable(foo main.cpp)
target_link_libraries( foo bar)
apparently cmake enacts that via <LINK_LIBRARIES>.
Also, what happens if the scripts don't redefine at all (and as you say, CMAKE_C_FLAGS are added implicitly)? I guess I should try it and see how CMAKE_C_FLAGS disrupt the link.
Hello!
From that what I can see the Thread and Zigbee SDK has similar directory structure as the nRF SDK, but some of the components are missing and some of components are present only in the former.
The contributing guide explains how to support a new library to use within the "normal" SDK. Most probably to use another SDK some extra steps should be made or the existing steps should be made in another way. I could even try to contribute to support the Thread and Zigbee SDK, but I need support from the authors to take a look at the current project structure and say whether the normal approach is fine or no.
To support the Thread and Zigbee SDK we would need most probably to make some changes in the definition of the cache variables.
What do you think about that?
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
Is this step missing from the tutorial in the readme?
Without it, I get:
CMake Error at CMakeLists.txt:13 (nRF5x_setup):
Unknown CMake command "nRF5x_setup".
when I run: cmake -H. -B"cmake-build" -G "Unix Makefiles"
although I think I followed your tutorial closely.
Alternatively, can you link to a project that uses your cmake script? Or put a template CMakeLists.txt in your repository? That might help other CMake newbies like myself.
Add an option to the main target to generate .map file for the project.
in case user didn't provide linker a scripts, c-nRF can do smarter then now.
Based on this input:
it can provide suitable linker script or generate it on the fly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.