开源RTOS(实时操作系统):nuttx 编译

news2025/5/18 22:06:06

开源RTOS(实时操作系统):nuttx 编译

手册:Installing — NuttX latest documentation

源码:GitHub - apache/nuttx: Apache NuttX is a mature, real-time embedded operating system (RTOS)

Installing

The first step to get started with NuttX is to install a series of required tools, a toolchain for the architecture you will be working with and, finally, download NuttX source code itself.

Prerequisites

First, install the following set of system dependencies according to your Operating System:

Linux (debian based)Linux (Fedora / RPM based)macOSWindows / WSLWindows/Cygwin

Run the following command to install packages:

$ sudo apt install \
$ bison flex gettext texinfo libncurses5-dev libncursesw5-dev xxd \
$ git gperf automake libtool pkg-config build-essential gperf genromfs \
$ libgmp-dev libmpc-dev libmpfr-dev libisl-dev binutils-dev libelf-dev \
$ libexpat1-dev gcc-multilib g++-multilib picocom u-boot-tools util-linux

KConfig frontend

NuttX configuration system uses KConfig which is exposed via a series of interactive menu-based frontends, part of the kconfig-frontends package. Depending on your OS you may use a precompiled package or you will have to build it from source, which is available in the NuttX tools repository:

Ubuntu 20.04 LTS and laterUbuntu 18.04 LTS and earlierFedoramacOS

$ sudo apt install kconfig-frontends

NuttX also supports kconfiglib by default, which is a Kconfig tool implemented in Python 2/3. Compared with kconfig-frontends, kconfiglib provides NuttX with the possibility of multi-platform support(configure NuttX in Windows native/Visual Studio), and also kconfiglib has a stronger Kconfig syntax check, this will help developers to avoid some Kconfig syntax errors. Install kconfiglib via following command:

sudo apt install python3-kconfiglib

If you are a working on Windows, which also need the support of windows-curses:

pip install windows-curses

Toolchain

To build Apache NuttX you need the appropriate toolchain according to your target platform. Some Operating Systems such as Linux distribute toolchains for various architectures. This is usually an easy choice however you should be aware that in some cases the version offered by your OS may have problems and it may be better to use a widely used build from another source.

The following example shows how to install a toolchain for ARM architecture:

Ubuntu (deb)macOSFrom arm.com

$ sudo apt install gcc-arm-none-eabi binutils-arm-none-eabi

Tip

There are hints on how to get the latest tool chains for most supported architectures in the Apache NuttX CI helper script and Docker container

Todo

Required toolchain should be part of each arch documentation (see relevant issue).

Download NuttX

Apache NuttX is actively developed on GitHub. There are two main repositories, nuttx and apps, where the latter is technically optional (but recommended for complete set of features). If you intend to contribute changes, you need the absolute latest version or you simply prefer to work using git, you should clone these repositories (recommended). Otherwise you can choose to download any stable release archive.

Clone git repositoriesDownload stable release

$ mkdir nuttxspace
$ cd nuttxspace
$ git clone https://github.com/apache/nuttx.git nuttx
$ git clone https://github.com/apache/nuttx-apps apps

The development source code is also available as a compressed archive, should you need it:

$ mkdir nuttxspace
$ cd nuttxspace
$ curl -L https://github.com/apache/nuttx/tarball/master -o nuttx.tar.gz
$ curl -L https://github.com/apache/nuttx-apps/tarball/master -o apps.tar.gz
$ tar zxf nuttx.tar.gz --one-top-level=nuttx --strip-components 1
$ tar zxf apps.tar.gz --one-top-level=apps --strip-components 1

There are also .zip archives available (useful for Windows users): just replace tarball with zipball.

在Windows10的WSL Ubuntu22.04环境下实践安装Nuttx 

首先进入WSL

安装基本库

sudo apt install \
bison flex gettext texinfo libncurses5-dev libncursesw5-dev xxd \
git gperf automake libtool pkg-config build-essential gperf genromfs \
libgmp-dev libmpc-dev libmpfr-dev libisl-dev binutils-dev libelf-dev \
libexpat1-dev gcc-multilib g++-multilib picocom u-boot-tools util-linux

 安装KConfig frontend

sudo apt install kconfig-frontends

安装工具链

sudo apt install gcc-arm-none-eabi binutils-arm-none-eabi

这个占用空间较大,需要2.5G空间

下载源代码

mkdir nuttxspace
cd nuttxspace
git clone https://github.com/apache/nuttx.git nuttx
git clone https://github.com/apache/nuttx-apps apps

如果github抽风,可以使用镜像加速

使用make进行编译

初始化配置

cd nuttx
./tools/configure.sh -L | less

哇塞,这个支持的实在太多了!光esp的就这么多:

  esp32c3-devkit:efuse
  esp32c3-devkit:watchdog
  esp32c3-devkit:pwm
  esp32c3-devkit:gdbstub
  esp32c3-devkit:module
  esp32c3-devkit:watcher
  esp32c3-devkit:wifi
  esp32c3-devkit:romfs
  esp32c3-devkit:tickless
  esp32c3-devkit:coremark
  esp32c3-devkit:sotest
  esp32c3-devkit:bmp180
  esp32c3-devkit:random
  esp32c3-devkit:rtc
  esp32c3-devkit:ble
  esp32c3-devkit:twai
  esp32c3-devkit:ostest
  esp32c3-devkit:usbconsole
  esp32c3-devkit:autopm
  esp32c3-devkit:oneshot
  esp32c3-devkit:pm
  esp32c3-devkit:knsh
  esp32c3-devkit:gpio
  esp32c3-devkit:nvcfgdata
  esp32c3-devkit:sta_softap
  esp32c3-devkit:nsh
  esp32c3-devkit:lvgl
  esp32c3-devkit:timer
  esp32c3-devkit:mcuboot_slot_confirm
  esp32c3-devkit:cxx
  esp32c3-devkit:spiflash
  esp32c3-devkit:crypto
  esp32c3-devkit:uid
  esp32c3-devkit:elf
  esp32c3-devkit:adc
  esp32c3-devkit-rust-1:nsh
  esp32c3-devkit-rust-1:brickmatch
  esp32h2-devkit:i2c
  esp32h2-devkit:efuse
  esp32h2-devkit:watchdog
  esp32h2-devkit:pwm
  esp32h2-devkit:timers
  esp32h2-devkit:tickless
  esp32h2-devkit:i2schar
  esp32h2-devkit:bmp180
  esp32h2-devkit:spi
  esp32h2-devkit:random
  esp32h2-devkit:rtc
  esp32h2-devkit:buttons
  esp32h2-devkit:twai
  esp32h2-devkit:ostest
  esp32h2-devkit:qencoder
  esp32h2-devkit:capture
  esp32h2-devkit:usbconsole
  esp32h2-devkit:motor
  esp32h2-devkit:gpio
  esp32h2-devkit:nsh
  esp32h2-devkit:temperature_sensor
  esp32h2-devkit:rmt
  esp32h2-devkit:spiflash
  esp32h2-devkit:sdm
  esp32h2-devkit:mcuboot_nsh
  esp32h2-devkit:adc
  esp32c3-xiao:wifi
  esp32c3-xiao:ble
  esp32c3-xiao:usbnsh
  esp32c3-xiao:gpio
  esp32c3-xiao:nsh
  esp32c3-generic:i2c
  esp32c3-generic:efuse
  esp32c3-generic:watchdog
  esp32c3-generic:pwm
  esp32c3-generic:timers
  esp32c3-generic:nimble
  esp32c3-generic:wifi
  esp32c3-generic:tickless
  esp32c3-generic:i2schar
  esp32c3-generic:bmp180
  esp32c3-generic:spi
  esp32c3-generic:random
  esp32c3-generic:rtc
  esp32c3-generic:buttons
  esp32c3-generic:ble
  esp32c3-generic:twai
  esp32c3-generic:ostest
  esp32c3-generic:usbconsole
  esp32c3-generic:gpio
  esp32c3-generic:sta_softap
  esp32c3-generic:nsh
  esp32c3-generic:temperature_sensor
  esp32c3-generic:rmt
  esp32c3-generic:spiflash
  esp32c3-generic:sdm
  esp32c3-generic:mcuboot_nsh
  esp32c3-generic:adc
  esp32c6-devkitm:i2c
  esp32c6-devkitm:efuse
  esp32c6-devkitm:watchdog
  esp32c6-devkitm:pwm
  esp32c6-devkitm:timers
  esp32c6-devkitm:wifi
  esp32c6-devkitm:tickless
  esp32c6-devkitm:i2schar
  esp32c6-devkitm:bmp180
  esp32c6-devkitm:spi
  esp32c6-devkitm:random
  esp32c6-devkitm:rtc
  esp32c6-devkitm:buttons
  esp32c6-devkitm:spislv
  esp32c6-devkitm:twai
  esp32c6-devkitm:ostest
  esp32c6-devkitm:usbconsole
  esp32c6-devkitm:gpio
  esp32c6-devkitm:sta_softap
  esp32c6-devkitm:nsh
  esp32c6-devkitm:rmt
  esp32c6-devkitm:spiflash
  esp32c6-devkitm:mcuboot_nsh
  esp32c6-devkitc:i2c
  esp32c6-devkitc:efuse
  esp32c6-devkitc:watchdog
  esp32c6-devkitc:pwm
  esp32c6-devkitc:timers
  esp32c6-devkitc:mpu60x0
  esp32c6-devkitc:wifi
  esp32c6-devkitc:tickless
  esp32c6-devkitc:i2schar
  esp32c6-devkitc:bmp180
  esp32c6-devkitc:spi
  esp32c6-devkitc:random
  esp32c6-devkitc:rtc
  esp32c6-devkitc:buttons
  esp32c6-devkitc:spislv
  esp32c6-devkitc:twai
  esp32c6-devkitc:ostest
  esp32c6-devkitc:qencoder
  esp32c6-devkitc:capture
  esp32c6-devkitc:usbconsole
  esp32c6-devkitc:motor
  esp32c6-devkitc:gpio
  esp32c6-devkitc:sta_softap
  esp32c6-devkitc:nsh
  esp32c6-devkitc:temperature_sensor
  esp32c6-devkitc:rmt
  esp32c6-devkitc:spiflash
  esp32c6-devkitc:sdm
  esp32c6-devkitc:mcuboot_nsh
  esp32c6-devkitc:adc
  esp32c6-xiao:wifi
  esp32c6-xiao:usbnsh
  esp32c6-xiao:gpio
  esp32c6-xiao:nsh
  esp32s3-eye:i2c
  esp32s3-eye:wifi
  esp32s3-eye:usbnsh
  esp32s3-eye:gpio
  esp32s3-eye:nsh
  esp32s3-eye:lcd
  esp32s3-lcd-ev:buttons
  esp32s3-lcd-ev:ws2812
  esp32s3-lcd-ev:audio
  esp32s3-lcd-ev:nsh
  esp32s3-lcd-ev:lcd
  esp32s3-lcd-ev:lvgl
  esp32s3-lhcbit:usbnsh
  esp32s3-korvo-2:rtptools
  esp32s3-korvo-2:sdmmc
  esp32s3-korvo-2:audio
  esp32s3-korvo-2:nsh
  esp32s3-box:lvgl-3
  esp32s3-box:buttons
  esp32s3-box:nsh
  esp32s3-box:touchscreen
  esp32s3-box:lvgl
  esp32s3-devkit:psram_octal
  esp32s3-devkit:i2c
  esp32s3-devkit:watchdog
  esp32s3-devkit:pwm
  esp32s3-devkit:nxlooper
  esp32s3-devkit:usb_device
  esp32s3-devkit:wifi
  esp32s3-devkit:python
  esp32s3-devkit:qemu_toywasm
  esp32s3-devkit:sdmmc
  esp32s3-devkit:tickless
  esp32s3-devkit:psram_quad
  esp32s3-devkit:ksta_softap
  esp32s3-devkit:coremark
  esp32s3-devkit:sotest
  esp32s3-devkit:i2schar
  esp32s3-devkit:spi
  esp32s3-devkit:random
  esp32s3-devkit:smp
  esp32s3-devkit:qemu_openeth
  esp32s3-devkit:rtc
  esp32s3-devkit:buttons
  esp32s3-devkit:ble
  esp32s3-devkit:twai
  esp32s3-devkit:qencoder
  esp32s3-devkit:audio
  esp32s3-devkit:capture
  esp32s3-devkit:txtable
  esp32s3-devkit:usbnsh
  esp32s3-devkit:psram_usrheap
  esp32s3-devkit:oneshot
  esp32s3-devkit:adb
  esp32s3-devkit:pm
  esp32s3-devkit:knsh
  esp32s3-devkit:motor
  esp32s3-devkit:blewifi
  esp32s3-devkit:gpio
  esp32s3-devkit:sta_softap
  esp32s3-devkit:nsh
  esp32s3-devkit:usbmsc
  esp32s3-devkit:qemu_debug
  esp32s3-devkit:temperature_sensor
  esp32s3-devkit:timer
  esp32s3-devkit:rmt
  esp32s3-devkit:eth_lan9250
  esp32s3-devkit:stack
  esp32s3-devkit:cxx
  esp32s3-devkit:spiflash
  esp32s3-devkit:sdm
  esp32s3-devkit:toywasm
  esp32s3-devkit:mcuboot_nsh
  esp32s3-devkit:elf
  esp32s3-devkit:fastboot
  esp32s3-devkit:adc
  esp32s3-xiao:usbnsh
  esp32s3-xiao:combo
  esp32s3-meadow:usbnsh
  esp32s3-meadow:nsh
  lckfb-szpi-esp32s3:pwm
  lckfb-szpi-esp32s3:usb_device
  lckfb-szpi-esp32s3:pca9557
  lckfb-szpi-esp32s3:txtable
  lckfb-szpi-esp32s3:adb
  lckfb-szpi-esp32s3:gpio
  lckfb-szpi-esp32s3:nsh
  lckfb-szpi-esp32s3:psram
  lckfb-szpi-esp32s3:lcd
  lckfb-szpi-esp32s3:lvgl
  lckfb-szpi-esp32s3:fastboot
  esp32-wrover-kit:nx
  esp32-wrover-kit:wifi
  esp32-wrover-kit:leds
  esp32-wrover-kit:lcd1602
  esp32-wrover-kit:bmp180
  esp32-wrover-kit:rtc
  esp32-wrover-kit:buttons
  esp32-wrover-kit:autopm
  esp32-wrover-kit:oneshot
  esp32-wrover-kit:lua
  esp32-wrover-kit:mmcsdspi
  esp32-wrover-kit:gpio
  esp32-wrover-kit:nsh
  esp32-wrover-kit:lvgl
  esp32-devkitc:efuse
  esp32-devkitc:watchdog
  esp32-devkitc:ms5611
  esp32-devkitc:pwm
  esp32-devkitc:nxlooper
  esp32-devkitc:mcuboot_update_agent
  esp32-devkitc:modbus
  esp32-devkitc:softap
  esp32-devkitc:module
  esp32-devkitc:nxdiag
  esp32-devkitc:watcher
  esp32-devkitc:wifi
  esp32-devkitc:tickless
  esp32-devkitc:coremark
  esp32-devkitc:mcp2515
  esp32-devkitc:wifishare
  esp32-devkitc:leds
  esp32-devkitc:sotest
  esp32-devkitc:mqttc
  esp32-devkitc:i2schar
  esp32-devkitc:bmp280
  esp32-devkitc:max6675
  esp32-devkitc:random
  esp32-devkitc:smp
  esp32-devkitc:qemu_openeth
  esp32-devkitc:rtc
  esp32-devkitc:buttons
  esp32-devkitc:wamr_wasi_debug
  esp32-devkitc:ble
  esp32-devkitc:twai
  esp32-devkitc:ostest
  esp32-devkitc:qencoder
  esp32-devkitc:audio
  esp32-devkitc:capture
  esp32-devkitc:dac
  esp32-devkitc:autopm
  esp32-devkitc:snake
  esp32-devkitc:psram_usrheap
  esp32-devkitc:oneshot
  esp32-devkitc:pm
  esp32-devkitc:knsh
  esp32-devkitc:motor
  esp32-devkitc:wifi_smp
  esp32-devkitc:blewifi
  esp32-devkitc:espnow
  esp32-devkitc:sta_softap
  esp32-devkitc:nsh
  esp32-devkitc:psram
  esp32-devkitc:timer
  esp32-devkitc:mcuboot_slot_confirm
  esp32-devkitc:rmt
  esp32-devkitc:cxx
  esp32-devkitc:spiflash
  esp32-devkitc:sdm
  esp32-devkitc:wifinsh
  esp32-devkitc:mcuboot_nsh
  esp32-devkitc:elf
  esp32-devkitc:brickmatch
  esp32-devkitc:adc
  ttgo_lora_esp32:sx127x
  ttgo_lora_esp32:nsh
  ttgo_t_display_esp32:lvgl_fb
  ttgo_t_display_esp32:nsh
  ttgo_t_display_esp32:lvgl_lcd
  esp32-audio-kit:wifi
  esp32-audio-kit:audio
  esp32-audio-kit:nsh
  esp32-pico-kit:nsh
  esp32-2432S028:nsh
  esp32-2432S028:lvgl
  esp32-ethernet-kit:ethernet
  esp32-ethernet-kit:wifi
  esp32-ethernet-kit:rtc
  esp32-ethernet-kit:buttons
  esp32-ethernet-kit:autopm
  esp32-ethernet-kit:oneshot
  esp32-ethernet-kit:nsh
  esp32-sparrow-kit:wifi
  esp32-sparrow-kit:mqttc
  esp32-sparrow-kit:nsh
  esp32-lyrat:nxrecorder
  esp32-lyrat:rtptools
  esp32-lyrat:wifi
  esp32-lyrat:buttons
  esp32-lyrat:audio
  esp32-lyrat:mmcsdspi
  esp32-lyrat:nsh
  esp32s2-kaluga-1:i2c
  esp32s2-kaluga-1:watchdog
  esp32s2-kaluga-1:nxlooper
  esp32s2-kaluga-1:rtc
  esp32s2-kaluga-1:buttons
  esp32s2-kaluga-1:twai
  esp32s2-kaluga-1:audio
  esp32s2-kaluga-1:nsh
  esp32s2-kaluga-1:lvgl_ili9341
  esp32s2-kaluga-1:lvgl_st7789
  esp32s2-saola-1:i2c
  esp32s2-saola-1:watchdog
  esp32s2-saola-1:pwm
  esp32s2-saola-1:nxlooper
  esp32s2-saola-1:wifi
  esp32s2-saola-1:coremark
  esp32s2-saola-1:sotest
  esp32s2-saola-1:i2schar
  esp32s2-saola-1:random
  esp32s2-saola-1:rtc
  esp32s2-saola-1:buttons
  esp32s2-saola-1:twai
  esp32s2-saola-1:ostest
  esp32s2-saola-1:qencoder
  esp32s2-saola-1:audio
  esp32s2-saola-1:oneshot
  esp32s2-saola-1:gpio
  esp32s2-saola-1:sta_softap
  esp32s2-saola-1:nsh
  esp32s2-saola-1:temperature_sensor
  esp32s2-saola-1:timer
  esp32s2-saola-1:rmt
  esp32s2-saola-1:cxx
  esp32s2-saola-1:spiflash
  esp32s2-saola-1:sdm
  esp32s2-saola-1:mcuboot_nsh
  esp32s2-saola-1:adc

列出所有的esp32c3

./tools/configure.sh -L |grep esp32c3
  esp32c3-devkit:efuse
  esp32c3-devkit:watchdog
  esp32c3-devkit:pwm
  esp32c3-devkit:gdbstub
  esp32c3-devkit:module
  esp32c3-devkit:watcher
  esp32c3-devkit:wifi
  esp32c3-devkit:romfs
  esp32c3-devkit:tickless
  esp32c3-devkit:coremark
  esp32c3-devkit:sotest
  esp32c3-devkit:bmp180
  esp32c3-devkit:random
  esp32c3-devkit:rtc
  esp32c3-devkit:ble
  esp32c3-devkit:twai
  esp32c3-devkit:ostest
  esp32c3-devkit:usbconsole
  esp32c3-devkit:autopm
  esp32c3-devkit:oneshot
  esp32c3-devkit:pm
  esp32c3-devkit:knsh
  esp32c3-devkit:gpio
  esp32c3-devkit:nvcfgdata
  esp32c3-devkit:sta_softap
  esp32c3-devkit:nsh
  esp32c3-devkit:lvgl
  esp32c3-devkit:timer
  esp32c3-devkit:mcuboot_slot_confirm
  esp32c3-devkit:cxx
  esp32c3-devkit:spiflash
  esp32c3-devkit:crypto
  esp32c3-devkit:uid
  esp32c3-devkit:elf
  esp32c3-devkit:adc
  esp32c3-devkit-rust-1:nsh
  esp32c3-devkit-rust-1:brickmatch
  esp32c3-xiao:wifi
  esp32c3-xiao:ble
  esp32c3-xiao:usbnsh
  esp32c3-xiao:gpio
  esp32c3-xiao:nsh
  esp32c3-generic:i2c
  esp32c3-generic:efuse
  esp32c3-generic:watchdog
  esp32c3-generic:pwm
  esp32c3-generic:timers
  esp32c3-generic:nimble
  esp32c3-generic:wifi
  esp32c3-generic:tickless
  esp32c3-generic:i2schar
  esp32c3-generic:bmp180
  esp32c3-generic:spi
  esp32c3-generic:random
  esp32c3-generic:rtc
  esp32c3-generic:buttons
  esp32c3-generic:ble
  esp32c3-generic:twai
  esp32c3-generic:ostest
  esp32c3-generic:usbconsole
  esp32c3-generic:gpio
  esp32c3-generic:sta_softap
  esp32c3-generic:nsh
  esp32c3-generic:temperature_sensor
  esp32c3-generic:rmt
  esp32c3-generic:spiflash
  esp32c3-generic:sdm
  esp32c3-generic:mcuboot_nsh
  esp32c3-generic:adc

配置  esp32c3-devkit:nsh

cd nuttx
./tools/configure.sh -l   esp32c3-devkit:nsh

完成显示:

 configuration written to .config

make menuconfig

cd nuttx
make menuconfig

出现菜单界面

对于ammy 也就是Ubuntu 22.04版本,需要加上参数make CONFIG_LIBM=y

在library Routines里加上本地math库的支持:

选择-> Library Routines (库函数) -> Select math library (Math library from NuttX)  -> Math library from NuttX 

设好后,保存退出

make

make

make输出

make
Create version.h
LN: platform/board to /home/skywalk/github/nuttxspace/apps/platform/dummy
Register: dd
Register: dumpstack
Register: nsh
Register: sh
CPP:  /home/skywalk/github/nuttxspace/nuttx/boards/risc-v/esp32c3-legacy/esp32c3-devkit/../common/scripts/esp32c3_rom.ld-> /home/skywalk/github/nuttxspace/nuttx/boards/risc-v/esp32c3-legacy/esp32c3-devkit/../common/scripts/esp32c3_rom.ld.tmCPP:  /home/skywalk/github/nuttxspace/nuttx/boards/risc-v/esp32c3-legacy/esp32c3-devkit/../common/scripts/flat_memory.ld-> /home/skywalk/github/nuttxspace/nuttx/boards/risc-v/esp32c3-legacy/esp32c3-devkit/../common/scripts/flat_memory.ld.tmCPP:  /home/skywalk/github/nuttxspace/nuttx/boards/risc-v/esp32c3-legacy/esp32c3-devkit/../common/scripts/legacy_sections.ld-> /home/skywalk/github/nuttxspace/nuttx/boards/risc-v/esp32c3-legacy/esp32c3-devkit/../common/scripts/legacy_sectioLD: nuttx
Memory region         Used Size  Region Size  %age Used
     iram0_0_seg:        6624 B     321296 B      2.06%
     irom0_0_seg:      107028 B    4194272 B      2.55%
     dram0_0_seg:       13792 B     321296 B      4.29%
     drom0_0_seg:      147892 B    4194272 B      3.53%
         rtc_seg:          0 GB         8 KB      0.00%
CP: nuttx.hex
MKIMAGE: ESP32-C3 binary
esptool.py not found. Please run: 'pip install esptool'
Run make again to create the nuttx.bin image.
make: *** [tools/Unix.mk:559: nuttx] Error 1 

按照提示,安装esptool

pip install esptool

然后再make

输出:

LD: nuttx
Memory region         Used Size  Region Size  %age Used
     iram0_0_seg:        6624 B     321296 B      2.06%
     irom0_0_seg:      107028 B    4194272 B      2.55%
     dram0_0_seg:       13792 B     321296 B      4.29%
     drom0_0_seg:      147892 B    4194272 B      3.53%
         rtc_seg:          0 GB         8 KB      0.00%
CP: nuttx.hex
MKIMAGE: ESP32-C3 binary
esptool.py -c esp32c3 elf2image -fs 4MB -fm dio -ff 40m -o nuttx.bin nuttx
esptool.py v4.8.1
Creating esp32c3 image...
Merged 1 ELF section
Successfully created esp32c3 image.
Generated: nuttx.bin (ESP32-C3 compatible)

使用Cmake

先安装cmake

sudo apt isntall cmake

cd nuttx
cmake -B build -DBOARD_CONFIG=esp32c3-devkit:nsh -GNinja

cmake -B build -DBOARD_CONFIG=esp32c3-devkit:nsh -GNinja

配置管理

cmake --build build -t menuconfig

 cmake失败

烧录

烧录之前安装esptool工具

pip install esptool

使用这条命令:

esptool --chip esp32c3 --port com3 --baud 460800 write_flash -z 0x0  E:\tmp\nuttx.bin

显示:

esptool --chip esp32c3 --port com3 --baud 460800 write_flash -z 0x0  E:\tmp\nuttx.bin
esptool.py v4.8.1
Serial port com3
Connecting...
Failed to get PID of a device on com3, using standard reset sequence.
.
Chip is ESP32-C3 (QFN32) (revision v0.4)
Features: WiFi, BLE
Crystal is 40MHz
MAC: e4:b0:63:22:df:68
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x0002afff...
Compressed 172640 bytes to 81799...
Wrote 172640 bytes (81799 compressed) at 0x00000000 in 2.3 seconds (effective 610.2 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

 也不知道是否成功了...

至少生成了文件:

-rwxr-xr-x  1 skywalk skywalk 2808092 May 17 19:08 nuttx
-rw-r--r--  1 skywalk skywalk  172640 May 17 19:08 nuttx.bin
-rw-r--r--  1 skywalk skywalk  369186 May 17 19:08 nuttx.hex
-rw-r--r--  1 skywalk skywalk      47 May 17 19:08 nuttx.manifest
-rw-r--r--  1 skywalk skywalk 1660487 May 17 19:08 nuttx.map

就先到这里吧! 

调试

编译报错ERROR: riscv64-unknown-elf-gcc failed: 1

make
Create version.h
LN: platform/board to /home/skywalk/github/nuttxspace/apps/platform/dummy
Register: dd
Register: dumpstack
Register: nsh
Register: sh
./stdlib/lib_strtold.c:42:10: fatal error: math.h: No such file or directory
   42 | #include <math.h>
      |          ^~~~~~~~
compilation terminated.
ERROR: riscv64-unknown-elf-gcc failed: 1
       command: riscv64-unknown-elf-gcc -MT bin/lib_strtold.o  -M '-fno-common' '-Wall' '-Wstrict-prototypes' '-Wshadow' '-Wundef' '-Wno-attributes' '-Wno-unknown-pragmas' '-Wno-psabi' '-Os' '-fno-strict-aliasing' '-fno-omit-frame-pointer' '-fno-optimize-sibling-calls' '-ffunction-sections' '-fdata-sections' '-nostdlib' '-g' '-march=rv32imc' '-mabi=ilp32' '-isystem' '/home/skywalk/github/nuttxspace/nuttx/include' '-D__NuttX__' '-DNDEBUG' '-D__KERNEL__' '-Werror=return-type' '-I' '/home/skywalk/github/nuttxspace/nuttx/libs/libc' ./stdlib/lib_strtold.c
make[2]: *** [/home/skywalk/github/nuttxspace/nuttx/tools/Config.mk:232: lib_strtold.ddc] Error 1
make[1]: *** [Makefile:202: .depend] Error 2
make: *** [tools/Unix.mk:660: pass2dep] Error 2

又重新make了一下,报错简化成:

make

CC:  stdlib/lib_strtold.c stdlib/lib_strtold.c:42:10: fatal error: math.h: No such file or directory
   42 | #include <math.h>
      |          ^~~~~~~~
compilation terminated.
make[1]: *** [Makefile:156: bin/lib_strtold.o] Error 1
make: *** [tools/LibTargets.mk:196: libs/libc/libc.a] Error 2

检查math.h 是否存在

find /usr/include -name math.h

find /usr/include -name math.h
/usr/include/newlib/math.h
/usr/include/newlib/c++/10.3.1/math.h
/usr/include/newlib/c++/10.3.1/tr1/math.h
/usr/include/math.h
/usr/include/c++/11/math.h
/usr/include/c++/11/tr1/math.h

检查编译器路径

echo | gcc -E -v -

看到这句

#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/11/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include

证明应该可以看到math.h文件啊!

检查这两项:

7. 检查环境变量

确保环境变量 CC 和 CFLAGS 没有错误配置。例如:

export CC=gcc
export CFLAGS="-I/usr/include"

8. 检查 Makefile 配置

检查 Makefile 中是否有错误的配置,例如缺少 -lm 链接数学库。在 Makefile 中添加以下内容:

LDFLAGS += -lm

问题解决

最终发现,这是已知的问题:`rv-virt:nsh64` can't build with stock gcc-riscv64-unknown-elf on Ubuntu Jammy · Issue #11341 · apache/nuttx 

This is a know issue. Ubuntu release of RISC-V GCC is compiled without math libs. We can do nothing with that, but you can enable NuttX native math libraries support via CONFIG_ LIBM=y and still use RISC-V GCC provided by Ubuntu apt or pick another more mature toolchain

👍1

 直接用命令:

make CONFIG_LIBM=y

哇塞,终于过去了 

cmake -B build -DBOARD_CONFIG=esp32c3-devkit:nsh -GNinja报错

cmake -B build -DBOARD_CONFIG=esp32c3-devkit:nsh -GNinja
CMake Error at CMakeLists.txt:89 (message):
  Kconfig environment depends on kconfiglib, Please install:

    (APT source)
      $ sudo apt install python3-kconfiglib
    or (pip source)
      $ pip install kconfiglib
    or (After Ubuntu 24.04)
      $ pip install kconfiglib --break-system-packages


-- Configuring incomplete, errors occurred!

 放弃cmake

make报错esptool.py not found. Please run: 'pip install esptool'

make
Create version.h
LN: platform/board to /home/skywalk/github/nuttxspace/apps/platform/dummy
Register: dd
Register: dumpstack
Register: nsh
Register: sh
CPP:  /home/skywalk/github/nuttxspace/nuttx/boards/risc-v/esp32c3-legacy/esp32c3-devkit/../common/scripts/esp32c3_rom.ld-> /home/skywalk/github/nuttxspace/nuttx/boards/risc-v/esp32c3-legacy/esp32c3-devkit/../common/scripts/esp32c3_rom.ld.tmCPP:  /home/skywalk/github/nuttxspace/nuttx/boards/risc-v/esp32c3-legacy/esp32c3-devkit/../common/scripts/flat_memory.ld-> /home/skywalk/github/nuttxspace/nuttx/boards/risc-v/esp32c3-legacy/esp32c3-devkit/../common/scripts/flat_memory.ld.tmCPP:  /home/skywalk/github/nuttxspace/nuttx/boards/risc-v/esp32c3-legacy/esp32c3-devkit/../common/scripts/legacy_sections.ld-> /home/skywalk/github/nuttxspace/nuttx/boards/risc-v/esp32c3-legacy/esp32c3-devkit/../common/scripts/legacy_sectioLD: nuttx
Memory region         Used Size  Region Size  %age Used
     iram0_0_seg:        6624 B     321296 B      2.06%
     irom0_0_seg:      107028 B    4194272 B      2.55%
     dram0_0_seg:       13792 B     321296 B      4.29%
     drom0_0_seg:      147892 B    4194272 B      3.53%
         rtc_seg:          0 GB         8 KB      0.00%
CP: nuttx.hex
MKIMAGE: ESP32-C3 binary
esptool.py not found. Please run: 'pip install esptool'
Run make again to create the nuttx.bin image.
make: *** [tools/Unix.mk:559: nuttx] Error 1

按照提示的运行

pip install esptool

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2378811.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

python打包exe报错:处理文件时错误:Excel xlsx file; not supported

背景&#xff1a;最近用python写一个excel解析工具&#xff0c;然后打包成exe可执行文件的时候&#xff0c;遇到这样的问题 1.在我自己编译器运行是可以正常将上传后的excel进行解析&#xff0c;但是在打包成exe后&#xff0c;就无法正常解析excel 问题排查&#xff1a; 1.切换…

VUE3 -综合实践(Mock+Axios+ElementPlus)

目录 前言 目标 1.工程创建 2.Mock 2.1 配置Mock 扩 展 2.2 定义模拟数据 2.3 创建Mock服务器 3.导入ElementPlus 4.表格页面搭建 5.动态路由跳转 6.详情页面的制作 前言 基于前文 VUE3详细入门&#xff0c;我们对VUE3的基本使用有了初步的了解&#xff0c;下…

NDS3211HV单路H.264/HEVC/HD视频编码器

1产品概述 NDS3211HV单路高清编码器是一款功能强大的音/视频编码设备&#xff0c;支持2组立体声&#xff0c;同时还支持CC(CVBS)字幕。支持多种音频编码方式。该设备配备了多种音/视频输入接口&#xff1a;HD-SDI数字视频输入、HDMI高清输入&#xff08;支持CC&#xff09;、A…

LeetCode热题100--206.反转链表--简单

1. 题目 给你单链表的头节点 head &#xff0c;请你反转链表&#xff0c;并返回反转后的链表。 示例 1&#xff1a; 输入&#xff1a;head [1,2,3,4,5] 输出&#xff1a;[5,4,3,2,1] 示例 2&#xff1a; 输入&#xff1a;head [1,2] 输出&#xff1a;[2,1] 示例 3&…

来一个复古的技术FTP

背景 10年前的老代码&#xff0c;需要升级springboot框架&#xff0c;在升级过程中&#xff0c;测试业务流程里&#xff0c;有FTP的下载业务&#xff0c;不管测试环境如何测试&#xff0c;都没有成功&#xff0c;最后只能自己搭建一个FTP服务器&#xff0c;写一个ftp-demo来测试…

OpenWebUI新突破,MCPO框架解锁MCP工具新玩法

大家好&#xff0c;Open WebUI 迎来重要更新&#xff0c;现已正式支持 MCP 工具服务器&#xff0c;但 MCP 工具服务器需由兼容 OpenAPI 的代理作为前端。mcpo 是一款实用代理&#xff0c;经测试&#xff0c;它能让开发者使用 MCP 服务器命令和标准 OpenAPI 服务器工具&#xff…

TRTC实时对话式AI解决方案,助力人机语音交互极致体验

近年来&#xff0c;AI热度持续攀升&#xff0c;无论是融资规模还是用户热度都大幅增长。2023 年&#xff0c;中国 AI 行业融资规模达2631亿人民币&#xff0c;较2022年上升51%&#xff1b;2024年第二季度&#xff0c;全球 AI 初创企业融资规模为 240 亿美金&#xff0c;较第一季…

Linux安全篇 --firewalld

一、Firewalld 防火墙概述 1、Firewalld 简介 firewalld 的作用是为包过滤机制提供匹配规则(或称为策略)&#xff0c;通过各种不同的规则告诉netfilter 对来自指定源、前往指定目的或具有某些协议特征的数据包采取何种处理方式为了更加方便地组织和管理防火墙,firewalld 提供…

系分论文《论系统需求分析方法及应用》

系统分析师论文范文系列 【摘要】 2022年6月&#xff0c;我作为系统分析师参与了某金融机构“智能信贷风控系统”的建设项目。该系统旨在通过对业务流程的数字化重构&#xff0c;优化信贷审批效率并降低风险。项目涉及信贷申请、资质审核、风险评估、额度审批等核心流程&#x…

LIIGO ❤️ RUST: 12 YEARS

LIIGO &#x1f496; RUST: 12 YEARS 今天是RUST语言1.0发布十周年纪念日。十年前的今天&#xff0c;2015年的今天&#xff0c;Rust 1.0 正式发行。这是值得全球Rust支持者隆重纪念的日子。我借此机会衷心感谢Rust语言创始人Graydon Hoare&#xff0c;Mozilla公司&#xff0c;…

Trivy:让你时刻掌控的开源安全扫描器

深入了解 Trivy:全面的安全扫描工具 在如今互联网快速发展的时代,软件的安全性显得尤为重要。随着应用程序的复杂性增加,其可能带来的安全漏洞也在不断增多。如何快速、准确地发现这些潜在威胁是每个开发者和运维人员心中的课题。今天,我们将为大家介绍一个开源的安全扫描…

LlamaIndex 第八篇 MilvusVectorStore

本指南演示了如何使用 LlamaIndex 和 Milvus 构建一个检索增强生成&#xff08;RAG&#xff09;系统。 RAG 系统将检索系统与生成模型相结合&#xff0c;根据给定的提示生成新的文本。该系统首先使用 Milvus 等向量相似性搜索引擎从语料库中检索相关文档&#xff0c;然后使用生…

2022河南CCPC(前四题)

签到题目 #include <bits/stdc.h> using namespace std; #define int long long #define PII pair<int,int> #define fi first #define se second #define endl \n #define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);void solve() {int n;cin>>…

谷歌浏览器(Google Chrome)136.0.7103.93便携增强版|Win中文|安装教程

软件下载 【名称】&#xff1a;谷歌浏览器&#xff08;Google Chrome&#xff09;136.0.7103.93 【大小】&#xff1a;170M 【语言】&#xff1a;简体中文 【安装环境】&#xff1a;Win10/Win11 【夸克网盘下载链接】&#xff08;务必手机注册&#xff09;&#xff1a; h…

高可用消息队列实战:AWS SQS 在分布式系统中的核心解决方案

引言&#xff1a;消息队列的“不可替代性” 在微服务架构和分布式系统盛行的今天&#xff0c;消息队列&#xff08;Message Queue&#xff09; 已成为解决系统解耦、流量削峰、异步处理等难题的核心组件。然而&#xff0c;传统的自建消息队列&#xff08;如RabbitMQ、Kafka&am…

「Mac畅玩AIGC与多模态41」开发篇36 - 用 ArkTS 构建聚合搜索前端页面

一、概述 本篇基于上一节 Python 实现的双通道搜索服务&#xff08;聚合 SearxNG 本地知识库&#xff09;&#xff0c;构建一个完整的 HarmonyOS ArkTS 前端页面。用户可在输入框中输入关键词&#xff0c;实时查询本地服务 http://localhost:5001/search?q...&#xff0c;返…

springCloud/Alibaba常用中间件之Seata分布式事务

文章目录 SpringCloud Alibaba:依赖版本补充Seata处理分布式事务(AT模式)AT模式介绍核心组件介绍AT的工作流程&#xff1a;两阶段提交&#xff08;**2PC**&#xff09; Seata-AT模式使用Seata(2.0.0)下载、配置和启动Seata案例实战前置代码添加全局注解 GlobalTransactional Sp…

Datawhale FastAPI Web框架5月第1次笔记

原课程地址&#xff1a; FastAPI Web框架https://www.datawhale.cn/learn/summary/164本次难点&#xff1a; 切换python的版本为3.10 作业过程 启动&#xff1a; jupyter notebook 首先我们要确保自己的python版本是3.10 import sys print(sys.version) 第一个fastapi…

操作系统:os概述

操作系统&#xff1a;OS概述 程序、进程与线程无极二级目录三级目录 程序、进程与线程 指令执行需要那些条件&#xff1f;CPU内存 需要数据和 无极 二级目录 三级目录

LLaMA-Factory:环境准备

一、硬件和系统 操作系统: Ubuntu 24.04.2 LTS&#xff08;64位&#xff09;GPU: NVIDIA RTX 4090 笔记本 GPU&#xff0c;16GB显存CPU: 建议高性能多核 CPU&#xff08;如 Intel i7/i9 或 AMD Ryzen 7/9&#xff09;以支持数据预处理&#xff0c;我的是32核。RAM: 至少 32GB&…