Skip to content

Commit 71de529

Browse files
me-no-devJason2866
andauthored
Esp32 s3 support (#62)
Fixes: espressif/arduino-esp32#6187 Co-authored-by: Jason2866 <[email protected]>
1 parent 5a8939e commit 71de529

34 files changed

+768
-5410
lines changed

Diff for: .github/workflows/push.yml

+13-6
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,26 @@ on:
66
- master
77
pull_request:
88

9-
jobs:
9+
concurrency:
10+
group: esp-idf-libs-${{github.event.pull_request.number || github.ref}}
11+
cancel-in-progress: true
1012

13+
jobs:
1114
build-libs:
12-
name: Build Arduino Libs
15+
name: Build Libs for ${{ matrix.target }}
1316
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
target: [esp32, esp32s2, esp32s3, esp32c3]
20+
fail-fast: false
1421
steps:
15-
- uses: actions/checkout@v1
22+
- uses: actions/checkout@v2
1623
- name: Install dependencies
1724
run: bash ./tools/prepare-ci.sh
18-
- name: Build Arduino Libs
19-
run: bash ./build.sh
25+
- name: Build Libs for ${{ matrix.target }}
26+
run: bash ./build.sh -t ${{ matrix.target }}
2027
- name: Upload archive
2128
uses: actions/upload-artifact@v1
2229
with:
23-
name: artifacts
30+
name: artifacts-${{ matrix.target }}
2431
path: dist

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
.DS_Store
22
.vscode
33
components/arduino/
4-
components/esp-face/
4+
components/esp-dl/
5+
components/esp-sr/
56
components/esp32-camera/
67
components/esp_littlefs/
78
components/esp-rainmaker/

Diff for: .travis.yml

-42
This file was deleted.

Diff for: CMakeLists.txt

+24-6
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,36 @@
22
# CMakeLists in this exact order for cmake to work correctly
33
cmake_minimum_required(VERSION 3.5)
44

5-
if(IDF_TARGET STREQUAL "esp32")
6-
set(EXTRA_COMPONENT_DIRS ${CMAKE_SOURCE_DIR}/components/esp-rainmaker/components)
7-
endif()
5+
set(EXTRA_COMPONENT_DIRS ${CMAKE_SOURCE_DIR}/components/esp-rainmaker/components)
86

97
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
108
project(arduino-lib-builder)
119

10+
idf_build_get_property(elf EXECUTABLE GENERATOR_EXPRESSION)
11+
1212
add_custom_command(
1313
OUTPUT "idf_libs"
14-
COMMAND ${CMAKE_SOURCE_DIR}/tools/prepare-libs.sh ${IDF_TARGET}
15-
DEPENDS gen_project_binary bootloader partition_table
14+
COMMAND ${CMAKE_SOURCE_DIR}/tools/copy-libs.sh ${IDF_TARGET} "${CONFIG_ESPTOOLPY_OCT_FLASH}" "${CONFIG_SPIRAM_MODE_OCT}"
15+
DEPENDS ${elf}
16+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
17+
VERBATIM
18+
)
19+
add_custom_target(idf-libs DEPENDS "idf_libs")
20+
21+
add_custom_command(
22+
OUTPUT "copy_bootloader"
23+
COMMAND ${CMAKE_SOURCE_DIR}/tools/copy-bootloader.sh ${IDF_TARGET} "${CONFIG_LIB_BUILDER_FLASHMODE}" "${CONFIG_LIB_BUILDER_FLASHFREQ}"
24+
DEPENDS bootloader
25+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
26+
VERBATIM
27+
)
28+
add_custom_target(copy-bootloader DEPENDS "copy_bootloader")
29+
30+
add_custom_command(
31+
OUTPUT "mem_variant"
32+
COMMAND ${CMAKE_SOURCE_DIR}/tools/copy-mem-variant.sh ${IDF_TARGET} "${CONFIG_ESPTOOLPY_OCT_FLASH}" "${CONFIG_SPIRAM_MODE_OCT}"
33+
DEPENDS ${elf}
1634
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
1735
VERBATIM
1836
)
19-
add_custom_target(idf-libs ALL DEPENDS "idf_libs")
37+
add_custom_target(mem-variant DEPENDS "mem_variant")

Diff for: build.sh

+173-31
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,192 @@
11
#!/bin/bash
22

33
if ! [ -x "$(command -v python)" ]; then
4-
echo "ERROR: python is not installed! Please install python first."
5-
exit 1
4+
echo "ERROR: python is not installed! Please install python first."
5+
exit 1
66
fi
77

88
if ! [ -x "$(command -v git)" ]; then
9-
echo "ERROR: git is not installed! Please install git first."
10-
exit 1
9+
echo "ERROR: git is not installed! Please install git first."
10+
exit 1
1111
fi
1212

13-
mkdir -p dist
13+
TARGET="all"
14+
BUILD_TYPE="all"
15+
SKIP_ENV=0
16+
COPY_OUT=0
17+
DEPLOY_OUT=0
1418

15-
# update components from git
16-
./tools/update-components.sh
17-
if [ $? -ne 0 ]; then exit 1; fi
19+
function print_help() {
20+
echo "Usage: build.sh [-s] [-A <arduino_branch>] [-I <idf_branch>] [-i <idf_commit>] [-c <path>] [-t <target>] [-b <build|menuconfig|idf_libs|copy_bootloader|mem_variant>] [config ...]"
21+
echo " -s Skip installing/updating of ESP-IDF and all components"
22+
echo " -A Set which branch of arduino-esp32 to be used for compilation"
23+
echo " -I Set which branch of ESP-IDF to be used for compilation"
24+
echo " -i Set which commit of ESP-IDF to be used for compilation"
25+
echo " -d Deploy the build to github arduino-esp32"
26+
echo " -c Set the arduino-esp32 folder to copy the result to. ex. '$HOME/Arduino/hardware/espressif/esp32'"
27+
echo " -t Set the build target(chip). ex. 'esp32s3'"
28+
echo " -b Set the build type. ex. 'build' to build the project and prepare for uploading to a board"
29+
echo " ... Specify additional configs to be applied. ex. 'qio 80m' to compile for QIO Flash@80MHz. Requires -b"
30+
exit 1
31+
}
1832

19-
# install esp-idf and gcc toolchain
20-
source ./tools/install-esp-idf.sh
21-
if [ $? -ne 0 ]; then exit 1; fi
33+
while getopts ":A:I:i:c:t:b:sd" opt; do
34+
case ${opt} in
35+
s )
36+
SKIP_ENV=1
37+
;;
38+
d )
39+
DEPLOY_OUT=1
40+
;;
41+
c )
42+
export ESP32_ARDUINO="$OPTARG"
43+
COPY_OUT=1
44+
;;
45+
A )
46+
export AR_BRANCH="$OPTARG"
47+
;;
48+
I )
49+
export IDF_BRANCH="$OPTARG"
50+
;;
51+
i )
52+
export IDF_COMMIT="$OPTARG"
53+
;;
54+
t )
55+
TARGET=$OPTARG
56+
;;
57+
b )
58+
b=$OPTARG
59+
if [ "$b" != "build" ] &&
60+
[ "$b" != "menuconfig" ] &&
61+
[ "$b" != "idf_libs" ] &&
62+
[ "$b" != "copy_bootloader" ] &&
63+
[ "$b" != "mem_variant" ]; then
64+
print_help
65+
fi
66+
BUILD_TYPE="$b"
67+
;;
68+
\? )
69+
echo "Invalid option: -$OPTARG" 1>&2
70+
print_help
71+
;;
72+
: )
73+
echo "Invalid option: -$OPTARG requires an argument" 1>&2
74+
print_help
75+
;;
76+
esac
77+
done
78+
shift $((OPTIND -1))
79+
CONFIGS=$@
80+
81+
if [ $SKIP_ENV -eq 0 ]; then
82+
echo "* Installing/Updating ESP-IDF and all components..."
83+
# update components from git
84+
./tools/update-components.sh
85+
if [ $? -ne 0 ]; then exit 1; fi
2286

23-
if [ -z $TARGETS ]; then
24-
TARGETS="esp32c3 esp32s2 esp32"
87+
# install esp-idf
88+
source ./tools/install-esp-idf.sh
89+
if [ $? -ne 0 ]; then exit 1; fi
90+
else
91+
source ./tools/config.sh
2592
fi
2693

94+
if [ "$BUILD_TYPE" != "all" ]; then
95+
if [ "$TARGET" = "all" ]; then
96+
echo "ERROR: You need to specify target for non-default builds"
97+
print_help
98+
fi
99+
configs="configs/defconfig.common;configs/defconfig.$TARGET"
100+
101+
# Target Features Configs
102+
for target_json in `jq -c '.targets[]' configs/builds.json`; do
103+
target=$(echo "$target_json" | jq -c '.target' | tr -d '"')
104+
if [ "$TARGET" == "$target" ]; then
105+
for defconf in `echo "$target_json" | jq -c '.features[]' | tr -d '"'`; do
106+
configs="$configs;configs/defconfig.$defconf"
107+
done
108+
fi
109+
done
110+
111+
# Configs From Arguments
112+
for conf in $CONFIGS; do
113+
configs="$configs;configs/defconfig.$conf"
114+
done
115+
116+
echo "idf.py -DIDF_TARGET=\"$TARGET\" -DSDKCONFIG_DEFAULTS=\"$configs\" $BUILD_TYPE"
117+
rm -rf build sdkconfig
118+
idf.py -DIDF_TARGET="$TARGET" -DSDKCONFIG_DEFAULTS="$configs" $BUILD_TYPE
119+
if [ $? -ne 0 ]; then exit 1; fi
120+
exit 0
121+
fi
122+
123+
rm -rf build sdkconfig out
124+
27125
echo $(git -C $AR_COMPS/arduino describe --all --long) > version.txt
28126

29-
rm -rf out build sdkconfig sdkconfig.old
30-
31-
for target in $TARGETS; do
32-
# configure the build for the target
33-
rm -rf build sdkconfig sdkconfig.old
34-
cp "sdkconfig.$target" sdkconfig
35-
# uncomment next line to access menuconfig
36-
# idf.py menuconfig
37-
# build and prepare libs
38-
idf.py build
39-
if [ $? -ne 0 ]; then exit 1; fi
40-
cp sdkconfig "sdkconfig.$target"
41-
# build bootloaders
42-
./tools/build-bootloaders.sh
43-
if [ $? -ne 0 ]; then exit 1; fi
127+
#targets_count=`jq -c '.targets[] | length' configs/builds.json`
128+
for target_json in `jq -c '.targets[]' configs/builds.json`; do
129+
target=$(echo "$target_json" | jq -c '.target' | tr -d '"')
130+
131+
if [ "$TARGET" != "all" ] && [ "$TARGET" != "$target" ]; then
132+
echo "* Skipping Target: $target"
133+
continue
134+
fi
135+
136+
echo "* Target: $target"
137+
138+
# Build Main Configs List
139+
main_configs="configs/defconfig.common;configs/defconfig.$target"
140+
for defconf in `echo "$target_json" | jq -c '.features[]' | tr -d '"'`; do
141+
main_configs="$main_configs;configs/defconfig.$defconf"
142+
done
143+
144+
# Build IDF Libs
145+
idf_libs_configs="$main_configs"
146+
for defconf in `echo "$target_json" | jq -c '.idf_libs[]' | tr -d '"'`; do
147+
idf_libs_configs="$idf_libs_configs;configs/defconfig.$defconf"
148+
done
149+
echo "* Build IDF-Libs: $idf_libs_configs"
150+
rm -rf build sdkconfig
151+
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf_libs
152+
if [ $? -ne 0 ]; then exit 1; fi
153+
154+
# Build Bootloaders
155+
for boot_conf in `echo "$target_json" | jq -c '.bootloaders[]'`; do
156+
bootloader_configs="$main_configs"
157+
for defconf in `echo "$boot_conf" | jq -c '.[]' | tr -d '"'`; do
158+
bootloader_configs="$bootloader_configs;configs/defconfig.$defconf";
159+
done
160+
echo "* Build BootLoader: $bootloader_configs"
161+
rm -rf build sdkconfig
162+
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$bootloader_configs" copy_bootloader
163+
if [ $? -ne 0 ]; then exit 1; fi
164+
done
165+
166+
# Build Memory Variants
167+
for mem_conf in `echo "$target_json" | jq -c '.mem_variants[]'`; do
168+
mem_configs="$main_configs"
169+
for defconf in `echo "$mem_conf" | jq -c '.[]' | tr -d '"'`; do
170+
mem_configs="$mem_configs;configs/defconfig.$defconf";
171+
done
172+
echo "* Build Memory Variant: $mem_configs"
173+
rm -rf build sdkconfig
174+
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$mem_configs" mem_variant
175+
if [ $? -ne 0 ]; then exit 1; fi
176+
done
44177
done
45178

46179
# archive the build
47-
./tools/archive-build.sh
48-
if [ $? -ne 0 ]; then exit 1; fi
180+
if [ "$BUILD_TYPE" = "all" ]; then
181+
./tools/archive-build.sh
182+
if [ $? -ne 0 ]; then exit 1; fi
183+
fi
184+
185+
# copy everything to arduino-esp32 installation
186+
if [ $COPY_OUT -eq 1 ] && [ -d "$ESP32_ARDUINO" ]; then
187+
./tools/copy-to-arduino.sh
188+
fi
49189

50-
#./tools/copy-to-arduino.sh
190+
if [ $DEPLOY_OUT -eq 1 ]; then
191+
./tools/push-to-arduino.sh
192+
fi

Diff for: components/arduino_tinyusb/CMakeLists.txt

+13-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ if(CONFIG_TINYUSB_ENABLED)
44

55
### variables ###
66
#################
7-
set(compile_options
8-
"-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
9-
"-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}"
10-
"-Wno-type-limits" # needed for the vanila tinyusb with turned off classes
11-
)
7+
# if(IDF_TARGET STREQUAL "esp32s2")
8+
set(compile_options
9+
"-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
10+
"-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}"
11+
"-Wno-type-limits" # needed for the vanila tinyusb with turned off classes
12+
)
13+
# elseif(IDF_TARGET STREQUAL "esp32s3")
14+
# set(compile_options
15+
# "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
16+
# "-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}"
17+
# "-Wno-type-limits" # needed for the vanila tinyusb with turned off classes
18+
# )
19+
# endif()
1220
idf_component_get_property(FREERTOS_ORIG_INCLUDE_PATH freertos
1321
ORIG_INCLUDE_PATH)
1422
set(includes_private

Diff for: components/arduino_tinyusb/Kconfig.projbuild

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ menu "Arduino TinyUSB"
33
config TINYUSB_ENABLED
44
bool "Enable TinyUSB driver"
55
default y
6-
depends on IDF_TARGET_ESP32S2
6+
depends on IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
77
select FREERTOS_SUPPORT_STATIC_ALLOCATION
88
select FREERTOS_USE_AUTHENTIC_INCLUDE_PATHS
99
help

0 commit comments

Comments
 (0)