NimBLE-Arduino icon indicating copy to clipboard operation
NimBLE-Arduino copied to clipboard

"undefined reference to 'na_ble_sm_alg_encrypt'" linker error when using CONFIG_BT_NIMBLE_ROLE_PERIPHERAL_DISABLED and CONFIG_BT_NIMBLE_ROLE_CENTRAL_DISABLED

Open Bascy opened this issue 2 months ago • 1 comments

When compiling our project using NimBLE 2.3.6. I get the wollowing linker error when using multiple compiler options:

platformio.ini

;PlatformIO Project Configuration File

[platformio]
default_envs = debug

[env]
platform = espressif32
board = esp32dev
framework = arduino

board_upload.flash_size = 16MB
board_build.partitions = default_16MB.csv
board_upload.maximum_size = 16777216
board_build.filesystem = spiffs

;======================================================
[env:debug]
build_type = debug
build_flags = 
	${env.build_flags}
	-DDEBUG_SENSE  
  -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
  -DDEBUG_NODEIDS=""

  -D CONFIG_BT_NIMBLE_ROLE_PERIPHERAL_DISABLED  #not using NimBLE Server functions (uses approx. 16kB flash.)
  -D CONFIG_BT_NIMBLE_ROLE_CENTRAL_DISABLED #not using NimBLE Client functions (uses approx. 7kB flash.)

C:/Users/bas/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld.exe: .pio/build/debug/lib439/NimBLE-Arduino/nimble/nimble/host/src/ble_hs_resolv.c.o:(.literal.ble_hs_resolv_gen_priv_addr+0x4): undefined reference to na_ble_sm_alg_encrypt' C:/Users/bas/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld.exe: .pio/build/debug/lib439/NimBLE-Arduino/nimble/nimble/host/src/ble_hs_resolv.c.o: in function ble_hs_resolv_gen_priv_addr': D:\Projects\Libraries\Sense_EnOcean/.pio/libdeps/debug/NimBLE-Arduino/src/nimble/nimble/host/src/ble_hs_resolv.c:410:(.text.ble_hs_resolv_gen_priv_addr+0x73): undefined reference to `na_ble_sm_alg_encrypt' collect2.exe: error: ld returned 1 exit status *** [.pio\build\debug\firmware.elf] Error 1

Bascy avatar Oct 05 '25 20:10 Bascy

Yes, this is an issue in idf as well. workaround options are to enable one or other of peripheral/central roles, define the missing functions in your code, or use a different esp32 chip, s2,c3 etc..

h2zero avatar Oct 15 '25 22:10 h2zero