Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K64F linker script refactor, also fix some misc bugs #402

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ bool Kinetis_EMAC::link_out(emac_mem_buf_t *buf)
}

/* Check if a descriptor is available for the transfer (wait 10ms before dropping the buffer) */
if (!xTXDCountSem.try_acquire_for(10)) {
if (!xTXDCountSem.try_acquire_for(10ms)) {
JohnK1987 marked this conversation as resolved.
Show resolved Hide resolved
memory_manager->free(buf);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion platform/mbed-trace/include/mbed-trace/mbed_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ const char *mbed_trace_exclude_filters_get(void);
* mbed_tracef(TRACE_ACTIVE_LEVEL_DEBUG, "mygr", "Hi There");
* mbed_tracef(TRACE_ACTIVE_LEVEL_DEBUG, "grp2", "This is not printed");
*/
void mbed_trace_include_filters_set(char *filters);
void mbed_trace_include_filters_set(char const *filters);
JohnK1987 marked this conversation as resolved.
Show resolved Hide resolved
/** get trace include filters
*/
const char *mbed_trace_include_filters_get(void);
Expand Down
2 changes: 1 addition & 1 deletion platform/mbed-trace/source/mbed_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ const char *mbed_trace_include_filters_get(void)
{
return m_trace.filters_include;
}
void mbed_trace_include_filters_set(char *filters)
void mbed_trace_include_filters_set(char const *filters)
{
if (filters) {
(void)strncpy(m_trace.filters_include, filters, m_trace.filters_length);
Expand Down
11 changes: 9 additions & 2 deletions storage/blockdevice/include/blockdevice/BufferedBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ namespace mbed {
/** \addtogroup storage-blockdevice */
/** @{*/

/** Block device for allowing minimal read and program sizes (of 1) for the underlying BD,
* using a buffer on the heap.
/**
* Block device which allows minimal read and program sizes (of 1) for the underlying BD
JohnK1987 marked this conversation as resolved.
Show resolved Hide resolved
* using a buffer on the heap. This essentially "simulates" a byte-programmable device
* like a NOR flash or an EEPROM, using a non-byte-programmable device like an SD card or
* NAND flash.
*
* @note While the read and write size of the buffered block device will always be 1,
* the erase size is the same as the underlying block device. In other words, you
multiplemonomials marked this conversation as resolved.
Show resolved Hide resolved
* still must erase in the hardware erase sector size.
*/
class BufferedBlockDevice : public BlockDevice {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,7 @@ ENTRY(Reset_Handler)

__ram_vector_table__ = 1;

#if !defined(MBED_APP_START)
#define MBED_APP_START 0
#elif MBED_APP_START > 0 && MBED_APP_START < 0x410
#error MBED_APP_START too small and will overwrite interrupts and flash config
#endif

#if !defined(MBED_APP_SIZE)
#define MBED_APP_SIZE 0x100000
#endif

#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
#define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400
Expand All @@ -72,19 +64,42 @@ __stack_size__ = MBED_CONF_TARGET_BOOT_STACK_SIZE;
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x0400 : 0x0;
M_CRASH_DATA_RAM_SIZE = 0x100;
FLASH_VTOR_TABLE_SIZE = 0x400;
FLASH_CONFIG_FIELD_SIZE = 0x10;

/* If we are not configured to execute out of the start of ROM, then a bootloader is
* present. This tells us whether we need to add the Flash Configuration Field at the start of flash. */
#if MBED_CONFIGURED_ROM_BANK_IROM1_START == 0
#define IS_BOOTLOADER_PRESENT 0
#else
#define IS_BOOTLOADER_PRESENT 1
#endif

#if IS_BOOTLOADER_PRESENT && MBED_CONFIGURED_ROM_BANK_IROM1_START < 0x410
#error MBED_CONFIGURED_ROM_BANK_IROM1_START too small and will overwrite interrupts and flash config
#endif

/* Specify the ELF segments (program headers) */
PHDRS
multiplemonomials marked this conversation as resolved.
Show resolved Hide resolved
{
text PT_LOAD FLAGS(5); /* read + execute */
ram_vector_table PT_LOAD FLAGS(6); /* read + write */
ram_noinit PT_LOAD FLAGS(6); /* read + write */
ram_init PT_LOAD FLAGS(6); /* read + write */
sram_l PT_LOAD FLAGS(6); /* read + write */
}

/* Specify the memory areas */
MEMORY
{
#if MBED_APP_START == 0
m_interrupts (RX) : ORIGIN = MBED_APP_START, LENGTH = 0x400
m_flash_config (RX) : ORIGIN = MBED_APP_START + 0x400, LENGTH = 0x10
m_text (RX) : ORIGIN = MBED_APP_START + 0x410, LENGTH = MBED_APP_SIZE - 0x410
#else
m_text (RX) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE
#endif
m_data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000
m_data_2 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00030000
m_text (RX) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE

/*
* Note: while these two SRAMs occupy a contiguous address space, we have to keep them as
* separate memory banks because the MCU doesn't support accesses that bridge the two banks.
*/
m_sram_l (RW) : ORIGIN = MBED_RAM_BANK_SRAM_L_START, LENGTH = MBED_RAM_BANK_SRAM_L_SIZE
m_sram_u (RW) : ORIGIN = MBED_RAM_BANK_SRAM_U_START, LENGTH = MBED_RAM_BANK_SRAM_U_SIZE
}

/* Define output sections */
Expand All @@ -97,18 +112,20 @@ SECTIONS
. = ALIGN(8);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(8);
#if MBED_APP_START == 0
} > m_interrupts
} > m_text AT> m_text :text

.flash_config :
/* FCF to absolute address of 0x400, but only if bootloader is not present. */
#if !IS_BOOTLOADER_PRESENT
.flash_config FLASH_VTOR_TABLE_SIZE :
{
. = ALIGN(8);
KEEP(*(.FlashConfig)) /* Flash Configuration Field (FCF) */
. = ALIGN(8);
} > m_flash_config
} > m_text AT> m_text :text
#else
} > m_text
/DISCARD/ : {
*(.FlashConfig)
}
#endif

.text :
{

Expand All @@ -123,19 +140,19 @@ SECTIONS
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(8);
} > m_text
} > m_text AT> m_text :text
multiplemonomials marked this conversation as resolved.
Show resolved Hide resolved

.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > m_text
} > m_text AT> m_text :text

.ARM :
{
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} > m_text
} > m_text AT> m_text :text

.ctors :
{
Expand All @@ -159,7 +176,7 @@ SECTIONS
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
__CTOR_END__ = .;
} > m_text
} > m_text AT> m_text :text

.dtors :
{
Expand All @@ -170,78 +187,79 @@ SECTIONS
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
__DTOR_END__ = .;
} > m_text
} > m_text AT> m_text :text

.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} > m_text
} > m_text AT> m_text :text

.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} > m_text
} > m_text AT> m_text :text

.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} > m_text
} > m_text AT> m_text :text

.interrupts_ram :
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
/* Stick the crash data ram at the start of sram_l */
.crash_data_ram : ALIGN(8)
{
. = ALIGN(8);
__VECTOR_RAM__ = .;
__interrupts_ram_start__ = .; /* Create a global symbol at data start */
*(.m_interrupts_ram) /* This is a user defined section */
. += M_VECTOR_RAM_SIZE;
. = ALIGN(8);
__interrupts_ram_end__ = .; /* Define a global symbol at data end */
} > m_data

.crash_data_ram :
{
. = ALIGN(8);
__CRASH_DATA_RAM__ = .;
__CRASH_DATA_RAM_START__ = .; /* Create a global symbol at data start */
KEEP(*(.keep.crash_data_ram))
*(.m_crash_data_ram) /* This is a user defined section */
. += M_CRASH_DATA_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > m_data
} > m_sram_l :sram_l
#endif

.heap_0 :
/* Fill the entire sram_l with the heap 0 section. */
.heap_0 (NOLOAD): ALIGN(8)
{
. = ALIGN(8);
__mbed_sbrk_start_0 = .;
. += (ORIGIN(m_data) + LENGTH(m_data) - .);
. += (ORIGIN(m_sram_l) + LENGTH(m_sram_l) - .);
__mbed_krbs_start_0 = .;
} > m_data
} > m_sram_l :sram_l

__VECTOR_RAM = DEFINED(__ram_vector_table__) ? __VECTOR_RAM__ : ORIGIN(m_interrupts);
__RAM_VECTOR_TABLE_SIZE_BYTES = DEFINED(__ram_vector_table__) ? (__interrupts_ram_end__ - __interrupts_ram_start__) : 0x0;

.data :
.interrupts_ram :
{
. = ALIGN(8);
__VECTOR_RAM__ = .;
__interrupts_ram_start__ = .; /* Create a global symbol at data start */
*(.m_interrupts_ram) /* This is a user defined section */
. += M_VECTOR_RAM_SIZE;
. = ALIGN(8);
__interrupts_ram_end__ = .; /* Define a global symbol at data end */
} > m_sram_u :ram_vector_table

.data : ALIGN(8)
{
PROVIDE(__etext = LOADADDR(.data)); /* Define a global symbol at end of code, */
PROVIDE(__DATA_ROM = LOADADDR(.data)); /* Symbol is used by startup for data initialization. */
. = ALIGN(8);
__DATA_RAM = .;
__data_start__ = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
KEEP(*(.jcr*))
. = ALIGN(8);
__data_end__ = .; /* define a global symbol at data end */
} > m_data_2 AT > m_text
} > m_sram_u AT > m_text :ram_init

__DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
text_end = ORIGIN(m_text) + LENGTH(m_text);
Expand All @@ -259,15 +277,14 @@ SECTIONS
KEEP(*(.keep.uninitialized))
. = ALIGN(32);
__uninitialized_end = .;
} > m_data_2
} > m_sram_u AT> m_sram_u :ram_noinit

USB_RAM_GAP = DEFINED(__usb_ram_size__) ? __usb_ram_size__ : 0x800;

/* Uninitialized data section */
.bss :
.bss : ALIGN(8)
{
/* This is used by the startup in order to initialize the .bss section */
. = ALIGN(8);
__START_BSS = .;
__bss_start__ = .;
*(.bss)
Expand All @@ -279,39 +296,41 @@ SECTIONS
. = ALIGN(8);
__bss_end__ = .;
__END_BSS = .;
} > m_data_2
} > m_sram_u AT> m_sram_u :ram_noinit

.heap :
.heap : ALIGN(8)
{
. = ALIGN(8);
__end__ = .;
PROVIDE(end = .);

ASSERT((__end__ - ORIGIN(m_sram_u)) + STACK_SIZE <= LENGTH(m_sram_u), "SRAM_U is not large enough to contain globals and boot stack!");

__mbed_sbrk_start = .;
__HeapBase = .;
. = ORIGIN(m_data_2) + LENGTH(m_data_2) - STACK_SIZE;
. = ORIGIN(m_sram_u) + LENGTH(m_sram_u) - STACK_SIZE;
__mbed_krbs_start = .;
__HeapLimit = .;
__heap_limit = .; /* Add for _sbrk */
} > m_data_2
} > m_sram_u AT> m_sram_u :ram_noinit

m_usb_bdt USB_RAM_START (NOLOAD) :
multiplemonomials marked this conversation as resolved.
Show resolved Hide resolved
/* USB RAM sections. These live inside a "gap" created in .bss. */
m_usb_bdt USB_RAM_START (OVERLAY) :
{
*(m_usb_bdt)
USB_RAM_BDT_END = .;
}
} :ram_noinit

m_usb_global USB_RAM_BDT_END (NOLOAD) :
m_usb_global USB_RAM_BDT_END (OVERLAY) :
{
*(m_usb_global)
}
} :ram_noinit

/* Initializes stack on the end of block */
__StackTop = ORIGIN(m_data_2) + LENGTH(m_data_2);
__StackTop = ORIGIN(m_sram_u) + LENGTH(m_sram_u);
__StackLimit = __StackTop - STACK_SIZE;
PROVIDE(__stack = __StackTop);

.ARM.attributes 0 : { *(.ARM.attributes) }

ASSERT(__StackLimit >= __HeapLimit, "Region m_data_2 overflowed with stack and heap")
multiplemonomials marked this conversation as resolved.
Show resolved Hide resolved

/DISCARD/ : {
*(.ARM.attributes)
}
}
11 changes: 9 additions & 2 deletions targets/TARGET_NUVOTON/scripts/mbed_set_post_build_nuvoton.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ macro(mbed_post_build_nuvoton_tfm_sign_image
function(mbed_post_build_function target)
find_package(Python3)

if("${MBED_OUTPUT_EXT}" STREQUAL "")
JohnK1987 marked this conversation as resolved.
Show resolved Hide resolved
# If both bin and hex are being generated, just pick one.
set(EXT hex)
else()
set(EXT ${MBED_OUTPUT_EXT})
endif()

# NOTE: Macro arguments are not variables and cannot pass to if(<condition>).
set(signing_key_1_ ${signing_key_1})
if(signing_key_1_)
Expand All @@ -30,7 +37,7 @@ macro(mbed_post_build_nuvoton_tfm_sign_image
--tfm-import-path ${tfm_import_path}
--signing_key ${signing_key}
--signing_key_1 ${signing_key_1}
--non-secure-binhex $<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_BASE_NAME:${target}>.${MBED_OUTPUT_EXT}
--non-secure-binhex $<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_BASE_NAME:${target}>.${EXT}
)
else()
add_custom_command(
Expand All @@ -43,7 +50,7 @@ macro(mbed_post_build_nuvoton_tfm_sign_image
tfm_sign_image
--tfm-import-path ${tfm_import_path}
--signing_key ${signing_key}
--non-secure-binhex $<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_BASE_NAME:${target}>.${MBED_OUTPUT_EXT}
--non-secure-binhex $<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_BASE_NAME:${target}>.${EXT}
)
endif()
endfunction()
Expand Down
Loading
Loading