ports/zephyr fails to compile with CONFIG_BT=y : 'CONFIG_BT_DEVICE_NAME_MAX' undeclared
Port, board and/or hardware
nRF52840 Dongle
MicroPython version
micropython 1.27.0 or master: build is zephyr on Ubuntu 24.04.
Reproduction
I am trying to bring up the zephyr port on the nRF52840 dongle (which is supported by Zephyr: the similar nRF52840DK is supported by both zephyr and micropython's zephyr port). If I build micropython with default kernel config as per the instructions (west build -p always -b nrf52840dongle micropython/ports/zephyr, with no ports/zephyr/boards/nrf52840dongle.conf present) then the build is fine and completes, and works when flashed to the device. However, when I turn bluetooth on (by creating ports/zephyr/boards/nrf52840dongle.conf with CONFIG_BT=y in it) and build again with the same command, the build fails, with a bunch of compilation errors to do with missing symbols and the like, as listed below
Expected behaviour
No response
Observed behaviour
end section of the build log (project name shortened to <myproject> just to keep the line lengths down!)
[466/476] Building C object CMakeFiles/micropython.dir/modbluetooth_zephyr.c.obj
FAILED: CMakeFiles/micropython.dir/modbluetooth_zephyr.c.obj
ccache <myproject>/zephyrproject/zephyr/zephyr-sdk-latest/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DFFCONF_H=\"<myproject>/micropython/ports/zephyr/../../lib/oofatfs/ffconf.h\" -DKERNEL -DK_HEAP_MEM_POOL_SIZE=0 -DMICROPY_BOARD_BUILD_NAME=\"ZEPHYR_NRF52840DONGLE\" -DMICROPY_HEAP_SIZE=49152 -DMICROPY_VFS_FAT=1 -DMICROPY_VFS_LFS1=0 -DMICROPY_VFS_LFS2=1 -DMP_CONFIGFILE="<mpconfigport.h>" -DNDEBUG -DNRF52840_XXAA -DNRF54L_CONFIGURATION_56_ENABLE=0 -DPICOLIBC_DOUBLE_PRINTF_SCANF -D_POSIX_THREAD_SAFE_FUNCTIONS=200809L -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -I<myproject>/micropython/ports/zephyr/../.. -I<myproject>/micropython/ports/zephyr -I<myproject>/zephyrproject/zephyr/build -I<myproject>/zephyrproject/zephyr/include -I<myproject>/zephyrproject/zephyr/build/zephyr/include/generated -I<myproject>/zephyrproject/zephyr/soc/nordic -I<myproject>/zephyrproject/zephyr/lib/libc/picolibc/include -I<myproject>/zephyrproject/zephyr/lib/posix/c_lib_ext/getopt -I<myproject>/zephyrproject/zephyr/soc/nordic/nrf52/. -I<myproject>/zephyrproject/zephyr/soc/nordic/common/. -I<myproject>/zephyrproject/zephyr/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/nrfx_glue -I<myproject>/zephyrproject/zephyr/subsys/bluetooth -I<myproject>/zephyrproject/zephyr/drivers/usb/common/nrf_usbd_common/. -I<myproject>/zephyrproject/modules/hal/cmsis_6/CMSIS/Core/Include -I<myproject>/zephyrproject/zephyr/modules/cmsis_6/. -I<myproject>/zephyrproject/modules/hal/nordic/nrfx -I<myproject>/zephyrproject/modules/hal/nordic/nrfx/drivers/include -I<myproject>/zephyrproject/modules/hal/nordic/nrfx/bsp/stable -I<myproject>/zephyrproject/modules/hal/nordic/nrfx/bsp/stable/templates -I<myproject>/zephyrproject/zephyr/modules/hal_nordic/nrfx/. -isystem <myproject>/zephyrproject/zephyr/lib/libc/common/include -fno-strict-aliasing -Os -imacros <myproject>/zephyrproject/zephyr/build/zephyr/include/generated/zephyr/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mfp16-format=ieee -mtp=soft --sysroot=<myproject>/zephyrproject/zephyr/zephyr-sdk-latest/arm-zephyr-eabi/arm-zephyr-eabi -imacros <myproject>/zephyrproject/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=<myproject>/micropython/ports/zephyr=CMAKE_SOURCE_DIR -fmacro-prefix-map=<myproject>/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=<myproject>/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=picolibc.specs -std=c17 -std=gnu99 -fomit-frame-pointer -MD -MT CMakeFiles/micropython.dir/modbluetooth_zephyr.c.obj -MF CMakeFiles/micropython.dir/modbluetooth_zephyr.c.obj.d -o CMakeFiles/micropython.dir/modbluetooth_zephyr.c.obj -c <myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c
<myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c: In function 'mp_bluetooth_gap_set_device_name':
<myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c:367:18: error: 'CONFIG_BT_DEVICE_NAME_MAX' undeclared (first use in this function); did you mean 'CONFIG_BT_DEVICE_NAME'?
367 | char tmp_buf[CONFIG_BT_DEVICE_NAME_MAX + 1];
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| CONFIG_BT_DEVICE_NAME
<myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c:367:18: note: each undeclared identifier is reported only once for each function it appears in
<myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c:367:10: warning: unused variable 'tmp_buf' [-Wunused-variable]
367 | char tmp_buf[CONFIG_BT_DEVICE_NAME_MAX + 1];
| ^~~~~~~
<myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c: In function 'mp_bluetooth_gap_advertise_start':
<myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c:412:35: error: 'BT_LE_ADV_OPT_CONNECTABLE' undeclared (first use in this function); did you mean 'BT_LE_ADV_OPT_SCANNABLE'?
412 | .options = (connectable ? BT_LE_ADV_OPT_CONNECTABLE : 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| BT_LE_ADV_OPT_SCANNABLE
<myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c:413:15: error: 'BT_LE_ADV_OPT_ONE_TIME' undeclared (first use in this function); did you mean 'BT_LE_ADV_OPT_NO_2M'?
413 | | BT_LE_ADV_OPT_ONE_TIME
| ^~~~~~~~~~~~~~~~~~~~~~
| BT_LE_ADV_OPT_NO_2M
<myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c: In function 'mp_bluetooth_gap_set_device_name':
<myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c:374:1: warning: control reaches end of non-void function [-Wreturn-type]
374 | }
| ^
<myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c: At top level:
<myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c:979:13: warning: 'add_descriptor' defined but not used [-Wunused-function]
979 | static void add_descriptor(struct bt_gatt_attr *chrc, struct add_descriptor *d, struct bt_gatt_attr *attr_desc) {
| ^~~~~~~~~~~~~~
<myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c:921:13: warning: 'add_characteristic' defined but not used [-Wunused-function]
921 | static void add_characteristic(struct add_characteristic *ch, struct bt_gatt_attr *attr_chrc, struct bt_gatt_attr *attr_value) {
| ^~~~~~~~~~~~~~~~~~
<myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c:907:13: warning: 'add_service' defined but not used [-Wunused-function]
907 | static void add_service(const struct bt_uuid *u, struct bt_gatt_attr *attr) {
| ^~~~~~~~~~~
<myproject>/micropython/ports/zephyr/modbluetooth_zephyr.c:869:24: warning: 'create_zephyr_uuid' defined but not used [-Wunused-function]
869 | static struct bt_uuid *create_zephyr_uuid(const mp_obj_bluetooth_uuid_t *uuid) {
| ^~~~~~~~~~~~~~~~~~
[468/476] Building C object CMakeFiles/micropy...ini_zephyr/micropython/lib/littlefs/lfs2.c.obj
<myproject>/micropython/lib/littlefs/lfs2.c:508:13: warning: 'lfs2_mlist_isopen' defined but not used [-Wunused-function]
508 | static bool lfs2_mlist_isopen(struct lfs2_mlist *head,
| ^~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/bin/cmake --build <myproject>/zephyrproject/zephyr/build
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree
Undefined real_main building zephyr port
Hello!
I was trying to build micropython Zephyr port on MacOS. My target is arduino_due. I can build Zephyr sample applications, upload them to the device and run. Thus I assume build configuration for Zephyr shall be usable. Zephyr src version is git clone from last Friday (commit 20cd4b551b938e83d8de250ebf810455a2a8a35f). cmake version is 3.10.3
When I try to build zephyr port with make BOARD=arduino_due I get:
micropython/ports/zephyr/src/zephyr_start.c:38: undefined reference to `real_main'
collect2: error: ld returned 1 exit status
I get the same if I do make_minimal instead of make.