Skip to content

Commit 8b3bb1f

Browse files
authored
Merge branch 'master' into pr-heap-refactor3
2 parents 6dfd46a + b565b86 commit 8b3bb1f

File tree

116 files changed

+3579
-188
lines changed

Some content is hidden

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

116 files changed

+3579
-188
lines changed

boards.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,18 @@ generic.menu.sdk.nonosdk221=nonos-sdk 2.2.1 (legacy)
365365
generic.menu.sdk.nonosdk221.build.sdk=NONOSDK221
366366
generic.menu.sdk.nonosdk3v0=nonos-sdk pre-3 (180626 known issues)
367367
generic.menu.sdk.nonosdk3v0.build.sdk=NONOSDK3V0
368+
generic.menu.sdk.nonosdk300=nonos-sdk 3.0.0
369+
generic.menu.sdk.nonosdk300.build.sdk=NONOSDK300
370+
generic.menu.sdk.nonosdk301=nonos-sdk 3.0.1
371+
generic.menu.sdk.nonosdk301.build.sdk=NONOSDK301
372+
generic.menu.sdk.nonosdk302=nonos-sdk 3.0.2
373+
generic.menu.sdk.nonosdk302.build.sdk=NONOSDK302
374+
generic.menu.sdk.nonosdk303=nonos-sdk 3.0.3
375+
generic.menu.sdk.nonosdk303.build.sdk=NONOSDK303
376+
generic.menu.sdk.nonosdk304=nonos-sdk 3.0.4
377+
generic.menu.sdk.nonosdk304.build.sdk=NONOSDK304
378+
generic.menu.sdk.nonosdk305=nonos-sdk 3.0.5
379+
generic.menu.sdk.nonosdk305.build.sdk=NONOSDK305
368380
generic.menu.ip.lm2f=v2 Lower Memory
369381
generic.menu.ip.lm2f.build.lwip_include=lwip2/include
370382
generic.menu.ip.lm2f.build.lwip_lib=-llwip2-536-feat
@@ -710,6 +722,18 @@ esp8285.menu.sdk.nonosdk221=nonos-sdk 2.2.1 (legacy)
710722
esp8285.menu.sdk.nonosdk221.build.sdk=NONOSDK221
711723
esp8285.menu.sdk.nonosdk3v0=nonos-sdk pre-3 (180626 known issues)
712724
esp8285.menu.sdk.nonosdk3v0.build.sdk=NONOSDK3V0
725+
esp8285.menu.sdk.nonosdk300=nonos-sdk 3.0.0
726+
esp8285.menu.sdk.nonosdk300.build.sdk=NONOSDK300
727+
esp8285.menu.sdk.nonosdk301=nonos-sdk 3.0.1
728+
esp8285.menu.sdk.nonosdk301.build.sdk=NONOSDK301
729+
esp8285.menu.sdk.nonosdk302=nonos-sdk 3.0.2
730+
esp8285.menu.sdk.nonosdk302.build.sdk=NONOSDK302
731+
esp8285.menu.sdk.nonosdk303=nonos-sdk 3.0.3
732+
esp8285.menu.sdk.nonosdk303.build.sdk=NONOSDK303
733+
esp8285.menu.sdk.nonosdk304=nonos-sdk 3.0.4
734+
esp8285.menu.sdk.nonosdk304.build.sdk=NONOSDK304
735+
esp8285.menu.sdk.nonosdk305=nonos-sdk 3.0.5
736+
esp8285.menu.sdk.nonosdk305.build.sdk=NONOSDK305
713737
esp8285.menu.ip.lm2f=v2 Lower Memory
714738
esp8285.menu.ip.lm2f.build.lwip_include=lwip2/include
715739
esp8285.menu.ip.lm2f.build.lwip_lib=-llwip2-536-feat

cores/esp8266/FS.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,15 @@ File File::openNextFile() {
173173
return _fakeDir->openFile("r");
174174
}
175175

176-
String File::readString()
177-
{
176+
String File::readString() {
178177
String ret;
179178
ret.reserve(size() - position());
180-
char temp[256+1];
181-
int countRead = readBytes(temp, sizeof(temp)-1);
182-
while (countRead > 0)
183-
{
184-
temp[countRead] = 0;
185-
ret += temp;
186-
countRead = readBytes(temp, sizeof(temp)-1);
187-
}
179+
uint8_t temp[256];
180+
int countRead;
181+
do {
182+
countRead = read(temp, sizeof(temp));
183+
ret.concat((const char*)temp, countRead);
184+
} while (countRead > 0);
188185
return ret;
189186
}
190187

cores/esp8266/core_esp8266_main.cpp

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,77 @@ extern "C" void flashinit (void);
404404
uint32_t __flashindex;
405405
#endif
406406

407+
#if (NONOSDK >= (0x30000))
408+
409+
extern "C" void ICACHE_FLASH_ATTR user_pre_init(void)
410+
{
411+
uint32_t rf_cal = 0;
412+
uint32_t phy_data = 0;
413+
uint32_t system_parameter = 0;
414+
415+
switch (system_get_flash_size_map())
416+
{
417+
case FLASH_SIZE_2M:
418+
rf_cal = 0x3b000;
419+
phy_data = 0x3c000;
420+
system_parameter = 0x3d000;
421+
break;
422+
case FLASH_SIZE_4M_MAP_256_256:
423+
rf_cal = 0x7b000;
424+
phy_data = 0x7c000;
425+
system_parameter = 0x7d000;
426+
break;
427+
case FLASH_SIZE_8M_MAP_512_512:
428+
rf_cal = 0xfb000;
429+
phy_data = 0xfc000;
430+
system_parameter = 0xfd000;
431+
break;
432+
case FLASH_SIZE_16M_MAP_512_512:
433+
case FLASH_SIZE_16M_MAP_1024_1024:
434+
rf_cal = 0x1fb000;
435+
phy_data = 0x1fc000;
436+
system_parameter = 0x1fd000;
437+
break;
438+
case FLASH_SIZE_32M_MAP_512_512:
439+
case FLASH_SIZE_32M_MAP_1024_1024:
440+
case FLASH_SIZE_32M_MAP_2048_2048:
441+
rf_cal = 0x3fb000;
442+
phy_data = 0x3fc000;
443+
system_parameter = 0x3fd000;
444+
break;
445+
case FLASH_SIZE_64M_MAP_1024_1024:
446+
rf_cal = 0x7fb000;
447+
phy_data = 0x7fc000;
448+
system_parameter = 0x7fd000;
449+
break;
450+
case FLASH_SIZE_128M_MAP_1024_1024:
451+
rf_cal = 0xffb000;
452+
phy_data = 0xffc000;
453+
system_parameter = 0xffd000;
454+
break;
455+
}
456+
457+
extern uint32_t user_rf_cal_sector_set(void);
458+
user_rf_cal_sector_set();
459+
460+
const partition_item_t at_partition_table[] =
461+
{
462+
{ SYSTEM_PARTITION_RF_CAL, rf_cal, 0x1000 },
463+
{ SYSTEM_PARTITION_PHY_DATA, phy_data, 0x1000 },
464+
{ SYSTEM_PARTITION_SYSTEM_PARAMETER, system_parameter, 0x3000 },
465+
};
466+
system_partition_table_regist(at_partition_table, sizeof(at_partition_table) / sizeof(at_partition_table[0]), system_get_flash_size_map());
467+
}
468+
469+
#endif
470+
407471
extern "C" void user_init(void) {
472+
473+
#if (NONOSDK >= (0x30000))
474+
extern void user_rf_pre_init();
475+
user_rf_pre_init();
476+
#endif
477+
408478
struct rst_info *rtc_info_ptr = system_get_rst_info();
409479
memcpy((void *) &resetInfo, (void *) rtc_info_ptr, sizeof(resetInfo));
410480

@@ -426,7 +496,7 @@ extern "C" void user_init(void) {
426496
install_vm_exception_handler();
427497
#endif
428498

429-
#if defined(NON32XFER_HANDLER) || defined(MMU_IRAM_HEAP)
499+
#if defined(NON32XFER_HANDLER) || (defined(MMU_IRAM_HEAP) && (NONOSDK < (0x30000 - 1)))
430500
install_non32xfer_exception_handler();
431501
#endif
432502

cores/esp8266/core_esp8266_non32xfer.cpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@
2626
* Code taken directly from @pvvx's public domain code in
2727
* https://github.com/pvvx/esp8266web/blob/master/app/sdklib/system/app_main.c
2828
*
29+
* In Espressif versions NONOSDK v3.0.0+ a similar feature was added
30+
* load_non_32_wide_handler. Theirs is always loaded. Add weak attribute to
31+
* theirs so we can choose by adding an alias to ours.
2932
*
3033
*/
3134

3235
#include <Arduino.h>
36+
#include <user_interface.h>
3337
#define VERIFY_C_ASM_EXCEPTION_FRAME_STRUCTURE
3438
#include <esp8266_undocumented.h>
3539
#include <core_esp8266_non32xfer.h>
@@ -58,10 +62,13 @@ extern "C" {
5862

5963
#define EXCCAUSE_LOAD_STORE_ERROR 3 /* Non 32-bit read/write error */
6064

65+
#if (defined(NON32XFER_HANDLER) || defined(MMU_IRAM_HEAP)) && (NONOSDK < (0x30000 - 1))
6166
static fn_c_exception_handler_t old_c_handler = NULL;
67+
#endif
6268

69+
#if defined(NON32XFER_HANDLER) || (defined(MMU_IRAM_HEAP) && (NONOSDK < (0x30000 - 1)))
6370
static
64-
IRAM_ATTR void non32xfer_exception_handler(struct __exception_frame *ef, int cause)
71+
IRAM_ATTR void non32xfer_exception_handler(struct __exception_frame *ef, [[maybe_unused]] int cause)
6572
{
6673
do {
6774
uint32_t insn, excvaddr;
@@ -138,6 +145,7 @@ IRAM_ATTR void non32xfer_exception_handler(struct __exception_frame *ef, int cau
138145
} while(false);
139146

140147
/* Fail request, die */
148+
#if (NONOSDK < (0x30000 - 1))
141149
/*
142150
The old handler points to the SDK. Be alert for HWDT when Calling with
143151
INTLEVEL != 0. I cannot create it any more. I thought I saw this as a
@@ -148,16 +156,23 @@ IRAM_ATTR void non32xfer_exception_handler(struct __exception_frame *ef, int cau
148156
old_c_handler(ef, cause);
149157
return;
150158
}
151-
159+
#endif
152160
/*
153161
Calling _xtos_unhandled_exception(ef, cause) in the Boot ROM, gets us a
154162
hardware wdt.
155163
156164
Use panic instead as a fall back. It will produce a stack trace.
157165
*/
166+
#if defined(DEBUG_ESP_PORT) || defined(DEBUG_ESP_MMU)
158167
panic();
168+
#else
169+
// For non-debug builds, save on resources
170+
abort();
171+
#endif
159172
}
173+
#endif // #if defined(NON32XFER_HANDLER) || (defined(MMU_IRAM_HEAP) && (NONOSDK < (0x30000 - 1)))
160174

175+
#if (defined(NON32XFER_HANDLER) || defined(MMU_IRAM_HEAP)) && (NONOSDK < (0x30000 - 1))
161176
/*
162177
To operate reliably, this module requires the new
163178
`_xtos_set_exception_handler` from `exc-sethandler.cpp` and
@@ -174,5 +189,17 @@ void install_non32xfer_exception_handler(void) {
174189
non32xfer_exception_handler);
175190
}
176191
}
192+
#else
193+
// For v3.0.x SDKs, no need for install - call_user_start will do the job.
194+
// Need this for build dependencies
195+
void install_non32xfer_exception_handler(void) __attribute__((weak));
196+
void install_non32xfer_exception_handler(void) {}
197+
#endif
198+
199+
#if defined(NON32XFER_HANDLER)
200+
// For SDKs 3.0.x, we made load_non_32_wide_handler in
201+
// libmain.c:user_exceptions.o a weak symbol allowing this override to work.
202+
extern void load_non_32_wide_handler(struct __exception_frame *ef, int cause) __attribute__((alias("non32xfer_exception_handler")));
203+
#endif
177204

178205
};

cores/esp8266/exc-sethandler.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@
3939
* architecture, I am not convinced it can be done safely.
4040
*
4141
*/
42+
#include <user_interface.h> // need NONOSDK
4243

43-
#if defined(NON32XFER_HANDLER) || defined(MMU_IRAM_HEAP) || defined(NEW_EXC_C_WRAPPER) || defined(MMU_EXTERNAL_HEAP)
44+
#if defined(NON32XFER_HANDLER) || defined(MMU_IRAM_HEAP) || \
45+
defined(NEW_EXC_C_WRAPPER) || defined(MMU_EXTERNAL_HEAP) || (NONOSDK >= (0x30000 - 1))
4446

4547
/*
4648
* The original module source code came from:

cores/esp8266/heap.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,61 @@ void* _heap_abi_malloc(size_t size, bool unhandled, const void* caller)
670670
}
671671
#endif
672672

673+
#if (NONOSDK >= (0x30000))
674+
////////////////////////////////////////////////////////////////////////////////
675+
/*
676+
New for NON-OS SDK 3.0.0 and up
677+
Needed for WPA2 Enterprise support. This was not present in SDK pre 3.0
678+
679+
The NON-OS SDK 3.0.x has breaking changes to pvPortMalloc. They added one more
680+
argument for selecting a heap. To avoid breaking the build, I renamed their
681+
broken version pvEsprMalloc. To be used, the LIBS need to be edited.
682+
683+
They also added pvPortZallocIram and pvPortCallocIram, which are not a
684+
problem.
685+
686+
WPA2 Enterprise connect crashing is fixed at v3.0.2 and up.
687+
688+
Not used for unreleased version NONOSDK3V0.
689+
*/
690+
void* IRAM_ATTR sdk3_pvPortMalloc(size_t size, const char* file, int line, bool iram)
691+
{
692+
if (iram) {
693+
HeapSelectIram ephemeral;
694+
return heap_pvPortMalloc(size, file, line);
695+
} else {
696+
HeapSelectDram ephemeral;
697+
return heap_pvPortMalloc(size, file, line);
698+
}
699+
}
700+
701+
void* IRAM_ATTR pvPortCallocIram(size_t count, size_t size, const char* file, int line)
702+
{
703+
HeapSelectIram ephemeral;
704+
return heap_pvPortCalloc(count, size, file, line);
705+
}
706+
707+
void* IRAM_ATTR pvPortZallocIram(size_t size, const char* file, int line)
708+
{
709+
HeapSelectIram ephemeral;
710+
return heap_pvPortZalloc(size, file, line);
711+
}
712+
713+
/*
714+
uint32_t IRAM_ATTR user_iram_memory_is_enabled(void)
715+
{
716+
return CONFIG_ENABLE_IRAM_MEMORY;
717+
}
718+
719+
We do not need the function user_iram_memory_is_enabled().
720+
1. It was used by mem_manager.o which was replaced with this custom heap
721+
implementation. IRAM memory selection is handled differently.
722+
2. In libmain.a, Cache_Read_Enable_New uses it for cache size. However, When
723+
using IRAM for memory or running with 48K IRAM for code, we use a
724+
replacement Cache_Read_Enable to correct the cache size ignoring
725+
Cache_Read_Enable_New's selected value.
726+
*/
727+
#endif
673728
};
674729

675730
#if defined(ENABLE_THICK_DEBUG_WRAPPERS)

0 commit comments

Comments
 (0)