From 21bf08f9d468f0bbf0960a7e552bf7de885a526d Mon Sep 17 00:00:00 2001 From: famfo Date: Fri, 4 Apr 2025 15:57:39 +0300 Subject: [PATCH] main: Move initialization of board_data to the stack When the board_data is initialized at compile time, it is placed into the data section, which doesn't get relocated by the linker. The resulting address of the board_data that is passed to board_init lies within reserved memory and the device crashes. --- main/main.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/main/main.c b/main/main.c index 7e3775d..4a6d64b 100644 --- a/main/main.c +++ b/main/main.c @@ -8,23 +8,23 @@ #include #include -/* - * Provide an empty board config that has - * to be filled in the board files - * TODO: figure out why having it in - * the board files makes devices reboot. - */ -struct board_data board = { - .name = "default", - .ops = { - [BOARD_OP_INIT] = BOARD_OP_INIT, - [BOARD_OP_LATE_INIT] = BOARD_OP_LATE_INIT, - [BOARD_OP_DRIVER_SETUP] = BOARD_OP_DRIVER_SETUP, - } -}; - void main(void* dt, void* kernel, void* ramdisk) { + /* + * Provide an empty board config that has + * to be filled in the board files + * TODO: figure out why having it in + * the board files makes devices reboot. + */ + struct board_data board = { + .name = "default", + .ops = { + [BOARD_OP_INIT] = BOARD_OP_INIT, + [BOARD_OP_LATE_INIT] = BOARD_OP_LATE_INIT, + [BOARD_OP_DRIVER_SETUP] = BOARD_OP_DRIVER_SETUP, + } + }; + /* Initialize SoC and Board specific peripherals/quirks */ init_board_funcs(&board);