Skip to content

Commit da3f56f

Browse files
committed
Add PICO_CONFIG entries for the metadata block configuration defines
Includes rejigging it a bit, as the checking script requires #defines for all configs
1 parent 299fb7d commit da3f56f

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed

src/rp2_common/pico_crt0/embedded_start_block.inc.S

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
#if !defined(PICO_CRT0_INCLUDE_PICOBIN_IMAGE_TYPE_ITEM)
1+
// PICO_CONFIG: PICO_CRT0_INCLUDE_PICOBIN_IMAGE_TYPE_ITEM, Include an image type item in the metadata block, default=0 on RP2040, 1 otherwise, type=bool, group=pico_crt0
2+
#ifndef PICO_CRT0_INCLUDE_PICOBIN_IMAGE_TYPE_ITEM
23
// todo decide whether we want this item for RP2040 by default, probably not (there are a zilloon binaries out there without it)
34
#if !PICO_RP2040
45
#define PICO_CRT0_INCLUDE_PICOBIN_IMAGE_TYPE_ITEM 1
56
#endif
67
#endif
78

9+
// PICO_CONFIG: PICO_CRT0_INCLUDE_PICOBIN_VECTOR_TABLE_ITEM, Include a vector table item in the metadata block, default=1 for no_flash binaries, 0 otherwise or on RP2040, type=bool, group=pico_crt0
810
#ifndef PICO_CRT0_INCLUDE_PICOBIN_VECTOR_TABLE_ITEM
911
// If no_flash bin, then include a vector table item
1012
#if PICO_NO_FLASH && !PICO_RP2040
1113
#define PICO_CRT0_INCLUDE_PICOBIN_VECTOR_TABLE_ITEM 1
1214
#endif
1315
#endif
1416

17+
// PICO_CONFIG: PICO_CRT0_INCLUDE_PICOBIN_ENTRY_POINT_ITEM, Include an entry point item in the metadata block, default=1 for Risc-V, 0 otherwise, type=bool, group=pico_crt0
1518
#ifndef PICO_CRT0_INCLUDE_PICOBIN_ENTRY_POINT_ITEM
1619
// On RISC-V the default entry point from bootrom is the start of the binary, but
1720
// we have our vtable at the start, so we must include an entry point
@@ -20,55 +23,72 @@
2023
#endif
2124
#endif
2225

26+
// PICO_CONFIG: PICO_CRT0_INCLUDE_PICOBIN_BLOCK, Include a metadata block at the start of the image, default=PICO_CRT0_INCLUDE_PICOBIN_IMAGE_TYPE_ITEM, type=bool, group=pico_crt0
2327
#ifndef PICO_CRT0_INCLUDE_PICOBIN_BLOCK
2428
#define PICO_CRT0_INCLUDE_PICOBIN_BLOCK PICO_CRT0_INCLUDE_PICOBIN_IMAGE_TYPE_ITEM
2529
#endif
2630

31+
// PICO_CONFIG: PICO_CRT0_INCLUDE_PICOBIN_END_BLOCK, Include a metadata block at the end of the image, default=1 for flash binaries with a metadata block at the start, type=bool, group=pico_crt0
2732
#ifndef PICO_CRT0_INCLUDE_PICOBIN_END_BLOCK
2833
#define PICO_CRT0_INCLUDE_PICOBIN_END_BLOCK (PICO_CRT0_INCLUDE_PICOBIN_BLOCK && !PICO_NO_FLASH)
2934
#endif
3035

36+
// PICO_CONFIG: PICO_CRT0_IMAGE_TYPE_TBYB, Set the TBYB flag for the IMAGE_DEF which requires a flash update boot to boot it, default=0, type=bool, group=pico_crt0
37+
#ifndef PICO_CRT0_IMAGE_TYPE_TBYB
38+
#define PICO_CRT0_IMAGE_TYPE_TBYB 0
39+
#endif
40+
3141
#if PICO_CRT0_IMAGE_TYPE_TBYB
3242
#define CRT0_TBYB_FLAG PICOBIN_IMAGE_TYPE_EXE_TBYB_BITS
3343
#else
3444
#define CRT0_TBYB_FLAG 0
3545
#endif
3646

47+
// PICO_CONFIG: PICO_CRT0_VERSION_MAJOR, The major version for the metadata block (ignored if 0), default=0, type=int, group=pico_crt0
48+
// PICO_CONFIG: PICO_CRT0_VERSION_MINOR, The minor version for the metadata block (ignored if 0), default=0, type=int, group=pico_crt0
3749
#if defined(PICO_CRT0_VERSION_MINOR) && !defined(PICO_CRT0_VERSION_MAJOR)
3850
#define PICO_CRT0_VERSION_MAJOR 0
51+
#elif defined(PICO_CRT0_VERSION_MAJOR) && !defined(PICO_CRT0_VERSION_MINOR)
52+
#define PICO_CRT0_VERSION_MINOR 0
3953
#endif
4054

41-
#if PICO_CRT0_INCLUDE_PICOBIN_BLOCK
42-
.section .embedded_block, "a"
43-
.p2align 2
44-
embedded_block:
45-
.word PICOBIN_BLOCK_MARKER_START
46-
47-
#if PICO_CRT0_INCLUDE_PICOBIN_IMAGE_TYPE_ITEM
48-
// include an IMAGE_TYPE item at the start so this block is a valid IMAGE_DEF block, and can be used as a basis
49-
// for booting the binary with a known type.
50-
.byte PICOBIN_BLOCK_ITEM_1BS_IMAGE_TYPE
51-
.byte 0x1 // 1 word
52-
#ifdef PICO_CRT0_IMAGE_TYPE_ITEM_VALUE
53-
.hword PICO_CRT0_IMAGE_TYPE_ITEM_VALUE
54-
#elif defined(__riscv)
55-
.hword PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(EXE) | \
55+
// PICO_CONFIG: PICO_CRT0_IMAGE_TYPE_ITEM_VALUE, The IMAGE_TYPE value for the IMAGE_DEF, default=matching the PICO_PLATFORM, type=int, group=pico_crt0
56+
#ifndef PICO_CRT0_IMAGE_TYPE_ITEM_VALUE
57+
#if defined(__riscv)
58+
#define PICO_CRT0_IMAGE_TYPE_ITEM_VALUE \
59+
PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(EXE) | \
5660
PICOBIN_IMAGE_TYPE_EXE_CPU_AS_BITS(RISCV) | \
5761
PICOBIN_IMAGE_TYPE_EXE_CHIP_AS_BITS(RP2350) | \
5862
CRT0_TBYB_FLAG
5963
#elif PICO_RP2040
60-
.hword PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(EXE) | \
64+
#define PICO_CRT0_IMAGE_TYPE_ITEM_VALUE \
65+
PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(EXE) | \
6166
PICOBIN_IMAGE_TYPE_EXE_SECURITY_AS_BITS(NS) | \
6267
PICOBIN_IMAGE_TYPE_EXE_CPU_AS_BITS(ARM) | \
6368
PICOBIN_IMAGE_TYPE_EXE_CHIP_AS_BITS(RP2040) | \
6469
CRT0_TBYB_FLAG
6570
#else
66-
.hword PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(EXE) | \
71+
#define PICO_CRT0_IMAGE_TYPE_ITEM_VALUE \
72+
PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(EXE) | \
6773
PICOBIN_IMAGE_TYPE_EXE_SECURITY_AS_BITS(S) | \
6874
PICOBIN_IMAGE_TYPE_EXE_CPU_AS_BITS(ARM) | \
6975
PICOBIN_IMAGE_TYPE_EXE_CHIP_AS_BITS(RP2350) | \
7076
CRT0_TBYB_FLAG
7177
#endif
78+
#endif
79+
80+
#if PICO_CRT0_INCLUDE_PICOBIN_BLOCK
81+
.section .embedded_block, "a"
82+
.p2align 2
83+
embedded_block:
84+
.word PICOBIN_BLOCK_MARKER_START
85+
86+
#if PICO_CRT0_INCLUDE_PICOBIN_IMAGE_TYPE_ITEM
87+
// include an IMAGE_TYPE item at the start so this block is a valid IMAGE_DEF block, and can be used as a basis
88+
// for booting the binary with a known type.
89+
.byte PICOBIN_BLOCK_ITEM_1BS_IMAGE_TYPE
90+
.byte 0x1 // 1 word
91+
.hword PICO_CRT0_IMAGE_TYPE_ITEM_VALUE
7292
#else
7393
// if no image type, then add ignored item
7494
.byte PICOBIN_BLOCK_ITEM_2BS_IGNORED
@@ -80,11 +100,7 @@ embedded_block:
80100
.byte PICOBIN_BLOCK_ITEM_1BS_VERSION
81101
.byte 0x2 // 2 words
82102
.hword 0
83-
#ifdef PICO_CRT0_VERSION_MINOR
84103
.hword PICO_CRT0_VERSION_MINOR
85-
#else
86-
.hword 0
87-
#endif
88104
.hword PICO_CRT0_VERSION_MAJOR
89105
#endif
90106

0 commit comments

Comments
 (0)