Skip to content

Idf v5.1 #51

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 25 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
39 changes: 0 additions & 39 deletions .github/workflows/cron.yml

This file was deleted.

45 changes: 23 additions & 22 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
name: ESP32 Arduino Libs CI
name: Arduino IDF 5.x

on:
push:
branches:
- master
pull_request:

concurrency:
group: esp-idf-libs-${{github.event.pull_request.number || github.ref}}
cancel-in-progress: true
workflow_dispatch: # Manually start a workflow

jobs:
build-libs:
name: Build Libs for ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
matrix:
target: [esp32, esp32s2, esp32s3, esp32c3]
fail-fast: false
name: Build Arduino Libs
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
- name: Install dependencies
run: bash ./tools/prepare-ci.sh
- name: Build Libs for ${{ matrix.target }}
run: bash ./build.sh -t ${{ matrix.target }}
- name: Upload archive
uses: actions/upload-artifact@v1
- name: Build Arduino Libs
run: bash ./build.sh
- name: Display files
run: ls -R ./*
- name: Release
uses: jason2866/[email protected]
with:
name: artifacts-${{ matrix.target }}
path: dist
tag_name: ${{ github.run_number }}
body_path: release-info.txt
prerelease: true
files: |
dist/framework*
release-info.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 changes: 0 additions & 23 deletions .github/workflows/repository_dispatch.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ sdkconfig
sdkconfig.old
version.txt
dependencies.lock
managed_components/
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

set(EXTRA_COMPONENT_DIRS ${CMAKE_SOURCE_DIR}/components/esp-rainmaker/components ${CMAKE_SOURCE_DIR}/components/esp-insights/components)

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

Expand Down
6 changes: 5 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ COPY_OUT=0
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|idf_libs|copy_bootloader|mem_variant>] [config ...]"
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 " -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"
Expand Down Expand Up @@ -58,6 +58,7 @@ while getopts ":A:I:i:c:t:b:sd" opt; do
b=$OPTARG
if [ "$b" != "build" ] &&
[ "$b" != "menuconfig" ] &&
[ "$b" != "reconfigure" ] &&
[ "$b" != "idf_libs" ] &&
[ "$b" != "copy_bootloader" ] &&
[ "$b" != "mem_variant" ]; then
Expand Down Expand Up @@ -121,6 +122,9 @@ if [ "$BUILD_TYPE" != "all" ]; then
fi

rm -rf build sdkconfig out
echo "* Reconfigure Project"
idf.py reconfigure
rm -rf build sdkconfig

# Add components version info
mkdir -p "$AR_TOOLS/sdk" && rm -rf version.txt && rm -rf "$AR_TOOLS/sdk/versions.txt"
Expand Down
70 changes: 39 additions & 31 deletions components/arduino_tinyusb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,22 @@
idf_component_register(REQUIRES esp_rom freertos soc PRIV_REQUIRES arduino main)

if(CONFIG_TINYUSB_ENABLED)

### variables ###
#################
# if(IDF_TARGET STREQUAL "esp32s2")

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
# tusb:
"${COMPONENT_DIR}/tinyusb/hw/bsp/"
"${COMPONENT_DIR}/tinyusb/src/"
"${COMPONENT_DIR}/tinyusb/src/device"
)
elseif(IDF_TARGET STREQUAL "esp32s3")
set(compile_options
"-DCFG_TUSB_MCU=OPT_MCU_ESP32S3"
"-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}"
"-Wno-type-limits" # needed for the vanila tinyusb with turned off classes
)
endif()

set(includes_public
# tusb:
"${FREERTOS_ORIG_INCLUDE_PATH}"
"${COMPONENT_DIR}/tinyusb/src/"
# espressif:
"${COMPONENT_DIR}/include")
set(srcs
# espressif:
"${COMPONENT_DIR}/src/dcd_esp32sx.c"
Expand All @@ -49,14 +34,37 @@ if(CONFIG_TINYUSB_ENABLED)
"${COMPONENT_DIR}/tinyusb/src/device/usbd.c"
"${COMPONENT_DIR}/tinyusb/src/tusb.c")

set(includes_private
# tusb:
"${COMPONENT_DIR}/tinyusb/hw/bsp/"
"${COMPONENT_DIR}/tinyusb/src/"
"${COMPONENT_DIR}/tinyusb/src/device"
)

idf_component_get_property(FREERTOS_ORIG_INCLUDE_PATH freertos
ORIG_INCLUDE_PATH)
set(includes_public
# tusb:
"${FREERTOS_ORIG_INCLUDE_PATH}"
"${COMPONENT_DIR}/tinyusb/src/"
# espressif:
"${COMPONENT_DIR}/include")

set(requires esp_rom freertos soc)
set(priv_requires arduino main)
### tinyusb lib ###
###################
add_library(arduino_tinyusb STATIC ${srcs})
target_include_directories(
arduino_tinyusb
PUBLIC ${includes_public}
PRIVATE ${includes_private})
target_compile_options(arduino_tinyusb PRIVATE ${compile_options})
target_link_libraries(${COMPONENT_TARGET} INTERFACE arduino_tinyusb)
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})
target_compile_options(${COMPONENT_TARGET} PRIVATE ${compile_options})
#target_link_libraries(${COMPONENT_TARGET} INTERFACE ${COMPONENT_TARGET})

else()

idf_component_register()

endif()
29 changes: 26 additions & 3 deletions components/arduino_tinyusb/src/dcd_esp32sx.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@

#include "tusb_option.h"

#if (((CFG_TUSB_MCU == OPT_MCU_ESP32S2) || (CFG_TUSB_MCU == OPT_MCU_ESP32S3)) && TUSB_OPT_DEVICE_ENABLED)
#if (((CFG_TUSB_MCU == OPT_MCU_ESP32S2) || (CFG_TUSB_MCU == OPT_MCU_ESP32S3)) && CFG_TUD_ENABLED)

// Espressif
#include "driver/periph_ctrl.h"
#include "freertos/xtensa_api.h"
#include "esp_intr_alloc.h"
#include "esp_log.h"
#include "driver/gpio.h"
#include "soc/dport_reg.h"
#include "soc/gpio_sig_map.h"
#include "soc/usb_periph.h"
#include "soc/periph_defs.h" // for interrupt source

#include "device/dcd.h"

Expand All @@ -60,6 +59,7 @@ typedef struct {
uint16_t queued_len;
uint16_t max_size;
bool short_packet;
uint8_t interval;
} xfer_ctl_t;

static const char *TAG = "TUSB:DCD";
Expand Down Expand Up @@ -284,6 +284,14 @@ void dcd_disconnect(uint8_t rhport)
USB0.dctl |= USB_SFTDISCON_M;
}

void dcd_sof_enable(uint8_t rhport, bool en)
{
(void) rhport;
(void) en;

// TODO implement later
}

/*------------------------------------------------------------------*/
/* DCD Endpoint port
*------------------------------------------------------------------*/
Expand All @@ -303,6 +311,7 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const *desc_edpt)

xfer_ctl_t *xfer = XFER_CTL_BASE(epnum, dir);
xfer->max_size = tu_edpt_packet_size(desc_edpt);
xfer->interval = desc_edpt->bInterval;

if (dir == TUSB_DIR_OUT) {
out_ep[epnum].doepctl &= ~(USB_D_EPTYPE0_M | USB_D_MPS0_M);
Expand Down Expand Up @@ -423,6 +432,13 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t to
USB0.in_ep_reg[epnum].dieptsiz = (num_packets << USB_D_PKTCNT0_S) | total_bytes;
USB0.in_ep_reg[epnum].diepctl |= USB_D_EPENA1_M | USB_D_CNAK1_M; // Enable | CNAK

// For ISO endpoint with interval=1 set correct DATA0/DATA1 bit for next frame
if ((USB0.in_ep_reg[epnum].diepctl & USB_D_EPTYPE0_M) == (1 << USB_D_EPTYPE1_S) && xfer->interval == 1) {
// Take odd/even bit from frame counter.
uint32_t const odd_frame_now = (USB0.dsts & (1u << USB_SOFFN_S));
USB0.in_ep_reg[epnum].diepctl |= (odd_frame_now ? USB_DI_SETD0PID1 : USB_DI_SETD1PID1);
}

// Enable fifo empty interrupt only if there are something to put in the fifo.
if(total_bytes != 0) {
USB0.dtknqr4_fifoemptymsk |= (1 << epnum);
Expand All @@ -431,6 +447,13 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t to
// Each complete packet for OUT xfers triggers XFRC.
USB0.out_ep_reg[epnum].doeptsiz |= USB_PKTCNT0_M | ((xfer->max_size & USB_XFERSIZE0_V) << USB_XFERSIZE0_S);
USB0.out_ep_reg[epnum].doepctl |= USB_EPENA0_M | USB_CNAK0_M;

// For ISO endpoint with interval=1 set correct DATA0/DATA1 bit for next frame
if ((USB0.out_ep_reg[epnum].doepctl & USB_D_EPTYPE0_M) == (1 << USB_D_EPTYPE1_S) && xfer->interval == 1) {
// Take odd/even bit from frame counter.
uint32_t const odd_frame_now = (USB0.dsts & (1u << USB_SOFFN_S));
USB0.out_ep_reg[epnum].doepctl |= (odd_frame_now ? USB_DO_SETD0PID1 : USB_DO_SETD1PID1);
}
}
return true;
}
Expand Down
Loading