From e0cbdf60e50cb5bff67b1f50d8ef1e3342576451 Mon Sep 17 00:00:00 2001 From: TOKITA Hiroshi Date: Thu, 26 Sep 2024 06:12:11 +0900 Subject: [PATCH] x --- modules/hal_rpi_pico/CMakeLists.txt | 4 +- .../rpi_pico/common/CMakeLists.txt | 13 + soc/raspberrypi/rpi_pico/common/Kconfig | 3 + soc/raspberrypi/rpi_pico/common/binary_info.c | 261 ++++++++++++------ soc/raspberrypi/rpi_pico/common/soc.h | 1 - 5 files changed, 197 insertions(+), 85 deletions(-) create mode 100644 soc/raspberrypi/rpi_pico/common/Kconfig diff --git a/modules/hal_rpi_pico/CMakeLists.txt b/modules/hal_rpi_pico/CMakeLists.txt index 42b48e93ce24720..819e723bda8be90 100644 --- a/modules/hal_rpi_pico/CMakeLists.txt +++ b/modules/hal_rpi_pico/CMakeLists.txt @@ -8,7 +8,7 @@ if(CONFIG_HAS_RPI_PICO) set(rp2_common_dir ${ZEPHYR_HAL_RPI_PICO_MODULE_DIR}/src/rp2_common) set(rp2xxx_dir ${ZEPHYR_HAL_RPI_PICO_MODULE_DIR}/src/${CONFIG_SOC_SERIES}) set(common_dir ${ZEPHYR_HAL_RPI_PICO_MODULE_DIR}/src/common) - set(boot_stage_dir ${rp2xxx_dir}/boot_stage2) + set(boot_stage2_dir ${rp2xxx_dir}/boot_stage2) # The Second Stage Bootloader is only linked to the app that resides # at 0x100. Therefore, only if the app's offset is 0x100, the second @@ -91,7 +91,7 @@ if(CONFIG_HAS_RPI_PICO) ${rp2xxx_dir}/hardware_regs/include ${rp2xxx_dir}/hardware_structs/include ${rp2xxx_dir}/pico_platform/include - ${boot_stage_dir}/include + ${boot_stage2_dir}/include ${CMAKE_CURRENT_LIST_DIR} ) diff --git a/soc/raspberrypi/rpi_pico/common/CMakeLists.txt b/soc/raspberrypi/rpi_pico/common/CMakeLists.txt index d87ecff49c08db4..ef561f0abd79c56 100644 --- a/soc/raspberrypi/rpi_pico/common/CMakeLists.txt +++ b/soc/raspberrypi/rpi_pico/common/CMakeLists.txt @@ -6,3 +6,16 @@ zephyr_include_directories(.) zephyr_sources( soc.c ) + +zephyr_library_sources_ifdef(CONFIG_RP2_BINARY_INFO + binary_info.c + binary_info_header.S +) + +zephyr_linker_sources_ifdef(CONFIG_RP2_BINARY_INFO + ROM_START SORT_KEY 0x0binary_info_header binary_info_header.ld +) + +zephyr_linker_sources_ifdef(CONFIG_RP2_BINARY_INFO + RODATA binary_info.ld +) diff --git a/soc/raspberrypi/rpi_pico/common/Kconfig b/soc/raspberrypi/rpi_pico/common/Kconfig new file mode 100644 index 000000000000000..532f068ad57fc00 --- /dev/null +++ b/soc/raspberrypi/rpi_pico/common/Kconfig @@ -0,0 +1,3 @@ +config RP2_BINARY_INFO + bool "" + default y diff --git a/soc/raspberrypi/rpi_pico/common/binary_info.c b/soc/raspberrypi/rpi_pico/common/binary_info.c index 02225d490a72fd7..0cf4b482da582de 100644 --- a/soc/raspberrypi/rpi_pico/common/binary_info.c +++ b/soc/raspberrypi/rpi_pico/common/binary_info.c @@ -23,88 +23,7 @@ #include #include -#ifdef CONFIG_BINARY_INFO_PROGRAM_NAME -#define BI_PROGRAM_NAME CONFIG_BINARY_INFO_PROGRAM_NAME -#else -/* Use project folder name as application name */ -#define BI_PROGRAM_NAME APPLICATION_SOURCE_DIR_BASE -#endif - -#ifdef CONFIG_BINARY_INFO_PICO_BOARD -#define BI_PICO_BOARD CONFIG_BINARY_INFO_PICO_BOARD -#else -#define BI_PICO_BOARD CONFIG_BOARD -#endif - -#ifdef CONFIG_BINARY_INFO_SDK_VERSION_STRING -#define BI_SDK_VERSION_STRING CONFIG_BINARY_INFO_SDK_VERSION_STRING -#else -#define BI_SDK_VERSION_STRING "zephyr-" STRINGIFY(BUILD_VERSION) -#endif - -#ifdef CONFIG_BINARY_INFO_PROGRAM_VERSION_STRING -#define BI_PROGRAM_VERSION_STRING CONFIG_BINARY_INFO_PROGRAM_VERSION_STRING -#else -#define BI_PROGRAM_VERSION_STRING APP_VERSION_EXTENDED_STRING -#endif - -#ifdef CONFIG_BINARY_INFO_PROGRAM_BUILD_DATE -#define BI_PROGRAM_BUILD_DATE CONFIG_BINARY_INFO_PROGRAM_BUILD_DATE -#else -#define BI_PROGRAM_BUILD_DATE __DATE__ -#endif - -#ifdef CONFIG_BINARY_INFO_PROGRAM_DESCRIPTION -#define BI_PROGRAM_DESCRIPTION CONFIG_BINARY_INFO_PROGRAM_DESCRIPTION -#endif - -#ifdef CONFIG_BINARY_INFO_PROGRAM_URL -#define BI_PROGRAM_URL CONFIG_BINARY_INFO_PROGRAM_URL -#endif - -extern uint32_t __rom_region_end; -bi_decl(bi_binary_end((intptr_t)&__rom_region_end)); - -#ifdef CONFIG_BINARY_INFO_PROGRAM_NAME_ENABLE -bi_decl(bi_program_name((uint32_t)BI_PROGRAM_NAME)); -#endif - -#ifdef CONFIG_BINARY_INFO_PICO_BOARD_ENABLE -bi_decl(bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_PICO_BOARD, - (uint32_t)BI_PICO_BOARD)); -#endif - -#ifdef CONFIG_BINARY_INFO_PROGRAM_VERSION_STRING_ENABLE -bi_decl(bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_SDK_VERSION, - (uint32_t)BI_SDK_VERSION_STRING)); -#endif - -#ifdef CONFIG_BINARY_INFO_PROGRAM_VERSION_STRING_ENABLE -bi_decl(bi_program_version_string((uint32_t)BI_PROGRAM_VERSION_STRING)); -#endif - -#ifdef CONFIG_BINARY_INFO_PROGRAM_DESCRIPTION_ENABLE -bi_decl(bi_program_description((uint32_t)BI_PROGRAM_DESCRIPTION)); -#endif - -#ifdef CONFIG_BINARY_INFO_PROGRAM_URL_ENABLE -bi_decl(bi_program_url((uint32_t)BI_PROGRAM_URL)); -#endif - -#ifdef CONFIG_BINARY_INFO_PROGRAM_BUILD_DATE_ENABLE -bi_decl(bi_program_build_date_string((uint32_t)BI_PROGRAM_BUILD_DATE)); -#endif - -#ifdef CONFIG_BINARY_INFO_BOOT_STAGE2_NAME_ENABLE -bi_decl(bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_BOOT2_NAME, - (uint32_t)PICO_BOOT_STAGE2_NAME)); -#endif - -#ifndef NDEBUG -bi_decl(bi_program_build_attribute((uint32_t) "Debug")); -#else -bi_decl(bi_program_build_attribute((uint32_t) "Release")); -#endif +/* Definition for simple calculations using macros */ #define EXPR_ADD_0_0 0 #define EXPR_ADD_0_1 1 @@ -113,27 +32,99 @@ bi_decl(bi_program_build_attribute((uint32_t) "Release")); #define EXPR_ADD_0_4 4 #define EXPR_ADD_0_5 5 #define EXPR_ADD_0_6 6 +#define EXPR_ADD_0_7 7 +#define EXPR_ADD_0_8 8 +#define EXPR_ADD_0_9 9 #define EXPR_ADD_1_0 1 #define EXPR_ADD_1_1 2 #define EXPR_ADD_1_2 3 #define EXPR_ADD_1_3 4 #define EXPR_ADD_1_4 5 #define EXPR_ADD_1_5 6 +#define EXPR_ADD_1_6 7 +#define EXPR_ADD_1_7 8 +#define EXPR_ADD_1_8 9 +#define EXPR_ADD_1_9 10 #define EXPR_ADD_2_0 2 #define EXPR_ADD_2_1 3 #define EXPR_ADD_2_2 4 #define EXPR_ADD_2_3 5 #define EXPR_ADD_2_4 6 +#define EXPR_ADD_2_5 7 +#define EXPR_ADD_2_6 8 +#define EXPR_ADD_2_7 9 +#define EXPR_ADD_2_8 10 +#define EXPR_ADD_2_9 11 #define EXPR_ADD_3_0 3 #define EXPR_ADD_3_1 4 #define EXPR_ADD_3_2 5 #define EXPR_ADD_3_3 6 +#define EXPR_ADD_3_4 7 +#define EXPR_ADD_3_5 8 +#define EXPR_ADD_3_6 9 +#define EXPR_ADD_3_7 10 +#define EXPR_ADD_3_8 11 +#define EXPR_ADD_3_9 12 #define EXPR_ADD_4_0 4 #define EXPR_ADD_4_1 5 #define EXPR_ADD_4_2 6 +#define EXPR_ADD_4_3 7 +#define EXPR_ADD_4_4 8 +#define EXPR_ADD_4_5 9 +#define EXPR_ADD_4_6 10 +#define EXPR_ADD_4_7 11 +#define EXPR_ADD_4_8 12 +#define EXPR_ADD_4_9 13 #define EXPR_ADD_5_0 5 #define EXPR_ADD_5_1 6 +#define EXPR_ADD_5_2 7 +#define EXPR_ADD_5_3 8 +#define EXPR_ADD_5_4 9 +#define EXPR_ADD_5_5 10 +#define EXPR_ADD_5_6 11 +#define EXPR_ADD_5_7 12 +#define EXPR_ADD_5_8 13 +#define EXPR_ADD_5_9 14 #define EXPR_ADD_6_0 6 +#define EXPR_ADD_6_1 7 +#define EXPR_ADD_6_2 8 +#define EXPR_ADD_6_3 9 +#define EXPR_ADD_6_4 10 +#define EXPR_ADD_6_5 11 +#define EXPR_ADD_6_6 12 +#define EXPR_ADD_6_7 13 +#define EXPR_ADD_6_8 14 +#define EXPR_ADD_6_9 15 +#define EXPR_ADD_7_0 7 +#define EXPR_ADD_7_1 8 +#define EXPR_ADD_7_2 9 +#define EXPR_ADD_7_3 10 +#define EXPR_ADD_7_4 11 +#define EXPR_ADD_7_5 12 +#define EXPR_ADD_7_6 13 +#define EXPR_ADD_7_7 14 +#define EXPR_ADD_7_8 15 +#define EXPR_ADD_7_9 16 +#define EXPR_ADD_8_0 8 +#define EXPR_ADD_8_1 9 +#define EXPR_ADD_8_2 10 +#define EXPR_ADD_8_3 11 +#define EXPR_ADD_8_4 12 +#define EXPR_ADD_8_5 13 +#define EXPR_ADD_8_6 14 +#define EXPR_ADD_8_7 15 +#define EXPR_ADD_8_8 16 +#define EXPR_ADD_8_9 17 +#define EXPR_ADD_9_0 9 +#define EXPR_ADD_9_1 10 +#define EXPR_ADD_9_2 11 +#define EXPR_ADD_9_3 12 +#define EXPR_ADD_9_4 13 +#define EXPR_ADD_9_5 14 +#define EXPR_ADD_9_6 15 +#define EXPR_ADD_9_7 16 +#define EXPR_ADD_9_8 17 +#define EXPR_ADD_9_9 18 #define EXPR_ADD(n, m) UTIL_CAT(UTIL_CAT(UTIL_CAT(EXPR_ADD_, n), _), m) #define EXPR_INCR(n) EXPR_ADD(n, 1) @@ -147,6 +138,7 @@ bi_decl(bi_program_build_attribute((uint32_t) "Release")); #define EXPR_EQ_0_6 0 #define EXPR_EQ_0_7 0 #define EXPR_EQ_0_8 0 +#define EXPR_EQ_0_9 0 #define EXPR_EQ_1_0 0 #define EXPR_EQ_1_1 1 #define EXPR_EQ_1_2 0 @@ -156,6 +148,7 @@ bi_decl(bi_program_build_attribute((uint32_t) "Release")); #define EXPR_EQ_1_6 0 #define EXPR_EQ_1_7 0 #define EXPR_EQ_1_8 0 +#define EXPR_EQ_1_9 0 #define EXPR_EQ_2_0 0 #define EXPR_EQ_2_1 0 #define EXPR_EQ_2_2 1 @@ -165,6 +158,7 @@ bi_decl(bi_program_build_attribute((uint32_t) "Release")); #define EXPR_EQ_2_6 0 #define EXPR_EQ_2_7 0 #define EXPR_EQ_2_8 0 +#define EXPR_EQ_2_9 0 #define EXPR_EQ_3_0 0 #define EXPR_EQ_3_1 0 #define EXPR_EQ_3_2 0 @@ -174,6 +168,7 @@ bi_decl(bi_program_build_attribute((uint32_t) "Release")); #define EXPR_EQ_3_6 0 #define EXPR_EQ_3_7 0 #define EXPR_EQ_3_8 0 +#define EXPR_EQ_3_9 0 #define EXPR_EQ_4_0 0 #define EXPR_EQ_4_1 0 #define EXPR_EQ_4_2 0 @@ -183,6 +178,7 @@ bi_decl(bi_program_build_attribute((uint32_t) "Release")); #define EXPR_EQ_4_6 0 #define EXPR_EQ_4_7 0 #define EXPR_EQ_4_8 0 +#define EXPR_EQ_4_9 0 #define EXPR_EQ_5_0 0 #define EXPR_EQ_5_1 0 #define EXPR_EQ_5_2 0 @@ -192,6 +188,7 @@ bi_decl(bi_program_build_attribute((uint32_t) "Release")); #define EXPR_EQ_5_6 0 #define EXPR_EQ_5_7 0 #define EXPR_EQ_5_8 0 +#define EXPR_EQ_5_9 0 #define EXPR_EQ_6_0 0 #define EXPR_EQ_6_1 0 #define EXPR_EQ_6_2 0 @@ -201,6 +198,7 @@ bi_decl(bi_program_build_attribute((uint32_t) "Release")); #define EXPR_EQ_6_6 1 #define EXPR_EQ_6_7 0 #define EXPR_EQ_6_8 0 +#define EXPR_EQ_6_9 0 #define EXPR_EQ_7_0 0 #define EXPR_EQ_7_1 0 #define EXPR_EQ_7_2 0 @@ -210,6 +208,7 @@ bi_decl(bi_program_build_attribute((uint32_t) "Release")); #define EXPR_EQ_7_6 0 #define EXPR_EQ_7_7 1 #define EXPR_EQ_7_8 0 +#define EXPR_EQ_7_9 0 #define EXPR_EQ_8_0 0 #define EXPR_EQ_8_1 0 #define EXPR_EQ_8_2 0 @@ -218,6 +217,18 @@ bi_decl(bi_program_build_attribute((uint32_t) "Release")); #define EXPR_EQ_8_5 0 #define EXPR_EQ_8_6 0 #define EXPR_EQ_8_7 0 +#define EXPR_EQ_8_8 1 +#define EXPR_EQ_8_9 0 +#define EXPR_EQ_9_0 0 +#define EXPR_EQ_9_1 0 +#define EXPR_EQ_9_2 0 +#define EXPR_EQ_9_3 0 +#define EXPR_EQ_9_4 0 +#define EXPR_EQ_9_5 0 +#define EXPR_EQ_9_6 0 +#define EXPR_EQ_9_7 0 +#define EXPR_EQ_9_8 0 +#define EXPR_EQ_9_9 1 #define EXPR_EQ(n, m) UTIL_CAT(UTIL_CAT(UTIL_CAT(EXPR_EQ_, n), _), m) @@ -282,6 +293,92 @@ bi_decl(bi_program_build_attribute((uint32_t) "Release")); #define BI_PINS_FROM_PINCTRL_GROUP(n, idx) BI_PINS_FROM_PINCTRL_GROUP_(DT_CHILD_BY_IDX(n, idx)) + + + +#ifdef CONFIG_BINARY_INFO_PROGRAM_NAME +#define BI_PROGRAM_NAME CONFIG_BINARY_INFO_PROGRAM_NAME +#else +/* Use project folder name as application name */ +#define BI_PROGRAM_NAME APPLICATION_SOURCE_DIR_BASE +#endif + +#ifdef CONFIG_BINARY_INFO_PICO_BOARD +#define BI_PICO_BOARD CONFIG_BINARY_INFO_PICO_BOARD +#else +#define BI_PICO_BOARD CONFIG_BOARD +#endif + +#ifdef CONFIG_BINARY_INFO_SDK_VERSION_STRING +#define BI_SDK_VERSION_STRING CONFIG_BINARY_INFO_SDK_VERSION_STRING +#else +#define BI_SDK_VERSION_STRING "zephyr-" STRINGIFY(BUILD_VERSION) +#endif + +#ifdef CONFIG_BINARY_INFO_PROGRAM_VERSION_STRING +#define BI_PROGRAM_VERSION_STRING CONFIG_BINARY_INFO_PROGRAM_VERSION_STRING +#else +#define BI_PROGRAM_VERSION_STRING APP_VERSION_EXTENDED_STRING +#endif + +#ifdef CONFIG_BINARY_INFO_PROGRAM_BUILD_DATE +#define BI_PROGRAM_BUILD_DATE CONFIG_BINARY_INFO_PROGRAM_BUILD_DATE +#else +#define BI_PROGRAM_BUILD_DATE __DATE__ +#endif + +#ifdef CONFIG_BINARY_INFO_PROGRAM_DESCRIPTION +#define BI_PROGRAM_DESCRIPTION CONFIG_BINARY_INFO_PROGRAM_DESCRIPTION +#endif + +#ifdef CONFIG_BINARY_INFO_PROGRAM_URL +#define BI_PROGRAM_URL CONFIG_BINARY_INFO_PROGRAM_URL +#endif + +extern uint32_t __rom_region_end; +bi_decl(bi_binary_end((intptr_t)&__rom_region_end)); + +#ifdef CONFIG_BINARY_INFO_PROGRAM_NAME_ENABLE +bi_decl(bi_program_name((uint32_t)BI_PROGRAM_NAME)); +#endif + +#ifdef CONFIG_BINARY_INFO_PICO_BOARD_ENABLE +bi_decl(bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_PICO_BOARD, + (uint32_t)BI_PICO_BOARD)); +#endif + +#ifdef CONFIG_BINARY_INFO_PROGRAM_VERSION_STRING_ENABLE +bi_decl(bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_SDK_VERSION, + (uint32_t)BI_SDK_VERSION_STRING)); +#endif + +#ifdef CONFIG_BINARY_INFO_PROGRAM_VERSION_STRING_ENABLE +bi_decl(bi_program_version_string((uint32_t)BI_PROGRAM_VERSION_STRING)); +#endif + +#ifdef CONFIG_BINARY_INFO_PROGRAM_DESCRIPTION_ENABLE +bi_decl(bi_program_description((uint32_t)BI_PROGRAM_DESCRIPTION)); +#endif + +#ifdef CONFIG_BINARY_INFO_PROGRAM_URL_ENABLE +bi_decl(bi_program_url((uint32_t)BI_PROGRAM_URL)); +#endif + +#ifdef CONFIG_BINARY_INFO_PROGRAM_BUILD_DATE_ENABLE +bi_decl(bi_program_build_date_string((uint32_t)BI_PROGRAM_BUILD_DATE)); +#endif + +#ifdef CONFIG_BINARY_INFO_BOOT_STAGE2_NAME_ENABLE +bi_decl(bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_BOOT2_NAME, + (uint32_t)PICO_BOOT_STAGE2_NAME)); +#endif + +#ifndef NDEBUG +bi_decl(bi_program_build_attribute((uint32_t) "Debug")); +#else +bi_decl(bi_program_build_attribute((uint32_t) "Release")); +#endif + BI_PINS_FROM_PINCTRL_GROUP(DT_NODELABEL(pinctrl), 0); BI_PINS_FROM_PINCTRL_GROUP(DT_NODELABEL(pinctrl), 1); BI_PINS_FROM_PINCTRL_GROUP(DT_NODELABEL(pinctrl), 2); diff --git a/soc/raspberrypi/rpi_pico/common/soc.h b/soc/raspberrypi/rpi_pico/common/soc.h index 6427e2b124f43bd..c3d669ec99beb08 100644 --- a/soc/raspberrypi/rpi_pico/common/soc.h +++ b/soc/raspberrypi/rpi_pico/common/soc.h @@ -13,6 +13,5 @@ #define _RPI_PICO_COMMON_SOC_H_ #include -#include #endif /* _RPI_PICO_COMMON_SOC_H_ */