Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 774f275

Browse filesBrowse files
authored
Merge branch 'master' into release/v3.1.x
2 parents af40992 + f083e2d commit 774f275
Copy full SHA for 774f275

File tree

9 files changed

+732
-32
lines changed
Filter options

9 files changed

+732
-32
lines changed

‎boards.txt

Copy file name to clipboardExpand all lines: boards.txt
+473Lines changed: 473 additions & 0 deletions
Large diffs are not rendered by default.

‎cores/esp32/HardwareSerial.cpp

Copy file name to clipboardExpand all lines: cores/esp32/HardwareSerial.cpp
+9-14Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,14 @@
2424
#endif
2525

2626
void serialEvent(void) __attribute__((weak));
27-
void serialEvent(void) {}
2827

2928
#if SOC_UART_HP_NUM > 1
3029
void serialEvent1(void) __attribute__((weak));
31-
void serialEvent1(void) {}
32-
#endif /* SOC_UART_HP_NUM > 1 */
30+
#endif /* SOC_UART_NUM > 1 */
3331

3432
#if SOC_UART_HP_NUM > 2
3533
void serialEvent2(void) __attribute__((weak));
36-
void serialEvent2(void) {}
37-
#endif /* SOC_UART_HP_NUM > 2 */
34+
#endif /* SOC_UART_NUM > 2 */
3835

3936
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
4037
// There is always Seria0 for UART0
@@ -48,37 +45,35 @@ HardwareSerial Serial2(2);
4845

4946
#if HWCDC_SERIAL_IS_DEFINED == 1 // Hardware JTAG CDC Event
5047
extern void HWCDCSerialEvent(void) __attribute__((weak));
51-
void HWCDCSerialEvent(void) {}
5248
#endif
5349

5450
#if USB_SERIAL_IS_DEFINED == 1 // Native USB CDC Event
5551
// Used by Hardware Serial for USB CDC events
5652
extern void USBSerialEvent(void) __attribute__((weak));
57-
void USBSerialEvent(void) {}
5853
#endif
5954

6055
void serialEventRun(void) {
6156
#if HWCDC_SERIAL_IS_DEFINED == 1 // Hardware JTAG CDC Event
62-
if (HWCDCSerial.available()) {
57+
if (HWCDCSerialEvent && HWCDCSerial.available()) {
6358
HWCDCSerialEvent();
6459
}
6560
#endif
6661
#if USB_SERIAL_IS_DEFINED == 1 // Native USB CDC Event
67-
if (USBSerial.available()) {
62+
if (USBSerialEvent && USBSerial.available()) {
6863
USBSerialEvent();
6964
}
7065
#endif
7166
// UART0 is default serialEvent()
72-
if (Serial0.available()) {
67+
if (serialEvent && Serial0.available()) {
7368
serialEvent();
7469
}
75-
#if SOC_UART_HP_NUM > 1
76-
if (Serial1.available()) {
70+
#if SOC_UART_NUM > 1
71+
if (serialEvent1 && Serial1.available()) {
7772
serialEvent1();
7873
}
7974
#endif
80-
#if SOC_UART_HP_NUM > 2
81-
if (Serial2.available()) {
75+
#if SOC_UART_NUM > 2
76+
if (serialEvent2 && Serial2.available()) {
8277
serialEvent2();
8378
}
8479
#endif

‎libraries/AsyncUDP/src/AsyncUDP.cpp

Copy file name to clipboardExpand all lines: libraries/AsyncUDP/src/AsyncUDP.cpp
+21-18Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ extern "C" {
1515

1616
#include "lwip/priv/tcpip_priv.h"
1717

18+
#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING
19+
#define UDP_MUTEX_LOCK() \
20+
if (!sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER)) { \
21+
LOCK_TCPIP_CORE(); \
22+
}
23+
24+
#define UDP_MUTEX_UNLOCK() \
25+
if (sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER)) { \
26+
UNLOCK_TCPIP_CORE(); \
27+
}
28+
#else // CONFIG_LWIP_TCPIP_CORE_LOCKING
29+
#define UDP_MUTEX_LOCK()
30+
#define UDP_MUTEX_UNLOCK()
31+
#endif // CONFIG_LWIP_TCPIP_CORE_LOCKING
32+
1833
static const char *netif_ifkeys[TCPIP_ADAPTER_IF_MAX] = {"WIFI_STA_DEF", "WIFI_AP_DEF", "ETH_DEF", "PPP_DEF"};
1934

2035
static esp_err_t tcpip_adapter_get_netif(tcpip_adapter_if_t tcpip_if, void **netif) {
@@ -28,7 +43,9 @@ static esp_err_t tcpip_adapter_get_netif(tcpip_adapter_if_t tcpip_if, void **net
2843
if (netif_index < 0) {
2944
return ESP_FAIL;
3045
}
46+
UDP_MUTEX_LOCK();
3147
*netif = (void *)netif_get_by_index(netif_index);
48+
UDP_MUTEX_UNLOCK();
3249
} else {
3350
*netif = netif_default;
3451
}
@@ -232,9 +249,6 @@ static bool _udp_task_stop(){
232249
}
233250
*/
234251

235-
#define UDP_MUTEX_LOCK() //xSemaphoreTake(_lock, portMAX_DELAY)
236-
#define UDP_MUTEX_UNLOCK() //xSemaphoreGive(_lock)
237-
238252
AsyncUDPMessage::AsyncUDPMessage(size_t size) {
239253
_index = 0;
240254
if (size > CONFIG_TCP_MSS) {
@@ -473,12 +487,14 @@ bool AsyncUDP::_init() {
473487
if (_pcb) {
474488
return true;
475489
}
490+
UDP_MUTEX_LOCK();
476491
_pcb = udp_new();
477492
if (!_pcb) {
493+
UDP_MUTEX_UNLOCK();
478494
return false;
479495
}
480-
//_lock = xSemaphoreCreateMutex();
481496
udp_recv(_pcb, &_udp_recv, (void *)this);
497+
UDP_MUTEX_UNLOCK();
482498
return true;
483499
}
484500

@@ -493,22 +509,19 @@ AsyncUDP::~AsyncUDP() {
493509
close();
494510
UDP_MUTEX_LOCK();
495511
udp_recv(_pcb, NULL, NULL);
512+
UDP_MUTEX_UNLOCK();
496513
_udp_remove(_pcb);
497514
_pcb = NULL;
498-
UDP_MUTEX_UNLOCK();
499-
//vSemaphoreDelete(_lock);
500515
}
501516

502517
void AsyncUDP::close() {
503-
UDP_MUTEX_LOCK();
504518
if (_pcb != NULL) {
505519
if (_connected) {
506520
_udp_disconnect(_pcb);
507521
}
508522
_connected = false;
509523
//todo: unjoin multicast group
510524
}
511-
UDP_MUTEX_UNLOCK();
512525
}
513526

514527
bool AsyncUDP::connect(const ip_addr_t *addr, uint16_t port) {
@@ -520,14 +533,11 @@ bool AsyncUDP::connect(const ip_addr_t *addr, uint16_t port) {
520533
return false;
521534
}
522535
close();
523-
UDP_MUTEX_LOCK();
524536
_lastErr = _udp_connect(_pcb, addr, port);
525537
if (_lastErr != ERR_OK) {
526-
UDP_MUTEX_UNLOCK();
527538
return false;
528539
}
529540
_connected = true;
530-
UDP_MUTEX_UNLOCK();
531541
return true;
532542
}
533543

@@ -544,13 +554,10 @@ bool AsyncUDP::listen(const ip_addr_t *addr, uint16_t port) {
544554
IP_SET_TYPE_VAL(_pcb->local_ip, addr->type);
545555
IP_SET_TYPE_VAL(_pcb->remote_ip, addr->type);
546556
}
547-
UDP_MUTEX_LOCK();
548557
if (_udp_bind(_pcb, addr, port) != ERR_OK) {
549-
UDP_MUTEX_UNLOCK();
550558
return false;
551559
}
552560
_connected = true;
553-
UDP_MUTEX_UNLOCK();
554561
return true;
555562
}
556563

@@ -624,12 +631,10 @@ bool AsyncUDP::listenMulticast(const ip_addr_t *addr, uint16_t port, uint8_t ttl
624631
return false;
625632
}
626633

627-
UDP_MUTEX_LOCK();
628634
_pcb->mcast_ttl = ttl;
629635
_pcb->remote_port = port;
630636
ip_addr_copy(_pcb->remote_ip, *addr);
631637
//ip_addr_copy(_pcb->remote_ip, ip_addr_any_type);
632-
UDP_MUTEX_UNLOCK();
633638

634639
return true;
635640
}
@@ -651,7 +656,6 @@ size_t AsyncUDP::writeTo(const uint8_t *data, size_t len, const ip_addr_t *addr,
651656
if (pbt != NULL) {
652657
uint8_t *dst = reinterpret_cast<uint8_t *>(pbt->payload);
653658
memcpy(dst, data, len);
654-
UDP_MUTEX_LOCK();
655659
if (tcpip_if < TCPIP_ADAPTER_IF_MAX) {
656660
void *nif = NULL;
657661
tcpip_adapter_get_netif((tcpip_adapter_if_t)tcpip_if, &nif);
@@ -663,7 +667,6 @@ size_t AsyncUDP::writeTo(const uint8_t *data, size_t len, const ip_addr_t *addr,
663667
} else {
664668
_lastErr = _udp_sendto(_pcb, pbt, addr, port);
665669
}
666-
UDP_MUTEX_UNLOCK();
667670
pbuf_free(pbt);
668671
if (_lastErr < ERR_OK) {
669672
return 0;

‎tests/validation/psram/ci.json

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"platforms": {
3+
"qemu": false,
4+
"wokwi": false
5+
},
6+
"requires": [
7+
"CONFIG_SPIRAM=y"
8+
],
9+
"targets": {
10+
"esp32c3": false,
11+
"esp32c6": false,
12+
"esp32h2": false
13+
}
14+
}

‎tests/validation/psram/psram.ino

Copy file name to clipboard
+112Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#include <Arduino.h>
2+
#include <unity.h>
3+
4+
#define MAX_TEST_SIZE 512 * 1024 // 512KB
5+
6+
void *buf = NULL;
7+
8+
void test_malloc_success(void) {
9+
buf = ps_malloc(MAX_TEST_SIZE);
10+
TEST_ASSERT_NOT_NULL(buf);
11+
free(buf);
12+
buf = NULL;
13+
}
14+
15+
void test_calloc_success(void) {
16+
buf = ps_calloc(MAX_TEST_SIZE, 1);
17+
TEST_ASSERT_NOT_NULL(buf);
18+
free(buf);
19+
buf = NULL;
20+
}
21+
22+
void test_realloc_success(void) {
23+
buf = ps_malloc(MAX_TEST_SIZE);
24+
TEST_ASSERT_NOT_NULL(buf);
25+
buf = ps_realloc(buf, MAX_TEST_SIZE + 1024);
26+
TEST_ASSERT_NOT_NULL(buf);
27+
free(buf);
28+
buf = NULL;
29+
}
30+
31+
void test_malloc_fail(void) {
32+
buf = ps_malloc(0xFFFFFFFF);
33+
TEST_ASSERT_NULL(buf);
34+
}
35+
36+
void test_memset_all_zeroes(void) {
37+
memset(buf, 0, MAX_TEST_SIZE);
38+
for (size_t i = 0; i < MAX_TEST_SIZE; i++) {
39+
TEST_ASSERT_EQUAL(0, ((uint8_t *)buf)[i]);
40+
}
41+
}
42+
43+
void test_memset_all_ones(void) {
44+
memset(buf, 0xFF, MAX_TEST_SIZE);
45+
for (size_t i = 0; i < MAX_TEST_SIZE; i++) {
46+
TEST_ASSERT_EQUAL(0xFF, ((uint8_t *)buf)[i]);
47+
}
48+
}
49+
50+
void test_memset_alternating(void) {
51+
for (size_t i = 0; i < MAX_TEST_SIZE; i++) {
52+
((uint8_t *)buf)[i] = i % 2 == 0 ? 0x00 : 0xFF;
53+
}
54+
memset(buf, 0xAA, MAX_TEST_SIZE);
55+
for (size_t i = 0; i < MAX_TEST_SIZE; i++) {
56+
TEST_ASSERT_EQUAL(0xAA, ((uint8_t *)buf)[i]);
57+
}
58+
}
59+
60+
void test_memset_random(void) {
61+
for (size_t i = 0; i < MAX_TEST_SIZE; i++) {
62+
((uint8_t *)buf)[i] = random(0, 256);
63+
}
64+
memset(buf, 0x55, MAX_TEST_SIZE);
65+
for (size_t i = 0; i < MAX_TEST_SIZE; i++) {
66+
TEST_ASSERT_EQUAL(0x55, ((uint8_t *)buf)[i]);
67+
}
68+
}
69+
70+
void test_memcpy(void) {
71+
void *buf2 = malloc(1024); // 1KB
72+
TEST_ASSERT_NOT_NULL(buf2);
73+
memset(buf, 0x55, MAX_TEST_SIZE);
74+
memset(buf2, 0xAA, 1024);
75+
76+
#pragma GCC diagnostic push
77+
#pragma GCC diagnostic ignored "-Wpointer-arith"
78+
79+
for (size_t i = 0; i < MAX_TEST_SIZE; i += 1024) {
80+
memcpy(buf + i, buf2, 1024);
81+
}
82+
83+
for (size_t i = 0; i < MAX_TEST_SIZE; i += 1024) {
84+
TEST_ASSERT_NULL(memcmp(buf + i, buf2, 1024));
85+
}
86+
87+
#pragma GCC diagnostic pop
88+
89+
free(buf2);
90+
}
91+
92+
void setup() {
93+
Serial.begin(115200);
94+
while (!Serial) {
95+
delay(10);
96+
}
97+
98+
UNITY_BEGIN();
99+
RUN_TEST(test_malloc_success);
100+
RUN_TEST(test_malloc_fail);
101+
RUN_TEST(test_calloc_success);
102+
RUN_TEST(test_realloc_success);
103+
buf = ps_malloc(MAX_TEST_SIZE);
104+
RUN_TEST(test_memset_all_zeroes);
105+
RUN_TEST(test_memset_all_ones);
106+
RUN_TEST(test_memset_alternating);
107+
RUN_TEST(test_memset_random);
108+
RUN_TEST(test_memcpy);
109+
UNITY_END();
110+
}
111+
112+
void loop() {}

‎tests/validation/psram/test_psram.py

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def test_psram(dut):
2+
dut.expect_unity_test_output(timeout=120)
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#ifndef Pins_Arduino_h
2+
#define Pins_Arduino_h
3+
4+
#include <stdint.h>
5+
6+
static const uint8_t LED_BUILTIN = 2;
7+
#define BUILTIN_LED LED_BUILTIN // backward compatibility
8+
#define LED_BUILTIN LED_BUILTIN // allow testing #ifdef LED_BUILTIN
9+
10+
static const uint8_t A0 = 14;
11+
static const uint8_t A1 = 13;
12+
static const uint8_t A2 = 12;
13+
static const uint8_t A3 = 4;
14+
static const uint8_t A4 = 2;
15+
static const uint8_t A5 = 0;
16+
17+
static const uint8_t TX = 1;
18+
static const uint8_t RX = 3;
19+
20+
static const uint8_t TX_4G = 17;
21+
static const uint8_t RX_4G = 16;
22+
23+
static const uint8_t SDA = 21;
24+
static const uint8_t SCL = 22;
25+
26+
static const uint8_t SS = 5;
27+
static const uint8_t MOSI = 23;
28+
static const uint8_t MISO = 19;
29+
static const uint8_t SCK = 18;
30+
31+
#endif /* Pins_Arduino_h */

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.