Skip to content

Esp32 s3 support #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@ on:
- master
pull_request:

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

jobs:
build-libs:
name: Build Arduino Libs
name: Build Libs for ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
matrix:
target: [esp32, esp32s2, esp32s3, esp32c3]
fail-fast: false
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Install dependencies
run: bash ./tools/prepare-ci.sh
- name: Build Arduino Libs
run: bash ./build.sh
- name: Build Libs for ${{ matrix.target }}
run: bash ./build.sh -t ${{ matrix.target }}
- name: Upload archive
uses: actions/upload-artifact@v1
with:
name: artifacts
name: artifacts-${{ matrix.target }}
path: dist
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.DS_Store
.vscode
components/arduino/
components/esp-face/
components/esp-dl/
components/esp-sr/
components/esp32-camera/
components/esp_littlefs/
components/esp-rainmaker/
Expand Down
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

30 changes: 24 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,36 @@
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

if(IDF_TARGET STREQUAL "esp32")
set(EXTRA_COMPONENT_DIRS ${CMAKE_SOURCE_DIR}/components/esp-rainmaker/components)
endif()
set(EXTRA_COMPONENT_DIRS ${CMAKE_SOURCE_DIR}/components/esp-rainmaker/components)

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

idf_build_get_property(elf EXECUTABLE GENERATOR_EXPRESSION)

add_custom_command(
OUTPUT "idf_libs"
COMMAND ${CMAKE_SOURCE_DIR}/tools/prepare-libs.sh ${IDF_TARGET}
DEPENDS gen_project_binary bootloader partition_table
COMMAND ${CMAKE_SOURCE_DIR}/tools/copy-libs.sh ${IDF_TARGET} "${CONFIG_ESPTOOLPY_OCT_FLASH}" "${CONFIG_SPIRAM_MODE_OCT}"
DEPENDS ${elf}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
VERBATIM
)
add_custom_target(idf-libs DEPENDS "idf_libs")

add_custom_command(
OUTPUT "copy_bootloader"
COMMAND ${CMAKE_SOURCE_DIR}/tools/copy-bootloader.sh ${IDF_TARGET} "${CONFIG_LIB_BUILDER_FLASHMODE}" "${CONFIG_LIB_BUILDER_FLASHFREQ}"
DEPENDS bootloader
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
VERBATIM
)
add_custom_target(copy-bootloader DEPENDS "copy_bootloader")

add_custom_command(
OUTPUT "mem_variant"
COMMAND ${CMAKE_SOURCE_DIR}/tools/copy-mem-variant.sh ${IDF_TARGET} "${CONFIG_ESPTOOLPY_OCT_FLASH}" "${CONFIG_SPIRAM_MODE_OCT}"
DEPENDS ${elf}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
VERBATIM
)
add_custom_target(idf-libs ALL DEPENDS "idf_libs")
add_custom_target(mem-variant DEPENDS "mem_variant")
204 changes: 173 additions & 31 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,192 @@
#!/bin/bash

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

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

mkdir -p dist
TARGET="all"
BUILD_TYPE="all"
SKIP_ENV=0
COPY_OUT=0
DEPLOY_OUT=0

# update components from git
./tools/update-components.sh
if [ $? -ne 0 ]; then exit 1; fi
function print_help() {
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 ...]"
echo " -s Skip installing/updating of ESP-IDF and all components"
echo " -A Set which branch of arduino-esp32 to be used for compilation"
echo " -I Set which branch of ESP-IDF to be used for compilation"
echo " -i Set which commit of ESP-IDF to be used for compilation"
echo " -d Deploy the build to github arduino-esp32"
echo " -c Set the arduino-esp32 folder to copy the result to. ex. '$HOME/Arduino/hardware/espressif/esp32'"
echo " -t Set the build target(chip). ex. 'esp32s3'"
echo " -b Set the build type. ex. 'build' to build the project and prepare for uploading to a board"
echo " ... Specify additional configs to be applied. ex. 'qio 80m' to compile for QIO Flash@80MHz. Requires -b"
exit 1
}

# install esp-idf and gcc toolchain
source ./tools/install-esp-idf.sh
if [ $? -ne 0 ]; then exit 1; fi
while getopts ":A:I:i:c:t:b:sd" opt; do
case ${opt} in
s )
SKIP_ENV=1
;;
d )
DEPLOY_OUT=1
;;
c )
export ESP32_ARDUINO="$OPTARG"
COPY_OUT=1
;;
A )
export AR_BRANCH="$OPTARG"
;;
I )
export IDF_BRANCH="$OPTARG"
;;
i )
export IDF_COMMIT="$OPTARG"
;;
t )
TARGET=$OPTARG
;;
b )
b=$OPTARG
if [ "$b" != "build" ] &&
[ "$b" != "menuconfig" ] &&
[ "$b" != "idf_libs" ] &&
[ "$b" != "copy_bootloader" ] &&
[ "$b" != "mem_variant" ]; then
print_help
fi
BUILD_TYPE="$b"
;;
\? )
echo "Invalid option: -$OPTARG" 1>&2
print_help
;;
: )
echo "Invalid option: -$OPTARG requires an argument" 1>&2
print_help
;;
esac
done
shift $((OPTIND -1))
CONFIGS=$@

if [ $SKIP_ENV -eq 0 ]; then
echo "* Installing/Updating ESP-IDF and all components..."
# update components from git
./tools/update-components.sh
if [ $? -ne 0 ]; then exit 1; fi

if [ -z $TARGETS ]; then
TARGETS="esp32c3 esp32s2 esp32"
# install esp-idf
source ./tools/install-esp-idf.sh
if [ $? -ne 0 ]; then exit 1; fi
else
source ./tools/config.sh
fi

if [ "$BUILD_TYPE" != "all" ]; then
if [ "$TARGET" = "all" ]; then
echo "ERROR: You need to specify target for non-default builds"
print_help
fi
configs="configs/defconfig.common;configs/defconfig.$TARGET"

# Target Features Configs
for target_json in `jq -c '.targets[]' configs/builds.json`; do
target=$(echo "$target_json" | jq -c '.target' | tr -d '"')
if [ "$TARGET" == "$target" ]; then
for defconf in `echo "$target_json" | jq -c '.features[]' | tr -d '"'`; do
configs="$configs;configs/defconfig.$defconf"
done
fi
done

# Configs From Arguments
for conf in $CONFIGS; do
configs="$configs;configs/defconfig.$conf"
done

echo "idf.py -DIDF_TARGET=\"$TARGET\" -DSDKCONFIG_DEFAULTS=\"$configs\" $BUILD_TYPE"
rm -rf build sdkconfig
idf.py -DIDF_TARGET="$TARGET" -DSDKCONFIG_DEFAULTS="$configs" $BUILD_TYPE
if [ $? -ne 0 ]; then exit 1; fi
exit 0
fi

rm -rf build sdkconfig out

echo $(git -C $AR_COMPS/arduino describe --all --long) > version.txt

rm -rf out build sdkconfig sdkconfig.old

for target in $TARGETS; do
# configure the build for the target
rm -rf build sdkconfig sdkconfig.old
cp "sdkconfig.$target" sdkconfig
# uncomment next line to access menuconfig
# idf.py menuconfig
# build and prepare libs
idf.py build
if [ $? -ne 0 ]; then exit 1; fi
cp sdkconfig "sdkconfig.$target"
# build bootloaders
./tools/build-bootloaders.sh
if [ $? -ne 0 ]; then exit 1; fi
#targets_count=`jq -c '.targets[] | length' configs/builds.json`
for target_json in `jq -c '.targets[]' configs/builds.json`; do
target=$(echo "$target_json" | jq -c '.target' | tr -d '"')

if [ "$TARGET" != "all" ] && [ "$TARGET" != "$target" ]; then
echo "* Skipping Target: $target"
continue
fi

echo "* Target: $target"

# Build Main Configs List
main_configs="configs/defconfig.common;configs/defconfig.$target"
for defconf in `echo "$target_json" | jq -c '.features[]' | tr -d '"'`; do
main_configs="$main_configs;configs/defconfig.$defconf"
done

# Build IDF Libs
idf_libs_configs="$main_configs"
for defconf in `echo "$target_json" | jq -c '.idf_libs[]' | tr -d '"'`; do
idf_libs_configs="$idf_libs_configs;configs/defconfig.$defconf"
done
echo "* Build IDF-Libs: $idf_libs_configs"
rm -rf build sdkconfig
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf_libs
if [ $? -ne 0 ]; then exit 1; fi

# Build Bootloaders
for boot_conf in `echo "$target_json" | jq -c '.bootloaders[]'`; do
bootloader_configs="$main_configs"
for defconf in `echo "$boot_conf" | jq -c '.[]' | tr -d '"'`; do
bootloader_configs="$bootloader_configs;configs/defconfig.$defconf";
done
echo "* Build BootLoader: $bootloader_configs"
rm -rf build sdkconfig
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$bootloader_configs" copy_bootloader
if [ $? -ne 0 ]; then exit 1; fi
done

# Build Memory Variants
for mem_conf in `echo "$target_json" | jq -c '.mem_variants[]'`; do
mem_configs="$main_configs"
for defconf in `echo "$mem_conf" | jq -c '.[]' | tr -d '"'`; do
mem_configs="$mem_configs;configs/defconfig.$defconf";
done
echo "* Build Memory Variant: $mem_configs"
rm -rf build sdkconfig
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$mem_configs" mem_variant
if [ $? -ne 0 ]; then exit 1; fi
done
done

# archive the build
./tools/archive-build.sh
if [ $? -ne 0 ]; then exit 1; fi
if [ "$BUILD_TYPE" = "all" ]; then
./tools/archive-build.sh
if [ $? -ne 0 ]; then exit 1; fi
fi

# copy everything to arduino-esp32 installation
if [ $COPY_OUT -eq 1 ] && [ -d "$ESP32_ARDUINO" ]; then
./tools/copy-to-arduino.sh
fi

#./tools/copy-to-arduino.sh
if [ $DEPLOY_OUT -eq 1 ]; then
./tools/push-to-arduino.sh
fi
18 changes: 13 additions & 5 deletions components/arduino_tinyusb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ if(CONFIG_TINYUSB_ENABLED)

### variables ###
#################
set(compile_options
"-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
"-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}"
"-Wno-type-limits" # needed for the vanila tinyusb with turned off classes
)
# if(IDF_TARGET STREQUAL "esp32s2")
set(compile_options
"-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
"-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}"
"-Wno-type-limits" # needed for the vanila tinyusb with turned off classes
)
# elseif(IDF_TARGET STREQUAL "esp32s3")
# set(compile_options
# "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
# "-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}"
# "-Wno-type-limits" # needed for the vanila tinyusb with turned off classes
# )
# endif()
idf_component_get_property(FREERTOS_ORIG_INCLUDE_PATH freertos
ORIG_INCLUDE_PATH)
set(includes_private
Expand Down
2 changes: 1 addition & 1 deletion components/arduino_tinyusb/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ menu "Arduino TinyUSB"
config TINYUSB_ENABLED
bool "Enable TinyUSB driver"
default y
depends on IDF_TARGET_ESP32S2
depends on IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
select FREERTOS_SUPPORT_STATIC_ALLOCATION
select FREERTOS_USE_AUTHENTIC_INCLUDE_PATHS
help
Expand Down
Loading