1 /*
2  * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #if !PICO_NO_BINARY_INFO && !PICO_NO_PROGRAM_INFO
8 #include "pico/binary_info.h"
9 
10 #if LIB_BOOT_STAGE2_HEADERS && !PICO_NO_FLASH
11 #include "boot_stage2/config.h"
12 #endif
13 
14 // Note we put at most 4 pieces of binary info in the binary_info_header section because that's how much spare space we
15 // have before the vector table in a RAM binary (we use the attribute for the most common ones since the choice is static)...
16 // if there is a link failure because of .reset section overflow then move more out.
17 #if PICO_NO_FLASH
18 #define section_hack_attr __attribute__((section(".binary_info_header")))
19 #else
20 #define section_hack_attr
21 #endif
22 
23 #if !PICO_NO_FLASH
24 #ifndef PICO_NO_BI_BINARY_SIZE
25 extern char __flash_binary_end;
26 bi_decl_with_attr(bi_binary_end((intptr_t)&__flash_binary_end), section_hack_attr)
27 #endif
28 #endif
29 
30 #if !PICO_NO_BI_PROGRAM_BUILD_DATE
31 #ifndef PICO_PROGRAM_BUILD_DATE
32 #define PICO_PROGRAM_BUILD_DATE __DATE__
33 #endif
34 bi_decl_with_attr(bi_program_build_date_string(PICO_PROGRAM_BUILD_DATE), section_hack_attr);
35 #endif
36 
37 #if !PICO_NO_BI_PROGRAM_NAME
38 #if !defined(PICO_PROGRAM_NAME) && defined(PICO_TARGET_NAME)
39 #define PICO_PROGRAM_NAME PICO_TARGET_NAME
40 #endif
41 #ifdef PICO_PROGRAM_NAME
42 bi_decl_with_attr(bi_program_name(PICO_PROGRAM_NAME), section_hack_attr)
43 #endif
44 #endif
45 
46 #if !PICO_NO_BI_PICO_BOARD
47 #ifdef PICO_BOARD
48 bi_decl(bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_PICO_BOARD, PICO_BOARD))
49 #endif
50 #endif
51 
52 #if !PICO_NO_BI_SDK_VERSION
53 #ifdef PICO_SDK_VERSION_STRING
54 bi_decl_with_attr(bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_SDK_VERSION, PICO_SDK_VERSION_STRING), section_hack_attr)
55 #endif
56 #endif
57 
58 #if !PICO_NO_BI_PROGRAM_VERSION_STRING
59 #ifdef PICO_PROGRAM_VERSION_STRING
60 bi_decl(bi_program_version_string(PICO_PROGRAM_VERSION_STRING))
61 #endif
62 #endif
63 
64 #if !PICO_NO_BI_PROGRAM_DESCRIPTION
65 #ifdef PICO_PROGRAM_DESCRIPTION
66 bi_decl(bi_program_description(PICO_PROGRAM_DESCRIPTION))
67 #endif
68 #endif
69 
70 #if !PICO_NO_BI_PROGRAM_URL
71 #ifdef PICO_PROGRAM_URL
72 bi_decl(bi_program_url(PICO_PROGRAM_URL))
73 #endif
74 #endif
75 
76 #if !PICO_NO_BI_BOOT_STAGE2_NAME
77 #ifdef PICO_BOOT_STAGE2_NAME
78 bi_decl(bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_BOOT2_NAME, PICO_BOOT_STAGE2_NAME))
79 #endif
80 #endif
81 
82 #if !PICO_NO_BI_BUILD_TYPE
83 #ifdef PICO_CMAKE_BUILD_TYPE
84 bi_decl(bi_program_build_attribute(PICO_CMAKE_BUILD_TYPE))
85 #else
86 #ifndef NDEBUG
87 bi_decl(bi_program_build_attribute("Debug"))
88 #else
89 bi_decl(bi_program_build_attribute("Release"))
90 #endif
91 #endif
92 
93 #if PICO_DEOPTIMIZED_DEBUG
94 bi_decl(bi_program_build_attribute("All optimization disabled"))
95 #endif
96 #endif
97 
98 #endif
99