What is the correct C/C++ library to use with mcu-boot / kboot?

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the correct C/C++ library to use with mcu-boot / kboot?

Jump to solution
785 Views
lucasrangit
Contributor III

What is the correct C/C++ library to use with mcu-boot / kboot? Specifically, the "freedom_bootloader" project from the FRDM-K22F SDK version 2.4.1.

Using the MCUXpresso IDE 10.2.1 (on Ubuntu Linux 16.04 64-bit) "Import SDK example(s)", and accepting the default, "Redlib (semihost-nf)" will be selected. However, this fails to compile with the following error.

Building file: ../source/usb/bm_composite/msc_disk.c
Invoking: MCU C Compiler
arm-none-eabi-gcc -std=gnu99 -D__REDLIB__ -DCPU_MK22FN512VDC12_cm4 -DCPU_MK22FN512VDC12 -D__SEMIHOST_HARDFAULT_DISABLE=1 -DCPU_MK22FN512VLH12 -DFREEDOM -DBL_TARGET_FLASH -DFRDM_K22F -DUSB_STACK_BM -DSDK_DEBUGCONSOLE=0 -DCR_INTEGER_PRINTF -DPRINTF_FLOAT_ENABLE=0 -D__MCUXPRESSO -D__USE_CMSIS -DDEBUG -I../board -I../source -I../ -I../MK22F51212_application_0x0000_linker -I../drivers -I../CMSIS -I../usb/device/source/khci -I../usb/include -I../osa -I../startup -I../source/autobaud -I../source/bootloader -I../source/crc -I../source/drivers/microseconds -I../source/include -I../source/memory/src -I../source/memory -I../source/packet -I../source/property -I../source/sbloader -I../source/utilities -I../source/drivers/smc -I../MK22F51212 -I../source/usb/bm_composite -I../usb/device/class/hid -I../usb/device/class/msc -I../usb/device/class -I../usb/device/source -I../usb/device/include -Os -fno-common -g -c -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -D__REDLIB__ -specs=redlib.specs -MMD -MP -MF"source/usb/bm_composite/msc_disk.d" -MT"source/usb/bm_composite/msc_disk.o" -MT"source/usb/bm_composite/msc_disk.d" -o "source/usb/bm_composite/msc_disk.o" "../source/usb/bm_composite/msc_disk.c"
In file included from ../source/usb/bm_composite/msc_disk.c:27:0:
../source/usb/bm_composite/fat_directory_entry.h:11:10: fatal error: wchar.h: No such file or directory
 #include <wchar.h>
 ^~~~~~~~~
compilation terminated.
source/usb/bm_composite/subdir.mk:27: recipe for target 'source/usb/bm_composite/msc_disk.o' failed
make: *** [source/usb/bm_composite/msc_disk.o] Error 1

Changing "Library headers" under “MCU Compiler” -> “Miscellaneous” and “Architecture & Headers” -> “MCU Assembler” to NewlibNano (auto) fixes the build. However, the setting does not persist. Reopening the project properties immediately after a build or after restarting the IDE shows the "Library headers" reverted back to "Redlib (auto)". Also, after changing the "Library headers" to "NewlibNano (auto)" the built-in include paths under "C/C++ General" -> "Paths and Symbols" does not change from the relib paths to the arm-none-eabi include paths.

The "Quick Settings" -> "Set library/header type" is also not available (grayed out).

The only way I can fix this permanently is if I re-import the project and select the C/C++ library before importing.

Am I doing this wrong? Is "NewlibNano (auto)" the correct library to use for the bootloader?

1 Solution
307 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

1. "semihost HardFault handler" is not must selected;

2. Yes, I recommend customer to select and use "NewlibNano (none)". In fact, the "NewlibNano (none)" doesn't add more footprint to bootloader image.

Thank you for the attention.


Have a great day,
Mike

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

3 Replies
307 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I import SDK [freedom_bootloader] example with below default setting without meet any compile error with MCUXpresso IDE.

Below is default selected "NewlibNano (None)".

pastedImage_1.png


Have a great day,
Mike

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

307 Views
lucasrangit
Contributor III

Thanks Hui_Ma‌. Not sure what's different with my system. I have two follow up questions.

1. I don't think the "semihost HardFault handler" should be selected by default though because "__SEMIHOST_HARDFAULT_DISABLE=1" is set in the project. Does having this checked matter?

2. Would you say then that "NewlibNano (none)" and not Redlib is the correct C library to use? I would have thought that Redlib would be smaller and more appropriate for the bootloader. Unless it needs C++.

0 Kudos
308 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

1. "semihost HardFault handler" is not must selected;

2. Yes, I recommend customer to select and use "NewlibNano (none)". In fact, the "NewlibNano (none)" doesn't add more footprint to bootloader image.

Thank you for the attention.


Have a great day,
Mike

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post