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/26 04:44] – drop -o from clone command jcmvbkbc | etc:users:jcmvbkbc:linux-xtensa:esp32s3 [2024/06/09 05:06] (current) – update bootloader instructions to wifi-enabled version jcmvbkbc | ||
---|---|---|---|
Line 4: | Line 4: | ||
* https:// | * https:// | ||
* https:// | * https:// | ||
- | * https:// | + | * https:// |
- | * https:// | + | * https:// |
- | * https:// | + | * https:// |
- | * https:// | + | * https:// |
- | * https:// | + | * https:// |
- | * https:// | + | * https:// |
* https:// | * https:// | ||
- | Example | + | Scripts with all steps below: https:// |
+ | |||
+ | ===== Details ===== | ||
+ | |||
+ | * [[.: | ||
+ | * [[.: | ||
+ | * [[.: | ||
+ | * [[.: | ||
+ | * [[.: | ||
+ | |||
+ | ===== Things that work ===== | ||
+ | |||
+ | * 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 | ||
+ | * 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). -D1 is needed to properly enable events (perf relies on ability to run code after the fork but before the exec in the child process to manage events on systems with mmu, -D1 looks like a good workaround for nommu case). | ||
+ | * c++ exceptions, c cleanup routines, forced stack unwinding, unwinding over signal frames. | ||
+ | * TLS and NPTL. Some corner cases still need attention though. | ||
+ | |||
+ | ===== Things that don't work ===== | ||
+ | |||
+ | * 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. | ||
+ | * 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. | ||
+ | |||
+ | ===== Building/flashing/running ===== | ||
+ | |||
+ | < | ||
+ | $ git clone https:// | ||
+ | $ cd esp32-linux-build | ||
+ | $ ./ | ||
+ | </ | ||
+ | |||
+ | 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. | ||
==== Build toolchain dynconfig library and export XTENSA_GNU_CONFIG for use by the toolchain ==== | ==== Build toolchain dynconfig library and export XTENSA_GNU_CONFIG for use by the toolchain ==== | ||
Line 24: | Line 67: | ||
==== Build the toolchain ==== | ==== Build the toolchain ==== | ||
- | |||
- | === Using crosstool-NG === | ||
< | < | ||
Line 34: | Line 75: | ||
$ CT_PREFIX=`pwd`/ | $ CT_PREFIX=`pwd`/ | ||
$ popd | $ popd | ||
- | </ | ||
- | |||
- | It doesn' | ||
- | < | ||
- | ... | ||
- | [INFO ] Installing final gcc compiler: done in 572.47s (at 29:47) | ||
- | [INFO ] ================================================================= | ||
- | [INFO ] Checking dynamic linker symlinks | ||
- | [EXTRA] | ||
- | [ERROR] | ||
- | [ERROR] | ||
- | [ERROR] | ||
- | [ERROR] | ||
- | [ERROR] | ||
- | [ERROR] | ||
- | [ERROR] | ||
- | [ERROR] | ||
- | [ERROR] | ||
- | [ERROR] | ||
- | [ERROR] | ||
- | [ERROR] | ||
- | [ERROR] | ||
- | [ERROR] | ||
- | ... | ||
- | </ | ||
- | |||
- | === Or manually === | ||
- | |||
- | < | ||
- | $ git clone https:// | ||
- | $ git clone https:// | ||
- | $ git clone https:// | ||
- | $ git clone https:// | ||
- | $ mkdir build-xtensa-fdpic-toolchain-esp32s3 ; mkdir build-xtensa-fdpic-nothread-esp32s3 | ||
- | $ ( 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: | ||
- | |||
- | < | ||
- | #! /bin/bash -ex | ||
- | |||
- | src_base=$(dirname $(readlink -f " | ||
- | binutils_src=" | ||
- | gcc_src=" | ||
- | |||
- | target=${TARGET: | ||
- | base=`pwd` | ||
- | |||
- | _FLAGS_FOR_TARGET=${FLAGS_FOR_TARGET: | ||
- | |||
- | mkdir binutils && ( | ||
- | cd binutils | ||
- | " | ||
- | --target=$target \ | ||
- | --disable-shared --disable-werror --disable-gdb --disable-gdbstub \ | ||
- | CFLAGS=' | ||
- | |||
- | make -j8 | ||
- | make -j8 install | ||
- | ) | ||
- | |||
- | mkdir gcc && ( | ||
- | 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=' | ||
- | CXXFLAGS=' | ||
- | |||
- | make -j8 all-gcc | ||
- | make -j8 all-target-libgcc | ||
- | make -j8 install-gcc | ||
- | make -j8 install-target-libgcc | ||
- | ) | ||
- | </ | ||
- | |||
- | build.sh: | ||
- | |||
- | < | ||
- | #! /bin/bash -ex | ||
- | |||
- | if [ $1 = " | ||
- | reconfigure=1 | ||
- | fi | ||
- | base=$(dirname $(readlink -f " | ||
- | export CROSS_COMPILE=${CROSS_COMPILE: | ||
- | export TARGET_CFLAGS=" | ||
- | |||
- | if [ ! -d build-linux ]; then | ||
- | cur=`pwd` | ||
- | mkdir -p build-linux | ||
- | cd build-linux | ||
- | make -C $base/linux ARCH=xtensa O=`pwd` defconfig | ||
- | make -C $base/linux ARCH=xtensa O=`pwd` INSTALL_HDR_PATH=" | ||
- | cd .. | ||
- | fi | ||
- | |||
- | # | ||
- | if [ -z " | ||
- | [ -f .config ] || make -C $base/ | ||
- | else | ||
- | make -C $base/ | ||
- | fi | ||
- | |||
- | make -C $base/ | ||
- | make -C $base/ | ||
</ | </ | ||
Line 155: | Line 80: | ||
< | < | ||
- | $ git clone https:// | + | $ git clone https:// |
- | $ nice make -C buildroot O=`pwd`/ | + | $ nice make -C buildroot O=`pwd`/ |
- | $ nice make -C buildroot | + | $ buildroot/ |
- | $ nice make -C buildroot O=`pwd`/ | + | $ buildroot/ |
+ | $ buildroot/ | ||
+ | $ nice make -C buildroot O=`pwd`/ | ||
</ | </ | ||
Line 164: | Line 91: | ||
< | < | ||
- | $ git clone https:// | + | $ git clone https:// |
- | $ pushd esp-idf | + | $ pushd esp-hosted/ |
+ | $ cmake . | ||
+ | $ cd esp-idf | ||
$ . export.sh | $ . export.sh | ||
- | $ cd examples/get-started/ | + | $ cd ../network_adapter |
$ idf.py set-target esp32s3 | $ idf.py set-target esp32s3 | ||
+ | $ cp sdkconfig.defaults.esp32s3 sdkconfig | ||
$ idf.py build | $ idf.py build | ||
$ idf.py flash | $ idf.py flash | ||
$ popd | $ popd | ||
- | $ parttool.py write_partition --partition-name linux --input build-xtensa-2023.02-fdpic-esp32s3/ | + | $ parttool.py write_partition --partition-name linux --input build-buildroot-esp32s3/ |
- | $ parttool.py write_partition --partition-name rootfs --input build-xtensa-2023.02-fdpic-esp32s3/ | + | $ parttool.py write_partition --partition-name rootfs --input build-buildroot-esp32s3/ |
+ | $ parttool.py write_partition --partition-name etc --input build-buildroot-esp32s3/ | ||
</ | </ | ||
etc/users/jcmvbkbc/linux-xtensa/esp32s3.1685065458.txt.gz · Last modified: 2023/05/26 04:44 by jcmvbkbc