From 1e49c3ff6f2398387c42b20b071062a1f8cc96da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Wed, 31 May 2023 12:36:46 +0200 Subject: [PATCH] [realtek-ambz2] Fix missing flash API resource lock unit --- builder/family/realtek-ambz2.py | 1 + cores/realtek-ambz2/base/fixups/hal_flash.h | 13 +++++++++++++ cores/realtek-ambz2/misc/rtl8710c_ram.ld | 8 +++++++- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 cores/realtek-ambz2/base/fixups/hal_flash.h diff --git a/builder/family/realtek-ambz2.py b/builder/family/realtek-ambz2.py index 14aff21..a6786e0 100644 --- a/builder/family/realtek-ambz2.py +++ b/builder/family/realtek-ambz2.py @@ -106,6 +106,7 @@ queue.AddLibrary( # cmsis "+", "+", + "+", # utilities "+", "+", diff --git a/cores/realtek-ambz2/base/fixups/hal_flash.h b/cores/realtek-ambz2/base/fixups/hal_flash.h new file mode 100644 index 0000000..ebbf1f7 --- /dev/null +++ b/cores/realtek-ambz2/base/fixups/hal_flash.h @@ -0,0 +1,13 @@ +/* Copyright (c) Kuba SzczodrzyƄski 2023-05-31. */ + +// - flash_api.c and flash_api_ext.c are both compiled in libambz2_sdk.a +// - the former declares weak functions 'flash_resource_lock' and 'flash_resource_unlock', +// while the latter actually implements them +// - for some reason, the linker resolves the weak functions only, +// and doesn't include them in the final binary + +#include_next "hal_flash.h" + +// try to remove the weak attribute +#undef __weak +#define __weak diff --git a/cores/realtek-ambz2/misc/rtl8710c_ram.ld b/cores/realtek-ambz2/misc/rtl8710c_ram.ld index 221819e..7dbe133 100644 --- a/cores/realtek-ambz2/misc/rtl8710c_ram.ld +++ b/cores/realtek-ambz2/misc/rtl8710c_ram.ld @@ -385,5 +385,11 @@ SECTIONS PROVIDE(__sram_end__ = __StackLimit); /* Check if data + heap + stack exceeds RAM limit */ - /* TODO: ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") + ASSERT(__bss_start__ >= __ram_code_text_end__, "sram heap will overwrite sram text") + ASSERT(__bss_start__ >= __ram_code_rodata_end__, "sram heap will overwrite sram rodata") + ASSERT(__bss_start__ >= __data_end__, "sram heap will overwrite sram data") + ASSERT(__psram_bss_start__ >= __psram_code_text_end__, "psram heap will overwrite psram text") + ASSERT(__psram_bss_start__ >= __psram_code_rodata_end__, "psram heap will overwrite psram rodata") + ASSERT(__psram_bss_start__ >= __psram_data_end__, "psram heap will overwrite psram data") }