1#if !defined(PICO_CRT0_INCLUDE_PICOBIN_IMAGE_TYPE_ITEM) 2// todo decide whether we want this item for RP2040 by default, probably not (there are a zilloon binaries out there without it) 3#if !PICO_RP2040 4#define PICO_CRT0_INCLUDE_PICOBIN_IMAGE_TYPE_ITEM 1 5#endif 6#endif 7 8#ifndef PICO_CRT0_INCLUDE_PICOBIN_BLOCK 9#define PICO_CRT0_INCLUDE_PICOBIN_BLOCK PICO_CRT0_INCLUDE_PICOBIN_IMAGE_TYPE_ITEM 10#endif 11 12#ifndef PICO_CRT0_INCLUDE_PICOBIN_END_BLOCK 13#define PICO_CRT0_INCLUDE_PICOBIN_END_BLOCK (PICO_CRT0_INCLUDE_PICOBIN_BLOCK && !PICO_NO_FLASH) 14#endif 15 16#if PICO_CRT0_IMAGE_TYPE_TBYB 17#define CRT0_TBYB_FLAG PICOBIN_IMAGE_TYPE_EXE_TBYB_BITS 18#else 19#define CRT0_TBYB_FLAG 0 20#endif 21 22#if defined(PICO_CRT0_VERSION_MINOR) && !defined(PICO_CRT0_VERSION_MAJOR) 23#define PICO_CRT0_VERSION_MAJOR 0 24#endif 25 26#if PICO_CRT0_INCLUDE_PICOBIN_BLOCK 27.section .embedded_block, "a" 28.p2align 2 29embedded_block: 30.word PICOBIN_BLOCK_MARKER_START 31 32#if PICO_CRT0_INCLUDE_PICOBIN_IMAGE_TYPE_ITEM 33// include an IMAGE_TYPE item at the start so this block is a valid IMAGE_DEF block, and can be used as a basis 34// for booting the binary with a known type. 35.byte PICOBIN_BLOCK_ITEM_1BS_IMAGE_TYPE 36.byte 0x1 // 1 word 37#ifdef PICO_CRT0_IMAGE_TYPE_ITEM_VALUE 38.hword PICO_CRT0_IMAGE_TYPE_ITEM_VALUE 39#elif defined(__riscv) 40.hword PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(EXE) | \ 41 PICOBIN_IMAGE_TYPE_EXE_CPU_AS_BITS(RISCV) | \ 42 PICOBIN_IMAGE_TYPE_EXE_CHIP_AS_BITS(RP2350) | \ 43 CRT0_TBYB_FLAG 44#elif defined(PICO_RP2040) 45.hword PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(EXE) | \ 46 PICOBIN_IMAGE_TYPE_EXE_SECURITY_AS_BITS(NS) | \ 47 PICOBIN_IMAGE_TYPE_EXE_CPU_AS_BITS(ARM) | \ 48 PICOBIN_IMAGE_TYPE_EXE_CHIP_AS_BITS(RP2040) | \ 49 CRT0_TBYB_FLAG 50#else 51.hword PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(EXE) | \ 52 PICOBIN_IMAGE_TYPE_EXE_SECURITY_AS_BITS(S) | \ 53 PICOBIN_IMAGE_TYPE_EXE_CPU_AS_BITS(ARM) | \ 54 PICOBIN_IMAGE_TYPE_EXE_CHIP_AS_BITS(RP2350) | \ 55 CRT0_TBYB_FLAG 56#endif 57#else 58// if no image type, then add ignored item 59.byte PICOBIN_BLOCK_ITEM_2BS_IGNORED 60.byte 0x1 // 1 word 61.hword 0 62#endif 63 64#ifdef PICO_CRT0_VERSION_MAJOR 65.byte PICOBIN_BLOCK_ITEM_1BS_VERSION 66.byte 0x2 // 2 words 67.hword 0 68#ifdef PICO_CRT0_VERSION_MINOR 69.hword PICO_CRT0_VERSION_MINOR 70#else 71.hword 0 72#endif 73.hword PICO_CRT0_VERSION_MAJOR 74#endif 75 76#ifdef __riscv 77// On RISC-V the default entry point from bootrom is the start of the binary, but 78// we have our vtable at the start, so we must include an entry point 79.byte PICOBIN_BLOCK_ITEM_1BS_ENTRY_POINT 80.byte 0x3 // word size to next item 81.byte 0 // pad 82.byte 0 // pad 83.word _reset_handler 84.word SRAM_END // stack pointer 85#endif 86 87#ifndef PICO_RP2040 88#if PICO_NO_FLASH 89// If no_flash bin, then include a vector table item 90.byte PICOBIN_BLOCK_ITEM_1BS_VECTOR_TABLE 91.byte 0x2 92.hword 0 93.word __vectors 94#endif 95#endif 96 97.byte PICOBIN_BLOCK_ITEM_2BS_LAST 98.hword (embedded_block_end - embedded_block - 16 ) / 4 // total size of all 99.byte 0 100#if PICO_CRT0_INCLUDE_PICOBIN_END_BLOCK 101.word embedded_end_block - embedded_block 102#else 103// offset from this block to next block in loop (since we are a single block loop, we point back to ourselves 104// so the offset is 0) 105.word 0 106#endif 107.word PICOBIN_BLOCK_MARKER_END 108embedded_block_end: 109#endif