Skip to content

Commit 2f25da2

Browse files
authored
Merge branch 'master' into revert_wifi_disconnect_usestaticip_false
2 parents 34e06dd + e97a519 commit 2f25da2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1735
-187
lines changed

boards.txt

+71-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ menu.MemoryType=Memory Type
1818
menu.EraseFlash=Erase All Flash Before Sketch Upload
1919
menu.JTAGAdapter=JTAG Adapter
2020
menu.ZigbeeMode=Zigbee Mode
21+
menu.PinNumbers=Pin Numbering
2122

2223
# Custom options
2324
menu.Revision=Board Revision
@@ -16274,7 +16275,7 @@ m5stack-core2.build.f_cpu=240000000L
1627416275
m5stack-core2.build.flash_size=16MB
1627516276
m5stack-core2.build.flash_freq=80m
1627616277
m5stack-core2.build.flash_mode=dio
16277-
m5stack-core2.build.boot=dio
16278+
m5stack-core2.build.boot=qio
1627816279
m5stack-core2.build.partitions=default_16MB
1627916280
m5stack-core2.build.defines=
1628016281

@@ -29688,4 +29689,72 @@ sensebox_mcu_esp32s2.menu.EraseFlash.none.upload.erase_cmd=
2968829689
sensebox_mcu_esp32s2.menu.EraseFlash.all=Enabled
2968929690
sensebox_mcu_esp32s2.menu.EraseFlash.all.upload.erase_cmd=-e
2969029691

29691-
##############################################################
29692+
##############################################################
29693+
29694+
nano_nora.name=Arduino Nano ESP32
29695+
nano_nora.vid.0=0x2341
29696+
nano_nora.pid.0=0x0070
29697+
nano_nora.upload_port.0.vid=0x2341
29698+
nano_nora.upload_port.0.pid=0x0070
29699+
29700+
nano_nora.bootloader.tool=esptool_py
29701+
nano_nora.bootloader.tool.default=esptool_py
29702+
29703+
nano_nora.upload.tool=dfu-util
29704+
nano_nora.upload.tool.default=dfu-util
29705+
nano_nora.upload.tool.network=esp_ota
29706+
nano_nora.upload.protocol=serial
29707+
nano_nora.upload.maximum_size=3145728
29708+
nano_nora.upload.maximum_data_size=327680
29709+
nano_nora.upload.use_1200bps_touch=false
29710+
nano_nora.upload.wait_for_upload_port=false
29711+
29712+
nano_nora.serial.disableDTR=false
29713+
nano_nora.serial.disableRTS=false
29714+
29715+
nano_nora.build.tarch=xtensa
29716+
nano_nora.build.bootloader_addr=0x0
29717+
nano_nora.build.target=esp32s3
29718+
nano_nora.build.mcu=esp32s3
29719+
nano_nora.build.core=esp32
29720+
nano_nora.build.variant=arduino_nano_nora
29721+
nano_nora.build.board=NANO_ESP32
29722+
nano_nora.build.code_debug=0
29723+
29724+
nano_nora.build.usb_mode=0
29725+
nano_nora.build.cdc_on_boot=1
29726+
nano_nora.build.msc_on_boot=0
29727+
nano_nora.build.dfu_on_boot=1
29728+
nano_nora.build.f_cpu=240000000L
29729+
nano_nora.build.flash_size=16MB
29730+
nano_nora.build.flash_freq=80m
29731+
nano_nora.build.flash_mode=dio
29732+
nano_nora.build.boot=qio
29733+
nano_nora.build.boot_freq=80m
29734+
nano_nora.build.partitions=app3M_fat9M_fact512k_16MB
29735+
nano_nora.build.defines=-DBOARD_HAS_PIN_REMAP {build.disable_pin_remap} -DBOARD_HAS_PSRAM '-DUSB_MANUFACTURER="Arduino"' '-DUSB_PRODUCT="Nano ESP32"'
29736+
nano_nora.build.loop_core=-DARDUINO_RUNNING_CORE=1
29737+
nano_nora.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1
29738+
nano_nora.build.psram_type=opi
29739+
nano_nora.build.memory_type={build.boot}_{build.psram_type}
29740+
nano_nora.build.disable_pin_remap=
29741+
29742+
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"
29743+
nano_nora.tools.esptool_py.erase.pattern_args=--chip {build.mcu} --port "{serial.port}" --before default_reset --after hard_reset erase_flash
29744+
29745+
nano_nora.menu.PartitionScheme.default=With FAT partition (default)
29746+
nano_nora.menu.PartitionScheme.spiffs=With SPIFFS partition (advanced)
29747+
nano_nora.menu.PartitionScheme.spiffs.build.partitions=app3M_spiffs9M_fact512k_16MB
29748+
29749+
nano_nora.menu.PinNumbers.default=By Arduino pin (default)
29750+
nano_nora.menu.PinNumbers.byGPIONumber=By GPIO number (legacy)
29751+
nano_nora.menu.PinNumbers.byGPIONumber.build.disable_pin_remap=-DBOARD_USES_HW_GPIO_NUMBERS
29752+
29753+
nano_nora.menu.USBMode.default=Normal mode (TinyUSB)
29754+
nano_nora.menu.USBMode.hwcdc=Debug mode (Hardware CDC)
29755+
nano_nora.menu.USBMode.hwcdc.build.usb_mode=1
29756+
nano_nora.menu.USBMode.hwcdc.build.copy_jtag_files=1
29757+
nano_nora.menu.USBMode.hwcdc.build.openocdscript=esp32s3-builtin.cfg
29758+
nano_nora.menu.USBMode.hwcdc.build.debugconfig=esp32s3-arduino.json
29759+
29760+
##############################################################

cores/esp32/Arduino.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@
111111
#define analogInPinToBit(P) (P)
112112
#if SOC_GPIO_PIN_COUNT <= 32
113113
#define digitalPinToPort(pin) (0)
114-
#define digitalPinToBitMask(pin) (1UL << (pin))
114+
#define digitalPinToBitMask(pin) (1UL << digitalPinToGPIONumber(pin))
115115
#define portOutputRegister(port) ((volatile uint32_t*)GPIO_OUT_REG)
116116
#define portInputRegister(port) ((volatile uint32_t*)GPIO_IN_REG)
117117
#define portModeRegister(port) ((volatile uint32_t*)GPIO_ENABLE_REG)
118118
#elif SOC_GPIO_PIN_COUNT <= 64
119-
#define digitalPinToPort(pin) (((pin)>31)?1:0)
120-
#define digitalPinToBitMask(pin) (1UL << (((pin)>31)?((pin)-32):(pin)))
119+
#define digitalPinToPort(pin) ((digitalPinToGPIONumber(pin)>31)?1:0)
120+
#define digitalPinToBitMask(pin) (1UL << (digitalPinToGPIONumber(pin)&31))
121121
#define portOutputRegister(port) ((volatile uint32_t*)((port)?GPIO_OUT1_REG:GPIO_OUT_REG))
122122
#define portInputRegister(port) ((volatile uint32_t*)((port)?GPIO_IN1_REG:GPIO_IN_REG))
123123
#define portModeRegister(port) ((volatile uint32_t*)((port)?GPIO_ENABLE1_REG:GPIO_ENABLE_REG))
@@ -139,8 +139,8 @@
139139
#endif
140140
#define EXTERNAL_NUM_INTERRUPTS NUM_DIGITAL_PINS // All GPIOs
141141
#define analogInputToDigitalPin(p) (((p)<NUM_ANALOG_INPUTS)?(analogChannelToDigitalPin(p)):-1)
142-
#define digitalPinToInterrupt(p) (((p)<NUM_DIGITAL_PINS)?(p):NOT_AN_INTERRUPT)
143-
#define digitalPinHasPWM(p) ((p)<NUM_DIGITAL_PINS)
142+
#define digitalPinToInterrupt(p) ((((uint8_t)digitalPinToGPIONumber(p))<NUM_DIGITAL_PINS)?digitalPinToGPIONumber(p):NOT_AN_INTERRUPT)
143+
#define digitalPinHasPWM(p) (((uint8_t)digitalPinToGPIONumber(p))<NUM_DIGITAL_PINS)
144144

145145
typedef bool boolean;
146146
typedef uint8_t byte;
@@ -236,5 +236,6 @@ void noTone(uint8_t _pin);
236236
#endif /* __cplusplus */
237237

238238
#include "pins_arduino.h"
239+
#include "io_pin_remap.h"
239240

240241
#endif /* _ESP32_CORE_ARDUINO_H_ */

cores/esp32/FunctionalInterrupt.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
#include <stdint.h>
1313

1414
struct InterruptArgStructure {
15-
std::function<void(void)> interruptFunction;
15+
std::function<void(void)> interruptFunction;
1616
};
1717

18-
void attachInterrupt(uint8_t pin, std::function<void(void)> intRoutine, int mode);
19-
18+
// The extra set of parentheses here prevents macros defined
19+
// in io_pin_remap.h from applying to this declaration.
20+
void (attachInterrupt)(uint8_t pin, std::function<void(void)> intRoutine, int mode);
2021

2122
#endif /* CORE_CORE_FUNCTIONALINTERRUPT_H_ */

cores/esp32/HardwareSerial.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <ctime>
66

77
#include "pins_arduino.h"
8+
#include "io_pin_remap.h"
89
#include "HardwareSerial.h"
910
#include "soc/soc_caps.h"
1011
#include "driver/uart.h"
@@ -325,6 +326,10 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
325326
}
326327
}
327328

329+
// map logical pins to GPIO numbers
330+
rxPin = digitalPinToGPIONumber(rxPin);
331+
txPin = digitalPinToGPIONumber(txPin);
332+
328333
if(_uart) {
329334
// in this case it is a begin() over a previous begin() - maybe to change baud rate
330335
// thus do not disable debug output
@@ -500,6 +505,12 @@ void HardwareSerial::setRxInvert(bool invert)
500505
// can be called after or before begin()
501506
bool HardwareSerial::setPins(int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin)
502507
{
508+
// map logical pins to GPIO numbers
509+
rxPin = digitalPinToGPIONumber(rxPin);
510+
txPin = digitalPinToGPIONumber(txPin);
511+
ctsPin = digitalPinToGPIONumber(ctsPin);
512+
rtsPin = digitalPinToGPIONumber(rtsPin);
513+
503514
// uartSetPins() checks if pins are valid and, if necessary, detaches the previous ones
504515
return uartSetPins(_uart_nr, rxPin, txPin, ctsPin, rtsPin);
505516
}

cores/esp32/USB.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@
5151
#define USB_WEBUSB_URL "https://espressif.github.io/arduino-esp32/webusb.html"
5252
#endif
5353

54-
#if CFG_TUD_DFU_RUNTIME
54+
#if CFG_TUD_DFU
55+
__attribute__((weak)) uint16_t load_dfu_ota_descriptor(uint8_t * dst, uint8_t * itf) {
56+
return 0;
57+
}
58+
#elif CFG_TUD_DFU_RUNTIME
5559
static uint16_t load_dfu_descriptor(uint8_t * dst, uint8_t * itf)
5660
{
5761
#define DFU_ATTRS (DFU_ATTR_CAN_DOWNLOAD | DFU_ATTR_CAN_UPLOAD | DFU_ATTR_MANIFESTATION_TOLERANT)
@@ -65,6 +69,9 @@ static uint16_t load_dfu_descriptor(uint8_t * dst, uint8_t * itf)
6569
memcpy(dst, descriptor, TUD_DFU_RT_DESC_LEN);
6670
return TUD_DFU_RT_DESC_LEN;
6771
}
72+
#endif /* CFG_TUD_DFU_RUNTIME */
73+
74+
#if CFG_TUD_DFU_RUNTIME
6875
// Invoked on DFU_DETACH request to reboot to the bootloader
6976
void tud_dfu_runtime_reboot_to_dfu_cb(void)
7077
{
@@ -207,7 +214,9 @@ ESPUSB::operator bool() const
207214
}
208215

209216
bool ESPUSB::enableDFU(){
210-
#if CFG_TUD_DFU_RUNTIME
217+
#if CFG_TUD_DFU
218+
return tinyusb_enable_interface(USB_INTERFACE_DFU, TUD_DFU_DESC_LEN(1), load_dfu_ota_descriptor) == ESP_OK;
219+
#elif CFG_TUD_DFU_RUNTIME
211220
return tinyusb_enable_interface(USB_INTERFACE_DFU, TUD_DFU_RT_DESC_LEN, load_dfu_descriptor) == ESP_OK;
212221
#endif /* CFG_TUD_DFU_RUNTIME */
213222
return false;

cores/esp32/chip-debug-report.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ static void printBoardInfo(void){
242242
static void printPerimanInfo(void){
243243
chip_report_printf("GPIO Info:\n");
244244
chip_report_printf("------------------------------------------\n");
245+
#if defined(BOARD_HAS_PIN_REMAP)
246+
chip_report_printf(" DPIN|GPIO : BUS_TYPE[bus/unit][chan]\n");
247+
#else
245248
chip_report_printf(" GPIO : BUS_TYPE[bus/unit][chan]\n");
249+
#endif
246250
chip_report_printf(" -------------------------------------- \n");
247251
for(uint8_t i = 0; i < SOC_GPIO_PIN_COUNT; i++){
248252
if(!perimanPinIsValid(i)){
@@ -252,8 +256,17 @@ static void printPerimanInfo(void){
252256
if(type == ESP32_BUS_TYPE_INIT){
253257
continue;//unused pin
254258
}
255-
const char* extra_type = perimanGetPinBusExtraType(i);
259+
#if defined(BOARD_HAS_PIN_REMAP)
260+
int dpin = gpioNumberToDigitalPin(i);
261+
if (dpin < 0) {
262+
continue;//pin is not exported
263+
} else {
264+
chip_report_printf(" D%-3d|%4u : ", dpin, i);
265+
}
266+
#else
256267
chip_report_printf(" %4u : ", i);
268+
#endif
269+
const char* extra_type = perimanGetPinBusExtraType(i);
257270
if(extra_type){
258271
chip_report_printf("%s", extra_type);
259272
}

cores/esp32/esp32-hal-adc.c

+22-19
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,19 @@ static bool adcDetachBus(void * pin){
6969
return false;
7070
}
7171
adc_handle[adc_unit].adc_oneshot_handle = NULL;
72+
if(adc_handle[adc_unit].adc_cali_handle != NULL){
7273
#if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
73-
err = adc_cali_delete_scheme_curve_fitting(adc_handle[adc_unit].adc_cali_handle);
74-
if(err != ESP_OK){
75-
return false;
76-
}
74+
err = adc_cali_delete_scheme_curve_fitting(adc_handle[adc_unit].adc_cali_handle);
75+
if(err != ESP_OK){
76+
return false;
77+
}
7778
#elif !defined(CONFIG_IDF_TARGET_ESP32H2)
78-
err = adc_cali_delete_scheme_line_fitting(adc_handle[adc_unit].adc_cali_handle);
79-
if(err != ESP_OK){
80-
return false;
81-
}
79+
err = adc_cali_delete_scheme_line_fitting(adc_handle[adc_unit].adc_cali_handle);
80+
if(err != ESP_OK){
81+
return false;
82+
}
8283
#endif
84+
}
8385
adc_handle[adc_unit].adc_cali_handle = NULL;
8486
}
8587
return true;
@@ -220,6 +222,7 @@ esp_err_t __analogInit(uint8_t pin, adc_channel_t channel, adc_unit_t adc_unit){
220222
return err;
221223
}
222224
}
225+
perimanSetBusDeinit(ESP32_BUS_TYPE_ADC_ONESHOT, adcDetachBus);
223226

224227
if(!perimanSetPinBus(pin, ESP32_BUS_TYPE_ADC_ONESHOT, (void *)(pin+1), adc_unit, channel)){
225228
adcDetachBus((void *)(pin+1));
@@ -236,7 +239,6 @@ esp_err_t __analogInit(uint8_t pin, adc_channel_t channel, adc_unit_t adc_unit){
236239
log_e("adc_oneshot_config_channel failed with error: %d", err);
237240
return err;
238241
}
239-
perimanSetBusDeinit(ESP32_BUS_TYPE_ADC_ONESHOT, adcDetachBus);
240242
return ESP_OK;
241243
}
242244

@@ -377,18 +379,19 @@ static bool adcContinuousDetachBus(void * adc_unit_number){
377379
return false;
378380
}
379381
adc_handle[adc_unit].adc_continuous_handle = NULL;
380-
381-
#if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
382-
err = adc_cali_delete_scheme_curve_fitting(adc_handle[adc_unit].adc_cali_handle);
383-
if(err != ESP_OK){
384-
return false;
385-
}
382+
if(adc_handle[adc_unit].adc_cali_handle != NULL){
383+
#if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
384+
err = adc_cali_delete_scheme_curve_fitting(adc_handle[adc_unit].adc_cali_handle);
385+
if(err != ESP_OK){
386+
return false;
387+
}
386388
#elif !defined(CONFIG_IDF_TARGET_ESP32H2)
387-
err = adc_cali_delete_scheme_line_fitting(adc_handle[adc_unit].adc_cali_handle);
388-
if(err != ESP_OK){
389-
return false;
390-
}
389+
err = adc_cali_delete_scheme_line_fitting(adc_handle[adc_unit].adc_cali_handle);
390+
if(err != ESP_OK){
391+
return false;
392+
}
391393
#endif
394+
}
392395
adc_handle[adc_unit].adc_cali_handle = NULL;
393396

394397
//set all used pins to INIT state

cores/esp32/esp32-hal-bt.c

+34-4
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,48 @@ bool btStarted(){
3838
return (esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_ENABLED);
3939
}
4040

41-
bool btStart(){
41+
bool btStart() {
42+
return btStartMode(BT_MODE);
43+
}
44+
45+
bool btStartMode(bt_mode mode){
46+
esp_bt_mode_t esp_bt_mode;
4247
esp_bt_controller_config_t cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
48+
#if CONFIG_IDF_TARGET_ESP32
49+
switch(mode) {
50+
case BT_MODE_BLE: esp_bt_mode=ESP_BT_MODE_BLE;
51+
break;
52+
case BT_MODE_CLASSIC_BT: esp_bt_mode=ESP_BT_MODE_CLASSIC_BT;
53+
break;
54+
case BT_MODE_BTDM: esp_bt_mode=ESP_BT_MODE_BTDM;
55+
break;
56+
default: esp_bt_mode=BT_MODE;
57+
break;
58+
}
59+
// esp_bt_controller_enable(MODE) This mode must be equal as the mode in “cfg” of esp_bt_controller_init().
60+
cfg.mode=esp_bt_mode;
61+
if(cfg.mode == ESP_BT_MODE_CLASSIC_BT) {
62+
esp_bt_controller_mem_release(ESP_BT_MODE_BLE);
63+
}
64+
#else
65+
// other esp variants dont support BT-classic / DM.
66+
esp_bt_mode=BT_MODE;
67+
#endif
68+
4369
if(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_ENABLED){
4470
return true;
4571
}
72+
esp_err_t ret;
4673
if(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_IDLE){
47-
esp_bt_controller_init(&cfg);
74+
if((ret = esp_bt_controller_init(&cfg)) != ESP_OK) {
75+
log_e("initialize controller failed: %s", esp_err_to_name(ret));
76+
return false;
77+
}
4878
while(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_IDLE){}
4979
}
5080
if(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_INITED){
51-
if (esp_bt_controller_enable(BT_MODE)) {
52-
log_e("BT Enable failed");
81+
if((ret = esp_bt_controller_enable(esp_bt_mode)) != ESP_OK) {
82+
log_e("BT Enable mode=%d failed %s", BT_MODE, esp_err_to_name(ret));
5383
return false;
5484
}
5585
}

cores/esp32/esp32-hal-bt.h

+3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@
2424
extern "C" {
2525
#endif
2626

27+
typedef enum {BT_MODE_DEFAULT, BT_MODE_BLE, BT_MODE_CLASSIC_BT, BT_MODE_BTDM } bt_mode;
28+
2729
bool btStarted();
2830
bool btStart();
31+
bool btStartMode(bt_mode mode);
2932
bool btStop();
3033

3134
#ifdef __cplusplus

cores/esp32/esp32-hal-periman.h

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#pragma once
8+
79
#ifdef __cplusplus
810
extern "C"
911
{

0 commit comments

Comments
 (0)