Skip to content

Espressif esp32 s3 support #94

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 7 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
149 changes: 149 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,155 @@ esp32.menu.DebugLevel.verbose.build.code_debug=5

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

esp32da.name=ESP32-WROOM-DA Module

esp32da.upload.tool=esptool_py
esp32da.upload.maximum_size=1310720
esp32da.upload.maximum_data_size=327680
esp32da.upload.flags=
esp32da.upload.extra_flags=

esp32da.serial.disableDTR=true
esp32da.serial.disableRTS=true

esp32da.build.tarch=xtensa
esp32da.build.bootloader_addr=0x1000
esp32da.build.target=esp32
esp32da.build.mcu=esp32
esp32da.build.core=esp32
esp32da.build.variant=esp32da
esp32da.build.board=ESP32_WROOM_DA

esp32da.build.f_cpu=240000000L
esp32da.build.flash_size=4MB
esp32da.build.flash_freq=40m
esp32da.build.flash_mode=dio
esp32da.build.boot=dio
esp32da.build.partitions=default
esp32da.build.defines=
esp32da.build.loop_core=
esp32da.build.event_core=

esp32da.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
esp32da.menu.PartitionScheme.default.build.partitions=default
esp32da.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
esp32da.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
esp32da.menu.PartitionScheme.default_8MB=8M Flash (3MB APP/1.5MB FAT)
esp32da.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
esp32da.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
esp32da.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
esp32da.menu.PartitionScheme.minimal.build.partitions=minimal
esp32da.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
esp32da.menu.PartitionScheme.no_ota.build.partitions=no_ota
esp32da.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
esp32da.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS)
esp32da.menu.PartitionScheme.noota_3g.build.partitions=noota_3g
esp32da.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576
esp32da.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS)
esp32da.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat
esp32da.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152
esp32da.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS)
esp32da.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat
esp32da.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576
esp32da.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
esp32da.menu.PartitionScheme.huge_app.build.partitions=huge_app
esp32da.menu.PartitionScheme.huge_app.upload.maximum_size=3145728
esp32da.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
esp32da.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
esp32da.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
esp32da.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FAT)
esp32da.menu.PartitionScheme.fatflash.build.partitions=ffat
esp32da.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
esp32da.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS)
esp32da.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB
esp32da.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728
esp32da.menu.PartitionScheme.rainmaker=RainMaker
esp32da.menu.PartitionScheme.rainmaker.build.partitions=rainmaker
esp32da.menu.PartitionScheme.rainmaker.upload.maximum_size=3145728

esp32da.menu.CPUFreq.240=240MHz (WiFi/BT)
esp32da.menu.CPUFreq.240.build.f_cpu=240000000L
esp32da.menu.CPUFreq.160=160MHz (WiFi/BT)
esp32da.menu.CPUFreq.160.build.f_cpu=160000000L
esp32da.menu.CPUFreq.80=80MHz (WiFi/BT)
esp32da.menu.CPUFreq.80.build.f_cpu=80000000L
esp32da.menu.CPUFreq.40=40MHz (40MHz XTAL)
esp32da.menu.CPUFreq.40.build.f_cpu=40000000L
esp32da.menu.CPUFreq.26=26MHz (26MHz XTAL)
esp32da.menu.CPUFreq.26.build.f_cpu=26000000L
esp32da.menu.CPUFreq.20=20MHz (40MHz XTAL)
esp32da.menu.CPUFreq.20.build.f_cpu=20000000L
esp32da.menu.CPUFreq.13=13MHz (26MHz XTAL)
esp32da.menu.CPUFreq.13.build.f_cpu=13000000L
esp32da.menu.CPUFreq.10=10MHz (40MHz XTAL)
esp32da.menu.CPUFreq.10.build.f_cpu=10000000L

esp32da.menu.FlashMode.qio=QIO
esp32da.menu.FlashMode.qio.build.flash_mode=dio
esp32da.menu.FlashMode.qio.build.boot=qio
esp32da.menu.FlashMode.dio=DIO
esp32da.menu.FlashMode.dio.build.flash_mode=dio
esp32da.menu.FlashMode.dio.build.boot=dio
esp32da.menu.FlashMode.qout=QOUT
esp32da.menu.FlashMode.qout.build.flash_mode=dout
esp32da.menu.FlashMode.qout.build.boot=qout
esp32da.menu.FlashMode.dout=DOUT
esp32da.menu.FlashMode.dout.build.flash_mode=dout
esp32da.menu.FlashMode.dout.build.boot=dout

esp32da.menu.FlashFreq.80=80MHz
esp32da.menu.FlashFreq.80.build.flash_freq=80m
esp32da.menu.FlashFreq.40=40MHz
esp32da.menu.FlashFreq.40.build.flash_freq=40m

esp32da.menu.FlashSize.4M=4MB (32Mb)
esp32da.menu.FlashSize.4M.build.flash_size=4MB
esp32da.menu.FlashSize.8M=8MB (64Mb)
esp32da.menu.FlashSize.8M.build.flash_size=8MB
esp32da.menu.FlashSize.8M.build.partitions=default_8MB
esp32da.menu.FlashSize.16M=16MB (128Mb)
esp32da.menu.FlashSize.16M.build.flash_size=16MB

esp32da.menu.UploadSpeed.921600=921600
esp32da.menu.UploadSpeed.921600.upload.speed=921600
esp32da.menu.UploadSpeed.115200=115200
esp32da.menu.UploadSpeed.115200.upload.speed=115200
esp32da.menu.UploadSpeed.256000.windows=256000
esp32da.menu.UploadSpeed.256000.upload.speed=256000
esp32da.menu.UploadSpeed.230400.windows.upload.speed=256000
esp32da.menu.UploadSpeed.230400=230400
esp32da.menu.UploadSpeed.230400.upload.speed=230400
esp32da.menu.UploadSpeed.460800.linux=460800
esp32da.menu.UploadSpeed.460800.macosx=460800
esp32da.menu.UploadSpeed.460800.upload.speed=460800
esp32da.menu.UploadSpeed.512000.windows=512000
esp32da.menu.UploadSpeed.512000.upload.speed=512000

esp32da.menu.LoopCore.1=Core 1
esp32da.menu.LoopCore.1.build.loop_core=-DARDUINO_RUNNING_CORE=1
esp32da.menu.LoopCore.0=Core 0
esp32da.menu.LoopCore.0.build.loop_core=-DARDUINO_RUNNING_CORE=0

esp32da.menu.EventsCore.1=Core 1
esp32da.menu.EventsCore.1.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1
esp32da.menu.EventsCore.0=Core 0
esp32da.menu.EventsCore.0.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=0

esp32da.menu.DebugLevel.none=None
esp32da.menu.DebugLevel.none.build.code_debug=0
esp32da.menu.DebugLevel.error=Error
esp32da.menu.DebugLevel.error.build.code_debug=1
esp32da.menu.DebugLevel.warn=Warn
esp32da.menu.DebugLevel.warn.build.code_debug=2
esp32da.menu.DebugLevel.info=Info
esp32da.menu.DebugLevel.info.build.code_debug=3
esp32da.menu.DebugLevel.debug=Debug
esp32da.menu.DebugLevel.debug.build.code_debug=4
esp32da.menu.DebugLevel.verbose=Verbose
esp32da.menu.DebugLevel.verbose.build.code_debug=5

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

esp32wrover.name=ESP32 Wrover Module

esp32wrover.upload.tool=esptool_py
Expand Down
3 changes: 2 additions & 1 deletion cores/esp32/esp32-hal-uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,12 @@ int log_printf(const char *format, ...)
va_list copy;
va_start(arg, format);
va_copy(copy, arg);
len = vsnprintf(NULL, 0, format, arg);
len = vsnprintf(NULL, 0, format, copy);
va_end(copy);
if(len >= sizeof(loc_buf)){
temp = (char*)malloc(len+1);
if(temp == NULL) {
va_end(arg);
return 0;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ void setup()
// Set WiFi to station mode and disconnect from an AP if it was previously connected
WiFi.mode(WIFI_STA);

// Set WiFi dual antenna configuration by passing the GPIO and antenna mode for RX ant TX
/* Attention: This is the manual prodecure for the dual antenna configuration.
* If you choose the ESP32-WROOM-DA module from the Tools -> Board, this configuration
* is not necessary!
*
* Set WiFi dual antenna configuration by passing the GPIO and antenna mode for RX ant TX
*/
err = WiFi.setDualAntennaConfig(GPIO_ANT1, GPIO_ANT1, WIFI_RX_ANT_AUTO, WIFI_TX_ANT_AUTO);

/* For more details on how to use this feature, see our docs:
Expand Down
18 changes: 1 addition & 17 deletions libraries/WiFi/src/WiFiAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,23 +205,7 @@ bool WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress
}

err = set_esp_interface_ip(ESP_IF_WIFI_AP, local_ip, gateway, subnet);

// testing effectiveness of the operation beyond internal DHCP Client process
esp_netif_ip_info_t ip;
if(esp_netif_get_ip_info(get_esp_interface_netif(ESP_IF_WIFI_AP), &ip) != ESP_OK){
log_e("Netif Get IP Failed!");
return false;
}
bool ip_ok = IPAddress(ip.ip.addr) == local_ip;
bool gw_ok = IPAddress(ip.gw.addr) == gateway;
bool mk_ok = IPAddress(ip.netmask.addr) == subnet;

if (ip_ok && gw_ok && mk_ok) {
return true;
} else {
log_e("Failed setting: %s %s %s", ip_ok ? "" : "Static IP", gw_ok ? "" : "- Gateway", mk_ok ? "" : "- Netmask");
return false;
}
return err == ESP_OK;
}


Expand Down
25 changes: 22 additions & 3 deletions libraries/WiFi/src/WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,20 @@ esp_err_t set_esp_interface_ip(esp_interface_t interface, IPAddress local_ip=IPA

dhcps_lease_t lease;
lease.enable = true;
lease.start_ip.addr = static_cast<uint32_t>(local_ip) + (1 << 24);
lease.end_ip.addr = static_cast<uint32_t>(local_ip) + (11 << 24);

uint32_t dhcp_ipaddr = static_cast<uint32_t>(local_ip);
// prevents DHCP lease range to overflow subnet/24 range
// there will be 11 addresses for DHCP to lease
uint8_t leaseStart = (uint8_t)(~subnet[3] - 12);
if ((local_ip[3]) < leaseStart) {
lease.start_ip.addr = dhcp_ipaddr + (1 << 24);
lease.end_ip.addr = dhcp_ipaddr + (11 << 24);
} else {
// make range stay in the begining of the netmask range
dhcp_ipaddr = (dhcp_ipaddr & 0x00FFFFFF);
lease.start_ip.addr = dhcp_ipaddr + (1 << 24);
lease.end_ip.addr = dhcp_ipaddr + (11 << 24);
}
log_v("DHCP Server Range: %s to %s", IPAddress(lease.start_ip.addr).toString(), IPAddress(lease.end_ip.addr).toString());
err = tcpip_adapter_dhcps_option(
(tcpip_adapter_dhcp_option_mode_t)TCPIP_ADAPTER_OP_SET,
(tcpip_adapter_dhcp_option_id_t)REQUESTED_IP_ADDRESS,
Expand Down Expand Up @@ -1061,6 +1072,14 @@ bool WiFiGenericClass::mode(wifi_mode_t m)
if(!espWiFiStart()){
return false;
}

#ifdef BOARD_HAS_DUAL_ANTENNA
if(!setDualAntennaConfig(ANT1, ANT2, WIFI_RX_ANT_AUTO, WIFI_TX_ANT_AUTO)){
log_e("Dual Antenna Config failed!");
return false;
}
#endif

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/WiFi/src/WiFiGeneric.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class WiFiGenericClass

bool initiateFTM(uint8_t frm_count=16, uint16_t burst_period=2, uint8_t channel=1, const uint8_t * mac=NULL);

bool setDualAntennaConfig(uint8_t gpio_ant1, uint8_t gpio_ant2, wifi_rx_ant_t rx_mode, wifi_tx_ant_t tx_mode);
static bool setDualAntennaConfig(uint8_t gpio_ant1, uint8_t gpio_ant2, wifi_rx_ant_t rx_mode, wifi_tx_ant_t tx_mode);

static const char * getHostname();
static bool setHostname(const char * hostname);
Expand Down
19 changes: 16 additions & 3 deletions libraries/WiFi/src/WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,15 @@ IPv6Address WiFiSTAClass::localIPv6()
bool WiFiSTAClass::_smartConfigStarted = false;
bool WiFiSTAClass::_smartConfigDone = false;


bool WiFiSTAClass::beginSmartConfig() {
/**
* @brief
*
* @param type Select type of SmartConfig. Default type is SC_TYPE_ESPTOUCH
* @param crypt_key When using type SC_TYPE_ESPTOUTCH_V2 crypt key needed, else ignored. Lenght should be 16 chars.
* @return true if configuration is successful.
* @return false if configuration fails.
*/
bool WiFiSTAClass::beginSmartConfig(smartconfig_type_t type, char* crypt_key) {
esp_err_t err;
if (_smartConfigStarted) {
return false;
Expand All @@ -668,7 +675,13 @@ bool WiFiSTAClass::beginSmartConfig() {
esp_wifi_disconnect();

smartconfig_start_config_t conf = SMARTCONFIG_START_CONFIG_DEFAULT();
err = esp_smartconfig_set_type(SC_TYPE_ESPTOUCH);

if (type == SC_TYPE_ESPTOUCH_V2){
conf.esp_touch_v2_enable_crypt = true;
conf.esp_touch_v2_key = crypt_key;
}

err = esp_smartconfig_set_type(type);
if (err != ESP_OK) {
log_e("SmartConfig Set Type Failed!");
return false;
Expand Down
2 changes: 1 addition & 1 deletion libraries/WiFi/src/WiFiSTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class WiFiSTAClass
static bool _autoReconnect;

public:
bool beginSmartConfig();
bool beginSmartConfig(smartconfig_type_t type = SC_TYPE_ESPTOUCH, char* crypt_key = NULL);
bool stopSmartConfig();
bool smartConfigDone();

Expand Down
60 changes: 60 additions & 0 deletions variants/esp32da/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <stdint.h>

#define EXTERNAL_NUM_INTERRUPTS 16
#define NUM_DIGITAL_PINS 40
#define NUM_ANALOG_INPUTS 16

#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1)
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
#define digitalPinHasPWM(p) (p < 34)

static const uint8_t TX = 1;
static const uint8_t RX = 3;

static const uint8_t SDA = 21;
static const uint8_t SCL = 22;

static const uint8_t SS = 5;
static const uint8_t MOSI = 23;
static const uint8_t MISO = 19;
static const uint8_t SCK = 18;

static const uint8_t A0 = 36;
static const uint8_t A3 = 39;
static const uint8_t A4 = 32;
static const uint8_t A5 = 33;
static const uint8_t A6 = 34;
static const uint8_t A7 = 35;
static const uint8_t A10 = 4;
static const uint8_t A11 = 0;
static const uint8_t A12 = 2;
static const uint8_t A13 = 15;
static const uint8_t A14 = 13;
static const uint8_t A15 = 12;
static const uint8_t A16 = 14;
static const uint8_t A17 = 27;
static const uint8_t A18 = 25;
static const uint8_t A19 = 26;

static const uint8_t T0 = 4;
static const uint8_t T1 = 0;
static const uint8_t T2 = 2;
static const uint8_t T3 = 15;
static const uint8_t T4 = 13;
static const uint8_t T5 = 12;
static const uint8_t T6 = 14;
static const uint8_t T7 = 27;
static const uint8_t T8 = 33;
static const uint8_t T9 = 32;

static const uint8_t DAC1 = 25;
static const uint8_t DAC2 = 26;

#define BOARD_HAS_DUAL_ANTENNA
static const uint8_t ANT1 = 2;
static const uint8_t ANT2 = 25;

#endif /* Pins_Arduino_h */