Loading...
Searching...
No Matches
config.h
1/*
2 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _BOOT_STAGE2_CONFIG_H_
8#define _BOOT_STAGE2_CONFIG_H_
9
10// NOTE THIS HEADER IS INCLUDED FROM ASSEMBLY
11
12#include "pico.h"
13
14// PICO_CONFIG: PICO_FLASH_SPI_CLKDIV, Clock divider from clk_sys to use for serial flash communications in boot stage 2. On RP2040 this must be a multiple of 2. This define applies to compilation of the boot stage 2 not the main application, type=int, default=varies; often specified in board header, advanced=true, group=boot_stage2
15// PICO_CONFIG: PICO_FLASH_SPI_RXDELAY, Receive delay in 1/2 clock cycles to use for serial flash communications in boot stage 2. This define applies to compilation of the boot stage 2 not the main application, type=int, default=varies; often specified in board header, advanced=true, group=boot_stage2
16
17// PICO_CONFIG: PICO_BUILD_BOOT_STAGE2_NAME, Name of the boot stage 2 if selected in the build system. This define applies to compilation of the boot stage 2 not the main application, group=boot_stage2
18#ifdef PICO_BUILD_BOOT_STAGE2_NAME
19 #define _BOOT_STAGE2_SELECTED
20#else
21 // check that multiple boot stage 2 options haven't been set...
22
23// PICO_CONFIG: PICO_BOOT_STAGE2_CHOOSE_IS25LP080, Select boot2_is25lp080 as the boot stage 2 when no boot stage 2 selection is made by the CMake build. This define applies to compilation of the boot stage 2 not the main application, type=bool, default=0, group=boot_stage2
24#ifndef PICO_BOOT_STAGE2_CHOOSE_IS25LP080
25 #define PICO_BOOT_STAGE2_CHOOSE_IS25LP080 0
26#elif PICO_BOOT_STAGE2_CHOOSE_IS25LP080
27 #ifdef _BOOT_STAGE2_SELECTED
28 #error multiple boot stage 2 options chosen
29 #endif
30 #define _BOOT_STAGE2_SELECTED
31#endif
32// PICO_CONFIG: PICO_BOOT_STAGE2_CHOOSE_W25Q080, Select boot2_w25q080 as the boot stage 2 when no boot stage 2 selection is made by the CMake build. This define applies to compilation of the boot stage 2 not the main application, type=bool, default=0, group=boot_stage2
33#ifndef PICO_BOOT_STAGE2_CHOOSE_W25Q080
34 #define PICO_BOOT_STAGE2_CHOOSE_W25Q080 0
35#elif PICO_BOOT_STAGE2_CHOOSE_W25Q080
36 #ifdef _BOOT_STAGE2_SELECTED
37 #error multiple boot stage 2 options chosen
38 #endif
39 #define _BOOT_STAGE2_SELECTED
40#endif
41// PICO_CONFIG: PICO_BOOT_STAGE2_CHOOSE_W25X10CL, Select boot2_w25x10cl as the boot stage 2 when no boot stage 2 selection is made by the CMake build. This define applies to compilation of the boot stage 2 not the main application, type=bool, default=0, group=boot_stage2
42#ifndef PICO_BOOT_STAGE2_CHOOSE_W25X10CL
43 #define PICO_BOOT_STAGE2_CHOOSE_W25X10CL 0
44#elif PICO_BOOT_STAGE2_CHOOSE_W25X10CL
45 #ifdef _BOOT_STAGE2_SELECTED
46 #error multiple boot stage 2 options chosen
47 #endif
48 #define _BOOT_STAGE2_SELECTED
49#endif
50// PICO_CONFIG: PICO_BOOT_STAGE2_CHOOSE_AT25SF128A, Select boot2_at25sf128a as the boot stage 2 when no boot stage 2 selection is made by the CMake build. This define applies to compilation of the boot stage 2 not the main application, type=bool, default=0, group=boot_stage2
51#ifndef PICO_BOOT_STAGE2_CHOOSE_AT25SF128A
52 #define PICO_BOOT_STAGE2_CHOOSE_AT25SF128A 0
53#elif PICO_BOOT_STAGE2_CHOOSE_AT25SF128A
54 #ifdef _BOOT_STAGE2_SELECTED
55 #error multiple boot stage 2 options chosen
56 #endif
57 #define _BOOT_STAGE2_SELECTED
58#endif
59
60// PICO_CONFIG: PICO_BOOT_STAGE2_CHOOSE_GENERIC_03H, Select boot2_generic_03h as the boot stage 2 when no boot stage 2 selection is made by the CMake build. This define applies to compilation of the boot stage 2 not the main application, type=bool, default=1, group=boot_stage2
61#if defined(PICO_BOOT_STAGE2_CHOOSE_GENERIC_03H) && PICO_BOOT_STAGE2_CHOOSE_GENERIC_03H
62 #ifdef _BOOT_STAGE2_SELECTED
63 #error multiple boot stage 2 options chosen
64 #endif
65 #define _BOOT_STAGE2_SELECTED
66#endif
67
68#endif // PICO_BUILD_BOOT_STAGE2_NAME
69
70#ifdef PICO_BUILD_BOOT_STAGE2_NAME
71 // boot stage 2 is configured by cmake, so use the name specified there
72 #define PICO_BOOT_STAGE2_NAME PICO_BUILD_BOOT_STAGE2_NAME
73#else
74 // boot stage 2 is selected by board config header, so we have to do some work
75 #if PICO_BOOT_STAGE2_CHOOSE_IS25LP080
76 #error "IS25LP080 boot2 is broken (FIXME)"
77 #define _BOOT_STAGE2 boot2_is25lp080
78 #elif PICO_BOOT_STAGE2_CHOOSE_W25Q080
79 #define _BOOT_STAGE2 boot2_w25q080
80 #elif PICO_BOOT_STAGE2_CHOOSE_W25X10CL
81 #error "W25X10CL boot2 is broken (FIXME)"
82 #define _BOOT_STAGE2 boot2_w25x10cl
83 #elif PICO_BOOT_STAGE2_CHOOSE_AT25SF128A
84 #error "AT25SF128A boot2 is broken (FIXME)"
85 #define _BOOT_STAGE2 boot2_at25sf128a
86 #elif !defined(PICO_BOOT_STAGE2_CHOOSE_GENERIC_03H) || PICO_BOOT_STAGE2_CHOOSE_GENERIC_03H
87 #undef PICO_BOOT_STAGE2_CHOOSE_GENERIC_03H
88 #define PICO_BOOT_STAGE2_CHOOSE_GENERIC_03H 1
89 #define _BOOT_STAGE2 boot2_generic_03h
90 #else
91 #error no boot stage 2 is defined by PICO_BOOT_STAGE2_CHOOSE_ macro
92 #endif
93 // we can't include cdefs in assembly, so define our own, but avoid conflict with real ones for c inclusion
94 #define _PICO__STRING(x) #x
95 #define _PICO__XSTRING(x) _PICO__STRING(x)
96 #define _PICO__CONCAT1(x, y) x ## y
97 #define PICO_BOOT_STAGE2_NAME _PICO__XSTRING(_BOOT_STAGE2)
98 #define PICO_BOOT_STAGE2_ASM _PICO__XSTRING(_PICO__CONCAT1(_BOOT_STAGE2,.S))
99#endif
100#endif