Skip to content

Commit 01b440e

Browse files
authored
Idf v5.1
1 parent e18eecd commit 01b440e

26 files changed

+377
-468
lines changed

.github/workflows/cron.yml

-39
This file was deleted.

.github/workflows/push.yml

+23-22
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
1-
name: ESP32 Arduino Libs CI
1+
name: Arduino IDF 5.x
22

33
on:
4-
push:
5-
branches:
6-
- master
7-
pull_request:
8-
9-
concurrency:
10-
group: esp-idf-libs-${{github.event.pull_request.number || github.ref}}
11-
cancel-in-progress: true
4+
workflow_dispatch: # Manually start a workflow
125

136
jobs:
147
build-libs:
15-
name: Build Libs for ${{ matrix.target }}
16-
runs-on: ubuntu-latest
17-
strategy:
18-
matrix:
19-
target: [esp32, esp32s2, esp32s3, esp32c3]
20-
fail-fast: false
8+
name: Build Arduino Libs
9+
runs-on: ubuntu-22.04
2110
steps:
22-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v3
12+
- name: Set up Python
13+
uses: actions/setup-python@v4
14+
with:
15+
python-version: '3.7'
2316
- name: Install dependencies
2417
run: bash ./tools/prepare-ci.sh
25-
- name: Build Libs for ${{ matrix.target }}
26-
run: bash ./build.sh -t ${{ matrix.target }}
27-
- name: Upload archive
28-
uses: actions/upload-artifact@v1
18+
- name: Build Arduino Libs
19+
run: bash ./build.sh
20+
- name: Display files
21+
run: ls -R ./*
22+
- name: Release
23+
uses: jason2866/[email protected]
2924
with:
30-
name: artifacts-${{ matrix.target }}
31-
path: dist
25+
tag_name: ${{ github.run_number }}
26+
body_path: release-info.txt
27+
prerelease: true
28+
files: |
29+
dist/framework*
30+
release-info.txt
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/repository_dispatch.yml

-23
This file was deleted.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ sdkconfig
1818
sdkconfig.old
1919
version.txt
2020
dependencies.lock
21+
managed_components/

CMakeLists.txt

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

5-
set(EXTRA_COMPONENT_DIRS ${CMAKE_SOURCE_DIR}/components/esp-rainmaker/components ${CMAKE_SOURCE_DIR}/components/esp-insights/components)
6-
75
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
86
project(arduino-lib-builder)
97

build.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ COPY_OUT=0
1717
DEPLOY_OUT=0
1818

1919
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 ...]"
20+
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 ...]"
2121
echo " -s Skip installing/updating of ESP-IDF and all components"
2222
echo " -A Set which branch of arduino-esp32 to be used for compilation"
2323
echo " -I Set which branch of ESP-IDF to be used for compilation"
@@ -58,6 +58,7 @@ while getopts ":A:I:i:c:t:b:sd" opt; do
5858
b=$OPTARG
5959
if [ "$b" != "build" ] &&
6060
[ "$b" != "menuconfig" ] &&
61+
[ "$b" != "reconfigure" ] &&
6162
[ "$b" != "idf_libs" ] &&
6263
[ "$b" != "copy_bootloader" ] &&
6364
[ "$b" != "mem_variant" ]; then
@@ -121,6 +122,9 @@ if [ "$BUILD_TYPE" != "all" ]; then
121122
fi
122123

123124
rm -rf build sdkconfig out
125+
echo "* Reconfigure Project"
126+
idf.py reconfigure
127+
rm -rf build sdkconfig
124128

125129
# Add components version info
126130
mkdir -p "$AR_TOOLS/sdk" && rm -rf version.txt && rm -rf "$AR_TOOLS/sdk/versions.txt"
+39-31
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,22 @@
1-
idf_component_register(REQUIRES esp_rom freertos soc PRIV_REQUIRES arduino main)
2-
31
if(CONFIG_TINYUSB_ENABLED)
42

53
### variables ###
64
#################
7-
# if(IDF_TARGET STREQUAL "esp32s2")
5+
6+
if(IDF_TARGET STREQUAL "esp32s2")
87
set(compile_options
98
"-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
109
"-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}"
1110
"-Wno-type-limits" # needed for the vanila tinyusb with turned off classes
1211
)
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()
20-
idf_component_get_property(FREERTOS_ORIG_INCLUDE_PATH freertos
21-
ORIG_INCLUDE_PATH)
22-
set(includes_private
23-
# tusb:
24-
"${COMPONENT_DIR}/tinyusb/hw/bsp/"
25-
"${COMPONENT_DIR}/tinyusb/src/"
26-
"${COMPONENT_DIR}/tinyusb/src/device"
27-
)
12+
elseif(IDF_TARGET STREQUAL "esp32s3")
13+
set(compile_options
14+
"-DCFG_TUSB_MCU=OPT_MCU_ESP32S3"
15+
"-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}"
16+
"-Wno-type-limits" # needed for the vanila tinyusb with turned off classes
17+
)
18+
endif()
2819

29-
set(includes_public
30-
# tusb:
31-
"${FREERTOS_ORIG_INCLUDE_PATH}"
32-
"${COMPONENT_DIR}/tinyusb/src/"
33-
# espressif:
34-
"${COMPONENT_DIR}/include")
3520
set(srcs
3621
# espressif:
3722
"${COMPONENT_DIR}/src/dcd_esp32sx.c"
@@ -49,14 +34,37 @@ if(CONFIG_TINYUSB_ENABLED)
4934
"${COMPONENT_DIR}/tinyusb/src/device/usbd.c"
5035
"${COMPONENT_DIR}/tinyusb/src/tusb.c")
5136

37+
set(includes_private
38+
# tusb:
39+
"${COMPONENT_DIR}/tinyusb/hw/bsp/"
40+
"${COMPONENT_DIR}/tinyusb/src/"
41+
"${COMPONENT_DIR}/tinyusb/src/device"
42+
)
43+
44+
idf_component_get_property(FREERTOS_ORIG_INCLUDE_PATH freertos
45+
ORIG_INCLUDE_PATH)
46+
set(includes_public
47+
# tusb:
48+
"${FREERTOS_ORIG_INCLUDE_PATH}"
49+
"${COMPONENT_DIR}/tinyusb/src/"
50+
# espressif:
51+
"${COMPONENT_DIR}/include")
52+
53+
set(requires esp_rom freertos soc)
54+
set(priv_requires arduino main)
5255
### tinyusb lib ###
5356
###################
54-
add_library(arduino_tinyusb STATIC ${srcs})
55-
target_include_directories(
56-
arduino_tinyusb
57-
PUBLIC ${includes_public}
58-
PRIVATE ${includes_private})
59-
target_compile_options(arduino_tinyusb PRIVATE ${compile_options})
60-
target_link_libraries(${COMPONENT_TARGET} INTERFACE arduino_tinyusb)
57+
idf_component_register(INCLUDE_DIRS ${includes_public} PRIV_INCLUDE_DIRS ${includes_private} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires})
58+
# add_library(${COMPONENT_TARGET} STATIC ${srcs})
59+
# target_include_directories(
60+
# ${COMPONENT_TARGET}
61+
# PUBLIC ${includes_public}
62+
# PRIVATE ${includes_private})
63+
target_compile_options(${COMPONENT_TARGET} PRIVATE ${compile_options})
64+
#target_link_libraries(${COMPONENT_TARGET} INTERFACE ${COMPONENT_TARGET})
65+
66+
else()
67+
68+
idf_component_register()
6169

6270
endif()

components/arduino_tinyusb/src/dcd_esp32sx.c

+26-3
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,16 @@
2828

2929
#include "tusb_option.h"
3030

31-
#if (((CFG_TUSB_MCU == OPT_MCU_ESP32S2) || (CFG_TUSB_MCU == OPT_MCU_ESP32S3)) && TUSB_OPT_DEVICE_ENABLED)
31+
#if (((CFG_TUSB_MCU == OPT_MCU_ESP32S2) || (CFG_TUSB_MCU == OPT_MCU_ESP32S3)) && CFG_TUD_ENABLED)
3232

3333
// Espressif
34-
#include "driver/periph_ctrl.h"
3534
#include "freertos/xtensa_api.h"
3635
#include "esp_intr_alloc.h"
3736
#include "esp_log.h"
38-
#include "driver/gpio.h"
3937
#include "soc/dport_reg.h"
4038
#include "soc/gpio_sig_map.h"
4139
#include "soc/usb_periph.h"
40+
#include "soc/periph_defs.h" // for interrupt source
4241

4342
#include "device/dcd.h"
4443

@@ -60,6 +59,7 @@ typedef struct {
6059
uint16_t queued_len;
6160
uint16_t max_size;
6261
bool short_packet;
62+
uint8_t interval;
6363
} xfer_ctl_t;
6464

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

287+
void dcd_sof_enable(uint8_t rhport, bool en)
288+
{
289+
(void) rhport;
290+
(void) en;
291+
292+
// TODO implement later
293+
}
294+
287295
/*------------------------------------------------------------------*/
288296
/* DCD Endpoint port
289297
*------------------------------------------------------------------*/
@@ -303,6 +311,7 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const *desc_edpt)
303311

304312
xfer_ctl_t *xfer = XFER_CTL_BASE(epnum, dir);
305313
xfer->max_size = tu_edpt_packet_size(desc_edpt);
314+
xfer->interval = desc_edpt->bInterval;
306315

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

435+
// For ISO endpoint with interval=1 set correct DATA0/DATA1 bit for next frame
436+
if ((USB0.in_ep_reg[epnum].diepctl & USB_D_EPTYPE0_M) == (1 << USB_D_EPTYPE1_S) && xfer->interval == 1) {
437+
// Take odd/even bit from frame counter.
438+
uint32_t const odd_frame_now = (USB0.dsts & (1u << USB_SOFFN_S));
439+
USB0.in_ep_reg[epnum].diepctl |= (odd_frame_now ? USB_DI_SETD0PID1 : USB_DI_SETD1PID1);
440+
}
441+
426442
// Enable fifo empty interrupt only if there are something to put in the fifo.
427443
if(total_bytes != 0) {
428444
USB0.dtknqr4_fifoemptymsk |= (1 << epnum);
@@ -431,6 +447,13 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t to
431447
// Each complete packet for OUT xfers triggers XFRC.
432448
USB0.out_ep_reg[epnum].doeptsiz |= USB_PKTCNT0_M | ((xfer->max_size & USB_XFERSIZE0_V) << USB_XFERSIZE0_S);
433449
USB0.out_ep_reg[epnum].doepctl |= USB_EPENA0_M | USB_CNAK0_M;
450+
451+
// For ISO endpoint with interval=1 set correct DATA0/DATA1 bit for next frame
452+
if ((USB0.out_ep_reg[epnum].doepctl & USB_D_EPTYPE0_M) == (1 << USB_D_EPTYPE1_S) && xfer->interval == 1) {
453+
// Take odd/even bit from frame counter.
454+
uint32_t const odd_frame_now = (USB0.dsts & (1u << USB_SOFFN_S));
455+
USB0.out_ep_reg[epnum].doepctl |= (odd_frame_now ? USB_DO_SETD0PID1 : USB_DO_SETD1PID1);
456+
}
434457
}
435458
return true;
436459
}

0 commit comments

Comments
 (0)