Hi all,
I am following the FreeRTOS MCUBoot Demo tutorial which demonstrates how to build and use MCUBoot on an ESP32 with FreeRTOS. This is based on the this GitHub Project., However, when I run the command:
cmake --build build --target mcuboot-flash
I encounter the following error related to undefined references:
undefined reference to '_exit', '_kill', '_getpid', and '_sbrk'
Below is the full output of the error:
admunin@PC:~/Documents/Lab-Project-FreeRTOS-MCUBoot/proj/espressif/esp32/bootloader$ cmake --build build --target mcuboot-flash
[1/3] Linking C executable mcuboot_esp32.elf
FAILED: mcuboot_esp32.elf
: && /home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc -mlongcalls -Wno-frame-address -Wl,--gc-sections CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/freertos/main.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/freertos/keys.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/boot_record.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/bootutil_misc.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/bootutil_public.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/caps.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/encrypted.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/fault_injection_hardening.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/fault_injection_hardening_delay_rng_mbedtls.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/image_ec.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/image_ec256.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/image_ed25519.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/image_rsa.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/image_validate.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/loader.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/swap_misc.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/swap_move.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/swap_scratch.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/bootutil/src/tlv.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/boot_serial/src/boot_serial.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/boot_serial/src/cbor_common.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/boot_serial/src/cbor_decode.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/boot_serial/src/cbor_encode.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/boot_serial/src/serial_recovery_cbor.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/ext/mbedtls/library/sha256.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/ext/mbedtls/library/platform_util.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/ext/mbedtls/library/asn1parse.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/ext/mbedtls/library/ecp.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/ext/mbedtls/library/ecp_curves.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/ext/mbedtls/library/bignum.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/ext/mbedtls/library/ecdsa.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/ext/mbedtls/library/base64.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/ext/mbedtls/library/memory_buffer_alloc.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/ext/tinycrypt/lib/source/ecc.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/ext/tinycrypt/lib/source/ecc_dsa.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/ext/tinycrypt/lib/source/sha256.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/ext/tinycrypt/lib/source/utils.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/espressif/port/esp_mcuboot.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/espressif/port/esp_loader.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/port/espressif/src/boot_startup_port.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/port/espressif/src/boot_log_port.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/port/espressif/src/boot_assert_port.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/port/espressif/src/boot_wdt_port.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/port/espressif/src/boot_heap_port.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/port/espressif/src/boot_serial_port.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/port/espressif/src/system_port.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/port/espressif/src/base64_port.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/port/espressif/src/crc16_port.c.obj CMakeFiles/mcuboot_esp32.elf.dir/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/lib/mcuboot/boot/espressif/hal/esp-idf/components/soc/esp32/uart_periph.c.obj -o mcuboot_esp32.elf -T/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/proj/espressif/esp32/bootloader/ld/bootloader.ld -T/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/proj/espressif/esp32/bootloader/ld/rom_32.ld -nostdlib -mlongcalls -Wno-frame-address -Wl,--cref -Wl,--Map=mcuboot_esp32.map -fno-rtti -fno-lto -Wl,--gc-sections -Wl,--undefined=uxTopUsedPriority -lm -lgcc -lgcov -lstdc++ -lc boot/espressif/hal/libhal.a -Wno-frame-address -Wl,--cref -Wl,--Map=mcuboot_esp32.map -fno-rtti -fno-lto -Wl,--gc-sections -Wl,--undefined=uxTopUsedPriority -lm -lgcc -lgcov -T/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/proj/espressif/esp32/bootloader/../../../../lib/mcuboot/boot/espressif/hal/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld -T/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/proj/espressif/esp32/bootloader/../../../../lib/mcuboot/boot/espressif/hal/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld -T/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/proj/espressif/esp32/bootloader/../../../../lib/mcuboot/boot/espressif/hal/esp-idf/components/esp_rom/esp32/ld/esp32.rom.api.ld -T/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/proj/espressif/esp32/bootloader/../../../../lib/mcuboot/boot/espressif/hal/esp-idf/components/esp32/ld/esp32.peripherals.ld -T/home/admunin/Documents/Lab-Project-FreeRTOS-MCUBoot/proj/espressif/esp32/bootloader/../../../../lib/mcuboot/boot/espressif/hal/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld && :
/home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: mcuboot_esp32.elf section `.iram.text' will not fit in region `iram_seg'
/home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: region `iram_seg' overflowed by 176 bytes
/home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: /home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/lib/esp32/no-rtti/libc.a(libc_a-abort.o):(.literal+0x0): undefined reference to `_exit'
/home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: /home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/lib/esp32/no-rtti/libc.a(libc_a-abort.o): in function `abort':
/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/newlib/newlib/libc/stdlib/abort.c:58:(.text+0xa): undefined reference to `_exit'
/home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: /home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/lib/esp32/no-rtti/libc.a(libc_a-signalr.o):(.literal+0x4): undefined reference to `_kill'
/home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: /home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/lib/esp32/no-rtti/libc.a(libc_a-signalr.o):(.literal+0x8): undefined reference to `_getpid'
/home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: /home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/lib/esp32/no-rtti/libc.a(libc_a-signalr.o): in function `_kill_r':
/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/newlib/newlib/libc/reent/signalr.c:53:(.text+0xe): undefined reference to `_kill'
/home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: /home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/lib/esp32/no-rtti/libc.a(libc_a-signalr.o): in function `_getpid_r':
/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/newlib/newlib/libc/reent/signalr.c:83:(.text+0x27): undefined reference to `_getpid'
/home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: /home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/lib/esp32/no-rtti/libc.a(libc_a-sbrkr.o):(.literal+0x0): undefined reference to `_sbrk'
/home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: /home/admunin/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/lib/esp32/no-rtti/libc.a(libc_a-sbrkr.o): in function `_sbrk_r':
/builds/idf/crosstool-NG/.build/xtensa-esp-elf/src/newlib/newlib/libc/reent/sbrkr.c:51:(.text+0xc): undefined reference to `_sbrk'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Has anyone encountered this issue before? Any advice on how to resolve the undefined references to _exit, _kill, _getpid, and _sbrk?