cederom edited a comment on issue #4674:
URL:
https://github.com/apache/incubator-nuttx/issues/4674#issuecomment-945206929
Thanks @xiaoxiang781216 and @Ouss4 (at the mailing lit) for the hints :-)
The quickest way to overcome this problem is to use `make
CROSSDEV=riscv32-esp-elf-`.
I did some toolchain auto-detection in
`arch/risc-v/src/rv32im/Toolchain.defs`:
```
RVTOOLCHAINS := \
riscv64-none-elf-\
riscv32-esp-elf-\
riscv32-unknown-elf-\
riscv64-unknown-elf
RVTOOLCHAINS_AVAILABLE := $(foreach rvtoolchain, $(RVTOOLCHAINS),\
$(if $(shell which $(rvtoolchain)gcc), $(rvtoolchain) ) )
CROSSDEV ?= $(word 1,${RVTOOLCHAINS_AVAILABLE})
$(info "USING CROSSDEV: ${CROSSDEV}")
```
The problem is it auto-detects over and over during build, as the file is
called multiple times, rendering build process inefficient. This is not the way
to go, at least not in this location :-)
I have found only ESP-IDF `riscv32-esp-elf-` toolchain to build the firmware
with success (on Linux and BSD). I did not try the `riscv64-unknown-elf` but
this one seems to work for you.
Also I have verified following toolchains NOT to build the firmware out of
the box:
1. FreeBSD system package `riscv64-none-elf-` has `-lm` linking problem at
the end of build:
```
"USING CROSSDEV: riscv64-none-elf-"
AS: chip/esp32c3_head.S
gmake[2]: Entering directory
'/XXX/nuttx.git/nuttx/boards/risc-v/esp32c3/esp32c3-devkit/src'
"USING CROSSDEV: riscv64-none-elf-"
CC: esp32c3_boot.c
CC: esp32c3_bringup.c
CC: esp32c3_appinit.c
CC: esp32c3_board_wlan.c
AR (create): libboard.a esp32c3_boot.o esp32c3_bringup.o esp32c3_appinit.o
esp32c3_board_wlan.o
gmake[2]: Leaving directory
'/XXX/nuttx.git/nuttx/boards/risc-v/esp32c3/esp32c3-devkit/src'
LD: nuttx
riscv64-none-elf-ld: skipping incompatible /usr/lib/libm.so when searching
for -lm
riscv64-none-elf-ld: skipping incompatible /usr/lib/libm.a when searching
for -lm
riscv64-none-elf-ld: cannot find -lm
riscv64-none-elf-ld: skipping incompatible /usr/lib/libm.so when searching
for -lm
gmake[1]: *** [Makefile:145: nuttx] Error 1
gmake[1]: Leaving directory '/XXX/nuttx.git/nuttx/arch/risc-v/src'
gmake: *** [tools/Makefile.unix:420: nuttx] Error 2
```
2. FreeBSD system package `riscv32-unknown-elf-` has `-lm` linking problem
at the end of build:
```
"USING CROSSDEV: riscv32-unknown-elf-"
AS: chip/esp32c3_head.S
gmake[2]: Entering directory
'/XXX/nuttx.git/nuttx/boards/risc-v/esp32c3/esp32c3-devkit/src'
"USING CROSSDEV: riscv32-unknown-elf-"
CC: esp32c3_boot.c
CC: esp32c3_bringup.c
CC: esp32c3_appinit.c
CC: esp32c3_board_wlan.c
AR (create): libboard.a esp32c3_boot.o esp32c3_bringup.o esp32c3_appinit.o
esp32c3_board_wlan.o
gmake[2]: Leaving directory
'/XXX/nuttx.git/nuttx/boards/risc-v/esp32c3/esp32c3-devkit/src'
LD: nuttx
riscv32-unknown-elf-ld: skipping incompatible /usr/lib/libm.so when
searching for -lm
riscv32-unknown-elf-ld: skipping incompatible /usr/lib/libm.a when searching
for -lm
riscv32-unknown-elf-ld: cannot find -lm
riscv32-unknown-elf-ld: skipping incompatible /usr/lib/libm.so when
searching for -lm
gmake[1]: *** [Makefile:145: nuttx] Error 1
gmake[1]: Leaving directory '/XXX/nuttx.git/nuttx/arch/risc-v/src'
gmake: *** [tools/Makefile.unix:420: nuttx] Error 2
```
3. Debian Linux system package `riscv32-unknown-elf-` has wrong linking
format problem at the end of build:
```
$ make CROSSDEV=riscv64-linux-gnu-
(...)
C: bluetooth/bt_uuid.c
AR (create): libwireless.a bt_buf.o bt_netdev.o bt_queue.o bt_hcicore.o
bt_atomic.o bt_att.o bt_conn.o bt_gatt.o bt_ioctl.o bt_keys.o bt_l2cap.o
bt_smp.o bt_uuid.o
make[1]: Leaving directory '/home/user/work/nuttx/nuttx.git/nuttx/wireless'
IN: wireless/libwireless.a -> staging/libwireless.a
make[1]: Entering directory
'/home/user/work/nuttx/nuttx.git/nuttx/arch/risc-v/src'
AS: chip/esp32c3_head.S
make[2]: Entering directory
'/home/user/work/nuttx/nuttx.git/nuttx/boards/risc-v/esp32c3/esp32c3-devkit/src'
CC: esp32c3_boot.c
CC: esp32c3_bringup.c
CC: esp32c3_appinit.c
CC: esp32c3_board_wlan.c
AR (create): libboard.a esp32c3_boot.o esp32c3_bringup.o esp32c3_appinit.o
esp32c3_board_wlan.o
make[2]: Leaving directory
'/home/user/work/nuttx/nuttx.git/nuttx/boards/risc-v/esp32c3/esp32c3-devkit/src'
LD: nuttx
riscv64-linux-gnu-ld:
/usr/lib/gcc-cross/riscv64-linux-gnu/8/../../../../riscv64-linux-gnu/lib/libm.so:
error adding symbols: file in wrong format
make[1]: *** [Makefile:145: nuttx] Error 1
make[1]: Leaving directory
'/home/user/work/nuttx/nuttx.git/nuttx/arch/risc-v/src'
make: *** [tools/Makefile.unix:420: nuttx] Error 2
```
For above "generic" system toolchains probably a `-l` needs to be passed to
use NuttX libraries not the system ones.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]