Skip to content

Commit

Permalink
fixing relocatable module, timers are not working correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
matgla committed May 29, 2024
1 parent f1169e3 commit b11afef
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 30 deletions.
10 changes: 7 additions & 3 deletions tests/simulation/mspc/firmware/yasld_firmwares/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ include (pico_sdk_init)
list (APPEND PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../board)
set (PICO_BOARD mspc)

set(common_flags "-Werror -Wall -Wextra -Wconversion -Wno-unused -Wshadow -Wpointer-arith -Wcast-qual -Wdouble-promotion -Wmissing-braces -fno-function-sections -fno-data-sections -fno-common")
set(common_flags "-fomit-frame-pointer -Werror -Wall -Wextra -Wconversion -Wno-unused -Wshadow -Wpointer-arith -Wcast-qual -Wdouble-promotion -Wmissing-braces -ffunction-sections -fdata-sections -fno-common")
set(common_release_flags "")
set(common_debug_flags "-g")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions -fmodules-ts -fno-threadsafe-statics -fno-module-lazy ${common_flags}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions -fmodules-ts -fno-threadsafe-statics -fno-module-lazy ${common_flags}")

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${common_release_flags}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${common_debug_flags}")
Expand All @@ -73,7 +73,11 @@ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${common_debug_flags}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${common_flags}")
set(CMAKE_ASM_FLAGS_RELEASE "${CMAKE_ASM_FLAGS_RELEASE} ${common_release_flags}")
set(CMAKE_ASM_FLAGS_DEBUG "${CMAKE_ASM_FLAGS_DEBUG} ${common_debug_flags}")


add_definitions(-D__NO_SYSTEM_INIT)

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections --specs=nano.specs")

pico_sdk_init()

project (yasld_firmwares ASM C CXX)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ target_link_libraries(hello_from_relocatable_module
PRIVATE
pico_stdlib
pico_runtime
yasld_executable_flags
gcc
c
yasld_standalone_executable_flags
)

target_link_options(hello_from_relocatable_module
Expand Down
41 changes: 24 additions & 17 deletions tests/simulation/mspc/firmware/yasld_firmwares/hello/executable.ld
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MEMORY
image(rwx) : ORIGIN = 0x00000000, LENGTH = 0xffffffff
}

ENTRY(_entry_point)
ENTRY(main)

SECTIONS
{
Expand All @@ -39,37 +39,44 @@ SECTIONS
*(.glue_7)
*(.glue_7t)
*(.eh_frame)

. = ALIGN(4);
PROVIDE_HIDDEN (__mutex_array_start = .);
KEEP(*(SORT(.mutex_array.*)))
KEEP(*(.mutex_array))
PROVIDE_HIDDEN (__mutex_array_end = .);
. = ALIGN(4);
PROVIDE_HIDDEN(__preinit_array_start = .);
KEEP(*(SORT(.preinit_array.*)))
KEEP(*(.preinit_array))
PROVIDE_HIDDEN(__preinit_array_end = .);

KEEP(*(.init))
KEEP(*(.fini))
*(.rodata)
*(.rodata*)
*(.ARM.extab*)
*(.ARM.exidx*)
PROVIDE_HIDDEN(__preinit_array_start = .);
*(.preinit_array*)
PROVIDE_HIDDEN(__preinit_array_end = .);
PROVIDE_HIDDEN(__init_array_start = .);
*(.init_array*)
PROVIDE_HIDDEN(__init_array_end = .);
PROVIDE_HIDDEN(__fini_array_start = .);
*(.fini_array*)
PROVIDE_HIDDEN(__fini_array_end = .);
*(.binary_info.*)
. = ALIGN(16);
} > image

.data :
{
. = ALIGN(16);
KEEP(*(.vector_table))
. = ALIGN(128);
KEEP(*(.ram_vector_table))
. = ALIGN(16);
. = ALIGN(4);
PROVIDE_HIDDEN(__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN(__init_array_end = .);
. = ALIGN(4);
PROVIDE_HIDDEN(__fini_array_start = .);
*(SORT(.fini_array.*))
*(.fini_array)
PROVIDE_HIDDEN(__fini_array_end = .);

__data_start__ = .;
PROVIDE_HIDDEN (__mutex_array_start = .);
KEEP(*(SORT(.mutex_array.*)))
KEEP(*(.mutex_array))
PROVIDE_HIDDEN (__mutex_array_end = .);

*(.data)
*(.data*)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
// This program is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// 3 of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General
Expand All @@ -25,7 +21,7 @@
#define M0PLUS_VTOR_OFFSET 0x0000ed08
#define VECTOR_TABLE_SIZE 48

.section .vector_table, "ax"
.section .ram_vector_table, "ax"
.align 2
.global __vector_table
__vector_table:
Expand Down Expand Up @@ -87,6 +83,24 @@ __vector_table:
__unhandled_user_irq:
bkpt #0

.global hardware_init_hook
.type hardware_init_hook,%function
.thumb_func
hardware_init_hook:
mov pc, lr

.global __register_frame_info
.type __register_frame_info,%function
.thumb_func
__register_frame_info:
mov pc, lr

.global __libc_fini
.type __libc_fini,%function
.thumb_func
__libc_fini:
mov pc, lr

.global initialize_on_entry
.type initialize_on_entry,%function
.thumb_func
Expand Down

0 comments on commit b11afef

Please sign in to comment.