mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-13 13:01:55 +03:00
boards.txt generator (#3722)
+ generates boards.rst + generate and replace boards section in package.json + generate ldscripts + new debug option: OOM + new led menu for generic board
This commit is contained in:
@ -283,3 +283,9 @@ extern "C" void configTime(long timezone, int daylightOffset_sec,
|
||||
#include "pins_arduino.h"
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_ESP_OOM
|
||||
// reinclude *alloc redefinition because of <cstdlib> undefining them
|
||||
// this is mandatory for allowing OOM *alloc definitions in .ino files
|
||||
#include "umm_malloc/umm_malloc_cfg.h"
|
||||
#endif
|
||||
|
@ -32,13 +32,6 @@ void* _calloc_r(struct _reent* unused, size_t count, size_t size)
|
||||
return calloc(count, size);
|
||||
}
|
||||
|
||||
void* ICACHE_RAM_ATTR pvPortMalloc(size_t size, const char* file, int line)
|
||||
{
|
||||
(void) file;
|
||||
(void) line;
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void ICACHE_RAM_ATTR vPortFree(void *ptr, const char* file, int line)
|
||||
{
|
||||
(void) file;
|
||||
@ -46,6 +39,100 @@ void ICACHE_RAM_ATTR vPortFree(void *ptr, const char* file, int line)
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ESP_OOM
|
||||
|
||||
void* ICACHE_RAM_ATTR pvPortMalloc(size_t size, const char* file, int line)
|
||||
{
|
||||
return malloc_loc(size, file, line);
|
||||
}
|
||||
|
||||
void* ICACHE_RAM_ATTR pvPortCalloc(size_t count, size_t size, const char* file, int line)
|
||||
{
|
||||
return calloc_loc(count, size, file, line);
|
||||
}
|
||||
|
||||
void* ICACHE_RAM_ATTR pvPortRealloc(void *ptr, size_t size, const char* file, int line)
|
||||
{
|
||||
return realloc_loc(ptr, size, file, line);
|
||||
}
|
||||
|
||||
void* ICACHE_RAM_ATTR pvPortZalloc(size_t size, const char* file, int line)
|
||||
{
|
||||
return calloc_loc(1, size, file, line);
|
||||
}
|
||||
|
||||
#undef malloc
|
||||
#undef calloc
|
||||
#undef realloc
|
||||
|
||||
static const char oom_fmt[] ICACHE_RODATA_ATTR STORE_ATTR = ":oom(%d)@?\n";
|
||||
static const char oom_fmt_1[] ICACHE_RODATA_ATTR STORE_ATTR = ":oom(%d)@";
|
||||
static const char oom_fmt_2[] ICACHE_RODATA_ATTR STORE_ATTR = ":%d\n";
|
||||
|
||||
void* malloc (size_t s)
|
||||
{
|
||||
void* ret = umm_malloc(s);
|
||||
if (!ret)
|
||||
os_printf(oom_fmt, (int)s);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void* calloc (size_t n, size_t s)
|
||||
{
|
||||
void* ret = umm_calloc(n, s);
|
||||
if (!ret)
|
||||
os_printf(oom_fmt, (int)s);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void* realloc (void* p, size_t s)
|
||||
{
|
||||
void* ret = umm_realloc(p, s);
|
||||
if (!ret)
|
||||
os_printf(oom_fmt, (int)s);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void print_loc (size_t s, const char* file, int line)
|
||||
{
|
||||
os_printf(oom_fmt_1, (int)s);
|
||||
os_printf(file);
|
||||
os_printf(oom_fmt_2, line);
|
||||
}
|
||||
|
||||
void* malloc_loc (size_t s, const char* file, int line)
|
||||
{
|
||||
void* ret = umm_malloc(s);
|
||||
if (!ret)
|
||||
print_loc(s, file, line);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void* calloc_loc (size_t n, size_t s, const char* file, int line)
|
||||
{
|
||||
void* ret = umm_calloc(n, s);
|
||||
if (!ret)
|
||||
print_loc(s, file, line);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void* realloc_loc (void* p, size_t s, const char* file, int line)
|
||||
{
|
||||
void* ret = umm_realloc(p, s);
|
||||
if (!ret)
|
||||
print_loc(s, file, line);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void* ICACHE_RAM_ATTR pvPortMalloc(size_t size, const char* file, int line)
|
||||
{
|
||||
(void) file;
|
||||
(void) line;
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void* ICACHE_RAM_ATTR pvPortCalloc(size_t count, size_t size, const char* file, int line)
|
||||
{
|
||||
(void) file;
|
||||
@ -67,6 +154,8 @@ void* ICACHE_RAM_ATTR pvPortZalloc(size_t size, const char* file, int line)
|
||||
return calloc(1, size);
|
||||
}
|
||||
|
||||
#endif // !defined(DEBUG_ESP_OOM)
|
||||
|
||||
size_t xPortGetFreeHeapSize(void)
|
||||
{
|
||||
return umm_free_heap_size();
|
||||
|
@ -2,17 +2,25 @@
|
||||
* Configuration for umm_malloc
|
||||
*/
|
||||
|
||||
// with DEBUG_ESP_OOM debug option activated,
|
||||
// implying gcc option '-include this-file'
|
||||
// this file is included in *every* source file
|
||||
// *before* any other include file
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
#ifndef _UMM_MALLOC_CFG_H
|
||||
#define _UMM_MALLOC_CFG_H
|
||||
|
||||
#include <debug.h>
|
||||
//#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
//#endif
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <osapi.h>
|
||||
|
||||
#include "c_types.h"
|
||||
//#ifdef __cplusplus
|
||||
//}
|
||||
//#endif
|
||||
/*
|
||||
* There are a number of defines you can set at compile time that affect how
|
||||
* the memory allocator will operate.
|
||||
@ -59,8 +67,34 @@
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
#ifdef DEBUG_ESP_OOM
|
||||
|
||||
#define MEMLEAK_DEBUG
|
||||
|
||||
// umm_*alloc are not renamed to *alloc
|
||||
|
||||
void *umm_malloc( size_t size );
|
||||
void *umm_calloc( size_t num, size_t size );
|
||||
void *umm_realloc( void *ptr, size_t size );
|
||||
#define umm_free free
|
||||
#define umm_zalloc(s) umm_calloc(1,s)
|
||||
|
||||
void* malloc_loc (size_t s, const char* file, int line);
|
||||
void* calloc_loc (size_t n, size_t s, const char* file, int line);
|
||||
void* realloc_loc (void* p, size_t s, const char* file, int line);
|
||||
|
||||
// *alloc are macro calling *alloc_loc calling+checking umm_*alloc()
|
||||
// they are defined at the bottom of this file
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
#else // !defined(ESP_DEBUG_OOM)
|
||||
|
||||
// umm_*alloc are renamed to *alloc
|
||||
#define UMM_REDEFINE_MEM_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
#define UMM_BEST_FIT
|
||||
|
||||
/* Start addresses and the size of the heap */
|
||||
@ -140,4 +174,21 @@ extern char _heap_start;
|
||||
#define UMM_POISONED_BLOCK_LEN_TYPE uint32_t
|
||||
|
||||
#define UMM_HEAP_CORRUPTION_CB() panic()
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _UMM_MALLOC_CFG_H */
|
||||
|
||||
#ifdef DEBUG_ESP_OOM
|
||||
// this must be outside from "#ifndef _UMM_MALLOC_CFG_H"
|
||||
// because Arduino.h's <cstdlib> does #undef *alloc
|
||||
// so Arduino.h recall us to redefine them
|
||||
#define malloc(s) ({ static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; malloc_loc(s, mem_debug_file, __LINE__); })
|
||||
#define calloc(n,s) ({ static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; calloc_loc(n, s, mem_debug_file, __LINE__); })
|
||||
#define realloc(p,s) ({ static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; realloc_loc(p, s, mem_debug_file, __LINE__); })
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !__ASSEMBLER__ */
|
||||
|
Reference in New Issue
Block a user