-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
soc: arm: rpi_pico: Add basic support for binary info feature
Enable embedding binary info to flash. As a default, information collects from the build configuration. It can override by the Kconfig configurations, such as ``` CONFIG_RP2_BINARY_INFO_PROGRAM_NAME_OVERRIDE=y CONFIG_RP2_BINARY_INFO_PROGRAM_NAME="my program name" ``` Signed-off-by: TOKITA Hiroshi <[email protected]>
- Loading branch information
Showing
7 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright (c) 2023 TOKITA Hiroshi <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <soc.h> | ||
|
||
#include <pico/binary_info.h> | ||
#include <boot_stage2/config.h> | ||
|
||
#include <version.h> | ||
|
||
#ifdef CONFIG_RP2_BINARY_INFO_RP_PROGRAM_NAME_OVERRIDE | ||
#define BI_PROGRAM_NAME CONFIG_RP2_BINARY_INFO_RP_PROGRAM_NAME | ||
#else | ||
#define BI_PROGRAM_NAME APPLICATION_SOURCE_DIR_BASE | ||
#endif | ||
|
||
#ifdef CONFIG_RP2_BINARY_INFO_RP_PICO_BOARD_OVERRIDE | ||
#define BI_PICO_BOARD CONFIG_RP2_BINARY_INFO_RP_PICO_BOARD | ||
#else | ||
#define BI_PICO_BOARD CONFIG_BOARD | ||
#endif | ||
|
||
#ifdef CONFIG_RP2_BINARY_INFO_RP_SDK_VERSION_STRING_OVERRIDE | ||
#define BI_SDK_VERSION_STRING CONFIG_RP2_BINARY_INFO_RP_SDK_VERSION_STRING | ||
#else | ||
#define BI_SDK_VERSION_STRING PICO_SDK_VERSION_STRING | ||
#endif | ||
|
||
#ifdef CONFIG_RP2_BINARY_INFO_RP_PROGRAM_VERSION_STRING_OVERRIDE | ||
#define BI_PROGRAM_VERSION_STRING CONFIG_RP2_BINARY_INFO_RP_PROGRAM_VERSION_STRING | ||
#else | ||
#define BI_PROGRAM_VERSION_STRING STRINGIFY(BUILD_VERSION) | ||
#endif | ||
|
||
#ifdef CONFIG_RP2_BINARY_INFO_RP_PROGRAM_BUILD_DATE_OVERRIDE | ||
#define BI_PROGRAM_BUILD_DATE CONFIG_RP2_BINARY_INFO_RP_PROGRAM_BUILD_DATE | ||
#else | ||
#define BI_PROGRAM_BUILD_DATE __DATE__ | ||
#endif | ||
|
||
#ifdef CONFIG_RP2_BINARY_INFO_RP_PROGRAM_DESCRIPTION_OVERRIDE | ||
#define BI_PROGRAM_DESCRIPTION CONFIG_RP2_BINARY_INFO_RP_PROGRAM_DESCRIPTION | ||
#endif | ||
|
||
#ifdef CONFIG_RP2_BINARY_INFO_RP_PROGRAM_URL_OVERRIDE | ||
#define BI_PROGRAM_URL CONFIG_RP2_BINARY_INFO_RP_PROGRAM_URL | ||
#endif | ||
|
||
extern uint32_t __rom_region_end; | ||
bi_decl(bi_binary_end((intptr_t)&__rom_region_end)); | ||
|
||
#ifdef BI_PROGRAM_NAME | ||
bi_decl(bi_program_name((uint32_t)BI_PROGRAM_NAME)); | ||
#endif | ||
|
||
#ifdef BI_PICO_BOARD | ||
bi_decl(bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_PICO_BOARD, | ||
(uint32_t)BI_PICO_BOARD)); | ||
#endif | ||
|
||
#ifdef BI_SDK_VERSION_STRING | ||
bi_decl(bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_SDK_VERSION, | ||
(uint32_t)BI_SDK_VERSION_STRING)); | ||
#endif | ||
|
||
#ifdef BI_PROGRAM_VERSION_STRING | ||
bi_decl(bi_program_version_string((uint32_t)BI_PROGRAM_VERSION_STRING)); | ||
#endif | ||
|
||
#ifdef BI_PROGRAM_DESCRIPTION | ||
bi_decl(bi_program_description((uint32_t)BI_PROGRAM_DESCRIPTION)); | ||
#endif | ||
|
||
#ifdef BI_PROGRAM_URL | ||
bi_decl(bi_program_url((uint32_t)BI_PROGRAM_URL)); | ||
#endif | ||
|
||
#ifdef BI_PROGRAM_BUILD_DATE | ||
bi_decl(bi_program_build_date_string((uint32_t)BI_PROGRAM_BUILD_DATE)); | ||
#endif | ||
|
||
#ifdef BI_BOOT_STAGE2_NAME | ||
bi_decl(bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_BOOT2_NAME, | ||
(uint32_t)BI_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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Copyright (c) 2023 TOKITA Hiroshi <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
. = ALIGN(4); | ||
__binary_info_start = .; | ||
KEEP(*(.binary_info.keep.*)) | ||
*(.binary_info.*) | ||
__binary_info_end = .; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) 2023 TOKITA Hiroshi <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "pico/binary_info/defs.h" | ||
|
||
.section .binary_info_header | ||
|
||
/* binary_info_header */ | ||
binary_info_header: | ||
.word BINARY_INFO_MARKER_START | ||
.word __binary_info_start | ||
.word __binary_info_end | ||
.word data_cpy_table // we may need to decode pointers that are in RAM at runtime. | ||
.word BINARY_INFO_MARKER_END | ||
|
||
.align 2 | ||
|
||
/* data_cpy_table */ | ||
data_cpy_table: | ||
.word 0 /* centinel */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright (c) 2023 TOKITA Hiroshi <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
KEEP (*(.binary_info_header)) |