@@ -395,51 +395,89 @@ void IRAM_ATTR vPortFree(void *ptr, const char* file, int line)
395
395
396
396
The NON-OS SDK 3.0.x has breaking changes to pvPortMalloc. They added one more
397
397
argument for selecting a heap. To avoid breaking the build, I renamed their
398
- broken version pvEsprMalloc. To be used, the LIBS need to be edited.
398
+ breaking version to sdk3_pvPortMalloc. To complete the fix, the LIBS need to
399
+ be edited.
399
400
400
- They also added pvPortZallocIram and pvPortCallocIram, which are not a
401
- problem.
401
+ Also in the release are low-level functions pvPortZallocIram and
402
+ pvPortCallocIram, which are not documented in the Espressif NONOS SDK manual.
403
+ No issues in providing replacements. For the non-Arduino ESP8266 applications,
404
+ pvPortZallocIram and pvPortCallocIram would have been selected through the
405
+ macros like os_malloc defined in `mem.h`.
406
+
407
+ OOM - Implementation strategy - Native v3.0 SDK
408
+ * For functions `pvPortMalloc(,,,true);` and `pvPortMallocIram(,,,);` on a
409
+ failed IRAM alloc, try DRAM.
410
+ * For function `pvPortMalloc(,,,false);` use DRAM only - on fail, do not
411
+ try IRAM.
402
412
403
413
WPA2 Enterprise connect crashing is fixed at v3.0.2 and up.
404
414
405
415
Not used for unreleased version NONOSDK3V0.
406
416
*/
417
+ #ifdef UMM_HEAP_IRAM
407
418
void * IRAM_ATTR sdk3_pvPortMalloc (size_t size, const char * file, int line, bool iram)
408
419
{
409
420
if (iram) {
410
421
HeapSelectIram ephemeral;
411
- return heap_pvPortMalloc (size, file, line);
412
- } else {
422
+ void * ret = heap_pvPortMalloc (size, file, line);
423
+ if (ret) return ret;
424
+ }
425
+ {
413
426
HeapSelectDram ephemeral;
414
427
return heap_pvPortMalloc (size, file, line);
415
428
}
416
429
}
417
430
418
431
void * IRAM_ATTR pvPortCallocIram (size_t count, size_t size, const char * file, int line)
419
432
{
420
- HeapSelectIram ephemeral;
421
- return heap_pvPortCalloc (count, size, file, line);
433
+ {
434
+ HeapSelectIram ephemeral;
435
+ void * ret = heap_pvPortCalloc (count, size, file, line);
436
+ if (ret) return ret;
437
+ }
438
+ {
439
+ HeapSelectDram ephemeral;
440
+ return heap_pvPortCalloc (count, size, file, line);
441
+ }
422
442
}
423
443
424
444
void * IRAM_ATTR pvPortZallocIram (size_t size, const char * file, int line)
425
445
{
426
- HeapSelectIram ephemeral;
427
- return heap_pvPortZalloc (size, file, line);
446
+ {
447
+ HeapSelectIram ephemeral;
448
+ void * ret = heap_pvPortZalloc (size, file, line);
449
+ if (ret) return ret;
450
+ }
451
+ {
452
+ HeapSelectDram ephemeral;
453
+ return heap_pvPortZalloc (size, file, line);
454
+ }
428
455
}
456
+ #define CONFIG_IRAM_MEMORY 1
429
457
430
- /*
431
- uint32_t IRAM_ATTR user_iram_memory_is_enabled(void)
432
- {
433
- return CONFIG_ENABLE_IRAM_MEMORY;
434
- }
458
+ #else
459
+ // For sdk3_pvPortMalloc, the bool argument is ignored and intentionally omitted.
460
+ extern " C" void * sdk3_pvPortMalloc (size_t size, const char * file, int line) __attribute__ ((alloc_size(1 ), malloc, nothrow, alias(" pvPortMalloc" )));
461
+ extern " C" void * pvPortCallocIram (size_t count, size_t size, const char * file, int line) __attribute__((alloc_size(1 , 2 ), malloc, nothrow, alias(" pvPortCalloc" )));
462
+ extern " C" void * pvPortZallocIram (size_t size, const char * file, int line) __attribute__((alloc_size(1 ), malloc, nothrow, alias(" pvPortZalloc" )));
463
+ #define CONFIG_IRAM_MEMORY 0
464
+ #endif // #ifdef UMM_HEAP_IRAM
435
465
466
+ /*
436
467
We do not need the function user_iram_memory_is_enabled().
437
468
1. It was used by mem_manager.o which was replaced with this custom heap
438
- implementation. IRAM memory selection is handled differently.
469
+ implementation. IRAM memory selection is handled differently for
470
+ Arduino ESP8266.
439
471
2. In libmain.a, Cache_Read_Enable_New uses it for cache size. However, When
440
472
using IRAM for memory or running with 48K IRAM for code, we use a
441
473
replacement Cache_Read_Enable to correct the cache size ignoring
442
474
Cache_Read_Enable_New's selected value.
475
+ 3. Create a linker conflicts in the event the sketch author tries to control
476
+ IRAM heap through this method.
443
477
*/
444
- #endif
478
+ uint32 IRAM_ATTR user_iram_memory_is_enabled (void )
479
+ {
480
+ return CONFIG_IRAM_MEMORY;
481
+ }
482
+ #endif // #if (NONOSDK >= (0x30000))
445
483
};
0 commit comments