Skip to content

Commit f967e98

Browse files
committed
Heap addendum to handle changes in NON-OS SDK 3.0.x
The NON-OS SDK 3.0.x has breaking changes to pvPortMalloc. They added one more argument for selecting a heap. To avoid breaking the build, I renamed their broken version pvEsprMalloc. To be used, the LIBS need to be edited. They also added pvPortZallocIram and pvPortCallocIram, which are not a problem. WPA2 Enterprise connect crashing is fixed at v3.0.2 and up.
1 parent da48a52 commit f967e98

File tree

2 files changed

+67
-6
lines changed

2 files changed

+67
-6
lines changed

cores/esp8266/heap.cpp

+42-5
Original file line numberDiff line numberDiff line change
@@ -356,25 +356,25 @@ void system_show_malloc(void)
356356
void* IRAM_ATTR pvPortMalloc(size_t size, const char* file, int line)
357357
{
358358
HeapSelectDram ephemeral;
359-
return heap_pvPortMalloc(size, file, line);;
359+
return heap_pvPortMalloc(size, file, line);;
360360
}
361361

362362
void* IRAM_ATTR pvPortCalloc(size_t count, size_t size, const char* file, int line)
363363
{
364364
HeapSelectDram ephemeral;
365-
return heap_pvPortCalloc(count, size, file, line);
365+
return heap_pvPortCalloc(count, size, file, line);
366366
}
367367

368368
void* IRAM_ATTR pvPortRealloc(void *ptr, size_t size, const char* file, int line)
369369
{
370370
HeapSelectDram ephemeral;
371-
return heap_pvPortRealloc(ptr, size, file, line);
371+
return heap_pvPortRealloc(ptr, size, file, line);
372372
}
373373

374374
void* IRAM_ATTR pvPortZalloc(size_t size, const char* file, int line)
375375
{
376376
HeapSelectDram ephemeral;
377-
return heap_pvPortZalloc(size, file, line);
377+
return heap_pvPortZalloc(size, file, line);
378378
}
379379

380380
void IRAM_ATTR vPortFree(void *ptr, const char* file, int line)
@@ -384,7 +384,44 @@ void IRAM_ATTR vPortFree(void *ptr, const char* file, int line)
384384
// correct context. umm_malloc free internally determines the correct heap.
385385
HeapSelectDram ephemeral;
386386
#endif
387-
return heap_vPortFree(ptr, file, line);
387+
return heap_vPortFree(ptr, file, line);
388+
}
389+
390+
////////////////////////////////////////////////////////////////////////////////
391+
/*
392+
New for NON-OS SDK 3.0.0 and up
393+
Needed for WPA2 Enterprise support. This was not present in SDK pre 3.0
394+
395+
The NON-OS SDK 3.0.x has breaking changes to pvPortMalloc. They added one more
396+
argument for selecting a heap. To avoid breaking the build, I renamed their
397+
broken version pvEsprMalloc. To be used, the LIBS need to be edited.
398+
399+
They also added pvPortZallocIram and pvPortCallocIram, which are not a
400+
problem.
401+
402+
WPA2 Enterprise connect crashing is fixed at v3.0.2 and up.
403+
*/
404+
void* IRAM_ATTR pvEsprMalloc(size_t size, const char* file, int line, bool iram)
405+
{
406+
if (iram) {
407+
HeapSelectIram ephemeral;
408+
return heap_pvPortMalloc(size, file, line);;
409+
} else {
410+
HeapSelectDram ephemeral;
411+
return heap_pvPortMalloc(size, file, line);;
412+
}
413+
}
414+
415+
void* IRAM_ATTR pvPortCallocIram(size_t count, size_t size, const char* file, int line)
416+
{
417+
HeapSelectIram ephemeral;
418+
return heap_pvPortCalloc(count, size, file, line);
419+
}
420+
421+
void* IRAM_ATTR pvPortZallocIram(size_t size, const char* file, int line)
422+
{
423+
HeapSelectIram ephemeral;
424+
return heap_pvPortZalloc(size, file, line);
388425
}
389426

390427
};

cores/esp8266/wpa2_eap_patch.cpp

+25-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,25 @@
55
* modules.
66
*
77
*/
8-
98
#include <string.h>
109
#include <ets_sys.h>
1110
#include <pgmspace.h>
1211
#include "coredecls.h"
1312

13+
#if defined(NONOSDK22x_190703) || \
14+
defined(NONOSDK22x_191122) || \
15+
defined(NONOSDK22x_191105) || \
16+
defined(NONOSDK22x_191124) || \
17+
defined(NONOSDK22x_190313) || \
18+
defined(NONOSDK221) || \
19+
defined(NONOSDK3V0)
20+
21+
// These are broken for WPA Enterprise - no patch leave as is for now:
22+
// NONOSDK300
23+
// NONOSDK301
24+
//
25+
// These appear to work without a patch NONOSDK302 - NONOSDK305
26+
1427
#ifdef DEBUG_WPA2_EAP_PATCH
1528
#include "esp8266_undocumented.h"
1629
#define DEBUG_PRINTF ets_uart_printf
@@ -141,6 +154,17 @@ void patch_wpa2_eap_vPortFree_a12(void *ptr, const char* file, int line, void* a
141154

142155
};
143156

157+
#elif defined(NONOSDK300) || defined(NONOSDK301)
158+
#error "NONOSDK300 and NONOSDK301 will crash with WPA2 Enterpise connection. Use NONOSDK302 or later"
159+
160+
#elif defined(NONOSDK302) || defined(NONOSDK303) || defined(NONOSDK304) || defined(NONOSDK305)
161+
// WPA2 Enterpise connections appear to work without crashing
162+
163+
#else
164+
#error "Internal error: A new SDK has been added. This module must be updated."
165+
#error " Need to test WPA2 Enterpise connectivity."
166+
#endif
167+
144168
/*
145169
* This will minimize code space for non-wifi enterprise sketches which do not
146170
* need the patch and disable_extra4k_at_link_time().

0 commit comments

Comments
 (0)