Skip to content

Commit 64e4ffa

Browse files
authored
Merge pull request #9 from hpsaturn/fix_issue6_sync_scripts
Fix issue6 sync scripts
2 parents 202b471 + e74cdd5 commit 64e4ffa

File tree

7 files changed

+60
-80
lines changed

7 files changed

+60
-80
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "esp32-linux-build"]
2+
path = esp32-linux-build
3+
url = https://github.com/jcmvbkbc/esp32-linux-build.git

Dockerfile

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
FROM ubuntu:22.04
66

77
RUN apt-get update
8-
RUN apt-get -y install gperf bison flex texinfo help2man gawk libtool-bin git unzip ncurses-dev rsync zlib1g zlib1g-dev xz-utils cmake wget bzip2 g++ python3 python3-dev python3-pip cpio bc virtualenv libusb-1.0 && \
8+
RUN apt-get -y install gperf bison flex texinfo help2man gawk libtool-bin git unzip ncurses-dev rsync zlib1g zlib1g-dev xz-utils cmake wget bzip2 g++ python3 python3-dev python3-pip python3.10-venv cpio bc virtualenv libusb-1.0 && \
99
ln -s /usr/bin/python3 /usr/bin/python
1010

1111
WORKDIR /app
@@ -19,62 +19,18 @@ RUN wget https://ftp.gnu.org/gnu/autoconf/autoconf-2.71.tar.xz && \
1919
make install
2020
ENV PATH="$PATH:/app/autoconf-2.71/root/bin"
2121

22-
# dynconfig
23-
RUN git clone https://github.com/jcmvbkbc/xtensa-dynconfig -b original --depth=1 && \
24-
git clone https://github.com/jcmvbkbc/config-esp32s3 esp32s3 --depth=1 && \
25-
make -C xtensa-dynconfig ORIG=1 CONF_DIR=`pwd` esp32s3.so
26-
ENV XTENSA_GNU_CONFIG="/app/xtensa-dynconfig/esp32s3.so"
22+
#COPY esp32-linux-build/* /app/
23+
RUN chmod a+rwx /app
2724

25+
ARG DOCKER_USER=default_user
26+
ARG DOCKER_USERID=default_userid
2827
# ct-ng cannot run as root, we'll just do everything else as a user
29-
RUN useradd -d /app/build -u 3232 esp32 && mkdir build && chown esp32:esp32 build
30-
USER esp32
31-
32-
# toolchain
33-
RUN cd build && \
34-
git clone https://github.com/jcmvbkbc/crosstool-NG.git -b xtensa-fdpic --depth=1 && \
35-
cd crosstool-NG && \
36-
./bootstrap && \
37-
./configure --enable-local && \
38-
make && \
39-
./ct-ng xtensa-esp32s3-linux-uclibcfdpic && \
40-
CT_PREFIX=`pwd`/builds ./ct-ng build || echo "Completed" # the complete ct-ng build fails but we still get what we wanted!
41-
RUN [ -e build/crosstool-NG/builds/xtensa-esp32s3-linux-uclibcfdpic/bin/xtensa-esp32s3-linux-uclibcfdpic-gcc ] || exit 1
42-
43-
# kernel and rootfs
44-
RUN cd build && \
45-
git clone https://github.com/jcmvbkbc/buildroot -b xtensa-2023.02-fdpic --depth=1 && \
46-
make -C buildroot O=`pwd`/build-xtensa-2023.02-fdpic-esp32s3 esp32s3wifi_defconfig && \
47-
buildroot/utils/config --file build-xtensa-2023.02-fdpic-esp32s3/.config --set-str TOOLCHAIN_EXTERNAL_PATH `pwd`/crosstool-NG/builds/xtensa-esp32s3-linux-uclibcfdpic && \
48-
buildroot/utils/config --file build-xtensa-2023.02-fdpic-esp32s3/.config --set-str TOOLCHAIN_EXTERNAL_PREFIX '$(ARCH)-esp32s3-linux-uclibcfdpic' && \
49-
buildroot/utils/config --file build-xtensa-2023.02-fdpic-esp32s3/.config --set-str TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX '$(ARCH)-esp32s3-linux-uclibcfdpic' && \
50-
make -C buildroot O=`pwd`/build-xtensa-2023.02-fdpic-esp32s3
51-
RUN [ -f build/build-xtensa-2023.02-fdpic-esp32s3/images/xipImage -a -f build/build-xtensa-2023.02-fdpic-esp32s3/images/rootfs.cramfs ] || exit 1
52-
53-
54-
# bootloader
55-
ENV IDF_PATH="/app/build/esp-hosted/esp_hosted_ng/esp/esp_driver/esp-idf"
56-
RUN cd build && \
57-
git clone https://github.com/jcmvbkbc/esp-hosted -b shmem --depth=1 && \
58-
cd esp-hosted/esp_hosted_ng/esp/esp_driver && cmake . && \
59-
cd esp-idf && . ./export.sh && \
60-
cd ../network_adapter && idf.py set-target esp32s3 && \
61-
cp sdkconfig.defaults.esp32s3 sdkconfig && idf.py build
62-
63-
64-
# move files over
65-
RUN cd build && mkdir release && \
66-
cp esp-hosted/esp_hosted_ng/esp/esp_driver/network_adapter/build/bootloader/bootloader.bin release && \
67-
cp esp-hosted/esp_hosted_ng/esp/esp_driver/network_adapter/build/partition_table/partition-table.bin release && \
68-
cp esp-hosted/esp_hosted_ng/esp/esp_driver/network_adapter/build/network_adapter.bin release && \
69-
cp build-xtensa-2023.02-fdpic-esp32s3/images/xipImage release && \
70-
cp build-xtensa-2023.02-fdpic-esp32s3/images/rootfs.cramfs release
71-
72-
# keep docker running so we can debug/rebuild :)
73-
USER root
74-
ENTRYPOINT ["tail", "-f", "/dev/null"]
28+
RUN useradd -d /app/build -u $DOCKER_USERID $DOCKER_USER && mkdir build && chown $DOCKER_USER:$DOCKER_USER build
29+
RUN usermod -a -G dialout $DOCKER_USER
7530

31+
USER $DOCKER_USER
7632

77-
# grab the files with `docker cp CONTAINER_NAME:/app/build/release/\* .`
33+
# final files: /app/build/release/
7834
# now you can burn the files from the 'release' folder with:
7935
# python esptool.py --chip esp32s3 -p /dev/ttyUSB0 -b 921600 --before=default_reset --after=hard_reset write_flash 0x0 bootloader.bin 0x10000 network_adapter.bin 0x8000 partition-table.bin
8036
# next we can burn in the kernel and filesys with parttool, which is part of esp-idf

README.md

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,73 @@ Dockerfile ported by Adafruit from the work of [@jcmvbkbc](https://gist.github.c
77

88
Please follow the next steps:
99

10-
1. Download or clone this repo, and then build the docker image:
10+
1. Download or clone this repo
1111

1212
```bash
13-
git clone https://github.com/hpsaturn/esp32s3-linux.git && cd esp32s3-linux
14-
docker build -t esp32-s3_linux .
13+
git clone --recursive https://github.com/hpsaturn/esp32s3-linux.git && cd esp32s3-linux
1514
```
1615

17-
This step takes around ~35 minutes and needs ~20Gb:
18-
19-
![ESP32S3 Linux image build](screenshots/docker_build.jpg)
20-
21-
2. Run a container in a terminal
16+
2. Then build the docker image:
2217

2318
```bash
24-
docker run --name esp32s3build -it esp32-s3_linux
19+
docker build --build-arg DOCKER_USER=$USER --build-arg DOCKER_USERID=$UID -t esp32linuxbase .
2520
```
2621

27-
3. In a second termintal, copy the binaries
22+
3. Copy settings sample and configure it:
2823

2924
```bash
30-
docker cp esp32s3build:/app/build/release/ bin_files
25+
cp settings.cfg.default settings.cfg
3126
```
3227

33-
4. Stop the container
28+
Possible settings:
3429

3530
```bash
36-
docker stop esp32s3build
37-
```
31+
keep_toolchain=
32+
keep_rootfs=
33+
keep_buildroot=
34+
keep_bootloader=
35+
keep_etc=
36+
```
3837

39-
# Upload
40-
41-
You must have two tools installed in your system, [ESPTool](https://docs.espressif.com/projects/esptool/en/latest/esp32/installation.html) and [Espressif IDF](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/#installation). After that please upload the binaries using:
38+
put `y` to enable some one like yes:
4239

4340
```bash
44-
python esptool.py --chip esp32s3 -p YOUR-PORT-HERE -b 921600 --before=default_reset --after=hard_reset write_flash 0x0 bootloader.bin 0x10000 network_adapter.bin 0x8000 partition-table.bin
45-
```
41+
# keep_toolchain=y -- don't rebuild the toolchain, but rebuild everything else
42+
# keep_rootfs=y -- don't reconfigure or rebuild rootfs from scratch. Would still apply overlay changes
43+
# keep_buildroot=y -- don't redownload the buildroot, only git pull any updates into it
44+
# keep_bootloader=y -- don't redownload the bootloader, only rebuild it
45+
# keep_etc=y -- don't overwrite the /etc partition
46+
```
47+
48+
4. Run the build script of your preference, for example:
4649

4750
```bash
48-
parttool.py write_partition --partition-name linux --input xipImage
51+
docker run --rm -it --name esp32s3linux --user="$(id -u):$(id -g)" -v ./esp32-linux-build:/app --env-file settings.cfg --device-cgroup-rule='c 166:* rmw' --device=/dev/ttyACM0 esp32linuxbase ./rebuild-esp32s3-linux-wifi.sh
4952
```
5053

54+
Keep in mind that you should change the --device to your USB device where is connected the ESP32S3.For a different script please check the directory `esp32-linux-build`.This step takes around ~35 minutes and needs ~20Gb:
55+
56+
![ESP32S3 Linux image build](screenshots/docker_build.jpg)
57+
58+
After that you should have this message:
59+
60+
![ESP32S3 Linux finish build](screenshots/docker_build_before_flash.jpg)
61+
62+
5. Open a different terminal and enter to the running container:
63+
5164
```bash
52-
parttool.py write_partition --partition-name rootfs --input rootfs.cramfs
65+
docker exec -it -u root esp32s3linux bash
5366
```
5467

55-
And the etc partition:¨ (skip it if you preserver your settings)
68+
and change the docker USB device permissions:
5669

5770
```bash
58-
parttool.py write_partition --partition-name etc --input build-buildroot-esp32s3/images/etc.jffs2
71+
chmod 666 /dev/ttyACM0
5972
```
6073

61-
Alternative following this [Adafruit guide](https://learn.adafruit.com/docker-esp32-s3-linux/docker-esp32-s3-linux-image).
74+
6. Return to the main terminal and perform the flashing. And that's it!
75+
76+
![ESP32S3 Linux final flashing](screenshots/docker_flashing.jpg)
6277

6378
# Linux boot
6479

@@ -124,9 +139,9 @@ keep_toolchain=y keep_rootfs=y keep_buildroot=y keep_bootloader=y keep_etc=y ./r
124139

125140
# TODO
126141

127-
- [ ] Migrate to the last script version with build parameters
128-
- [ ] Freezing repositories to specific commit
129-
- [ ] Add provisioning stuff
142+
- [x] Migrate to the last script version with build parameters
143+
- [x] Freezing repositories to specific commit
144+
- [x] Add provisioning stuff (etc partition)
130145

131146
# Credits
132147

esp32-linux-build

Submodule esp32-linux-build added at ae45f24
106 KB
Loading

screenshots/docker_flashing.jpg

53.3 KB
Loading

settings.cfg.default

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
keep_toolchain=
2+
keep_rootfs=
3+
keep_buildroot=
4+
keep_bootloader=
5+
keep_etc=

0 commit comments

Comments
 (0)