feat(system): Provide more heap region (16KB+)

1. Change cache size from 32KB to 16KB, reverse this 16KB region as heap;
2. New heap to support seperate heap region;
3. Modify pvPortMalloc, support to choose malloc in iram;
4. Add new macro os_malloc_iram to malloc in iram;
5. Default malloc will malloc in iram firstly;

Limitation:
1. Don't malloc task stack in iram;
2. Dont't use iram buffer as wifi tx buffer;

If possible, use all of iram heap region firstly.

internal : 2d3fbebb
This commit is contained in:
Espressif Systems
2017-12-08 14:02:57 +08:00
parent b6ddeca472
commit 2e89983282
24 changed files with 909 additions and 725 deletions

22
VERSION
View File

@ -1,14 +1,20 @@
gwen:
espnow: 1aafc07
main: caff253
mesh: 1aafc07
net80211: caff253
pp: caff253
wpa: caff253
wps: 1aafc07
crypto: a8c4880
espnow: a8c4880
main: a8c4880
mesh: a8c4880
minic: a8c4880
net80211: a8c4880
pp: a8c4880
pwm: a8c4880
smartconfig:a8c4880
wpa: a8c4880
wps: a8c4880
gitlab:
espconn: 3a998034
lwip: 2235ad17
freertos: ac047746
lwip: ac047746
driver: 7bee5263
mbedtls: 1ac9f1f4
ssl: eefb383a

View File

@ -126,7 +126,15 @@ do{\
#define os_malloc(s) \
({ \
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
pvPortMalloc(s, mem_debug_file, __LINE__); \
pvPortMalloc(s, mem_debug_file, __LINE__, false); \
})
#endif
#ifndef os_malloc_iram
#define os_malloc_iram(s) \
({ \
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
pvPortMalloc(s, mem_debug_file, __LINE__, true); \
})
#endif

View File

@ -368,7 +368,7 @@ extern "C" {
void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;
void vPortFree( void *pv ) PRIVILEGED_FUNCTION;
#else
void *pvPortMalloc( size_t xSize, const char *file, unsigned line) PRIVILEGED_FUNCTION;
void *pvPortMalloc( size_t xSize, const char *file, unsigned line, bool use_iram) PRIVILEGED_FUNCTION;
void vPortFree( void *pv, const char * file, unsigned line) PRIVILEGED_FUNCTION;
#endif

View File

@ -81,7 +81,7 @@ typedef size_t mem_size_t;
}while(0)
#endif
#ifndef mem_malloc
#define mem_malloc(s) ({const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__);})
#define mem_malloc(s) ({const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__, false);})
#endif
#ifndef mem_calloc
#define mem_calloc(s) ({const char *file = mem_debug_file; pvPortCalloc(s, file, __LINE__);})

View File

@ -25,14 +25,14 @@
#ifdef MEMLEAK_DEBUG
extern void *pvPortMalloc( size_t xWantedSize, const char * file, unsigned line);
extern void *pvPortMalloc( size_t xWantedSize, const char * file, unsigned line, bool use_iram);
extern void *pvPortZalloc( size_t xWantedSize, const char * file, unsigned line);
extern void vPortFree(void *pv, const char * file, unsigned line);
#define ssl_mem_malloc(s) \
({ \
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
pvPortMalloc(s, mem_debug_file, __LINE__); \
pvPortMalloc(s, mem_debug_file, __LINE__, false); \
})
#define ssl_mem_zalloc(s) \

View File

@ -94,6 +94,7 @@ SECTIONS
*(.init.literal)
*(.init)
*libfreertos.a:(.literal .text .literal.* .text.*)
*libmain.a:spi_flash.o(.literal .text .literal.* .text.*)
*(.literal .text .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
*(.fini.literal)
*(.fini)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -299,14 +299,14 @@ xQueueHandle xReturn = NULL;
/* Allocate the new queue structure. */
if( uxQueueLength > ( unsigned portBASE_TYPE ) 0 )
{
pxNewQueue = ( xQUEUE * ) os_malloc( sizeof( xQUEUE ) );
pxNewQueue = ( xQUEUE * ) os_malloc_iram( sizeof( xQUEUE ) );
if( pxNewQueue != NULL )
{
/* Create the list of pointers to queue items. The queue is one byte
longer than asked for to make wrap checking easier/faster. */
xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
pxNewQueue->pcHead = ( signed char * ) os_malloc( xQueueSizeInBytes );
pxNewQueue->pcHead = ( signed char * ) os_malloc_iram( xQueueSizeInBytes );
if( pxNewQueue->pcHead != NULL )
{
/* Initialise the queue members as described above where the
@ -356,7 +356,7 @@ xQueueHandle xReturn = NULL;
( void ) ucQueueType;
/* Allocate the new queue structure. */
pxNewQueue = ( xQUEUE * ) os_malloc( sizeof( xQUEUE ) );
pxNewQueue = ( xQUEUE * ) os_malloc_iram( sizeof( xQUEUE ) );
if( pxNewQueue != NULL )
{
/* Information required for priority inheritance. */

View File

@ -2486,7 +2486,7 @@ tskTCB *pxNewTCB;
/* Allocate space for the TCB. Where the memory comes from depends on
the implementation of the port malloc function. */
pxNewTCB = ( tskTCB * ) os_malloc( sizeof( tskTCB ) );
pxNewTCB = ( tskTCB * ) os_malloc_iram( sizeof( tskTCB ) );
if( pxNewTCB != NULL )
{

View File

@ -1406,7 +1406,7 @@ static int ecp_mul_comb( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
cleanup:
if( T != NULL && ! p_eq_g )
if( T != NULL && T != grp->T )
{
for( i = 0; i < pre_len; i++ )
mbedtls_ecp_point_free( &T[i] );