Skip to content

Commit dfc37d4

Browse files
committed
wrap all SDK memory functions in all libs, to get umm to work.
fix esp8266#1586
1 parent c2a34d2 commit dfc37d4

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

cores/esp8266/memory_wrap.c

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
memory_wrap.c
3+
4+
Copyright (c) 2015 Markus Sattler. All rights reserved.
5+
This file is part of the esp8266 core for Arduino environment.
6+
7+
This library is free software; you can redistribute it and/or
8+
modify it under the terms of the GNU Lesser General Public
9+
License as published by the Free Software Foundation; either
10+
version 2.1 of the License, or (at your option) any later version.
11+
12+
This library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public
18+
License along with this library; if not, write to the Free Software
19+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20+
21+
*/
22+
23+
#include <stdlib.h>
24+
#include <debug.h>
25+
#include <Arduino.h>
26+
27+
void ICACHE_RAM_ATTR __wrap_vPortFree(void *ptr, const char* file, int line) {
28+
free(ptr);
29+
}
30+
31+
void * ICACHE_RAM_ATTR __wrap_pvPortMalloc(size_t size, const char* file, int line) {
32+
return malloc(size);
33+
}
34+
35+
void * ICACHE_RAM_ATTR __wrap_pvPortCalloc(size_t num, size_t size, const char* file, int line) {
36+
return calloc(num, size);
37+
}
38+
39+
void * ICACHE_RAM_ATTR __wrap_pvPortRealloc(void *ptr, size_t size, const char* file, int line) {
40+
return realloc(ptr, size);
41+
}
42+
43+
void * ICACHE_RAM_ATTR __wrap_pvPortZalloc(size_t size, const char* file, int line) {
44+
return calloc(1, size);
45+
}
46+
47+
void ICACHE_RAM_ATTR __wrap_mem_free(void *ptr) {
48+
free(ptr);
49+
}
50+
51+
void * ICACHE_RAM_ATTR __wrap_mem_malloc(size_t size) {
52+
return malloc(size);
53+
}
54+
55+
void * ICACHE_RAM_ATTR __wrap_mem_realloc(void *ptr, size_t size) {
56+
return realloc(ptr, size);
57+
}
58+
59+
void * ICACHE_RAM_ATTR __wrap_mem_zalloc(size_t size) {
60+
return calloc(1, size);
61+
}
62+
63+
size_t ICACHE_RAM_ATTR __wrap_xPortGetFreeHeapSize(void) {
64+
return umm_free_heap_size();
65+
}

platform.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ compiler.c.flags=-c {compiler.warning_flags} -Os -g -Wpointer-arith -Wno-implici
2727
compiler.S.cmd=xtensa-lx106-elf-gcc
2828
compiler.S.flags=-c -g -x assembler-with-cpp -MMD -mlongcalls
2929

30-
compiler.c.elf.flags=-g {compiler.warning_flags} -Os -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-T{build.flash_ld}" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy
30+
compiler.c.elf.flags=-g {compiler.warning_flags} -Os -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-T{build.flash_ld}" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy -Wl,-wrap,vPortFree -Wl,-wrap,pvPortMalloc -Wl,-wrap,pvPortCalloc -Wl,-wrap,pvPortRealloc -Wl,-wrap,pvPortZalloc -Wl,-wrap,mem_free -Wl,-wrap,mem_malloc -Wl,-wrap,mem_realloc -Wl,-wrap,mem_zalloc -Wl,-wrap,xPortGetFreeHeapSize
3131

3232
compiler.c.elf.cmd=xtensa-lx106-elf-gcc
3333
compiler.c.elf.libs=-lm -lgcc -lhal -lphy -lpp -lnet80211 -llwip -lwpa -lcrypto -lmain -lwps -laxtls -lsmartconfig -lmesh

0 commit comments

Comments
 (0)