Skip to content

Commit fa44651

Browse files
committed
[heap] Fix allocator default by ram sizes
1 parent 23584ee commit fa44651

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

ext/tlsf/module.lb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ def prepare(module, options):
5959
return True
6060

6161
def build(env):
62+
env.collect(":build:path.include", "modm/ext")
6263
env.outbasepath = "modm/ext/tlsf"
63-
env.copy("tlsf.h")
64-
env.template("tlsf.c.in", substitutions={
64+
env.substitutions = {
6565
"sl_index_count_log2": math.ceil(math.log2(env["subdivisions"])),
6666
"fl_index_max": math.ceil(math.log2(env["minimum_pool_size"]))
67-
})
67+
}
68+
env.copy("tlsf.h")
69+
env.template("tlsf.c.in")

src/modm/platform/heap/cortex/heap_block.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void* __wrap__calloc_r(struct _reent *r, size_t size)
7272
return ptr;
7373
}
7474

75-
void* __wrap__realloc_r(struct _reent *r, void *, size_t size)
75+
void* __wrap__realloc_r(struct _reent *r, void *p, size_t size)
7676
{
7777
if (!p) return __wrap__malloc_r(r, size);
7878
// NOT IMPLEMENTED!

src/modm/platform/heap/cortex/module.lb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def continuous_ram_sizes(target):
1414
memories = listify(target.get_driver("core")["memory"])
1515
rams = ((int(m["start"], 16), int(m["start"], 16) + int(m["size"]))
16-
for m in memories if "rw" in m["access"] and "backup" not in m["name"])
16+
for m in memories if "rw" in m["access"] and "ram" in m["name"])
1717
rams = sorted(rams, key=lambda m: m[0])
1818

1919
pools = [rams[0]]
@@ -38,7 +38,7 @@ def prepare(module, options):
3838

3939
ram_sizes = continuous_ram_sizes(options[":target"])
4040
default_allocator = "newlib"
41-
if len(ram_sizes):
41+
if len(ram_sizes) > 1:
4242
default_allocator = "tlsf"
4343
elif ram_sizes[0] <= 4096:
4444
default_allocator = "block"

0 commit comments

Comments
 (0)