Skip to content

Commit b25728f

Browse files
authored
Merge branch 'espressif:release/v2.x' into release/v2.x
2 parents 6a8b1c5 + 9b4622d commit b25728f

File tree

40 files changed

+2838
-1261
lines changed

40 files changed

+2838
-1261
lines changed

.github/scripts/on-release.sh

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ echo "Event: $GITHUB_EVENT_NAME, Repo: $GITHUB_REPOSITORY, Path: $GITHUB_WORKSPA
3636
echo "Action: $action, Branch: $RELEASE_BRANCH, ID: $RELEASE_ID"
3737
echo "Tag: $RELEASE_TAG, Draft: $draft, Pre-Release: $RELEASE_PRE"
3838

39+
# Try extracting something like a JSON with a "boards" array/element and "vendor" fields
40+
BOARDS=`echo $RELEASE_BODY | grep -Pzo '(?s){.*}' | jq -r '.boards[]? // .boards? // empty' | xargs echo -n 2>/dev/null`
41+
VENDOR=`echo $RELEASE_BODY | grep -Pzo '(?s){.*}' | jq -r '.vendor? // empty' | xargs echo -n 2>/dev/null`
42+
if ! [ -z "${BOARDS}" ]; then echo "Releasing board(s): $BOARDS" ; fi
43+
if ! [ -z "${VENDOR}" ]; then echo "Setting packager: $VENDOR" ; fi
44+
3945
function get_file_size(){
4046
local file="$1"
4147
if [[ "$OSTYPE" == "darwin"* ]]; then
@@ -171,12 +177,26 @@ mkdir -p "$PKG_DIR/tools"
171177

172178
# Copy all core files to the package folder
173179
echo "Copying files for packaging ..."
174-
cp -f "$GITHUB_WORKSPACE/boards.txt" "$PKG_DIR/"
180+
if [ -z "${BOARDS}" ]; then
181+
# Copy all variants
182+
cp -f "$GITHUB_WORKSPACE/boards.txt" "$PKG_DIR/"
183+
cp -Rf "$GITHUB_WORKSPACE/variants" "$PKG_DIR/"
184+
else
185+
# Remove all entries not starting with any board code or "menu." from boards.txt
186+
cat "$GITHUB_WORKSPACE/boards.txt" | grep "^menu\." > "$PKG_DIR/boards.txt"
187+
for board in ${BOARDS} ; do
188+
cat "$GITHUB_WORKSPACE/boards.txt" | grep "^${board}\." >> "$PKG_DIR/boards.txt"
189+
done
190+
# Copy only relevant variant files
191+
mkdir "$PKG_DIR/variants/"
192+
for variant in `cat ${PKG_DIR}/boards.txt | grep "\.variant=" | cut -d= -f2` ; do
193+
cp -Rf "$GITHUB_WORKSPACE/variants/${variant}" "$PKG_DIR/variants/"
194+
done
195+
fi
175196
cp -f "$GITHUB_WORKSPACE/package.json" "$PKG_DIR/"
176197
cp -f "$GITHUB_WORKSPACE/programmers.txt" "$PKG_DIR/"
177198
cp -Rf "$GITHUB_WORKSPACE/cores" "$PKG_DIR/"
178199
cp -Rf "$GITHUB_WORKSPACE/libraries" "$PKG_DIR/"
179-
cp -Rf "$GITHUB_WORKSPACE/variants" "$PKG_DIR/"
180200
cp -f "$GITHUB_WORKSPACE/tools/espota.exe" "$PKG_DIR/tools/"
181201
cp -f "$GITHUB_WORKSPACE/tools/espota.py" "$PKG_DIR/tools/"
182202
cp -f "$GITHUB_WORKSPACE/tools/gen_esp32part.py" "$PKG_DIR/tools/"
@@ -209,6 +229,11 @@ sed 's/debug.server.openocd.scripts_dir={runtime.platform.path}\/tools\/openocd-
209229
sed 's/debug.server.openocd.scripts_dir.windows={runtime.platform.path}\\tools\\openocd-esp32\\share\\openocd\\scripts\\/debug.server.openocd.scripts_dir.windows=\{runtime.tools.openocd-esp32.path\}\\share\\openocd\\scripts\\/g' \
210230
> "$PKG_DIR/platform.txt"
211231

232+
if ! [ -z ${VENDOR} ]; then
233+
# Append vendor name to platform.txt to create a separate section
234+
sed -i "/^name=.*/s/$/ ($VENDOR)/" "$PKG_DIR/platform.txt"
235+
fi
236+
212237
# Add header with version information
213238
echo "Generating core_version.h ..."
214239
ver_define=`echo $RELEASE_TAG | tr "[:lower:].\055" "[:upper:]_"`

boards.txt

Lines changed: 1473 additions & 1145 deletions
Large diffs are not rendered by default.

cores/esp32/Arduino.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@
110110
#define analogInPinToBit(P) (P)
111111
#if SOC_GPIO_PIN_COUNT <= 32
112112
#define digitalPinToPort(pin) (0)
113-
#define digitalPinToBitMask(pin) (1UL << (pin))
113+
#define digitalPinToBitMask(pin) (1UL << digitalPinToGPIONumber(pin))
114114
#define portOutputRegister(port) ((volatile uint32_t*)GPIO_OUT_REG)
115115
#define portInputRegister(port) ((volatile uint32_t*)GPIO_IN_REG)
116116
#define portModeRegister(port) ((volatile uint32_t*)GPIO_ENABLE_REG)
117117
#elif SOC_GPIO_PIN_COUNT <= 64
118-
#define digitalPinToPort(pin) (((pin)>31)?1:0)
119-
#define digitalPinToBitMask(pin) (1UL << (((pin)>31)?((pin)-32):(pin)))
118+
#define digitalPinToPort(pin) ((digitalPinToGPIONumber(pin)>31)?1:0)
119+
#define digitalPinToBitMask(pin) (1UL << (digitalPinToGPIONumber(pin)&31))
120120
#define portOutputRegister(port) ((volatile uint32_t*)((port)?GPIO_OUT1_REG:GPIO_OUT_REG))
121121
#define portInputRegister(port) ((volatile uint32_t*)((port)?GPIO_IN1_REG:GPIO_IN_REG))
122122
#define portModeRegister(port) ((volatile uint32_t*)((port)?GPIO_ENABLE1_REG:GPIO_ENABLE_REG))
@@ -220,5 +220,6 @@ void noTone(uint8_t _pin);
220220
#endif /* __cplusplus */
221221

222222
#include "pins_arduino.h"
223+
#include "io_pin_remap.h"
223224

224225
#endif /* _ESP32_CORE_ARDUINO_H_ */

cores/esp32/FunctionalInterrupt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void ARDUINO_ISR_ATTR interruptFunctional(void* arg)
2828
void attachInterrupt(uint8_t pin, std::function<void(void)> intRoutine, int mode)
2929
{
3030
// use the local interrupt routine which takes the ArgStructure as argument
31-
__attachInterruptFunctionalArg (pin, (voidFuncPtrArg)interruptFunctional, new InterruptArgStructure{intRoutine}, mode, true);
31+
__attachInterruptFunctionalArg (digitalPinToGPIONumber(pin), (voidFuncPtrArg)interruptFunctional, new InterruptArgStructure{intRoutine}, mode, true);
3232
}
3333

3434
extern "C"

cores/esp32/HardwareSerial.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <inttypes.h>
55

66
#include "pins_arduino.h"
7+
#include "io_pin_remap.h"
78
#include "HardwareSerial.h"
89
#include "soc/soc_caps.h"
910
#include "driver/uart.h"
@@ -370,6 +371,10 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
370371
}
371372
}
372373

374+
// map logical pins to GPIO numbers
375+
rxPin = digitalPinToGPIONumber(rxPin);
376+
txPin = digitalPinToGPIONumber(txPin);
377+
373378
if(_uart) {
374379
// in this case it is a begin() over a previous begin() - maybe to change baud rate
375380
// thus do not disable debug output
@@ -554,6 +559,12 @@ bool HardwareSerial::setPins(int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t r
554559
return false;
555560
}
556561

562+
// map logical pins to GPIO numbers
563+
rxPin = digitalPinToGPIONumber(rxPin);
564+
txPin = digitalPinToGPIONumber(txPin);
565+
ctsPin = digitalPinToGPIONumber(ctsPin);
566+
rtsPin = digitalPinToGPIONumber(rtsPin);
567+
557568
// uartSetPins() checks if pins are valid for each function and for the SoC
558569
bool retCode = uartSetPins(_uart, rxPin, txPin, ctsPin, rtsPin);
559570
if (retCode) {

cores/esp32/USB.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@
4747
#define USB_WEBUSB_URL "https://espressif.github.io/arduino-esp32/webusb.html"
4848
#endif
4949

50+
#if CFG_TUD_DFU
51+
__attribute__((weak, unused)) uint16_t load_dfu_ota_descriptor(uint8_t * dst, uint8_t * itf) {
52+
return 0;
53+
}
54+
#endif /* CFG_TUD_DFU */
55+
5056
#if CFG_TUD_DFU_RUNTIME
51-
static uint16_t load_dfu_descriptor(uint8_t * dst, uint8_t * itf)
57+
__attribute__((unused)) static uint16_t load_dfu_descriptor(uint8_t * dst, uint8_t * itf)
5258
{
5359
#define DFU_ATTRS (DFU_ATTR_CAN_DOWNLOAD | DFU_ATTR_CAN_UPLOAD | DFU_ATTR_MANIFESTATION_TOLERANT)
5460

@@ -185,7 +191,7 @@ bool ESPUSB::begin(){
185191
.webusb_enabled = webusb_enabled,
186192
.webusb_url = webusb_url.c_str()
187193
};
188-
_started = tinyusb_init(&tinyusb_device_config) == ESP_OK;
194+
_started = tinyusb_init(&tinyusb_device_config) == ESP_OK;
189195
}
190196
return _started;
191197
}
@@ -203,7 +209,9 @@ ESPUSB::operator bool() const
203209
}
204210

205211
bool ESPUSB::enableDFU(){
206-
#if CFG_TUD_DFU_RUNTIME
212+
#if CFG_TUD_DFU
213+
return tinyusb_enable_interface(USB_INTERFACE_DFU, TUD_DFU_DESC_LEN(1), load_dfu_ota_descriptor) == ESP_OK;
214+
#elif CFG_TUD_DFU_RUNTIME
207215
return tinyusb_enable_interface(USB_INTERFACE_DFU, TUD_DFU_RT_DESC_LEN, load_dfu_descriptor) == ESP_OK;
208216
#endif /* CFG_TUD_DFU_RUNTIME */
209217
return false;

cores/esp32/esp32-hal-matrix.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
#include "esp_system.h"
1919
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
20+
#include "soc/gpio_pins.h"
2021
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
21-
#include "esp32/rom/gpio.h"
2222
#elif CONFIG_IDF_TARGET_ESP32S2
2323
#include "esp32s2/rom/gpio.h"
2424
#elif CONFIG_IDF_TARGET_ESP32S3
@@ -30,11 +30,10 @@
3030
#endif
3131
#else // ESP32 Before IDF 4.0
3232
#include "rom/gpio.h"
33+
#define GPIO_MATRIX_CONST_ZERO_INPUT GPIO_FUNC_IN_LOW
34+
#define GPIO_MATRIX_CONST_ONE_INPUT GPIO_FUNC_IN_HIGH
3335
#endif
3436

35-
#define MATRIX_DETACH_OUT_SIG 0x100
36-
#define MATRIX_DETACH_IN_LOW_PIN 0x30
37-
#define MATRIX_DETACH_IN_LOW_HIGH 0x38
3837

3938
void ARDUINO_ISR_ATTR pinMatrixOutAttach(uint8_t pin, uint8_t function, bool invertOut, bool invertEnable)
4039
{
@@ -43,7 +42,7 @@ void ARDUINO_ISR_ATTR pinMatrixOutAttach(uint8_t pin, uint8_t function, bool inv
4342

4443
void ARDUINO_ISR_ATTR pinMatrixOutDetach(uint8_t pin, bool invertOut, bool invertEnable)
4544
{
46-
gpio_matrix_out(pin, MATRIX_DETACH_OUT_SIG, invertOut, invertEnable);
45+
gpio_matrix_out(pin, SIG_GPIO_OUT_IDX, invertOut, invertEnable);
4746
}
4847

4948
void ARDUINO_ISR_ATTR pinMatrixInAttach(uint8_t pin, uint8_t signal, bool inverted)
@@ -53,7 +52,7 @@ void ARDUINO_ISR_ATTR pinMatrixInAttach(uint8_t pin, uint8_t signal, bool invert
5352

5453
void ARDUINO_ISR_ATTR pinMatrixInDetach(uint8_t signal, bool high, bool inverted)
5554
{
56-
gpio_matrix_in(high?MATRIX_DETACH_IN_LOW_HIGH:MATRIX_DETACH_IN_LOW_PIN, signal, inverted);
55+
gpio_matrix_in(high?GPIO_MATRIX_CONST_ONE_INPUT:GPIO_MATRIX_CONST_ZERO_INPUT, signal, inverted);
5756
}
5857
/*
5958
void ARDUINO_ISR_ATTR intrMatrixAttach(uint32_t source, uint32_t inum){

cores/esp32/io_pin_remap.h

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#ifndef __IO_PIN_REMAP_H__
2+
#define __IO_PIN_REMAP_H__
3+
4+
#include "Arduino.h"
5+
6+
#if defined(BOARD_HAS_PIN_REMAP) && !defined(BOARD_USES_HW_GPIO_NUMBERS)
7+
8+
// Pin remapping functions
9+
int8_t digitalPinToGPIONumber(int8_t digitalPin);
10+
int8_t digitalPinFromGPIONumber(int8_t gpioPin);
11+
12+
// Apply pin remapping to API only when building libraries and user sketch
13+
#ifndef ARDUINO_CORE_BUILD
14+
15+
// Override APIs requiring pin remapping
16+
17+
// cores/esp32/Arduino.h
18+
#define pulseInLong(pin, state, timeout) pulseInLong(digitalPinToGPIONumber(pin), state, timeout)
19+
#define pulseIn(pin, state, timeout) pulseIn(digitalPinToGPIONumber(pin), state, timeout)
20+
#define noTone(_pin) noTone(digitalPinToGPIONumber(_pin))
21+
#define tone(_pin, frequency, duration) tone(digitalPinToGPIONumber(_pin), frequency, duration)
22+
23+
// cores/esp32/esp32-hal.h
24+
#define analogGetChannel(pin) analogGetChannel(digitalPinToGPIONumber(pin))
25+
#define analogWrite(pin, value) analogWrite(digitalPinToGPIONumber(pin), value)
26+
27+
// cores/esp32/esp32-hal-adc.h
28+
#define adcAttachPin(pin) adcAttachPin(digitalPinToGPIONumber(pin))
29+
#define analogRead(pin) analogRead(digitalPinToGPIONumber(pin))
30+
#define analogReadMilliVolts(pin) analogReadMilliVolts(digitalPinToGPIONumber(pin))
31+
#define analogSetPinAttenuation(pin, attenuation) analogSetPinAttenuation(digitalPinToGPIONumber(pin), attenuation)
32+
#define analogSetVRefPin(pin) analogSetVRefPin(digitalPinToGPIONumber(pin))
33+
34+
// cores/esp32/esp32-hal-dac.h
35+
#define dacDisable(pin) dacDisable(digitalPinToGPIONumber(pin))
36+
#define dacWrite(pin, value) dacWrite(digitalPinToGPIONumber(pin), value)
37+
38+
// cores/esp32/esp32-hal-gpio.h
39+
#define analogChannelToDigitalPin(channel) gpioNumberToDigitalPin(analogChannelToDigitalPin(channel))
40+
#define digitalPinToAnalogChannel(pin) digitalPinToAnalogChannel(digitalPinToGPIONumber(pin))
41+
#define digitalPinToTouchChannel(pin) digitalPinToTouchChannel(digitalPinToGPIONumber(pin))
42+
#define digitalRead(pin) digitalRead(digitalPinToGPIONumber(pin))
43+
#define attachInterruptArg(pin, fcn, arg, mode) attachInterruptArg(digitalPinToGPIONumber(pin), fcn, arg, mode)
44+
#define attachInterrupt(pin, fcn, mode) attachInterrupt(digitalPinToGPIONumber(pin), fcn, mode)
45+
#define detachInterrupt(pin) detachInterrupt(digitalPinToGPIONumber(pin))
46+
#define digitalWrite(pin, val) digitalWrite(digitalPinToGPIONumber(pin), val)
47+
#define pinMode(pin, mode) pinMode(digitalPinToGPIONumber(pin), mode)
48+
49+
// cores/esp32/esp32-hal-i2c.h
50+
#define i2cInit(i2c_num, sda, scl, clk_speed) i2cInit(i2c_num, digitalPinToGPIONumber(sda), digitalPinToGPIONumber(scl), clk_speed)
51+
52+
// cores/esp32/esp32-hal-i2c-slave.h
53+
#define i2cSlaveInit(num, sda, scl, slaveID, frequency, rx_len, tx_len) i2cSlaveInit(num, digitalPinToGPIONumber(sda), digitalPinToGPIONumber(scl), slaveID, frequency, rx_len, tx_len)
54+
55+
// cores/esp32/esp32-hal-ledc.h
56+
#define ledcAttachPin(pin, channel) ledcAttachPin(digitalPinToGPIONumber(pin), channel)
57+
#define ledcDetachPin(pin) ledcDetachPin(digitalPinToGPIONumber(pin))
58+
59+
// cores/esp32/esp32-hal-matrix.h
60+
#define pinMatrixInAttach(pin, signal, inverted) pinMatrixInAttach(digitalPinToGPIONumber(pin), signal, inverted)
61+
#define pinMatrixOutAttach(pin, function, invertOut, invertEnable) pinMatrixOutAttach(digitalPinToGPIONumber(pin), function, invertOut, invertEnable)
62+
#define pinMatrixOutDetach(pin, invertOut, invertEnable) pinMatrixOutDetach(digitalPinToGPIONumber(pin), invertOut, invertEnable)
63+
64+
// cores/esp32/esp32-hal-rgb-led.h
65+
#define neopixelWrite(pin, red_val, green_val, blue_val) neopixelWrite(digitalPinToGPIONumber(pin), red_val, green_val, blue_val)
66+
67+
// cores/esp32/esp32-hal-rmt.h
68+
#define rmtInit(pin, tx_not_rx, memsize) rmtInit(digitalPinToGPIONumber(pin), tx_not_rx, memsize)
69+
70+
// cores/esp32/esp32-hal-sigmadelta.h
71+
#define sigmaDeltaSetup(pin, channel, freq) sigmaDeltaSetup(digitalPinToGPIONumber(pin), channel, freq)
72+
#define sigmaDeltaDetachPin(pin) sigmaDeltaDetachPin(digitalPinToGPIONumber(pin))
73+
74+
// cores/esp32/esp32-hal-spi.h
75+
#define spiAttachSCK(spi, sck) spiAttachSCK(spi, digitalPinToGPIONumber(sck))
76+
#define spiAttachMISO(spi, miso) spiAttachMISO(spi, digitalPinToGPIONumber(miso))
77+
#define spiAttachMOSI(spi, mosi) spiAttachMOSI(spi, digitalPinToGPIONumber(mosi))
78+
#define spiDetachSCK(spi, sck) spiDetachSCK(spi, digitalPinToGPIONumber(sck))
79+
#define spiDetachMISO(spi, miso) spiDetachMISO(spi, digitalPinToGPIONumber(miso))
80+
#define spiDetachMOSI(spi, mosi) spiDetachMOSI(spi, digitalPinToGPIONumber(mosi))
81+
#define spiAttachSS(spi, cs_num, ss) spiAttachSS(spi, cs_num, digitalPinToGPIONumber(ss))
82+
#define spiDetachSS(spi, ss) spiDetachSS(spi, digitalPinToGPIONumber(ss))
83+
84+
// cores/esp32/esp32-hal-touch.h
85+
#define touchInterruptGetLastStatus(pin) touchInterruptGetLastStatus(digitalPinToGPIONumber(pin))
86+
#define touchRead(pin) touchRead(digitalPinToGPIONumber(pin))
87+
#define touchAttachInterruptArg(pin, userFunc, arg, threshold) touchAttachInterruptArg(digitalPinToGPIONumber(pin), userFunc, arg, threshold)
88+
#define touchAttachInterrupt(pin, userFunc, threshold) touchAttachInterrupt(digitalPinToGPIONumber(pin), userFunc, threshold)
89+
#define touchDetachInterrupt(pin) touchDetachInterrupt(digitalPinToGPIONumber(pin))
90+
#define touchSleepWakeUpEnable(pin, threshold) touchSleepWakeUpEnable(digitalPinToGPIONumber(pin), threshold)
91+
92+
// cores/esp32/esp32-hal-uart.h
93+
#define uartBegin(uart_nr, baudrate, config, rxPin, txPin, rx_buffer_size, tx_buffer_size, inverted, rxfifo_full_thrhd) \
94+
uartBegin(uart_nr, baudrate, config, digitalPinToGPIONumber(rxPin), digitalPinToGPIONumber(txPin), rx_buffer_size, tx_buffer_size, inverted, rxfifo_full_thrhd)
95+
#define uartSetPins(uart, rxPin, txPin, ctsPin, rtsPin) \
96+
uartSetPins(uart, digitalPinToGPIONumber(rxPin), digitalPinToGPIONumber(txPin), digitalPinToGPIONumber(ctsPin), digitalPinToGPIONumber(rtsPin))
97+
#define uartDetachPins(uart, rxPin, txPin, ctsPin, rtsPin) \
98+
uartDetachPins(uart, digitalPinToGPIONumber(rxPin), digitalPinToGPIONumber(txPin), digitalPinToGPIONumber(ctsPin), digitalPinToGPIONumber(rtsPin))
99+
100+
#endif // ARDUINO_CORE_BUILD
101+
102+
#else
103+
104+
// pin remapping disabled: use stubs
105+
#define digitalPinToGPIONumber(digitalPin) (digitalPin)
106+
#define gpioNumberToDigitalPin(gpioNumber) (gpioNumber)
107+
108+
#endif
109+
110+
#endif /* __GPIO_PIN_REMAP_H__ */

docs/source/api/gpio.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The GPIO peripheral on the ESP32 supports interruptions.
8787
attachInterrupt
8888
***************
8989

90-
The function ``attachInterruptArg`` is used to attach the interrupt to the defined pin.
90+
The function ``attachInterrupt`` is used to attach the interrupt to the defined pin.
9191

9292
.. code-block:: arduino
9393

docs/source/api/wifi.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,15 @@ Get the softAP subnet CIDR.
222222
223223
uint8_t softAPSubnetCIDR();
224224
225+
softAPSubnetMask
226+
****************
227+
228+
Get the softAP subnet mask.
229+
230+
.. code-block:: arduino
231+
232+
IPAddress softAPSubnetMask();
233+
225234
softAPenableIpV6
226235
****************
227236

0 commit comments

Comments
 (0)