Zephyr and Nordic nRF52-DK Tutorial Build Fail

I followed the instructions listed in “Zephyr and Nordic nRF52-DK: debugging, unit testing, project analysis” tutorial ([link])(Zephyr and Nordic nRF52-DK: debugging, unit testing, project analysis — PlatformIO latest documentation), but I get the following error:

src/main.c:15:21: error: ‘CONFIG_BT_DEVICE_NAME’ undeclared here (not in a function); did you mean ‘CONFIG_TIMESLICE_SIZE’?

If I replace CONFIG_BT_DEVICE_NAME in main.c to “TEST” or 0, I get the folllowing linker error:

/home/mustafa/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/8.2.1/…/…/…/…/arm-none-eabi/bin/ld: .pio/build/nrf52840_dk/src/main.o: in function bt_ready': /home/mustafa/Documents/PlatformIO/Projects/hw2/src/main.c:51: undefined reference to bt_le_adv_start’
/home/mustafa/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/8.2.1/…/…/…/…/arm-none-eabi/bin/ld: .pio/build/nrf52840_dk/src/main.o: in function main': /home/mustafa/Documents/PlatformIO/Projects/hw2/src/main.c:68: undefined reference to bt_enable’
collect2: error: ld returned 1 exit status
*** [.pio/build/nrf52840_dk/firmware-pre.elf] Error 1

Any idea what is going on? Thx!

This is weird. Are you 100% you did

By default Bluetooth feature is disabled, we can enable it by creating a new file prj.conf in zephyr folder and adding the following lines:

    CONFIG_BT_DEVICE_NAME="Test beacon"

Correctly? Whats the content of <project root>/zephyr/prj.conf?

Yes. My prj.conf content is exactly the same as the text you copied and located under /zephyr.

I’ve followed the tutorial above and I don’t have any problems.

Try the following: Open a CLI and execute

pio upgrade --dev
pio platform update nordicnrf52

then use the project task “Clean” and then “Build” to retry.

1 Like

I had the same problem. My issue was that the prj.conf file was in the wrong directory. Once I moved it into the zephyr directory it worked. I had been looking at the project structure of the default examples and hadn’t realized the zephyr directory was where the prj.conf file was supposed to go when using platformio.