Skip to content

Commit

Permalink
Add Arduino Nano ESP32 target (espressif#8417)
Browse files Browse the repository at this point in the history
* USB: enable DFU interface and stub

* nano_nora: add Arduino Nano ESP32 board support

* [pin_remap 1/3] platform: define ARDUINO_CORE_BUILD when building core files

* [pin_remap 2/3] core,libs: add pin remap hooks

* [pin_remap 3/3] nano_nora: implement and enable pin remap

* nano_nora: fix: reset all matrix connections at boot

* nano_nora: add recovery image for release/v2.x

* nano_nora: use official Arduino branding

* nano_nora: core split + recovery mode rework

Use an absolute address in SPIRAM to store the magic tokens, almost at the
end of the memory, to avoid the markers from being overwritten on any kind
of sketch and core combination.

Also, only start the recovery once if a valid binary is present in the
Flash, by immediately setting that for the next boot when recovery
starts.

* platform: fix: use {compiler.sdk.path} for sdk path

In preparation for the sdk -> tool transition

* package_index: remove dfu-util from template

The tool is already available in mainline package_index.json

* on_release: allow single board packages

---------

Co-authored-by: Luca Burelli <l.burelli@arduino.cc>
  • Loading branch information
facchinm and pillo79 authored Jul 17, 2023
1 parent 1577701 commit 9b4622d
Show file tree
Hide file tree
Showing 22 changed files with 886 additions and 21 deletions.
29 changes: 27 additions & 2 deletions .github/scripts/on-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ echo "Event: $GITHUB_EVENT_NAME, Repo: $GITHUB_REPOSITORY, Path: $GITHUB_WORKSPA
echo "Action: $action, Branch: $RELEASE_BRANCH, ID: $RELEASE_ID"
echo "Tag: $RELEASE_TAG, Draft: $draft, Pre-Release: $RELEASE_PRE"

# Try extracting something like a JSON with a "boards" array/element and "vendor" fields
BOARDS=`echo $RELEASE_BODY | grep -Pzo '(?s){.*}' | jq -r '.boards[]? // .boards? // empty' | xargs echo -n 2>/dev/null`
VENDOR=`echo $RELEASE_BODY | grep -Pzo '(?s){.*}' | jq -r '.vendor? // empty' | xargs echo -n 2>/dev/null`
if ! [ -z "${BOARDS}" ]; then echo "Releasing board(s): $BOARDS" ; fi
if ! [ -z "${VENDOR}" ]; then echo "Setting packager: $VENDOR" ; fi

function get_file_size(){
local file="$1"
if [[ "$OSTYPE" == "darwin"* ]]; then
Expand Down Expand Up @@ -171,12 +177,26 @@ mkdir -p "$PKG_DIR/tools"

# Copy all core files to the package folder
echo "Copying files for packaging ..."
cp -f "$GITHUB_WORKSPACE/boards.txt" "$PKG_DIR/"
if [ -z "${BOARDS}" ]; then
# Copy all variants
cp -f "$GITHUB_WORKSPACE/boards.txt" "$PKG_DIR/"
cp -Rf "$GITHUB_WORKSPACE/variants" "$PKG_DIR/"
else
# Remove all entries not starting with any board code or "menu." from boards.txt
cat "$GITHUB_WORKSPACE/boards.txt" | grep "^menu\." > "$PKG_DIR/boards.txt"
for board in ${BOARDS} ; do
cat "$GITHUB_WORKSPACE/boards.txt" | grep "^${board}\." >> "$PKG_DIR/boards.txt"
done
# Copy only relevant variant files
mkdir "$PKG_DIR/variants/"
for variant in `cat ${PKG_DIR}/boards.txt | grep "\.variant=" | cut -d= -f2` ; do
cp -Rf "$GITHUB_WORKSPACE/variants/${variant}" "$PKG_DIR/variants/"
done
fi
cp -f "$GITHUB_WORKSPACE/package.json" "$PKG_DIR/"
cp -f "$GITHUB_WORKSPACE/programmers.txt" "$PKG_DIR/"
cp -Rf "$GITHUB_WORKSPACE/cores" "$PKG_DIR/"
cp -Rf "$GITHUB_WORKSPACE/libraries" "$PKG_DIR/"
cp -Rf "$GITHUB_WORKSPACE/variants" "$PKG_DIR/"
cp -f "$GITHUB_WORKSPACE/tools/espota.exe" "$PKG_DIR/tools/"
cp -f "$GITHUB_WORKSPACE/tools/espota.py" "$PKG_DIR/tools/"
cp -f "$GITHUB_WORKSPACE/tools/gen_esp32part.py" "$PKG_DIR/tools/"
Expand Down Expand Up @@ -209,6 +229,11 @@ sed 's/debug.server.openocd.scripts_dir={runtime.platform.path}\/tools\/openocd-
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' \
> "$PKG_DIR/platform.txt"

if ! [ -z ${VENDOR} ]; then
# Append vendor name to platform.txt to create a separate section
sed -i "/^name=.*/s/$/ ($VENDOR)/" "$PKG_DIR/platform.txt"
fi

# Add header with version information
echo "Generating core_version.h ..."
ver_define=`echo $RELEASE_TAG | tr "[:lower:].\055" "[:upper:]_"`
Expand Down
51 changes: 51 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24112,3 +24112,54 @@ nebulas3.menu.EraseFlash.all=Enabled
nebulas3.menu.EraseFlash.all.upload.erase_cmd=-e

##############################################################

nano_nora.name=Arduino Nano ESP32
nano_nora.vid.0=0x2341
nano_nora.pid.0=0x0070
nano_nora.upload_port.0.vid=0x2341
nano_nora.upload_port.0.pid=0x0070

nano_nora.bootloader.tool=esptool_py
nano_nora.bootloader.tool.default=esptool_py

nano_nora.upload.tool=dfu-util
nano_nora.upload.tool.default=dfu-util
nano_nora.upload.tool.network=esp_ota
nano_nora.upload.protocol=serial
nano_nora.upload.maximum_size=3145728
nano_nora.upload.maximum_data_size=327680
nano_nora.upload.use_1200bps_touch=false
nano_nora.upload.wait_for_upload_port=false

nano_nora.serial.disableDTR=false
nano_nora.serial.disableRTS=false

nano_nora.build.tarch=xtensa
nano_nora.build.bootloader_addr=0x0
nano_nora.build.target=esp32s3
nano_nora.build.mcu=esp32s3
nano_nora.build.core=esp32
nano_nora.build.variant=arduino_nano_nora
nano_nora.build.board=NANO_ESP32
nano_nora.build.code_debug=0

nano_nora.build.usb_mode=0
nano_nora.build.cdc_on_boot=1
nano_nora.build.msc_on_boot=0
nano_nora.build.dfu_on_boot=1
nano_nora.build.f_cpu=240000000L
nano_nora.build.flash_size=16MB
nano_nora.build.flash_freq=80m
nano_nora.build.flash_mode=dio
nano_nora.build.boot=qio
nano_nora.build.boot_freq=80m
nano_nora.build.partitions=app3M_fat9M_fact512k_16MB
nano_nora.build.defines=-DBOARD_HAS_PIN_REMAP -DBOARD_HAS_PSRAM '-DUSB_MANUFACTURER="Arduino"' '-DUSB_PRODUCT="Nano ESP32"'
nano_nora.build.loop_core=-DARDUINO_RUNNING_CORE=1
nano_nora.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1
nano_nora.build.psram_type=opi
nano_nora.build.memory_type={build.boot}_{build.psram_type}

nano_nora.tools.esptool_py.program.pattern_args=--chip {build.mcu} --port "{serial.port}" --before default_reset --after hard_reset write_flash -z --flash_mode {build.flash_mode} --flash_freq {build.flash_freq} --flash_size {build.flash_size} {build.bootloader_addr} "{build.path}/{build.project_name}.bootloader.bin" 0x8000 "{build.path}/{build.project_name}.partitions.bin" 0xe000 "{runtime.platform.path}/tools/partitions/boot_app0.bin" 0xf70000 "{build.variant.path}/extra/nora_recovery/nora_recovery.ino.bin" 0x10000 "{build.path}/{build.project_name}.bin"

##############################################################
7 changes: 4 additions & 3 deletions cores/esp32/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@
#define analogInPinToBit(P) (P)
#if SOC_GPIO_PIN_COUNT <= 32
#define digitalPinToPort(pin) (0)
#define digitalPinToBitMask(pin) (1UL << (pin))
#define digitalPinToBitMask(pin) (1UL << digitalPinToGPIONumber(pin))
#define portOutputRegister(port) ((volatile uint32_t*)GPIO_OUT_REG)
#define portInputRegister(port) ((volatile uint32_t*)GPIO_IN_REG)
#define portModeRegister(port) ((volatile uint32_t*)GPIO_ENABLE_REG)
#elif SOC_GPIO_PIN_COUNT <= 64
#define digitalPinToPort(pin) (((pin)>31)?1:0)
#define digitalPinToBitMask(pin) (1UL << (((pin)>31)?((pin)-32):(pin)))
#define digitalPinToPort(pin) ((digitalPinToGPIONumber(pin)>31)?1:0)
#define digitalPinToBitMask(pin) (1UL << (digitalPinToGPIONumber(pin)&31))
#define portOutputRegister(port) ((volatile uint32_t*)((port)?GPIO_OUT1_REG:GPIO_OUT_REG))
#define portInputRegister(port) ((volatile uint32_t*)((port)?GPIO_IN1_REG:GPIO_IN_REG))
#define portModeRegister(port) ((volatile uint32_t*)((port)?GPIO_ENABLE1_REG:GPIO_ENABLE_REG))
Expand Down Expand Up @@ -220,5 +220,6 @@ void noTone(uint8_t _pin);
#endif /* __cplusplus */

#include "pins_arduino.h"
#include "io_pin_remap.h"

#endif /* _ESP32_CORE_ARDUINO_H_ */
2 changes: 1 addition & 1 deletion cores/esp32/FunctionalInterrupt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void ARDUINO_ISR_ATTR interruptFunctional(void* arg)
void attachInterrupt(uint8_t pin, std::function<void(void)> intRoutine, int mode)
{
// use the local interrupt routine which takes the ArgStructure as argument
__attachInterruptFunctionalArg (pin, (voidFuncPtrArg)interruptFunctional, new InterruptArgStructure{intRoutine}, mode, true);
__attachInterruptFunctionalArg (digitalPinToGPIONumber(pin), (voidFuncPtrArg)interruptFunctional, new InterruptArgStructure{intRoutine}, mode, true);
}

extern "C"
Expand Down
11 changes: 11 additions & 0 deletions cores/esp32/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <inttypes.h>

#include "pins_arduino.h"
#include "io_pin_remap.h"
#include "HardwareSerial.h"
#include "soc/soc_caps.h"
#include "driver/uart.h"
Expand Down Expand Up @@ -370,6 +371,10 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
}
}

// map logical pins to GPIO numbers
rxPin = digitalPinToGPIONumber(rxPin);
txPin = digitalPinToGPIONumber(txPin);

if(_uart) {
// in this case it is a begin() over a previous begin() - maybe to change baud rate
// thus do not disable debug output
Expand Down Expand Up @@ -554,6 +559,12 @@ bool HardwareSerial::setPins(int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t r
return false;
}

// map logical pins to GPIO numbers
rxPin = digitalPinToGPIONumber(rxPin);
txPin = digitalPinToGPIONumber(txPin);
ctsPin = digitalPinToGPIONumber(ctsPin);
rtsPin = digitalPinToGPIONumber(rtsPin);

// uartSetPins() checks if pins are valid for each function and for the SoC
bool retCode = uartSetPins(_uart, rxPin, txPin, ctsPin, rtsPin);
if (retCode) {
Expand Down
14 changes: 11 additions & 3 deletions cores/esp32/USB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@
#define USB_WEBUSB_URL "https://espressif.github.io/arduino-esp32/webusb.html"
#endif

#if CFG_TUD_DFU
__attribute__((weak, unused)) uint16_t load_dfu_ota_descriptor(uint8_t * dst, uint8_t * itf) {
return 0;
}
#endif /* CFG_TUD_DFU */

#if CFG_TUD_DFU_RUNTIME
static uint16_t load_dfu_descriptor(uint8_t * dst, uint8_t * itf)
__attribute__((unused)) static uint16_t load_dfu_descriptor(uint8_t * dst, uint8_t * itf)
{
#define DFU_ATTRS (DFU_ATTR_CAN_DOWNLOAD | DFU_ATTR_CAN_UPLOAD | DFU_ATTR_MANIFESTATION_TOLERANT)

Expand Down Expand Up @@ -185,7 +191,7 @@ bool ESPUSB::begin(){
.webusb_enabled = webusb_enabled,
.webusb_url = webusb_url.c_str()
};
_started = tinyusb_init(&tinyusb_device_config) == ESP_OK;
_started = tinyusb_init(&tinyusb_device_config) == ESP_OK;
}
return _started;
}
Expand All @@ -203,7 +209,9 @@ ESPUSB::operator bool() const
}

bool ESPUSB::enableDFU(){
#if CFG_TUD_DFU_RUNTIME
#if CFG_TUD_DFU
return tinyusb_enable_interface(USB_INTERFACE_DFU, TUD_DFU_DESC_LEN(1), load_dfu_ota_descriptor) == ESP_OK;
#elif CFG_TUD_DFU_RUNTIME
return tinyusb_enable_interface(USB_INTERFACE_DFU, TUD_DFU_RT_DESC_LEN, load_dfu_descriptor) == ESP_OK;
#endif /* CFG_TUD_DFU_RUNTIME */
return false;
Expand Down
110 changes: 110 additions & 0 deletions cores/esp32/io_pin_remap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#ifndef __IO_PIN_REMAP_H__
#define __IO_PIN_REMAP_H__

#include "Arduino.h"

#if defined(BOARD_HAS_PIN_REMAP) && !defined(BOARD_USES_HW_GPIO_NUMBERS)

// Pin remapping functions
int8_t digitalPinToGPIONumber(int8_t digitalPin);
int8_t digitalPinFromGPIONumber(int8_t gpioPin);

// Apply pin remapping to API only when building libraries and user sketch
#ifndef ARDUINO_CORE_BUILD

// Override APIs requiring pin remapping

// cores/esp32/Arduino.h
#define pulseInLong(pin, state, timeout) pulseInLong(digitalPinToGPIONumber(pin), state, timeout)
#define pulseIn(pin, state, timeout) pulseIn(digitalPinToGPIONumber(pin), state, timeout)
#define noTone(_pin) noTone(digitalPinToGPIONumber(_pin))
#define tone(_pin, frequency, duration) tone(digitalPinToGPIONumber(_pin), frequency, duration)

// cores/esp32/esp32-hal.h
#define analogGetChannel(pin) analogGetChannel(digitalPinToGPIONumber(pin))
#define analogWrite(pin, value) analogWrite(digitalPinToGPIONumber(pin), value)

// cores/esp32/esp32-hal-adc.h
#define adcAttachPin(pin) adcAttachPin(digitalPinToGPIONumber(pin))
#define analogRead(pin) analogRead(digitalPinToGPIONumber(pin))
#define analogReadMilliVolts(pin) analogReadMilliVolts(digitalPinToGPIONumber(pin))
#define analogSetPinAttenuation(pin, attenuation) analogSetPinAttenuation(digitalPinToGPIONumber(pin), attenuation)
#define analogSetVRefPin(pin) analogSetVRefPin(digitalPinToGPIONumber(pin))

// cores/esp32/esp32-hal-dac.h
#define dacDisable(pin) dacDisable(digitalPinToGPIONumber(pin))
#define dacWrite(pin, value) dacWrite(digitalPinToGPIONumber(pin), value)

// cores/esp32/esp32-hal-gpio.h
#define analogChannelToDigitalPin(channel) gpioNumberToDigitalPin(analogChannelToDigitalPin(channel))
#define digitalPinToAnalogChannel(pin) digitalPinToAnalogChannel(digitalPinToGPIONumber(pin))
#define digitalPinToTouchChannel(pin) digitalPinToTouchChannel(digitalPinToGPIONumber(pin))
#define digitalRead(pin) digitalRead(digitalPinToGPIONumber(pin))
#define attachInterruptArg(pin, fcn, arg, mode) attachInterruptArg(digitalPinToGPIONumber(pin), fcn, arg, mode)
#define attachInterrupt(pin, fcn, mode) attachInterrupt(digitalPinToGPIONumber(pin), fcn, mode)
#define detachInterrupt(pin) detachInterrupt(digitalPinToGPIONumber(pin))
#define digitalWrite(pin, val) digitalWrite(digitalPinToGPIONumber(pin), val)
#define pinMode(pin, mode) pinMode(digitalPinToGPIONumber(pin), mode)

// cores/esp32/esp32-hal-i2c.h
#define i2cInit(i2c_num, sda, scl, clk_speed) i2cInit(i2c_num, digitalPinToGPIONumber(sda), digitalPinToGPIONumber(scl), clk_speed)

// cores/esp32/esp32-hal-i2c-slave.h
#define i2cSlaveInit(num, sda, scl, slaveID, frequency, rx_len, tx_len) i2cSlaveInit(num, digitalPinToGPIONumber(sda), digitalPinToGPIONumber(scl), slaveID, frequency, rx_len, tx_len)

// cores/esp32/esp32-hal-ledc.h
#define ledcAttachPin(pin, channel) ledcAttachPin(digitalPinToGPIONumber(pin), channel)
#define ledcDetachPin(pin) ledcDetachPin(digitalPinToGPIONumber(pin))

// cores/esp32/esp32-hal-matrix.h
#define pinMatrixInAttach(pin, signal, inverted) pinMatrixInAttach(digitalPinToGPIONumber(pin), signal, inverted)
#define pinMatrixOutAttach(pin, function, invertOut, invertEnable) pinMatrixOutAttach(digitalPinToGPIONumber(pin), function, invertOut, invertEnable)
#define pinMatrixOutDetach(pin, invertOut, invertEnable) pinMatrixOutDetach(digitalPinToGPIONumber(pin), invertOut, invertEnable)

// cores/esp32/esp32-hal-rgb-led.h
#define neopixelWrite(pin, red_val, green_val, blue_val) neopixelWrite(digitalPinToGPIONumber(pin), red_val, green_val, blue_val)

// cores/esp32/esp32-hal-rmt.h
#define rmtInit(pin, tx_not_rx, memsize) rmtInit(digitalPinToGPIONumber(pin), tx_not_rx, memsize)

// cores/esp32/esp32-hal-sigmadelta.h
#define sigmaDeltaSetup(pin, channel, freq) sigmaDeltaSetup(digitalPinToGPIONumber(pin), channel, freq)
#define sigmaDeltaDetachPin(pin) sigmaDeltaDetachPin(digitalPinToGPIONumber(pin))

// cores/esp32/esp32-hal-spi.h
#define spiAttachSCK(spi, sck) spiAttachSCK(spi, digitalPinToGPIONumber(sck))
#define spiAttachMISO(spi, miso) spiAttachMISO(spi, digitalPinToGPIONumber(miso))
#define spiAttachMOSI(spi, mosi) spiAttachMOSI(spi, digitalPinToGPIONumber(mosi))
#define spiDetachSCK(spi, sck) spiDetachSCK(spi, digitalPinToGPIONumber(sck))
#define spiDetachMISO(spi, miso) spiDetachMISO(spi, digitalPinToGPIONumber(miso))
#define spiDetachMOSI(spi, mosi) spiDetachMOSI(spi, digitalPinToGPIONumber(mosi))
#define spiAttachSS(spi, cs_num, ss) spiAttachSS(spi, cs_num, digitalPinToGPIONumber(ss))
#define spiDetachSS(spi, ss) spiDetachSS(spi, digitalPinToGPIONumber(ss))

// cores/esp32/esp32-hal-touch.h
#define touchInterruptGetLastStatus(pin) touchInterruptGetLastStatus(digitalPinToGPIONumber(pin))
#define touchRead(pin) touchRead(digitalPinToGPIONumber(pin))
#define touchAttachInterruptArg(pin, userFunc, arg, threshold) touchAttachInterruptArg(digitalPinToGPIONumber(pin), userFunc, arg, threshold)
#define touchAttachInterrupt(pin, userFunc, threshold) touchAttachInterrupt(digitalPinToGPIONumber(pin), userFunc, threshold)
#define touchDetachInterrupt(pin) touchDetachInterrupt(digitalPinToGPIONumber(pin))
#define touchSleepWakeUpEnable(pin, threshold) touchSleepWakeUpEnable(digitalPinToGPIONumber(pin), threshold)

// cores/esp32/esp32-hal-uart.h
#define uartBegin(uart_nr, baudrate, config, rxPin, txPin, rx_buffer_size, tx_buffer_size, inverted, rxfifo_full_thrhd) \
uartBegin(uart_nr, baudrate, config, digitalPinToGPIONumber(rxPin), digitalPinToGPIONumber(txPin), rx_buffer_size, tx_buffer_size, inverted, rxfifo_full_thrhd)
#define uartSetPins(uart, rxPin, txPin, ctsPin, rtsPin) \
uartSetPins(uart, digitalPinToGPIONumber(rxPin), digitalPinToGPIONumber(txPin), digitalPinToGPIONumber(ctsPin), digitalPinToGPIONumber(rtsPin))
#define uartDetachPins(uart, rxPin, txPin, ctsPin, rtsPin) \
uartDetachPins(uart, digitalPinToGPIONumber(rxPin), digitalPinToGPIONumber(txPin), digitalPinToGPIONumber(ctsPin), digitalPinToGPIONumber(rtsPin))

#endif // ARDUINO_CORE_BUILD

#else

// pin remapping disabled: use stubs
#define digitalPinToGPIONumber(digitalPin) (digitalPin)
#define gpioNumberToDigitalPin(gpioNumber) (gpioNumber)

#endif

#endif /* __GPIO_PIN_REMAP_H__ */
14 changes: 7 additions & 7 deletions libraries/I2S/src/I2S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,24 +317,24 @@ int I2SClass::begin(int mode, int sampleRate, int bitsPerSample, bool driveClock
int I2SClass::_applyPinSetting(){
if(_driverInstalled){
esp_i2s::i2s_pin_config_t pin_config = {
.bck_io_num = _sckPin,
.ws_io_num = _fsPin,
.bck_io_num = digitalPinToGPIONumber(_sckPin),
.ws_io_num = digitalPinToGPIONumber(_fsPin),
.data_out_num = I2S_PIN_NO_CHANGE,
.data_in_num = I2S_PIN_NO_CHANGE
};
if (_state == I2S_STATE_DUPLEX){ // duplex
pin_config.data_out_num = _outSdPin;
pin_config.data_in_num = _inSdPin;
pin_config.data_out_num = digitalPinToGPIONumber(_outSdPin);
pin_config.data_in_num = digitalPinToGPIONumber(_inSdPin);
}else{ // simplex
if(_state == I2S_STATE_RECEIVER){
pin_config.data_out_num = I2S_PIN_NO_CHANGE;
pin_config.data_in_num = _sdPin;
pin_config.data_in_num = digitalPinToGPIONumber(_sdPin);
}else if(_state == I2S_STATE_TRANSMITTER){
pin_config.data_out_num = _sdPin;
pin_config.data_out_num = digitalPinToGPIONumber(_sdPin);
pin_config.data_in_num = I2S_PIN_NO_CHANGE;
}else{
pin_config.data_out_num = I2S_PIN_NO_CHANGE;
pin_config.data_in_num = _sdPin;
pin_config.data_in_num = digitalPinToGPIONumber(_sdPin);
}
}
if(ESP_OK != esp_i2s::i2s_set_pin((esp_i2s::i2s_port_t) _deviceIndex, &pin_config)){
Expand Down
10 changes: 10 additions & 0 deletions libraries/SD_MMC/src/SD_MMC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

#include "pins_arduino.h"
#include "io_pin_remap.h"
#include "SD_MMC.h"
#ifdef SOC_SDMMC_HOST_SUPPORTED
#include "vfs_api.h"
Expand Down Expand Up @@ -54,6 +55,15 @@ bool SDMMCFS::setPins(int clk, int cmd, int d0, int d1, int d2, int d3)
log_e("SD_MMC.setPins must be called before SD_MMC.begin");
return false;
}

// map logical pins to GPIO numbers
clk = digitalPinToGPIONumber(clk);
cmd = digitalPinToGPIONumber(cmd);
d0 = digitalPinToGPIONumber(d0);
d1 = digitalPinToGPIONumber(d1);
d2 = digitalPinToGPIONumber(d2);
d3 = digitalPinToGPIONumber(d3);

#ifdef SOC_SDMMC_USE_GPIO_MATRIX
// SoC supports SDMMC pin configuration via GPIO matrix. Save the pins for later use in SDMMCFS::begin.
_pin_clk = (int8_t) clk;
Expand Down
1 change: 1 addition & 0 deletions libraries/SPI/src/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

#include "SPI.h"
#include "io_pin_remap.h"
#include "esp32-hal-log.h"

#if !CONFIG_DISABLE_HAL_LOCKS
Expand Down
Loading

0 comments on commit 9b4622d

Please sign in to comment.