jcmvbkbc / esp32-linux-build Goto Github PK
View Code? Open in Web Editor NEWxtensa linux build scripts for the esp32s3 and esp32
Home Page: http://wiki.osll.ru/doku.php/etc:users:jcmvbkbc:linux-xtensa:esp32s3
xtensa linux build scripts for the esp32s3 and esp32
Home Page: http://wiki.osll.ru/doku.php/etc:users:jcmvbkbc:linux-xtensa:esp32s3
Install the following packages (Debian 12) before running the build scripts: autoconf automake bash bc bison build-essential cmake flex gawk git gperf help2man libncurses-dev libtool libtool-bin libusb-1.0-0 python3 python3-venv rsync texinfo unzip wget
Hi,
I bought a esp32 board which has no UART connection it only works on the native USB. It gets flashed easily but when I open putty with 115200 baud rate and the correct COM port it is stuck at the very first line "ESP-ROM:esp32s3-20210327". Can someone help me out please?
This project is so cool,I compiled everything and it run well as expected.
Now I want to write some c program.
For example if I have a helloworld.c, how to cross compile it? I want to run it in ssh by using nfs mounted folder.
I will be very happy if you can gave me some example script for cross compiling user program.
Thank you very much.
/etc/nfs # ls
ls: can't open '.': Cannot allocate memory
[ 2042.134265] ls: page allocation failure: order:8, mode:0xcc0(GFP_KERNEL), )
[ 2042.146821] CPU: 0 PID: 155 Comm: ls Not tainted 6.10.0-rc2 #1
[ 2042.147645] Stack:
[ 2042.147919] > 00000100 00000000 3da19bb0 423be730
[ 2042.149033] 423be730 3d87d50b 3decd240 3d8850a8
[ 2042.153725] 8217e67b 3da19c00 00000000 3decd598
[ 2042.158400] 3da19be0 00000004 00060a00 00000000
[ 2042.163127] 8217eb7d 3da19c20 00000cc0 00000000
[ 2042.167799] > 3da19c3c 00000cc0 3da19c50 00000000
[ 2042.172467] 8217ebd9 3da19ca0 00000000 00000008
[ 2042.177144] > 00000000 00000000 00000000 00000000
[ 2042.181845] 3da19c80 3da19c60 0000000c 423be08a
[ 2042.186719] 3da19c30 00000000 3d87da8c 00000cc0
[ 2042.191327] 00000cc0 00000000 00000000 00000009
[ 2042.195907] 00000009 00000000 00000018 00000008
[ 2042.200624] 0000000c 3d87da8c 00000000 3dd03020
[ 2042.205281] 00000001 00000008 00000cc0 00000000
[ 2042.209994] 8217ecec 3da19d20 00000000 00000cc0
[ 2042.214667] > 00000024 00000001 3dd00f30 3d871c18
[ 2042.219247] Call Trace:
[ 2042.221686] [<42376e8d>] 0x42376e8d
[ 2042.225226] [<4217e67b>] 0x4217e67b
[ 2042.228770] [<4217eb7d>] 0x4217eb7d
[ 2042.232331] [<4217ebd9>] 0x4217ebd9
[ 2042.235888] [<4217ecec>] 0x4217ecec
[ 2042.239449] [<4217ed65>] 0x4217ed65
[ 2042.243005] [<4217ba6c>] 0x4217ba6c
[ 2042.246568] [<42176823>] 0x42176823
[ 2042.250123] [<4217bc5f>] 0x4217bc5f
[ 2042.253683] [<4217bc7e>] 0x4217bc7e
[ 2042.257240] [<42120770>] 0x42120770
[ 2042.260801] [<421204fa>] 0x421204fa
[ 2042.433624] Mem-Info:
[ 2042.434343] active_anon:0 inactive_anon:0 isolated_anon:0
[ 2042.434343] active_file:0 inactive_file:6 isolated_file:0
[ 2042.434343] unevictable:15 dirty:0 writeback:0
[ 2042.434343] slab_reclaimable:182 slab_unreclaimable:837
[ 2042.434343] mapped:0 shmem:0 pagetables:0
[ 2042.434343] sec_pagetables:0 bounce:0
[ 2042.434343] kernel_misc_reclaimable:0
[ 2042.434343] free:312 free_pcp:0 free_cma:0
[ 2042.491746] Node 0 active_anon:0kB inactive_anon:0kB active_file:0kB inacto
[ 2042.540604] Normal free:1248kB boost:0kB min:340kB low:424kB high:508kB reB
[ 2042.557675] lowmem_reserve[]: 0 0
[ 2042.559839] Normal: 52*4kB (U) 18*8kB (U) 4*16kB (U) 0*32kB 1*64kB (U) 0*1B
[ 2042.586510] 23 total pagecache pages
[ 2042.587215] 2048 pages RAM
[ 2042.587338] 0 pages HighMem/MovableOnly
[ 2042.587470] 217 pages reserved
[ 2042.589164] nommu: Allocation of length 528384 from process 155 (ls) failed
[ 2042.624788] Mem-Info:
[ 2042.626502] active_anon:0 inactive_anon:0 isolated_anon:0
[ 2042.626502] active_file:0 inactive_file:6 isolated_file:0
[ 2042.626502] unevictable:15 dirty:0 writeback:0
[ 2042.626502] slab_reclaimable:182 slab_unreclaimable:837
[ 2042.626502] mapped:0 shmem:0 pagetables:0
[ 2042.626502] sec_pagetables:0 bounce:0
[ 2042.626502] kernel_misc_reclaimable:0
[ 2042.626502] free:312 free_pcp:0 free_cma:0
[ 2042.686564] Node 0 active_anon:0kB inactive_anon:0kB active_file:0kB inacto
[ 2042.726540] Normal free:1244kB boost:0kB min:340kB low:424kB high:508kB reB
[ 2042.752655] lowmem_reserve[]: 0 0
[ 2042.753466] Normal: 51*4kB (U) 18*8kB (U) 4*16kB (U) 0*32kB 1*64kB (U) 0*1B
[ 2042.771679] 24 total pagecache pages
[ 2042.772375] 2048 pages RAM
[ 2042.772494] 0 pages HighMem/MovableOnly
[ 2042.772626] 217 pages reserved
First try to boot linux on esp32-s3 (ESP32-S3-WROOM-1 N16R8) fails.
build was done with rebuild-esp32s3-linux.sh
Seems to be address related. At the end of the boot it says:
ptr = 0x42830000
ptr = 0x42b30000
Guru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4282fffc: d5557555 ffffffff ffffffff
So apparently there is nothing at the first ptr address
full Boot log:
Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x403759c8
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3810,len:0x1098
load:0x403c9700,len:0x9c8
load:0x403cc700,len:0x2ce8
entry 0x403c9880
I (70) octal_psram: vendor id : 0x0d (AP)
I (70) octal_psram: dev id : 0x02 (generation 3)
I (70) octal_psram: density : 0x03 (64 Mbit)
I (75) octal_psram: good-die : 0x01 (Pass)
I (80) octal_psram: Latency : 0x01 (Fixed)
I (85) octal_psram: VCC : 0x01 (3V)
I (90) octal_psram: SRF : 0x01 (Fast Refresh)
I (96) octal_psram: BurstType : 0x01 (Hybrid Wrap)
I (101) octal_psram: BurstLen : 0x01 (32 Byte)
I (107) octal_psram: Readlatency : 0x02 (10 cycles@Fixed)
I (113) octal_psram: DriveStrength: 0x00 (1/1)
I (119) esp_psram: Found 8MB PSRAM device
I (123) esp_psram: Speed: 80MHz
I (127) cpu_start: Pro cpu up.
I (130) cpu_start: Starting app cpu, entry point is 0x403752d8
I (119) cpu_start: App cpu up.
I (583) esp_psram: SPI SRAM memory test OK
I (591) cpu_start: Pro cpu start user code
I (591) cpu_start: cpu freq: 160000000 Hz
I (591) cpu_start: Application information:
I (594) cpu_start: Project name: linux_boot
I (599) cpu_start: App version: v5.0.1-8-gfc1671b3cd
I (606) cpu_start: Compile time: Feb 21 2024 17:55:21
I (612) cpu_start: ELF file SHA256: c79414a9bc389250...
I (618) cpu_start: ESP-IDF: v5.0.1-8-gfc1671b3cd
I (624) cpu_start: Min chip rev: v0.0
I (628) cpu_start: Max chip rev: v0.99
I (633) cpu_start: Chip rev: v0.1
I (638) heap_init: Initializing. RAM available for dynamic allocation:
I (645) heap_init: At 3FC95340 len 000543D0 (336 KiB): D/IRAM
I (652) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DRAM
I (658) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (664) heap_init: At 600FE010 len 00001FF0 (7 KiB): RTCRAM
I (671) esp_psram: Adding pool of 8192K of PSRAM memory to heap allocator
I (679) spi_flash: detected chip: winbond
I (683) spi_flash: flash io: dio
W (687) spi_flash: Detected size(16384k) larger than the size in the binary image header(8192k). Using the size in the binary image header.
I (701) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (721) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations
ptr = 0x42830000
ptr = 0x42b30000
Guru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4282fffc: d5557555 ffffffff ffffffff
Core 0 register dump:
PC : 0x42830000 PS : 0x00060530 A0 : 0x82006131 A1 : 0x3fcea870
A2 : 0x42830000 A3 : 0x00000003 A4 : 0x00060023 A5 : 0x00000001
A6 : 0x00060623 A7 : 0x00000000 A8 : 0x803773c9 A9 : 0x3fcea820
A10 : 0x00000011 A11 : 0x3fceaa80 A12 : 0x00000001 A13 : 0x01ffffff
A14 : 0x00000000 A15 : 0x00008000 SAR : 0x00000011 EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x400554b9 LEND : 0x400554dd LCOUNT : 0x8200700b
Backtrace: 0x4282fffd:0x3fcea870 0x4200612e:0x3fcea890 0x4037cdad:0x3fcea8b0
ELF file SHA256: c79414a9bc389250
Rebooting...
There is an issue with the partition table.
If I run ./rebuild-esp32s3-linux-wifi.sh the resulting image cannot be flashed due to the size of the xipImage
Also the wiki mentions
parttool.py write_partition --partition-name etc --input build-buildroot-esp32s3/images/etc.jffs2
but there is no etc in the partition table.
I'm having an S3 N16R8 device
First of all, I'm super impressed how flawlessly the script works without any fixed or adjustments, just start it and at the end there is a fully running Linux 🤯
Thx a lot for providing this 🙌
What I wonder, Is there an easy way to enable USB Host on the ESP32-S?
I would like to connect a USB CDC ACM (virtual com port) USB-Device onto my ESP32-S3 board but it doesn't work out-of-the-box 🤔
I would be very grateful if you could point me in the right direction 🤗
The current version needs extra steps to change the USB permissions into the Docker container. Will be nice fix that. I added the internal user to dialup group and also I did some tests with special commands on docker run to have permissions into the device. If you know how to fix that, please do a PR.
In the side bar there is the url http://wiki.osll.ru/doku.php/etc:users:jcmvbkbc:linux-xtensa:esp32s3
However, the server wiki.osll.ru appears to be offline
Hi! First of all, congratulations on this excellent work!
Using precompiled binaries, I could easily flash my ESP32-S3-WROOM-1 N8R16 with Linux. However, when trying to recompile the files by myself, I cannot get it working.
While compiling the toolchain (CT_PREFIX=(./builds nice ./ct-ng build
), I get the following output:
[INFO ] Checking dynamic linker symlinks
[EXTRA] Checking dynamic linker for multilib ''
[ERROR] collect2: error: ld returned 1 exit status
[ERROR]
[ERROR] >>
[ERROR] >> Build failed in step 'Checking dynamic linker symlinks'
[ERROR] >> called in step '(top-level)'
[ERROR] >>
[ERROR] >> Error happened in: CT_DoExecLog[scripts/functions@377]
[ERROR] >> called from: CT__FixupLDSO[scripts/functions@1695]
[ERROR] >> called from: CT_IterateMultilibs[scripts/functions@1608]
[ERROR] >> called from: CT_MultilibFixupLDSO[scripts/functions@1761]
[ERROR] >> called from: uClibc_ng_post_cc[scripts/build/libc/uClibc-ng.sh@335]
[ERROR] >> called from: do_libc_post_cc[scripts/build/libc.sh@38]
[ERROR] >> called from: main[scripts/crosstool-NG.sh@697]
[ERROR] >>
[ERROR] >> For more info on this error, look at the file: 'build.log'
[ERROR] >> There is a list of known issues, some with workarounds, in:
[ERROR] >> https://crosstool-ng.github.io/docs/known-issues/
[ERROR] >>
[ERROR] >> NOTE: Your configuration includes features marked EXPERIMENTAL.
[ERROR] >> Before submitting a bug report, try to reproduce it without enabling
[ERROR] >> any experimental features. Otherwise, you'll need to debug it
[ERROR] >> and present an explanation why it is a bug in crosstool-NG - or
[ERROR] >> preferably, a fix.
[ERROR] >>
[ERROR] >> If you feel this is a bug in crosstool-NG, report it at:
[ERROR] >> https://github.com/crosstool-ng/crosstool-ng/issues/
[ERROR] >>
[ERROR] >> Make sure your report includes all the information pertinent to this issue.
[ERROR] >> Read the bug reporting guidelines here:
[ERROR] >> http://crosstool-ng.github.io/support/
[ERROR]
[ERROR] (elapsed: 16:36.19)
[16:38] / gmake: *** [ct-ng:261: build] Error 1
Nevertheless, xtensa-esp32s3-linux-uclibcfdpic-gcc
still gets produced, and I can successfully compile xipImage
, rootfs.cramfs
, and etc.jffs2
.
However, when I try to compile a simple application using the toolchain (to execute from the board), it always fails the linking process with the following message:
~ # xtensa-esp32s3-linux-uclibcfdpic-gcc hello.c -c -o hello.o
~ # xtensa-esp32s3-linux-uclibcfdpic-gcc hello.o -o hello
/home/joaovieira/esp/rebuild_linux/build/crosstool-NG/builds/xtensa-esp32s3-linux-uclibcfdpic/lib/gcc/xtensa-esp32s3-linux-uclibcfdpic/14.0.0/../../../../xtensa-esp32s3-linux-uclibcfdpic/bin/ld: /home/joaovieira/esp/rebuild_linux/build/crosstool-NG/builds/xtensa-esp32s3-linux-uclibcfdpic/xtensa-esp32s3-linux-uclibcfdpic/sysroot/usr/lib/crt1.o: in function `_start':
(.text+0x10): undefined reference to `__self_reloc'
/home/joaovieira/esp/rebuild_linux/build/crosstool-NG/builds/xtensa-esp32s3-linux-uclibcfdpic/lib/gcc/xtensa-esp32s3-linux-uclibcfdpic/14.0.0/../../../../xtensa-esp32s3-linux-uclibcfdpic/bin/ld: BFD (crosstool-NG 1.25.0.172_c29b568) 2.40.50.20230424 assertion fail /home/joaovieira/esp/rebuild_linux/build/crosstool-NG/.build/xtensa-esp32s3-linux-uclibcfdpic/src/binutils/bfd/elf32-xtensa.c:2699
collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
compilation terminated.
Could it be related to the error while compiling the toolchain?
Furthermore, I cannot generate the bootloader. After setting up the esp-idf that ships with the script, when loading the environment variables, I get the following error:
~ # ~/esp/rebuild_linux/build/esp-hosted/esp_hosted_ng/esp/esp_driver/esp-idf$ . export.sh
Setting IDF_PATH to '/home/joaovieira/esp/rebuild_linux/build/esp-hosted/esp_hosted_ng/esp/esp_driver/esp-idf'
Detecting the Python interpreter
Checking "python" ...
Python 3.10.12
"python" has been detected
Adding ESP-IDF tools to PATH...
Traceback (most recent call last):
File "/home/joaovieira/esp/rebuild_linux/build/esp-hosted/esp_hosted_ng/esp/esp_driver/esp-idf/tools/idf_tools.py", line 1860, in <module>
main(sys.argv[1:])
File "/home/joaovieira/esp/rebuild_linux/build/esp-hosted/esp_hosted_ng/esp/esp_driver/esp-idf/tools/idf_tools.py", line 1856, in main
action_func(args)
File "/home/joaovieira/esp/rebuild_linux/build/esp-hosted/esp_hosted_ng/esp/esp_driver/esp-idf/tools/idf_tools.py", line 1177, in action_export
tools_info = filter_tools_info(tools_info)
File "/home/joaovieira/esp/rebuild_linux/build/esp-hosted/esp_hosted_ng/esp/esp_driver/esp-idf/tools/idf_tools.py", line 1119, in filter_tools_info
targets = get_user_defined_targets()
File "/home/joaovieira/esp/rebuild_linux/build/esp-hosted/esp_hosted_ng/esp/esp_driver/esp-idf/tools/idf_tools.py", line 1099, in get_user_defined_targets
if env == idf_env_json['idfSelectedId']:
KeyError: 'idfSelectedId'
Also, when using my own esp-idf installation (which works fine for everything else), I get fatal compilation errors. Hence, no binaries are produced.
All in all, I encountered the following issues while running the rebuild-esp32s3-linux-wifi.sh
script from which I am unable to recover:
In addition, it seems that the used partition table is tailored for a device with an external expansion flash of 8M. However, I am using a ESP32-S3-WROOM-1 N8R16, which as a 16M external expansion flash. It would be very useful to assign that extra space to the partition mounted on /etc
, which is the only one with write permissions. Can you provide any pointers on how to do that?
Any help that you can provide to solve these issues would be greatly appreciated :)
Thank you in advance!
Kind regards,
Joao Vieira
PS.: I am using Ubuntu 22.04 with GCC 11.4.0.
Hey so I made a sort of a diy esp32 board using this tutorial -> https://www.youtube.com/watch?v=tQ0dL_9M1wI&pp=ygULZGl5IGVzcCBcMzI%3D
I was successful in my attempt and I could see this as a COM serial port in my terminal.
I built the linux for it and flashed it (accordingly for the USB serial to work with some modification to a file in the etc partition)
The problem is that when I try to use the "idf.py monitor" command it gets stuck at the following line.
linux ptr = 0x42120000
vectors ptr = 0x4037c000
am I missing something or is this a bug which needs to be fixed
ESP32 S3 wifi version
After boot I can connect to the console using ttyACM1 with baud rate 115200.
However the connection is dropped after 2.5 minute.
The shell is not closed; If I start this shell script:
while true
do
date
sleep 1
done
The script remains running. When I reconnect to the console it is still printing the date. but after 2.5 minute the connection is dropped again.
No idea what causes this.
It seems that with more activity on the console (me typing) the timeout happens faster.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.