etc:users:jcmvbkbc:linux-xtensa:esp32s3
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
etc:users:jcmvbkbc:linux-xtensa:esp32s3 [2023/05/08 15:19] – jcmvbkbc | etc:users:jcmvbkbc:linux-xtensa:esp32s3 [2024/06/09 05:06] (current) – update bootloader instructions to wifi-enabled version jcmvbkbc | ||
---|---|---|---|
Line 2: | Line 2: | ||
Sources: | Sources: | ||
- | * https:// | + | |
- | * https:// | + | * https:// |
- | * https:// | + | |
- | * https:// | + | * https:// |
- | * https:// | + | * https:// |
- | * https:// | + | * https:// |
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
- | Apply mforce-l32 patch on top of gcc. | + | Scripts with all steps below: https:// |
- | < | + | ===== Details ===== |
- | $ ( cd build-xtensa-fdpic-toolchain-esp32s3 ; rm -rf * ; FLAGS_FOR_TARGET=' | + | |
- | $ ( cd build-xtensa-fdpic-nothread-esp32s3 ; rm -rf * ; CROSS_COMPILE=`pwd`/ | + | |
- | $ ln -s `pwd`/ | + | |
- | </ | + | |
- | build-xtensa-fdpic-toolchain.sh: | + | * [[.:esp32s3: |
- | < | + | * [[.: |
- | #! / | + | * [[.: |
+ | * [[.: | ||
+ | * [[.: | ||
- | target=${TARGET: | + | ===== Things that work ===== |
- | binutils_src=$HOME/ | + | |
- | gcc_src=$HOME/ | + | |
- | base=`pwd` | + | |
- | _FLAGS_FOR_TARGET=${FLAGS_FOR_TARGET: | + | * WiFi. Use the script that builds firmware based on esp-hosted. The firmware runs on core 0, linux runs on core 1, special linux IPC is used for communication. WiFi transport that uses linux IPC is added both to the firmware and to the linux kernel wifi driver. Not all wifi security options may be working, e.g. open and wpa2-psk are working and 802.11w is not. |
+ | * Writing to FLASH and using ESP FLASH partition table. Driver based on linux IPC sends FLASH-related requests to the firmware. Default configuration has an etc partition that is flashed with /etc file system and mounted at boot time. The file system is writable and it can be used to store things like wpa_supplicant.conf, | ||
+ | * USB serial. It is visible as the / | ||
+ | * GPIO, including interrupts. Software I2C over GPIO and software SPI over GPIO. | ||
+ | * hardware SPI. Tested clock speed up to 20MHz with SD card. | ||
+ | * clock frequency detection. CPU, XTAL and APB clocks may be preset by the bootloader, the kernel will understand and use preset frequencies without additional configuration. | ||
+ | * ssh server and ssh client. There' | ||
+ | * mounting NFS shares. | ||
+ | * running executable code from outside the rootfs, e.g. from /etc or from NFS mounts. A special hack in the kernel code does address remapping, so that when an executable memory mapping is created, the mapping address points to the PSRAM alias in the IRAM address range. This does not work for ESP32 as it doesn' | ||
+ | * passing command line from bootloader to the kernel. Bootloader reads the file / | ||
+ | * strace (a one-line fix is needed for the mainline strace to correctly handle the initial exec). | ||
+ | * perf stat (heavy patching is needed to build it for nommu). | ||
+ | * c++ exceptions, c cleanup routines, forced stack unwinding, unwinding over signal frames. | ||
+ | * TLS and NPTL. Some corner cases still need attention though. | ||
- | mkdir binutils && ( | + | ===== Things that don't work ===== |
- | cd binutils | + | |
- | " | + | |
- | --target=$target \ | + | |
- | --disable-shared --disable-werror --disable-gdb --disable-gdbstub \ | + | |
- | CFLAGS='-O0 -g' | + | |
- | make -j8 | + | * 193 failing tests in the gcc testsuite, 340 failing tests in the g++ testsuite. This is now mostly on par with the regular xtensa ELF toolchain. |
- | make -j8 install | + | * mmap with MAP_FIXED flag. By design of the nommu linux, but it seems to me that it doesn' |
- | ) | + | * tcpdump and libpcap in general. It tries to mmap the packet socket and it's missing a few things (mm/nommu.c doesn' |
+ | * bluetooth. It requires heavy userspace support that includes dbus which wants fork. Looks like it can be worked around, but the amount of bloat is discouraging. | ||
+ | * perf record. It requires mmapping perf events and the kernel code somewhat relies on the presence of mmu. I've tried to add a workaround, but something is still missing. | ||
- | mkdir gcc && ( | + | ===== Building/flashing/running |
- | cd gcc | + | |
- | " | + | |
- | --target=$target \ | + | |
- | --with-sysroot=" | + | |
- | --enable-languages=c \ | + | |
- | --disable-shared \ | + | |
- | --enable-__cxa_atexit \ | + | |
- | --enable-tls --disable-threads \ | + | |
- | --without-headers --with-newlib \ | + | |
- | CFLAGS_FOR_TARGET=" | + | |
- | CXXFLAGS_FOR_TARGET=" | + | |
- | CFLAGS='-O0 -g' \ | + | |
- | CXXFLAGS='-O0 -g' | + | |
- | make -j8 all-gcc | + | < |
- | | + | $ git clone https:// |
- | | + | $ cd esp32-linux-build |
- | | + | $ ./rebuild-esp32s3-linux-wifi.sh |
- | ) | + | |
</ | </ | ||
- | build.sh: | + | It will run the following steps to build the toolchain, the kernel, the root and etc filesystem images and the firmware and it will flash it. |
- | < | + | |
- | #! /bin/bash -ex | + | |
- | if [ $1 = " | + | ==== Build toolchain dynconfig library and export |
- | reconfigure=1 | + | |
- | fi | + | |
- | base=$(dirname $(readlink -f " | + | |
- | export CROSS_COMPILE=${CROSS_COMPILE: | + | |
- | export | + | |
- | if [ ! -d build-linux ]; then | + | < |
- | | + | $ git clone https:// |
- | mkdir -p build-linux | + | $ git clone https:// |
- | cd build-linux | + | $ make -C xtensa-dynconfig ORIG=1 CONF_DIR=`pwd` |
- | make -C $base/linux ARCH=xtensa | + | $ export XTENSA_GNU_CONFIG=`pwd`/xtensa-dynconfig/ |
- | make -C $base/linux ARCH=xtensa O=`pwd` | + | </ |
- | cd .. | + | |
- | fi | + | |
- | #base=$(dirname " | + | ==== Build the toolchain |
- | if [ -z " | + | |
- | [ -f .config ] || make -C $base/ | + | |
- | else | + | |
- | make -C $base/ | + | |
- | fi | + | |
- | make -C $base/uclibc-ng ARCH=xtensa | + | < |
- | make -C $base/uclibc-ng ARCH=xtensa | + | $ git clone https:// |
+ | $ pushd crosstool-NG | ||
+ | $ ./bootstrap && ./configure --enable-local && make | ||
+ | $ ./ct-ng xtensa-esp32s3-linux-uclibcfdpic | ||
+ | $ CT_PREFIX=`pwd`/builds nice ./ct-ng build | ||
+ | $ popd | ||
</ | </ | ||
+ | |||
+ | ==== Build the rootfs and kernel image ==== | ||
< | < | ||
- | $ nice make -C buildroot O=`pwd`/ | + | $ git clone https:// |
- | $ # adjust external toolchain location to the one built above | + | $ nice make -C buildroot O=`pwd`/ |
- | $ nice make -C buildroot O=`pwd`/ | + | $ buildroot/ |
+ | $ buildroot/ | ||
+ | $ buildroot/ | ||
+ | $ nice make -C buildroot O=`pwd`/ | ||
</ | </ | ||
+ | |||
+ | ==== Build and flash the bootloader, flash kernel and rootfs images ==== | ||
< | < | ||
- | $ cd examples/get-started/linux_boot | + | $ git clone https:// |
+ | $ pushd esp-hosted/esp_hosted_ng/ | ||
+ | $ cmake . | ||
+ | $ cd esp-idf | ||
+ | $ . export.sh | ||
+ | $ cd ../ | ||
+ | $ idf.py set-target esp32s3 | ||
+ | $ cp sdkconfig.defaults.esp32s3 sdkconfig | ||
$ idf.py build | $ idf.py build | ||
$ idf.py flash | $ idf.py flash | ||
- | $ parttool.py | + | $ popd |
- | $ parttool.py | + | $ parttool.py write_partition --partition-name linux --input |
+ | $ parttool.py write_partition --partition-name rootfs --input build-buildroot-esp32s3/ | ||
+ | $ parttool.py write_partition | ||
</ | </ | ||
- | Gives the following: | + | ==== The result ==== |
< | < |
etc/users/jcmvbkbc/linux-xtensa/esp32s3.1683548359.txt.gz · Last modified: 2023/05/08 15:19 by jcmvbkbc