Skip to content

soc: arm: rpi_pico: Add support for binary info feature #54290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions include/zephyr/devicetree.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,44 @@
*/
#define DT_CHILD(node_id, child) UTIL_CAT(node_id, DT_S_PREFIX(child))

/**
* @brief Get a child node by index
*
* This macro retrieves a child node of a specified node by its
* index. The index corresponds to the order in which the child nodes
* are defined in the Devicetree source.
*
* Example devicetree fragment:
*
* @code{.dts}
* / {
* parent_node {
* first_child {
* reg = <0>;
* };
* second_child {
* reg = <1>;
* };
* };
* };
* @endcode
*
* Example usage:
*
* @code{.c}
* DT_CHILD_BY_IDX(DT_NODELABEL(parent_node), 0) // "first_child"
* DT_CHILD_BY_IDX(DT_NODELABEL(parent_node), 1) // "second_child"
* @endcode
*
* @param node_id The identifier of the parent node. This can be obtained
* using macros like DT_NODELABEL(), DT_PATH(), or similar.
* @param idx The index of the child node to retrieve. Must be within
* the range of 0 to DT_CHILD_NUM(node_id) - 1.
*
* @return The identifier of the child node at the specified index.
*/
#define DT_CHILD_BY_IDX(node_id, idx) UTIL_CAT(UTIL_CAT(node_id, _CHILD_IDX_), idx)

/**
* @brief Get a node identifier for a status `okay` node with a compatible
*
Expand Down
2 changes: 2 additions & 0 deletions modules/hal_rpi_pico/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ if(CONFIG_HAS_RPI_PICO)
${rp2_common_dir}/pico_platform_panic/include
${common_dir}/boot_picoboot_headers/include
${common_dir}/boot_picobin_headers/include
${common_dir}/pico_binary_info/include
${rp2xxx_dir}/hardware_regs/include
${rp2xxx_dir}/hardware_structs/include
${rp2xxx_dir}/pico_platform/include
${boot_stage_dir}/include
${CMAKE_CURRENT_LIST_DIR}
)

Expand Down
6 changes: 5 additions & 1 deletion modules/hal_rpi_pico/pico/config_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@
/* Convert uses of asm, which is not supported in c99, to __asm */
#define asm __asm

/* Disable binary info */
/* Configure binary info */
#ifndef CONFIG_RPI_PICO_BINARY_INFO
#define PICO_NO_BINARY_INFO 1
#else
#define PICO_NO_BINARY_INFO 0
#endif

#ifdef CONFIG_DT_HAS_RASPBERRYPI_PICO_XOSC_ENABLED
#include <zephyr/devicetree.h>
Expand Down
4 changes: 3 additions & 1 deletion scripts/dts/gen_defines.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,12 @@ def write_children(node: edtlib.Node) -> None:
out_dt_define(f"{node.z_path_id}_CHILD_NUM", len(node.children))

ok_nodes_num = 0
for child in node.children.values():
for i, child in enumerate(node.children.values()):
if child.status == "okay":
ok_nodes_num = ok_nodes_num + 1

out_dt_define(f"{node.z_path_id}_CHILD_IDX_{i}", f"DT_{child.z_path_id}")

out_dt_define(f"{node.z_path_id}_CHILD_NUM_STATUS_OKAY", ok_nodes_num)

out_dt_define(f"{node.z_path_id}_FOREACH_CHILD(fn)",
Expand Down
13 changes: 13 additions & 0 deletions soc/raspberrypi/rpi_pico/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,16 @@ zephyr_include_directories(.)
zephyr_sources(
soc.c
)

zephyr_library_sources_ifdef(CONFIG_RPI_PICO_BINARY_INFO
binary_info.c
binary_info_header.S
)

zephyr_linker_sources_ifdef(CONFIG_RPI_PICO_BINARY_INFO
ROM_START SORT_KEY 0x0binary_info_header binary_info_header.ld
)

zephyr_linker_sources_ifdef(CONFIG_RPI_PICO_BINARY_INFO
RODATA binary_info.ld
)
65 changes: 65 additions & 0 deletions soc/raspberrypi/rpi_pico/common/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright (c) 2024 TOKITA Hiroshi
# SPDX-License-Identifier: Apache-2.0

config RPI_PICO_BINARY_INFO
bool "Generate RaspberryPi Pico binary info"
default y
help
Binary info is able to embed machine readable information with the binary in FLASH.
It can read with picotool(https://github.com/raspberrypi/picotool).

if RPI_PICO_BINARY_INFO

config RPI_PICO_BINARY_INFO_PROGRAM_NAME_ENABLE
bool "Override program name in binary info"

config RPI_PICO_BINARY_INFO_PROGRAM_NAME
string "Override string for program name in binary info"
depends on RPI_PICO_BINARY_INFO_PROGRAM_NAME_ENABLE

config RPI_PICO_BINARY_INFO_PROGRAM_URL_ENABLE
bool "Override program url in binary info"

config RPI_PICO_BINARY_INFO_PROGRAM_URL
string "String for program description in binary info"
depends on RPI_PICO_BINARY_INFO_PROGRAM_URL_ENABLE

config RPI_PICO_BINARY_INFO_PROGRAM_DESCRIPTION_ENABLE
bool "Override program descrpition in binary info"

config RPI_PICO_BINARY_INFO_PROGRAM_DESCRIPTION
string "String for program description in binary info"
depends on RPI_PICO_BINARY_INFO_PROGRAM_DESCRIPTION_ENABLE

config RPI_PICO_BINARY_INFO_PROGRAM_BUILD_DATE_ENABLE
bool "Override build date in binary info"

config RPI_PICO_BINARY_INFO_PROGRAM_BUILD_DATE
string "Override string for build date in binary info"
depends on RPI_PICO_BINARY_INFO_PROGRAM_BUILD_DATE_ENABLE

config RPI_PICO_BINARY_INFO_PROGRAM_VERSION_STRING_ENABLE
bool "Override program version in binary info"
default y

config RPI_PICO_BINARY_INFO_SDK_VERSION_STRING_ENABLE
bool "Override sdk version in binary info"
default y

config RPI_PICO_BINARY_INFO_PICO_BOARD_ENABLE
bool "Override board in binary info"
default y

config RPI_PICO_BINARY_INFO_ATTRIBUTE_BUILD_TYPE_ENABLE
bool "Override board in binary info"
default y

config RPI_PICO_BINARY_INFO_BOOT_STAGE2_NAME_ENABLE
bool "Override board in binary info"
default y

config RPI_PICO_BINARY_INFO_PINS_WITH_FUNC_ENABLE
bool "Override board in binary info"
default y

endif
Loading
Loading