-
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. CMake's arguments or Kconfig configuration allow overriding of the values. It can override by command line argument to CMake, such as ``` west build -b rpi_pico -- -DPICO_PROGRAM_NAME="my program" ... ``` Or also can override by Kconfig definitions. ``` CONFIG_RP2_BINARY_INFO_PROGRAM_NAME_OVERRIDE=y CONFIG_RP2_BINARY_INFO_PROGRAM_NAME="my program override" ``` Signed-off-by: TOKITA Hiroshi <[email protected]>
- Loading branch information
Showing
7 changed files
with
262 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,118 @@ | ||
/* | ||
* Copyright (c) 2023 TOKITA Hiroshi <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
|
||
#include <pico/binary_info.h> | ||
#include <boot_stage2/config.h> | ||
|
||
#include <version.h> | ||
|
||
#if CONFIG_RP2_BINARY_INFO_PROGRAM_NAME_OVERRIDE | ||
#undef PICO_PROGRAM_NAME | ||
#define PICO_PROGRAM_NAME CONFIG_RP2_BINARY_INFO_PROGRAM_NAME | ||
#else | ||
#ifndef PICO_PROGRAM_NAME | ||
#define PICO_PROGRAM_NAME APPLICATION_SOURCE_DIR_BASE | ||
#endif | ||
#endif | ||
|
||
#if CONFIG_RP2_BINARY_INFO_BOARD_OVERRIDE | ||
#undef PICO_BOARD | ||
#define PICO_BOARD CONFIG_RP2_BINARY_INFO_BOARD | ||
#else | ||
#ifndef PICO_BOARD | ||
#define PICO_BOARD CONFIG_BOARD | ||
#endif | ||
#endif | ||
|
||
#if CONFIG_RP2_BINARY_INFO_SDK_VERSION_STRING_OVERRIDE | ||
#undef PICO_SDK_VERSION_STRING | ||
#define PICO_SDK_VERSION_STRING CONFIG_RP2_BINARY_INFO_SDK_VERSION_STRING | ||
#else | ||
#ifndef PICO_SDK_VERSION_STRING | ||
#define PICO_SDK_VERSION_STRING RPI_PICO_SDK_VERSION_STRING | ||
#endif | ||
#endif | ||
|
||
#if CONFIG_RP2_BINARY_INFO_PROGRAM_VERSION_STRING_OVERRIDE | ||
#undef PICO_PROGRAM_VERSION_STRING | ||
#define PICO_PROGRAM_VERSION_STRING CONFIG_RP2_BINARY_INFO_PROGRAM_VERSION_STRING | ||
#else | ||
#ifndef PICO_PROGRAM_VERSION_STRING | ||
#define PICO_PROGRAM_VERSION_STRING STRINGIFY(BUILD_VERSION) | ||
#endif | ||
#endif | ||
|
||
#if CONFIG_RP2_BINARY_INFO_PROGRAM_BUILD_DATE_OVERRIDE | ||
#undef PICO_PROGRAM_BUILD_DATE | ||
#define PICO_PROGRAM_BUILD_DATE CONFIG_RP2_BINARY_INFO_PROGRAM_BUILD_DATE | ||
#ifndef PICO_PROGRAM_BUILD_DATE | ||
#define PICO_PROGRAM_BUILD_DATE __DATE__ | ||
#endif | ||
#endif | ||
|
||
#if CONFIG_RP2_BINARY_INFO_PROGRAM_DESCRIPTION_OVERRIDE | ||
#undef PICO_PROGRAM_DESCRIPTION | ||
#define PICO_PROGRAM_DESCRIPTION CONFIG_RP2_BINARY_INFO_PROGRAM_DESCRIPTION | ||
#else | ||
#ifndef PICO_PROGRAM_DESCRIPTION | ||
#define PICO_PROGRAM_DESCRIPTION CONFIG_RP2_BINARY_INFO_PROGRAM_DESCRIPTION | ||
#endif | ||
#endif | ||
|
||
#if CONFIG_RP2_BINARY_INFO_PROGRAM_URL_OVERRIDE | ||
#undef PICO_PROGRAM_URL | ||
#define PICO_PROGRAM_URL CONFIG_RP2_BINARY_INFO_PROGRAM_URL | ||
#else | ||
#ifndef PICO_PROGRAM_URL | ||
#define PICO_PROGRAM_URL CONFIG_RP2_BINARY_INFO_PROGRAM_URL | ||
#endif | ||
#endif | ||
|
||
extern uint32_t __rom_region_end; | ||
bi_decl(bi_binary_end((intptr_t)&__rom_region_end)); | ||
|
||
#ifdef PICO_PROGRAM_NAME | ||
bi_decl(bi_program_name((uint32_t)PICO_PROGRAM_NAME)); | ||
#endif | ||
|
||
#ifdef PICO_BOARD | ||
bi_decl(bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_PICO_BOARD, | ||
(uint32_t)PICO_BOARD)); | ||
#endif | ||
|
||
#ifdef PICO_SDK_VERSION_STRING | ||
bi_decl(bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_SDK_VERSION, | ||
(uint32_t)PICO_SDK_VERSION_STRING)); | ||
#endif | ||
|
||
#ifdef PICO_PROGRAM_VERSION_STRING | ||
bi_decl(bi_program_version_string((uint32_t)PICO_PROGRAM_VERSION_STRING)); | ||
#endif | ||
|
||
#ifdef PICO_PROGRAM_DESCRIPTION | ||
bi_decl(bi_program_description((uint32_t)PICO_PROGRAM_DESCRIPTION)); | ||
#endif | ||
|
||
#ifdef PICO_PROGRAM_URL | ||
bi_decl(bi_program_url((uint32_t)PICO_PROGRAM_URL)); | ||
#endif | ||
|
||
#ifdef PICO_PROGRAM_BUILD_DATE | ||
bi_decl(bi_program_build_date_string((uint32_t)PICO_PROGRAM_BUILD_DATE)); | ||
#endif | ||
|
||
#ifdef PICO_BOOT_STAGE2_NAME | ||
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 |
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)) |