Standard libraries, like printf(), aren't working / available

Device: nRF51822_xxac; the Nordic-supplied NUS application worked after I figured out the softdevice and application loading sequence.

Development platform: Mac OS Tahoe 26.3; Toolchain: Arm GNU Toolchain 14.3.1, downloaded from https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads 

I'm in the "blink an LED" / see if it works stage of changing the UART NUS application, and haven't actually changed anything in the ble_peripheral/ble_app_uart application, except for DEVICE_NAME: I'm just testing that my build tools can correctly produce an output.  It's sort-of working, but the "printf( "UART start!" );" isn't working.  The binary builds, and the "make flash_softdevice && make flash" seem to work; I can see and connect to the updated DEVICE_NAME in the BLE scan tool, but the program serial output via printf() doesn't print.  Here's the build output:

$ make && make flash_softdevice && make flash
Compiling file: main.c
Linking target: _build/nrf51822_xxac.out
/Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld: /Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc_nano.a(libc_a-closer.o): in function `_close_r':
closer.c:(.text._close_r+0xc): warning: _close is not implemented and will always fail
/Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld: /Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc_nano.a(libc_a-closer.o): note: the message above does not take linker garbage collection into account
/Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld: /Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc_nano.a(libc_a-lseekr.o): in function `_lseek_r':
lseekr.c:(.text._lseek_r+0x10): warning: _lseek is not implemented and will always fail
/Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld: /Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc_nano.a(libc_a-lseekr.o): note: the message above does not take linker garbage collection into account
/Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld: /Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc_nano.a(libc_a-readr.o): in function `_read_r':
readr.c:(.text._read_r+0x10): warning: _read is not implemented and will always fail
/Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld: /Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc_nano.a(libc_a-readr.o): note: the message above does not take linker garbage collection into account
/Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld: /Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc_nano.a(libc_a-writer.o): in function `_write_r':
writer.c:(.text._write_r+0x10): warning: _write is not implemented and will always fail
/Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld: /Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc_nano.a(libc_a-writer.o): note: the message above does not take linker garbage collection into account

text data bss dec hex filename
20584 136 2208 22928 5990 _build/nrf51822_xxac.out

Preparing: _build/nrf51822_xxac.hex
Preparing: _build/nrf51822_xxac.bin
Flashing: s130_nrf51_2.0.1_softdevice.hex
nrfjprog --jdll /Applications/SEGGER/JLink_V890/libjlinkarm.8.90.0.dylib --program /Users/aaronm/Downloads/NordicSemi-nRF51822/nRF5_SDK_12.3.0_d7731ad/components/softdevice/s130/hex/s130_nrf51_2.0.1_softdevice.hex -f nrf51 --sectorerase
[ #################### ] 4.232s | Erase file - Done erasing
[ #################### ] 1.469s | Program file - Done programming
WARNING: A programming operation has been performed without --verify.
WARNING: Programming can fail without error.
nrfjprog --jdll /Applications/SEGGER/JLink_V890/libjlinkarm.8.90.0.dylib --reset -f nrf51
Applying system reset.
Run.
Flashing: _build/nrf51822_xxac.hex
nrfjprog --jdll /Applications/SEGGER/JLink_V890/libjlinkarm.8.90.0.dylib --program _build/nrf51822_xxac.hex -f nrf51 --sectorerase
[ #################### ] 0.807s | Erase file - Done erasing
[ #################### ] 0.283s | Program file - Done programming
WARNING: A programming operation has been performed without --verify.
WARNING: Programming can fail without error.
nrfjprog --jdll /Applications/SEGGER/JLink_V890/libjlinkarm.8.90.0.dylib --reset -f nrf51
Applying system reset.
Run.

I disabled #define RETARGET_ENABLED 0 to get it to compile; it wouldn't complete the linking phase at all with RETARGET set to 1.  I suspect the "LDFLAGS += --specs=nano.specs -lc -lnosys" has something to do with the missing printf() and related libraries, but I'm not wizard enough to determine how.  Hopefully, this is a trivial issue for the more experienced among us.

Thanks!

Parents
  • Hi Aaron

    It sounds like your application is working as expected, but that you don't get the logging you expect. Are you working on a development kit or a custom board here? If a custom board, how is the device connected to your computer and how is the serial data going to the computer's serial terminal?

    Best regards,

    Simon

  • It's an old Red Bear Nano *1, which uses a RayTec MDBT40 *2 module, which I bought years ago and never did anything with.  And logging / printf() does work with the Nordic hex files for the NUS UART example, but not with the UART hex built locally.

    I tried:

    official SD & local UART hex - no logging

    official SD & official UART hex - logging

    And this is reproducible.  So it looks like my compiled version of the UART hex doesn't have the standard libraries for printing.

    https://os.mbed.com/platforms/RedBearLab-BLE-Nano/

    https://www.tinyosshop.com/mdbt40-ble-module 

    Aside from pathnames to SDK_ROOT, the Makefile is taken straight from the SDK.  Here's the linker section:

    # Linker flags
    LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
    LDFLAGS += -mcpu=cortex-m0
    # let linker to dump unused sections
    LDFLAGS += -Wl,--gc-sections
    # use newlib in nano version
    LDFLAGS += --specs=nano.specs -lc -lnosys

Reply
  • It's an old Red Bear Nano *1, which uses a RayTec MDBT40 *2 module, which I bought years ago and never did anything with.  And logging / printf() does work with the Nordic hex files for the NUS UART example, but not with the UART hex built locally.

    I tried:

    official SD & local UART hex - no logging

    official SD & official UART hex - logging

    And this is reproducible.  So it looks like my compiled version of the UART hex doesn't have the standard libraries for printing.

    https://os.mbed.com/platforms/RedBearLab-BLE-Nano/

    https://www.tinyosshop.com/mdbt40-ble-module 

    Aside from pathnames to SDK_ROOT, the Makefile is taken straight from the SDK.  Here's the linker section:

    # Linker flags
    LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
    LDFLAGS += -mcpu=cortex-m0
    # let linker to dump unused sections
    LDFLAGS += -Wl,--gc-sections
    # use newlib in nano version
    LDFLAGS += --specs=nano.specs -lc -lnosys

Children
No Data
Related