@@ -678,53 +678,94 @@ void* _heap_abi_malloc(size_t size, bool unhandled, const void* caller)
678
678
679
679
The NON-OS SDK 3.0.x has breaking changes to pvPortMalloc. They added one more
680
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.
681
+ breaking version to sdk3_pvPortMalloc. To complete the fix, the LIBS need to
682
+ be edited.
682
683
683
- They also added pvPortZallocIram and pvPortCallocIram, which are not a
684
- problem.
684
+ Also in the release are low-level functions pvPortZallocIram and
685
+ pvPortCallocIram, which are not documented in the Espressif NONOS SDK manual.
686
+ No issues in providing replacements. For the non-Arduino ESP8266 applications,
687
+ pvPortZallocIram and pvPortCallocIram would have been selected through the
688
+ macros like os_malloc defined in `mem.h`.
689
+
690
+ OOM - Implementation strategy - Native v3.0 SDK
691
+ * For functions `pvPortMalloc(,,,true);` and `pvPortMallocIram(,,,);` on a
692
+ failed IRAM alloc, try DRAM.
693
+ * For function `pvPortMalloc(,,,false);` use DRAM only - on fail, do not
694
+ try IRAM.
685
695
686
696
WPA2 Enterprise connect crashing is fixed at v3.0.2 and up.
687
697
688
698
Not used for unreleased version NONOSDK3V0.
689
699
*/
700
+ #ifdef UMM_HEAP_IRAM
690
701
void * IRAM_ATTR sdk3_pvPortMalloc (size_t size, const char * file, int line, bool iram)
691
702
{
703
+ void * caller = __builtin_return_address (0 );
692
704
if (iram) {
693
705
HeapSelectIram ephemeral;
694
- return _heap_pvPortMalloc (size, file, line, __builtin_return_address (0 ));
695
- } else {
706
+ void * ret = _heap_pvPortMalloc (size, file, line, caller);
707
+ if (ret) return ret;
708
+ }
709
+ {
696
710
HeapSelectDram ephemeral;
697
- return _heap_pvPortMalloc (size, file, line, __builtin_return_address ( 0 ) );
711
+ return _heap_pvPortMalloc (size, file, line, caller );
698
712
}
699
713
}
700
714
701
715
void * IRAM_ATTR pvPortCallocIram (size_t count, size_t size, const char * file, int line)
702
716
{
703
- HeapSelectIram ephemeral;
704
- return _heap_pvPortCalloc (count, size, file, line, __builtin_return_address (0 ));
717
+ void * caller = __builtin_return_address (0 );
718
+ {
719
+ HeapSelectIram ephemeral;
720
+ void * ret = _heap_pvPortCalloc (count, size, file, line, caller);
721
+ if (ret) return ret;
722
+ }
723
+ {
724
+ HeapSelectDram ephemeral;
725
+ return _heap_pvPortCalloc (count, size, file, line, caller);
726
+ }
705
727
}
706
728
707
729
void * IRAM_ATTR pvPortZallocIram (size_t size, const char * file, int line)
708
730
{
709
- HeapSelectIram ephemeral;
710
- return _heap_pvPortCalloc (1 , size, file, line, __builtin_return_address (0 ));
731
+ void * caller = __builtin_return_address (0 );
732
+ {
733
+ HeapSelectIram ephemeral;
734
+ void * ret = _heap_pvPortCalloc (1 , size, file, line, caller);
735
+ if (ret) return ret;
736
+ }
737
+ {
738
+ HeapSelectDram ephemeral;
739
+ return _heap_pvPortCalloc (1 , size, file, line, caller);
740
+ }
711
741
}
742
+ #define CONFIG_IRAM_MEMORY 1
712
743
713
- /*
714
- uint32_t IRAM_ATTR user_iram_memory_is_enabled(void)
715
- {
716
- return CONFIG_ENABLE_IRAM_MEMORY;
717
- }
744
+ #else
745
+ // For sdk3_pvPortMalloc, the bool argument is ignored and intentionally omitted.
746
+ extern " C" void * sdk3_pvPortMalloc (size_t size, const char * file, int line) __attribute__ ((alloc_size(1 ), malloc, alias(" pvPortMalloc" )));
747
+ extern " C" void * pvPortCallocIram (size_t count, size_t size, const char * file, int line) __attribute__((alloc_size(1 , 2 ), malloc, alias(" pvPortCalloc" )));
748
+ extern " C" void * pvPortZallocIram (size_t size, const char * file, int line) __attribute__((alloc_size(1 ), malloc, alias(" pvPortZalloc" )));
749
+ #define CONFIG_IRAM_MEMORY 0
750
+ #endif // #ifdef UMM_HEAP_IRAM
718
751
752
+ /*
719
753
We do not need the function user_iram_memory_is_enabled().
720
754
1. It was used by mem_manager.o which was replaced with this custom heap
721
- implementation. IRAM memory selection is handled differently.
755
+ implementation. IRAM memory selection is handled differently for
756
+ Arduino ESP8266.
722
757
2. In libmain.a, Cache_Read_Enable_New uses it for cache size. However, When
723
758
using IRAM for memory or running with 48K IRAM for code, we use a
724
759
replacement Cache_Read_Enable to correct the cache size ignoring
725
760
Cache_Read_Enable_New's selected value.
761
+ 3. Create a linker conflicts in the event the sketch author tries to control
762
+ IRAM heap through this method.
726
763
*/
727
- #endif
764
+ uint32 IRAM_ATTR user_iram_memory_is_enabled (void )
765
+ {
766
+ return CONFIG_IRAM_MEMORY;
767
+ }
768
+ #endif // #if (NONOSDK >= (0x30000))
728
769
};
729
770
730
771
#if defined(ENABLE_THICK_DEBUG_WRAPPERS)
0 commit comments