Skip to content

Commit 7846ab3

Browse files
authored
Merge branch 'esp32-s3-support' into rainmaker-fix
2 parents 76d50ec + 75cac9c commit 7846ab3

File tree

1,951 files changed

+127416
-24150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,951 files changed

+127416
-24150
lines changed

Diff for: .github/scripts/install-platformio-esp32.sh

+7-6
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
export PLATFORMIO_ESP32_PATH="$HOME/.platformio/packages/framework-arduinoespressif32"
44
PLATFORMIO_ESP32_URL="https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master"
55

6-
XTENSA32_TOOLCHAIN_VERSION="8.4.0+2021r2-patch2"
7-
XTENSA32S2_TOOLCHAIN_VERSION="8.4.0+2021r2-patch2"
8-
RISCV_TOOLCHAIN_VERSION="8.4.0+2021r2-patch2"
6+
TOOLCHAIN_VERSION="8.4.0+2021r2-patch2"
97
ESPTOOLPY_VERSION="~1.30100.0"
108
ESPRESSIF_ORGANIZATION_NAME="espressif"
119

@@ -30,9 +28,12 @@ replace_script+="data['packages']['toolchain-xtensa-esp32']['owner']='$ESPRESSIF
3028
replace_script+="data['packages']['toolchain-xtensa-esp32s2']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
3129
replace_script+="data['packages']['toolchain-riscv32-esp']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
3230
# Update versions to use the upstream
33-
replace_script+="data['packages']['toolchain-xtensa-esp32']['version']='$XTENSA32_TOOLCHAIN_VERSION';"
34-
replace_script+="data['packages']['toolchain-xtensa-esp32s2']['version']='$XTENSA32S2_TOOLCHAIN_VERSION';"
35-
replace_script+="data['packages']['toolchain-riscv32-esp']['version']='$RISCV_TOOLCHAIN_VERSION';"
31+
replace_script+="data['packages']['toolchain-xtensa-esp32']['version']='$TOOLCHAIN_VERSION';"
32+
replace_script+="data['packages']['toolchain-xtensa-esp32s2']['version']='$TOOLCHAIN_VERSION';"
33+
replace_script+="data['packages']['toolchain-riscv32-esp']['version']='$TOOLCHAIN_VERSION';"
34+
# Add ESP32-S3 Toolchain
35+
replace_script+="data['packages'].update({'toolchain-xtensa-esp32s3':{'type':'toolchain','optional':True,'owner':'$ESPRESSIF_ORGANIZATION_NAME','version':'$TOOLCHAIN_VERSION'}});"
36+
replace_script+="data['packages']['toolchain-xtensa-esp32'].update({'optional':False});"
3637
# esptool.py may require an upstream version (for now platformio is the owner)
3738
replace_script+="data['packages']['tool-esptoolpy']['version']='$ESPTOOLPY_VERSION';"
3839
# Save results

Diff for: .github/scripts/on-push.sh

+21-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -e
44

5+
export ARDUINO_BUILD_DIR="$HOME/.arduino/build.tmp"
6+
57
function build(){
68
local target=$1
79
local fqbn=$2
@@ -58,11 +60,12 @@ fi
5860

5961
SCRIPTS_DIR="./.github/scripts"
6062
if [ "$BUILD_PIO" -eq 0 ]; then
61-
source ./.github/scripts/install-arduino-ide.sh
63+
source ${SCRIPTS_DIR}/install-arduino-ide.sh
6264
source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh
6365

6466
FQBN_ESP32="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app"
6567
FQBN_ESP32S2="espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app"
68+
FQBN_ESP32S3="espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app"
6669
FQBN_ESP32C3="espressif:esp32:esp32c3:PartitionScheme=huge_app"
6770

6871
SKETCHES_ESP32="\
@@ -76,11 +79,12 @@ if [ "$BUILD_PIO" -eq 0 ]; then
7679
$ARDUINO_ESP32_PATH/libraries/WiFi/examples/WiFiClient/WiFiClient.ino\
7780
"
7881

79-
build "esp32" $FQBN_ESP32 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32
82+
build "esp32s3" $FQBN_ESP32S3 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32
8083
build "esp32s2" $FQBN_ESP32S2 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32XX
8184
build "esp32c3" $FQBN_ESP32C3 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32XX
85+
build "esp32" $FQBN_ESP32 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32
8286
else
83-
source ./${SCRIPTS_DIR}/install-platformio-esp32.sh
87+
source ${SCRIPTS_DIR}/install-platformio-esp32.sh
8488
# PlatformIO ESP32 Test
8589
BOARD="esp32dev"
8690
OPTIONS="board_build.partitions = huge_app.csv"
@@ -96,6 +100,20 @@ else
96100
# build_pio_sketch "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries/WiFiClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino"
97101

98102
python -m platformio ci --board "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/WiFi/examples/WiFiClient" --project-option="board_build.mcu = esp32s2" --project-option="board_build.partitions = huge_app.csv"
103+
python -m platformio ci --board "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/WiFi/examples/WiFiClient" --project-option="board_build.mcu = esp32c3" --project-option="board_build.partitions = huge_app.csv"
104+
105+
echo "Hacking in S3 support ..."
106+
replace_script="import json; import os;"
107+
replace_script+="fp=open(os.path.expanduser('~/.platformio/platforms/espressif32/platform.json'), 'r+');"
108+
replace_script+="data=json.load(fp);"
109+
replace_script+="data['packages']['toolchain-xtensa-esp32']['optional']=True;"
110+
replace_script+="data['packages']['toolchain-xtensa-esp32s3']['optional']=False;"
111+
replace_script+="data['packages']['tool-esptoolpy']['owner']='tasmota';"
112+
replace_script+="data['packages']['tool-esptoolpy']['version']='https://github.com/tasmota/esptool/releases/download/v3.2.1/esptool-3.2.1.zip';"
113+
replace_script+="fp.seek(0);fp.truncate();json.dump(data, fp, indent=2);fp.close()"
114+
python -c "$replace_script"
115+
116+
python -m platformio ci --board "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/WiFi/examples/WiFiClient" --project-option="board_build.mcu = esp32s3" --project-option="board_build.partitions = huge_app.csv"
99117

100118
#build_pio_sketches "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries"
101119
fi

Diff for: .github/scripts/sketch_utils.sh

+11-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <fqbn> <path-to-i
88
fi
99

1010
ARDUINO_CACHE_DIR="$HOME/.arduino/cache.tmp"
11+
if [ -z "$ARDUINO_BUILD_DIR" ]; then
12+
build_dir="$(dirname $sketch)/build"
13+
else
14+
build_dir="$ARDUINO_BUILD_DIR"
15+
fi
1116
local ide_path=$1
1217
local usr_path=$2
1318
local fqbn=$3
1419
local sketch=$4
1520
local xtra_opts=$5
1621
local win_opts=$6
1722

18-
build_dir="$(dirname $sketch)/build"
23+
rm -rf "$build_dir"
1924
mkdir -p "$build_dir"
2025
mkdir -p "$ARDUINO_CACHE_DIR"
2126
$ide_path/arduino-builder -compile -logger=human -core-api-version=10810 \
@@ -32,13 +37,13 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <fqbn> <path-to-i
3237
$win_opts $xtra_opts "$sketch"
3338
}
3439

35-
function count_sketches(){ # count_sketches <path> <target>
40+
function count_sketches(){ # count_sketches <path> [target]
3641
local path=$1
3742
local target=$2
3843

39-
if [ $# -lt 2 ]; then
44+
if [ $# -lt 1 ]; then
4045
echo "ERROR: Illegal number of parameters"
41-
echo "USAGE: ${0} count <path> <target>"
46+
echo "USAGE: ${0} count <path> [target]"
4247
fi
4348

4449
rm -rf sketches.txt
@@ -47,15 +52,15 @@ function count_sketches(){ # count_sketches <path> <target>
4752
return 0
4853
fi
4954

50-
local sketches=$(find $path -name *.ino)
55+
local sketches=$(find $path -name *.ino | sort)
5156
local sketchnum=0
5257
for sketch in $sketches; do
5358
local sketchdir=$(dirname $sketch)
5459
local sketchdirname=$(basename $sketchdir)
5560
local sketchname=$(basename $sketch)
5661
if [[ "$sketchdirname.ino" != "$sketchname" ]]; then
5762
continue
58-
elif [[ -f "$sketchdir/.skip.$target" ]]; then
63+
elif [[ -n $target ]] && [[ -f "$sketchdir/.skip.$target" ]]; then
5964
continue
6065
else
6166
echo $sketch >> sketches.txt

Diff for: .github/scripts/tests_build.sh

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
SCRIPTS_DIR="./.github/scripts"
4+
BUILD_CMD=""
5+
6+
if [ $# -eq 3 ]; then
7+
chunk_build=1
8+
elif [ $# -eq 2 ]; then
9+
chunk_build=0
10+
else
11+
echo "ERROR: Illegal number of parameters"
12+
echo "USAGE:
13+
${0} <target> <sketch_dir>
14+
${0} <target> <chunk> <total_chunks>
15+
"
16+
exit 0
17+
fi
18+
19+
target=$1
20+
21+
case "$target" in
22+
"esp32") fqbn="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app"
23+
;;
24+
"esp32s2") fqbn="espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app"
25+
;;
26+
"esp32c3") fqbn="espressif:esp32:esp32c3:PartitionScheme=huge_app"
27+
;;
28+
"esp32s3") fqbn="espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app"
29+
;;
30+
esac
31+
32+
if [ -z $fqbn ]; then
33+
echo "Unvalid chip $1"
34+
exit 0
35+
fi
36+
37+
source ${SCRIPTS_DIR}/install-arduino-ide.sh
38+
source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh
39+
40+
args="$ARDUINO_IDE_PATH $ARDUINO_USR_PATH \"$fqbn\""
41+
42+
if [ $chunk_build -eq 1 ]; then
43+
chunk_index=$2
44+
chunk_max=$3
45+
46+
if [ "$chunk_index" -gt "$chunk_max" ] && [ "$chunk_max" -ge 2 ]; then
47+
chunk_index=$chunk_max
48+
fi
49+
BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh chunk_build"
50+
args+=" $target $PWD/tests $chunk_index $chunk_max"
51+
else
52+
sketchdir=$2
53+
BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh build"
54+
args+=" $PWD/tests/$sketchdir/$sketchdir.ino"
55+
fi
56+
57+
${BUILD_CMD} ${args}
58+

Diff for: .github/scripts/tests_run.sh

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
3+
target=$1
4+
chunk_idex=$2
5+
chunks_num=$3
6+
7+
SCRIPTS_DIR="./.github/scripts"
8+
COUNT_SKETCHES="${SCRIPTS_DIR}/sketch_utils.sh count"
9+
10+
source ${SCRIPTS_DIR}/install-arduino-ide.sh
11+
12+
if [ "$chunks_num" -le 0 ]; then
13+
echo "ERROR: Chunks count must be positive number"
14+
return 1
15+
fi
16+
if [ "$chunk_idex" -ge "$chunks_num" ] && [ "$chunks_num" -ge 2 ]; then
17+
echo "ERROR: Chunk index must be less than chunks count"
18+
return 1
19+
fi
20+
21+
set +e
22+
${COUNT_SKETCHES} $PWD/tests $target
23+
sketchcount=$?
24+
set -e
25+
sketches=$(cat sketches.txt)
26+
rm -rf sketches.txt
27+
28+
chunk_size=$(( $sketchcount / $chunks_num ))
29+
all_chunks=$(( $chunks_num * $chunk_size ))
30+
if [ "$all_chunks" -lt "$sketchcount" ]; then
31+
chunk_size=$(( $chunk_size + 1 ))
32+
fi
33+
34+
start_index=0
35+
end_index=0
36+
if [ "$chunk_idex" -ge "$chunks_num" ]; then
37+
start_index=$chunk_idex
38+
end_index=$sketchcount
39+
else
40+
start_index=$(( $chunk_idex * $chunk_size ))
41+
if [ "$sketchcount" -le "$start_index" ]; then
42+
echo "Skipping job"
43+
return 0
44+
fi
45+
46+
end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size ))
47+
if [ "$end_index" -gt "$sketchcount" ]; then
48+
end_index=$sketchcount
49+
fi
50+
fi
51+
52+
start_num=$(( $start_index + 1 ))
53+
sketchnum=0
54+
55+
for sketch in $sketches; do
56+
sketchdir=$(dirname $sketch)
57+
sketchdirname=$(basename $sketchdir)
58+
sketchname=$(basename $sketch)
59+
sketchnum=$(($sketchnum + 1))
60+
if [ "$sketchnum" -le "$start_index" ] \
61+
|| [ "$sketchnum" -gt "$end_index" ]; then
62+
continue
63+
fi
64+
echo ""
65+
echo "Test for Sketch Index $(($sketchnum - 1)) - $sketchdirname"
66+
pytest tests -k test_$sketchdirname --junit-xml=tests/$sketchdirname/$sketchdirname.xml
67+
result=$?
68+
if [ $result -ne 0 ]; then
69+
return $result
70+
fi
71+
done

Diff for: .github/scripts/update-version.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
if [ ! $# -eq 3 ]; then
4+
echo "Bad number of arguments: $#" >&2
5+
echo "usage: $0 <major> <minor> <patch>" >&2
6+
exit 1
7+
fi
8+
9+
re='^[0-9]+$'
10+
if [[ ! $1 =~ $re ]] || [[ ! $2 =~ $re ]] || [[ ! $3 =~ $re ]] ; then
11+
echo "error: Not a valid version: $1.$2.$3" >&2
12+
echo "usage: $0 <major> <minor> <patch>" >&2
13+
exit 1
14+
fi
15+
16+
ESP_ARDUINO_VERSION_MAJOR="$1"
17+
ESP_ARDUINO_VERSION_MINOR="$2"
18+
ESP_ARDUINO_VERSION_PATCH="$3"
19+
ESP_ARDUINO_VERSION="$ESP_ARDUINO_VERSION_MAJOR.$ESP_ARDUINO_VERSION_MINOR.$ESP_ARDUINO_VERSION_PATCH"
20+
21+
echo "New Arduino Version: $ESP_ARDUINO_VERSION"
22+
23+
echo "Updating platform.txt..."
24+
cat platform.txt | sed "s/version=.*/version=$ESP_ARDUINO_VERSION/g" > __platform.txt && mv __platform.txt platform.txt
25+
26+
echo "Updating package.json..."
27+
cat package.json | sed "s/.*\"version\":.*/ \"version\": \"$ESP_ARDUINO_VERSION\",/g" > __package.json && mv __package.json package.json
28+
29+
echo "Updating cores/esp32/esp_arduino_version.h..."
30+
cat cores/esp32/esp_arduino_version.h | \
31+
sed "s/#define ESP_ARDUINO_VERSION_MAJOR.*/#define ESP_ARDUINO_VERSION_MAJOR $ESP_ARDUINO_VERSION_MAJOR/g" | \
32+
sed "s/#define ESP_ARDUINO_VERSION_MINOR.*/#define ESP_ARDUINO_VERSION_MINOR $ESP_ARDUINO_VERSION_MINOR/g" | \
33+
sed "s/#define ESP_ARDUINO_VERSION_PATCH.*/#define ESP_ARDUINO_VERSION_PATCH $ESP_ARDUINO_VERSION_PATCH/g" > __esp_arduino_version.h && mv __esp_arduino_version.h cores/esp32/esp_arduino_version.h
34+
35+
exit 0

0 commit comments

Comments
 (0)