mcu能够启动到init

This commit is contained in:
zhangzheng
2024-04-10 17:08:21 +00:00
parent f3de8b8869
commit 5b2ac390ab
16 changed files with 55 additions and 20 deletions

View File

@@ -16,4 +16,17 @@
((type *)(((umword_t)(ptr)) - ((umword_t)(&(((type *)0)->member)))))
#define ATTR_ALIGN(a) __attribute__((aligned(a)))
#define AUTO_CALL(prio) __attribute__((constructor(prio)))
#define AUTO_CALL(prio) __attribute__((constructor(prio)))
#define __ARG_PLACEHOLDER_1 0,
#define __take_second_arg(__ignored, val, ...) val
#define __is_defined(x) ___is_defined(x)
#define ___is_defined(val) ____is_defined(__ARG_PLACEHOLDER_##val)
#define ____is_defined(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0)
#define __or(x, y) ___or(x, y)
#define ___or(x, y) ____or(__ARG_PLACEHOLDER_##x, y)
#define ____or(arg1_or_junk, y) __take_second_arg(arg1_or_junk 1, y)
#define IS_BUILTIN(option) __is_defined(option)
#define IS_MODULE(option) __is_defined(option##_MODULE)
#define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option))

View File

@@ -5,6 +5,7 @@ include_directories(
)
if (${ARCH_NAME} STREQUAL "armv7_8m")
set(START_LIB start)
set(START_INIT_LIB start_init)
# add_subdirectory(app)
add_subdirectory(hello)
@@ -17,6 +18,8 @@ elseif(${CONFIG_ARCH} STREQUAL "aarch64" )
START_LIB
""
)
set(START_INIT_LIB "")
set(
START_SRC
${CMAKE_SOURCE_DIR}/build/libc/output/lib/crt1.o

View File

@@ -64,7 +64,7 @@ if ((DEFINED CONFIG_ELF_LAUNCH) AND (CONFIG_ELF_LAUNCH STREQUAL "y"))
add_custom_target(
cpiofs_dump_elf ALL
COMMAND
cp cpiofs.elf ${CMAKE_SOURCE_DIR}/build/output/cpio/cpiofs.elf
cp cpiofs.elf ${CMAKE_SOURCE_DIR}/build/output/cpio/cpiofs
)
add_dependencies(cpiofs_dump_elf cpiofs_dump)
endif()

View File

@@ -1,4 +1,5 @@
#include <u_util.h>
#if !IS_ENABLED(CONFIG_MMU)
#define HEAP_SIZE 512
#define STACK_SIZE (2048)
@@ -15,3 +16,4 @@
__attribute__((used)) HEAP_ATTR static char _____heap_____[HEAP_SIZE];
__attribute__((used)) STACK_ATTR static char _____stack_____[STACK_SIZE];
#endif

View File

@@ -10,7 +10,7 @@ target_link_libraries(init.elf
PUBLIC
-Bstatic
${LIBC_NAME}
${START_LIB}
${START_INIT_LIB}
--whole-archive
libc_be
sys
@@ -59,7 +59,7 @@ if ((DEFINED CONFIG_ELF_LAUNCH) AND (CONFIG_ELF_LAUNCH STREQUAL "y"))
add_custom_target(
init_dump_elf ALL
COMMAND
cp init.elf ${CMAKE_SOURCE_DIR}/build/output/cpio/init.elf
cp init.elf ${CMAKE_SOURCE_DIR}/build/output/cpio/init
)
add_dependencies(init_dump_elf init_dump)
endif()

View File

@@ -1,4 +1,5 @@
#ifndef CONFIG_MMU
#include <u_util.h>
#if !IS_ENABLED(CONFIG_MMU)
/**
* @file heap_stack.c
* @author ATShining (1358745329@qq.com)

View File

@@ -1,8 +1,8 @@
#一次读取一行,每行代表启动的应用程序,暂时不支持参数
# fatfs
cpiofs.elf
cpiofs
# dm9000_drv
# net
sh.elf
sh
# lcd_drv

View File

@@ -53,7 +53,7 @@ if ((DEFINED CONFIG_ELF_LAUNCH) AND (CONFIG_ELF_LAUNCH STREQUAL "y"))
add_custom_target(
sh_dump_elf ALL
COMMAND
cp sh.elf ${CMAKE_SOURCE_DIR}/build/output/cpio/sh.elf
cp sh.elf ${CMAKE_SOURCE_DIR}/build/output/cpio/sh
)
add_dependencies(sh_dump_elf shell_dump)
endif()

View File

@@ -1,4 +1,5 @@
#ifndef CONFIG_MMU
#include <u_util.h>
#if !IS_ENABLED(CONFIG_MMU)
#define HEAP_SIZE 2048
#define STACK_SIZE (1024 + 512)