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: 2675
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
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)
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,17 +2,17 @@

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
```


### Using the User Interface

You can more easily build the libraries using the user interface found in the `tools/config_editor/` folder.
@@ -22,25 +22,23 @@ For more information and troubleshooting, please refer to the [UI README](tools/

To use it, follow these steps:

1. Make sure you have the required dependencies installed:
1. Make sure you have the following prerequisites:
- Python 3.9 or later
- The [Textual](https://github.com/textualize/textual/) library
- All the dependencies listed in the previous section

2. Execute the script `tools/config_editor/app.py` from any folder. It will automatically detect the path to the root of the repository.
2. Install the required UI packages using `pip install -r tools/config_editor/requirements.txt`.

3. Configure the compilation and ESP-IDF options as desired.
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. Click on the "Compile Static Libraries" button to start the compilation process.
4. Configure the compilation and ESP-IDF options as desired.

5. 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.
5. Click on the "Compile Static Libraries" button to start the compilation process.

6. If the compilation is successful you can find the Platformio framework in the `dist` folder alongside this repository.
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)

### Development builds
Look in release and download a version. There is the Info of the used commits of IDF / Arduino.
22 changes: 19 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
#!/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
@@ -18,8 +28,9 @@ 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"
@@ -35,6 +46,9 @@ while getopts ":A:I:i:c:t:b:sde" opt; do
s )
SKIP_ENV=1
;;
n )
CCACHE_ENABLE=0
;;
e )
ARCHIVE_OUT=1
;;
@@ -75,6 +89,8 @@ done
shift $((OPTIND -1))
CONFIGS=$@

export IDF_CCACHE_ENABLE=$CCACHE_ENABLE

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

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()

47 changes: 37 additions & 10 deletions components/arduino_tinyusb/Kconfig.projbuild
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ menu "Arduino TinyUSB"
config TINYUSB_ENABLED
bool "Enable TinyUSB driver"
default y
depends on IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
depends on IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32P4
select FREERTOS_SUPPORT_STATIC_ALLOCATION
select FREERTOS_USE_AUTHENTIC_INCLUDE_PATHS
help
@@ -28,18 +28,28 @@ menu "Arduino TinyUSB"

config TINYUSB_CDC_RX_BUFSIZE
int "CDC FIFO size of RX"
default 64
default 64 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
default 512 if IDF_TARGET_ESP32P4
depends on TINYUSB_CDC_ENABLED
help
CDC FIFO size of RX

config TINYUSB_CDC_TX_BUFSIZE
int "CDC FIFO size of TX"
default 64
default 64 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
default 512 if IDF_TARGET_ESP32P4
depends on TINYUSB_CDC_ENABLED
help
CDC FIFO size of TX

config TINYUSB_CDC_MAX_PORTS
int "Maximum enabled CDC ports"
range 1 2
default 1
depends on TINYUSB_CDC_ENABLED
help
Maximum enabled CDC ports

endmenu

menu "Mass Storage (MSC) driver"
@@ -86,7 +96,8 @@ menu "Arduino TinyUSB"

config TINYUSB_HID_BUFSIZE
int "HID Buffer size"
default 64
default 64 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
default 512 if IDF_TARGET_ESP32P4
depends on TINYUSB_HID_ENABLED
help
HID Buffer size. Should be sufficient to hold ID (if any) + Data
@@ -111,14 +122,16 @@ menu "Arduino TinyUSB"

config TINYUSB_MIDI_RX_BUFSIZE
int "MIDI FIFO size of RX"
default 64
default 64 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
default 512 if IDF_TARGET_ESP32P4
depends on TINYUSB_MIDI_ENABLED
help
MIDI FIFO size of RX

config TINYUSB_MIDI_TX_BUFSIZE
int "MIDI FIFO size of TX"
default 64
default 64 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
default 512 if IDF_TARGET_ESP32P4
depends on TINYUSB_MIDI_ENABLED
help
MIDI FIFO size of TX
@@ -143,8 +156,9 @@ menu "Arduino TinyUSB"

config TINYUSB_VIDEO_STREAMING_BUFSIZE
int "VIDEO streaming endpoint size"
range 0 64
default 64
range 0 512
default 64 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
default 512 if IDF_TARGET_ESP32P4
depends on TINYUSB_VIDEO_ENABLED
help
VIDEO streaming endpoint size
@@ -219,20 +233,33 @@ menu "Arduino TinyUSB"

config TINYUSB_VENDOR_RX_BUFSIZE
int "VENDOR FIFO size of RX"
default 64
default 64 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
default 512 if IDF_TARGET_ESP32P4
depends on TINYUSB_VENDOR_ENABLED
help
VENDOR FIFO size of RX

config TINYUSB_VENDOR_TX_BUFSIZE
int "VENDOR FIFO size of TX"
default 64
default 64 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
default 512 if IDF_TARGET_ESP32P4
depends on TINYUSB_VENDOR_ENABLED
help
VENDOR FIFO size of TX

endmenu

menu "NCM driver"
depends on TINYUSB_ENABLED

config TINYUSB_NCM_ENABLED
bool "Enable USB NCM TinyUSB driver"
default y
help
Enable USB NCM TinyUSB driver.

endmenu

config TINYUSB_DEBUG_LEVEL
int "TinyUSB log level (0-3)"
default 0
21 changes: 19 additions & 2 deletions components/arduino_tinyusb/include/tusb_config.h
Original file line number Diff line number Diff line change
@@ -72,11 +72,16 @@ extern "C" {
# define CONFIG_TINYUSB_VENDOR_ENABLED 0
#endif

#ifndef CONFIG_TINYUSB_NCM_ENABLED
# define CONFIG_TINYUSB_NCM_ENABLED 0
#endif

/* */
/* COMMON CONFIGURATION */
/* */

#ifndef CFG_TUSB_MCU
#define CFG_TUSB_MCU OPT_MCU_ESP32S2
#endif
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
#define CFG_TUSB_OS OPT_OS_FREERTOS

@@ -95,15 +100,26 @@ extern "C" {
# define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
#endif

#if CONFIG_IDF_TARGET_ESP32P4
#define CFG_TUD_MAX_SPEED OPT_MODE_HIGH_SPEED
#else
#define CFG_TUD_MAX_SPEED OPT_MODE_FULL_SPEED
#endif

/* */
/* DRIVER CONFIGURATION */
/* */

#define CFG_TUD_MAINTASK_SIZE 4096
#define CFG_TUD_ENDOINT_SIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
#define CFG_TUD_ENDOINT0_SIZE 64

// Enabled Drivers
#define CFG_TUD_CDC CONFIG_TINYUSB_CDC_ENABLED
#ifdef CONFIG_TINYUSB_CDC_MAX_PORTS
#define CFG_TUD_CDC CONFIG_TINYUSB_CDC_MAX_PORTS
#else
#define CFG_TUD_CDC 0
#endif
#define CFG_TUD_MSC CONFIG_TINYUSB_MSC_ENABLED
#define CFG_TUD_HID CONFIG_TINYUSB_HID_ENABLED
#define CFG_TUD_MIDI CONFIG_TINYUSB_MIDI_ENABLED
@@ -112,6 +128,7 @@ extern "C" {
#define CFG_TUD_DFU_RUNTIME CONFIG_TINYUSB_DFU_RT_ENABLED
#define CFG_TUD_DFU CONFIG_TINYUSB_DFU_ENABLED
#define CFG_TUD_VENDOR CONFIG_TINYUSB_VENDOR_ENABLED
#define CFG_TUD_NCM CONFIG_TINYUSB_NCM_ENABLED

// CDC FIFO size of TX and RX
#define CFG_TUD_CDC_RX_BUFSIZE CONFIG_TINYUSB_CDC_RX_BUFSIZE
Loading