← index #18820Issue #18202
Off-topic · high · value 1.936
QUERY · ISSUE

ports/zephyr fails to compile with CONFIG_BT=y : 'CONFIG_BT_DEVICE_NAME_MAX' undeclared

openby stuartlangridgeopened 2026-02-15updated 2026-02-25
bugport-zephyr

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

CANDIDATE · ISSUE

zephyr: CONFIG_NEWLIB_LIBC=y causes some things (USB on rp2350 on ARM) to fail

closedby VynDragonopened 2025-10-03updated 2025-10-17
bugport-zephyr

Port, board and/or hardware

zephyr

MicroPython version

1.26.1, and latest

Reproduction

see https://github.com/zephyrproject-rtos/zephyr/issues/96993

Build micropython zephyr port (CONFIG_XIP=y or CONFIG_XIP=n)
Put micropython zephyr port on the device
Run
Bug happens (no usb device if console is cdc, error on uart if it is uart).

Expected behaviour

USB works.

see https://github.com/zephyrproject-rtos/zephyr/issues/96993

Observed behaviour

 ***** USAGE FAULT *****
  Unaligned memory access
r0/a1:  0x50100109  r1/a2:  0x20066589  r2/a3:  0x80000000
r3/a4:  0x00000000 r12/ip:  0x50100100 r14/lr:  0x20000e71
 xpsr:  0xa100001e
Faulting instruction address (r15/pc): 0x10001ae8
arch_system_halt (reason=31) at /home/vdragon/dev/zephyr_upstreaming/zephyr/kernel/fatal.c:30
30              for (;;) {
(gdb) bt
#0  arch_system_halt (reason=31) at /home/vdragon/dev/zephyr_upstreaming/zephyr/kernel/fatal.c:30
#1  0x10026720 in k_sys_fatal_error_handler (reason=<optimized out>, esf=esf@entry=0x20067738 <z_interrupt_stacks+1848>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/kernel/fatal.c:44
#2  0x10009950 in z_fatal_error (reason=<optimized out>, esf=esf@entry=0x20067738 <z_interrupt_stacks+1848>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/kernel/fatal.c:119
#3  0x10003be0 in z_arm_fatal_error (reason=<optimized out>, esf=esf@entry=0x20067738 <z_interrupt_stacks+1848>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/arch/arm/core/fatal.c:87
#4  0x10003f4a in z_arm_fault (msp=<optimized out>, psp=<optimized out>, exc_return=<optimized out>, callee_regs=<optimized out>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/arch/arm/core/cortex_m/fault.c:1083
#5  0x10004000 in z_arm_usage_fault () at /home/vdragon/dev/zephyr_upstreaming/zephyr/arch/arm/core/cortex_m/fault_s.S:102
#6  <signal handler called>
#7  0x10001ae8 in memcpy ()
#8  0x20000e70 in rpi_pico_prep_tx (dev=dev@entry=0x1002f510 <__device_dts_ord_77>, buf=buf@entry=0x2006a098 <_net_buf_udc_ep_pool>, cfg=cfg@entry=0x20003030 <ep_cfg_out>)
    at /home/vdragon/dev/zephyr_upstreaming/zephyr/drivers/usb/udc/udc_rpi_pico.c:293
#9  0x20000d44 in rpi_pico_handle_buff_status_in (ep=128 '\200', dev=0x1002f510 <__device_dts_ord_77>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/drivers/usb/udc/udc_rpi_pico.c:600
#10 rpi_pico_handle_buff_status (dev=0x1002f510 <__device_dts_ord_77>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/drivers/usb/udc/udc_rpi_pico.c:664
#11 rpi_pico_isr_handler (dev=0x1002f510 <__device_dts_ord_77>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/drivers/usb/udc/udc_rpi_pico.c:808
#12 0x1000428a in _isr_wrapper () at /home/vdragon/dev/zephyr_upstreaming/zephyr/arch/arm/core/cortex_m/isr_wrapper.c:80
#13 <signal handler called>
#14 0x10022a36 in arch_cpu_idle () at /home/vdragon/dev/zephyr_upstreaming/zephyr/arch/arm/core/cortex_m/cpu_idle.c:106
#15 0x100268a4 in k_cpu_idle () at /home/vdragon/dev/zephyr_upstreaming/zephyr/include/zephyr/kernel.h:6395
#16 idle (unused1=<optimized out>, unused2=<optimized out>, unused3=<optimized out>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/kernel/idle.c:75
#17 0x1002247a in z_thread_entry (entry=0x10, p1=<optimized out>, p2=<optimized out>, p3=<optimized out>) at /home/vdragon/dev/zephyr_upstreaming/zephyr/lib/os/thread_entry.c:48
#18 0xaaaaaaaa in ?? ()

see https://github.com/zephyrproject-rtos/zephyr/issues/96993

Additional Information

Why do we have CONFIG_NEWLIB_LIBC=y in prj.conf ? It should probably be removed and let the default from zephyr be.
Alternative if concern is space usage: use picolibc?

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied