Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Jason2866/esp32-arduino-lib-builder
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2179
Choose a base ref
...
head repository: Jason2866/esp32-arduino-lib-builder
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.1_Arduino
Choose a head ref
Loading
Showing with 2,567 additions and 2,582 deletions.
  1. +2 −0 CMakeLists.txt
  2. +35 −6 README.md
  3. +83 −59 build.sh
  4. +18 −13 components/arduino_tinyusb/CMakeLists.txt
  5. +38 −10 components/arduino_tinyusb/Kconfig.projbuild
  6. +19 −2 components/arduino_tinyusb/include/tusb_config.h
  7. +766 −1,045 components/arduino_tinyusb/src/dcd_dwc2.c
  8. +0 −954 components/arduino_tinyusb/src/dcd_esp32sx.c
  9. +12 −6 configs/builds.json
  10. +1 −0 configs/defconfig.120m
  11. +25 −10 configs/defconfig.common
  12. +0 −1 configs/defconfig.dout
  13. +19 −6 configs/defconfig.esp32
  14. +23 −1 configs/defconfig.esp32c2
  15. +8 −0 configs/defconfig.esp32c3
  16. +10 −0 configs/defconfig.esp32c6
  17. +8 −0 configs/defconfig.esp32h2
  18. +9 −1 configs/defconfig.esp32s2
  19. +11 −0 configs/defconfig.esp32s3
  20. +0 −37 configs/defconfig.esp_sr
  21. +9 −1 configs/defconfig.opi_ram
  22. +0 −1 configs/defconfig.qout
  23. +1 −1 configs/pio_end.txt
  24. +33 −0 configs/pio_start.txt
  25. +1 −1 main/Kconfig.projbuild
  26. +6 −45 main/idf_component.yml
  27. +118 −0 patches/lwip_max_tcp_pcb.diff
  28. +24 −0 patches/mmu_map.diff
  29. +85 −0 patches/tinyusb_dcd_dwc2.diff
  30. +119 −0 patches/tinyusb_dcd_esp32sx.diff
  31. +0 −121 tools/add_sdk_json.py
  32. +6 −1 tools/archive-build.sh
  33. +3 −5 tools/config.sh
  34. +2 −0 tools/config_editor/.gitignore
  35. +38 −0 tools/config_editor/README.md
  36. +270 −0 tools/config_editor/app.py
  37. +163 −0 tools/config_editor/compile.py
  38. +86 −0 tools/config_editor/editor.py
  39. +1 −0 tools/config_editor/requirements.txt
  40. +133 −0 tools/config_editor/settings.py
  41. +202 −0 tools/config_editor/style.tcss
  42. +95 −0 tools/config_editor/widgets.py
  43. +73 −29 tools/copy-libs.sh
  44. +0 −23 tools/copy-to-arduino.sh
  45. 0 tools/gen_pio_frmwk_manifest.py
  46. 0 tools/gen_pio_lib_manifest.py
  47. +0 −166 tools/gen_tools_json.py
  48. 0 tools/get_projbuild_gitconfig.py
  49. +7 −13 tools/install-arduino.sh
  50. +5 −2 tools/install-esp-idf.sh
  51. +0 −22 tools/update-components.sh
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -33,3 +33,5 @@ add_custom_command(
VERBATIM
)
add_custom_target(mem-variant DEPENDS "mem_variant")

idf_build_set_property(COMPILE_DEFINITIONS "-DESP32_ARDUINO_LIB_BUILDER" APPEND)
41 changes: 35 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,14 +2,43 @@

This repository contains the scripts that produce the libraries included with Tasmota esp32-arduino.

Tested on Ubuntu and MacOS.

### Build on Ubuntu
```bash
sudo apt update && sudo apt install -y git wget curl libssl-dev libncurses-dev flex bison gperf python3 cmake ninja-build ccache jq
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3 get-pip.py && \
pip3 install setuptools pyserial click future wheel cryptography pyparsing pyelftools
git clone https://github.com/Jason2866/esp32-arduino-lib-builder
sudo apt-get install git wget curl libssl-dev libncurses-dev flex bison gperf python python-pip python-setuptools python-serial python-click python-cryptography python-future python-pyparsing python-pyelftools cmake ninja-build ccache jq
sudo pip install --upgrade pip
git clone https://github.com/espressif/esp32-arduino-lib-builder
cd esp32-arduino-lib-builder
./build.sh
```
### Development builds
Look in release and download a version. There is the Info of the used commits of IDF / Arduino.

### Using the User Interface

You can more easily build the libraries using the user interface found in the `tools/config_editor/` folder.
It is a Python script that allows you to select and edit the options for the libraries you want to build.
The script has mouse support and can also be pre-configured using the same command line arguments as the `build.sh` script.
For more information and troubleshooting, please refer to the [UI README](tools/config_editor/README.md).

To use it, follow these steps:

1. Make sure you have the following prerequisites:
- Python 3.9 or later
- All the dependencies listed in the previous section

2. Install the required UI packages using `pip install -r tools/config_editor/requirements.txt`.

3. Execute the script `tools/config_editor/app.py` from any folder. It will automatically detect the path to the root of the repository.

4. Configure the compilation and ESP-IDF options as desired.

5. Click on the "Compile Static Libraries" button to start the compilation process.

6. The script will show the compilation output in a new screen. Note that the compilation process can take many hours, depending on the number of libraries selected and the options chosen.

7. If the compilation is successful and the option to copy the libraries to the Arduino Core folder is enabled, it will already be available for use in the Arduino IDE. Otherwise, you can find the compiled libraries in the `esp32-arduino-libs` folder alongside this repository.
- Note that the copy operation doesn't currently support the core downloaded from the Arduino IDE Boards Manager, only the manual installation from the [`arduino-esp32`](https://github.com/espressif/arduino-esp32) repository.

### Documentation

For more information about how to use the Library builder, please refer to this [Documentation page](https://docs.espressif.com/projects/arduino-esp32/en/latest/lib_builder.html?highlight=lib%20builder)
142 changes: 83 additions & 59 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
#!/bin/bash

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

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

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

# Fixes building some components. See https://github.com/espressif/arduino-esp32/issues/10167
export IDF_COMPONENT_OVERWRITE_MANAGED_COMPONENTS=1

CCACHE_ENABLE=1

export TARGET="all"
BUILD_TYPE="all"
SKIP_ENV=0
COPY_OUT=0
ARCHIVE_OUT=0
if [ -z $DEPLOY_OUT ]; then
DEPLOY_OUT=0
fi
ARCHIVE_OUT=1
DEPLOY_OUT=0

function print_help() {
echo "Usage: build.sh [-s] [-A <arduino_branch>] [-I <idf_branch>] [-i <idf_commit>] [-c <path>] [-t <target>] [-b <build|menuconfig|reconfigure|idf_libs|copy_bootloader|mem_variant>] [config ...]"
echo "Usage: build.sh [-s] [-n] [-A <arduino_branch>] [-I <idf_branch>] [-i <idf_commit>] [-c <path>] [-t <target>] [-b <build|menuconfig|reconfigure|idf-libs|copy-bootloader|mem-variant>] [config ...]"
echo " -s Skip installing/updating of ESP-IDF and all components"
echo " -n Disable ccache"
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 " -e Archive the build to dist"
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 " -t Set the build target(chip) ex. 'esp32s3' or select multiple targets(chips) by separating them with comma ex. 'esp32,esp32s3,esp32c3'"
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
@@ -39,16 +46,12 @@ while getopts ":A:I:i:c:t:b:sde" opt; do
s )
SKIP_ENV=1
;;
d )
DEPLOY_OUT=1
n )
CCACHE_ENABLE=0
;;
e )
ARCHIVE_OUT=1
;;
c )
export ESP32_ARDUINO="$OPTARG"
COPY_OUT=1
;;
A )
export AR_BRANCH="$OPTARG"
;;
@@ -59,16 +62,16 @@ while getopts ":A:I:i:c:t:b:sde" opt; do
export IDF_COMMIT="$OPTARG"
;;
t )
TARGET=$OPTARG
IFS=',' read -ra TARGET <<< "$OPTARG"
;;
b )
b=$OPTARG
if [ "$b" != "build" ] &&
[ "$b" != "menuconfig" ] &&
[ "$b" != "reconfigure" ] &&
[ "$b" != "idf_libs" ] &&
[ "$b" != "copy_bootloader" ] &&
[ "$b" != "mem_variant" ]; then
[ "$b" != "idf-libs" ] &&
[ "$b" != "copy-bootloader" ] &&
[ "$b" != "mem-variant" ]; then
print_help
fi
BUILD_TYPE="$b"
@@ -86,6 +89,11 @@ done
shift $((OPTIND -1))
CONFIGS=$@

export IDF_CCACHE_ENABLE=$CCACHE_ENABLE

# Output the TARGET array
echo "TARGET(s): ${TARGET[@]}"

mkdir -p dist
rm -rf dependencies.lock

@@ -113,27 +121,42 @@ if [ "$BUILD_TYPE" != "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

# Check if $target is in the $TARGET array
target_in_array=false
for item in "${TARGET[@]}"; do
if [ "$item" = "$target" ]; then
target_in_array=true
break
fi
done

if [ "$target_in_array" = false ]; then
# Skip building for targets that are not in the $TARGET array
continue
fi
done

# Configs From Arguments
for conf in $CONFIGS; do
configs="$configs;configs/defconfig.$conf"
done
configs="configs/defconfig.common;configs/defconfig.$target"
for defconf in `echo "$target_json" | jq -c '.features[]' | tr -d '"'`; do
configs="$configs;configs/defconfig.$defconf"
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
echo "* Building for $target"

# 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
done
exit 0
fi

@@ -152,8 +175,28 @@ echo "Framework built from
#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 '"')
target_skip=$(echo "$target_json" | jq -c '.skip // 0')

# Check if $target is in the $TARGET array if not "all"
if [ "$TARGET" != "all" ]; then
target_in_array=false
for item in "${TARGET[@]}"; do
if [ "$item" = "$target" ]; then
target_in_array=true
break
fi
done

if [ "$TARGET" != "all" ] && [ "$TARGET" != "$target" ]; then
# If $target is not in the $TARGET array, skip processing
if [ "$target_in_array" = false ]; then
echo "* Skipping Target: $target"
continue
fi
fi

# Skip chips that should not be a part of the final libs
# WARNING!!! this logic needs to be updated when cron builds are split into jobs
if [ "$TARGET" = "all" ] && [ $target_skip -eq 1 ]; then
echo "* Skipping Target: $target"
continue
fi
@@ -174,7 +217,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do

echo "* Build IDF-Libs: $idf_libs_configs"
rm -rf build sdkconfig
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf_libs
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf-libs
if [ $? -ne 0 ]; then exit 1; fi

# Build Bootloaders
@@ -186,7 +229,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do

echo "* Build BootLoader: $bootloader_configs"
rm -rf build sdkconfig
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$bootloader_configs" copy_bootloader
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$bootloader_configs" copy-bootloader
if [ $? -ne 0 ]; then exit 1; fi
done

@@ -199,7 +242,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do

echo "* Build Memory Variant: $mem_configs"
rm -rf build sdkconfig
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$mem_configs" mem_variant
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$mem_configs" mem-variant
if [ $? -ne 0 ]; then exit 1; fi
done
done
@@ -237,13 +280,6 @@ done

export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD)

# update package_esp32_index.template.json
if [ "$BUILD_TYPE" = "all" ]; then
python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -j "$AR_COMPS/arduino/package/package_esp32_index.template.json" -o "$AR_OUT/"
python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -o "$TOOLS_JSON_OUT/"
if [ $? -ne 0 ]; then exit 1; fi
fi

# Generate PlatformIO library manifest file
if [ "$BUILD_TYPE" = "all" ]; then
python3 ./tools/gen_pio_lib_manifest.py -o "$TOOLS_JSON_OUT/" -s "v$IDF_VERSION" -c "$IDF_COMMIT"
@@ -267,20 +303,8 @@ echo "#define ARDUINO_ESP32_GIT_VER 0x$AR_Commit_short
#define ARDUINO_ESP32_RELEASE_$AR_VERSION_UNDERSCORE
#define ARDUINO_ESP32_RELEASE \"$AR_VERSION_UNDERSCORE\"" >> "$AR_ROOT/core_version.h"

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

# push changes to esp32-arduino-libs and create pull request into arduino-esp32
if [ $DEPLOY_OUT -eq 1 ]; then
./tools/push-to-arduino.sh
if [ $? -ne 0 ]; then exit 1; fi
fi

# archive the build
if [ "$BUILD_TYPE" = "all" ]; then
./tools/archive-build.sh
if [ $ARCHIVE_OUT -eq 1 ]; then
./tools/archive-build.sh "$TARGET"
if [ $? -ne 0 ]; then exit 1; fi
fi
31 changes: 18 additions & 13 deletions components/arduino_tinyusb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -15,15 +15,20 @@ if(CONFIG_TINYUSB_ENABLED)
"-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}"
"-Wno-type-limits" # needed for the vanila tinyusb with turned off classes
)
elseif(IDF_TARGET STREQUAL "esp32p4")
set(compile_options
"-DCFG_TUSB_MCU=OPT_MCU_ESP32P4"
"-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}"
"-Wno-type-limits" # needed for the vanila tinyusb with turned off classes
)
endif()

set(srcs
# espressif:
"${COMPONENT_DIR}/src/dcd_esp32sx.c"
#"${COMPONENT_DIR}/src/dcd_dwc2.c"
"${COMPONENT_DIR}/src/dcd_dwc2.c"
# tusb:
#"${COMPONENT_DIR}/tinyusb/src/portable/espressif/esp32sx/dcd_esp32sx.c"
#"{COMPONENT_DIR}/tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c"
#"${COMPONENT_DIR}/tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c"
"${COMPONENT_DIR}/tinyusb/src/portable/synopsys/dwc2/dwc2_common.c"
"${COMPONENT_DIR}/tinyusb/src/class/cdc/cdc_device.c"
"${COMPONENT_DIR}/tinyusb/src/class/hid/hid_device.c"
"${COMPONENT_DIR}/tinyusb/src/class/midi/midi_device.c"
@@ -32,6 +37,7 @@ if(CONFIG_TINYUSB_ENABLED)
"${COMPONENT_DIR}/tinyusb/src/class/dfu/dfu_rt_device.c"
"${COMPONENT_DIR}/tinyusb/src/class/dfu/dfu_device.c"
"${COMPONENT_DIR}/tinyusb/src/class/vendor/vendor_device.c"
"${COMPONENT_DIR}/tinyusb/src/class/net/ncm_device.c"
"${COMPONENT_DIR}/tinyusb/src/common/tusb_fifo.c"
"${COMPONENT_DIR}/tinyusb/src/device/usbd_control.c"
"${COMPONENT_DIR}/tinyusb/src/device/usbd.c"
@@ -56,16 +62,15 @@ if(CONFIG_TINYUSB_ENABLED)

set(requires esp_rom freertos soc)
set(priv_requires arduino main)
### tinyusb lib ###
###################
idf_component_register(INCLUDE_DIRS ${includes_public} PRIV_INCLUDE_DIRS ${includes_private} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires})
# add_library(${COMPONENT_TARGET} STATIC ${srcs})
# target_include_directories(
# ${COMPONENT_TARGET}
# PUBLIC ${includes_public}
# PRIVATE ${includes_private})

idf_component_register(
INCLUDE_DIRS ${includes_public}
PRIV_INCLUDE_DIRS ${includes_private}
SRCS ${srcs}
REQUIRES ${requires}
PRIV_REQUIRES ${priv_requires}
)
target_compile_options(${COMPONENT_TARGET} PRIVATE ${compile_options})
#target_link_libraries(${COMPONENT_TARGET} INTERFACE ${COMPONENT_TARGET})

else()

Loading