NuttX supports the Expressif ESP32 inclusive with SMP (Symmetric MultiProcessing) support, then I decided to post here the steps I followed to get it working:
Install esptool:
$ sudo pip install esptool
Install to toolchain:
You can download the pre-build toolchain:
https://esp-idf.readthedocs.io/en/latest/get-started/index.html
Or: you can compile it from source code:
$ git clone -b xtensa-1.22.x https://github.com/espressif/crosstool-NG.git $ cd crosstool-NG $ ./bootstrap && ./configure --prefix=$PWD && make install $ ./ct-ng xtensa-esp32-elf $ unset LD_LIBRARY_PATH $ ./ct-ng build $ chmod -R u+w builds/xtensa-esp32-elf $ sudo cp -a builds/xtensa-esp32-elf/* /usr/local/
Now you can compile the NuttX:
$ mkdir ~/nuttxspace $ cd ~/nuttxspace $ git clone https://bitbucket.org/nuttx/nuttx $ git clone https://bitbucket.org/nuttx/apps $ cd nuttx $ make distclean $ ./tools/configure.sh esp32-core/nsh $ make
The nuttx.bin generated is too big, you need to generate it from elf file (nuttx) :
$ esptool.py --chip esp32 elf2image --flash_mode dio --flash_size 4MB -o ./nuttx.bin nuttx
You will need the bootloader.bin and the partitions, you can get it from hello word example. You need to clone and update the submodules of esp-idf (read the Get Started from above link), then:
$ cp -a esp-idf/examples/get-started/hello_world . $ cd hello_world $ make $ cp build/bootloader/bootloader.bin ~/nuttxspace/nuttx/ $ cp build/partitions_singleapp.bin ~/nuttxspace/nuttx/partitions.bin
The files nuttx.bin, bootloader.bin and partitions.bin need to be flashed in the board. To do that first put the board in ROM Boot mode:
Press and hold the BOOT button of ESP32 board (IO0 pin will be put in low level) and press and release the RESET button. Now you can release the BOOT button.
This is the command to flash:
$ sudo esptool.py --chip esp32-c3 --port /dev/ttyUSB0 --baud 921600 write_flash 0x0 ../esp-bins/bootloader-esp32c3.bin 0x8000 ../esp-bins/partition-table-esp32c3.bin 0x10000 nuttx.bin esptool.py v3.0 Connecting.... Chip is ESP32D0WDQ6 (revision 0) Uploading stub... Running stub... Stub running... Changing baud rate to 921600 Changed. Configuring flash size... Auto-detected Flash size: 4MB Flash params set to 0x0220 Compressed 19392 bytes to 11445... Wrote 19392 bytes (11445 compressed) at 0x00001000 in 0.2 seconds (effective 901.6 kbit/s)... Hash of data verified. Compressed 3072 bytes to 82... Wrote 3072 bytes (82 compressed) at 0x00008000 in 0.0 seconds (effective 10507.6 kbit/s)... Hash of data verified. Compressed 185024 bytes to 45527... Wrote 185024 bytes (45527 compressed) at 0x00010000 in 2.1 seconds (effective 710.2 kbit/s)... Hash of data verified. Leaving... Hard resetting... $
Finally open minicom and just reset the board, you should get it:
$ minicom Welcome to minicom 2.7 OPTIONS: I18n Compiled on Feb 7 2016, 13:37:27. Port /dev/ttyUSB0, 15:40:48 Press CTRL-A Z for help on special keys ets Jun 8 2016 00:22:57 rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) ets Jun 8 2016 00:22:57 rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0018,len:4 load:0x3fff001c,len:5568 ho 0 tail 12 room 4 load:0x40078000,len:0 load:0x40078000,len:13716 entry 0x40078fb4 I (31) boot: ESP-IDF v3.1-dev-162-geb659e4 2nd stage bootloader I (31) boot: compile time 15:35:11 I (42) boot: Enabling RNG early entropy source... I (42) boot: SPI Speed : 40MHz I (42) boot: SPI Mode : DIO I (45) boot: SPI Flash Size : 4MB I (49) boot: Partition Table: I (52) boot: ## Label Usage Type ST Offset Length I (60) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (67) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (75) boot: 2 factory factory app 00 00 00010000 00100000 I (82) boot: End of partition table I (86) esp_image: segment 0: paddr=0x00010020 vaddr=0x3ffb0df0 size=0x00054 ( 84) load I (95) esp_image: segment 1: paddr=0x0001007c vaddr=0x40080000 size=0x00400 ( 1024) load I (104) esp_image: segment 2: paddr=0x00010484 vaddr=0x40080400 size=0x00300 ( 768) load I (113) esp_image: segment 3: paddr=0x0001078c vaddr=0x400c0000 size=0x00000 ( 0) load I (122) esp_image: segment 4: paddr=0x00010794 vaddr=0x00000000 size=0x0f874 ( 63604) I (153) esp_image: segment 5: paddr=0x00020010 vaddr=0x3f400010 size=0x018e4 ( 6372) map I (155) esp_image: segment 6: paddr=0x000218fc vaddr=0x00000000 size=0x0e714 ( 59156) I (179) esp_image: segment 7: paddr=0x00030018 vaddr=0x400d0018 size=0x0d278 ( 53880) map I (199) boot: Loaded app from partition at offset 0x10000 I (199) boot: Disabling RNG early entropy source... NuttShell (NSH) nsh> nsh> ? help usage: help [-v] [] [ cmp false mkdir rm true ? dirname free mh rmdir uname basename dd help mount set umount break df hexdump mv sh unset cat echo kill mw sleep usleep cd exec ls ps test xd cp exit mb pwd time Builtin Apps: nsh> P.S.: If your board is rebooting, then disable the RTC watchdog in the bootloader.
Alan, is the wifi fully functional ?
Not yet, Espressif didn’t release the agnostic library to use the ESP32 WiFi radio. The best option to use WiFi on NuttX is using some Broadcom FullMAC chip.
What do you think the roadmap is to having working wifi on it?
Hi Alex, no idea! But I’m interested to help it happen. You can also try to contact Espressif and tell them can you want to use NuttX on ESP32 đ .
Seria bom se ajudassem especificando alguns tipos de placas eu estou com a mach3 cinco portas estou perdido na identificação dos cabos que vem dos dribles.
OlĂĄ JosĂ©, vocĂȘ pode encontra a lista de placas suportadas neste link: https://bitbucket.org/nuttx/nuttx/src/9417bfde0ee3aff79d8e8413c3221e66e4f6c8bf/configs/?at=master
Eu recomendo a STM32F4-Discovery ou alguma placa suportada com o STM32F4 ou STM32F7. Outra opção seria uma placa com o microcontrolador SAMV70 da Microchip/Atmel.
Well, it’s been 2 years since developers claim for open-source.
https://github.com/espressif/esp32-wifi-lib/issues/2
Yes, they are delaying to open-source the WIFI Stack. So my suggestion is: use a FullMAC chip like this used on Photon board, it works fine with NuttX. I hope Someday Espressif release the WiFi MAC libs as open-source!
Hi. acassis
I’m interested in Nuttx recently, so when I tried to build Nuttx following your tutorial, I got the following error yesterday :
__________________________________
LD: nuttx
xtensa-esp32-elf-ld: cannot open linker script file /home/kdm/nuttxspace/nuttx/boards/xtensa/esp32/esp32-core/scripts/esp32_out.ld: No such file or directory
Makefile:143: recipe for target ‘nuttx’ failed
make[1]: *** [nuttx] Error 1
make[1]: directory ‘/home/kdm/nuttxspace/nuttx/arch/xtensa/src’ exit
tools/Makefile.unix:483: recipe for target ‘pass2’ failed
make: *** [pass2] Error 2
________________________________________________
Some idea?
Thanks
Best Regards
Hi Domyung,
It is very strange, in fact this “esp32_out.ld” never existed on NuttX, but the compilation never complain about it.
So try to remove all LDSCRIPT1 from nuttx/boards/xtensa/esp32/esp32-core/scripts/Make.defs
It should work! Also keep in mind that support to ESP32 on NuttX is minimal, only UART and GPIO.
If you want to see the NuttX’s power it is better to you other microcontroller with full support.
Hi acassis,
Thank you for your answer.
I fixed this problem. I think that there is a PATH error in the /home/kdm/nuttxspace/nuttx/boards/xtensa/esp32/esp32-core/src/make
Then I asked nuttx for a bug review. See the link below for more information.
https://bitbucket.org/nuttx/nuttx/issues/168/esp32-build-error
Best Regards.
Hi Domyung,
I saw your patch! Very nice, thanks for fixing It.
BR,
Alan
Hi, I’m trying to follow your instructions for compiling the toolchain, but it complains about not being able to find a usable python. Which version of the distro did you use to make this work?
Hi Nigel,
I used Ubuntu 18.04 at that time, but it should work on any distro. Did you install python 2.7 or python 3?