aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2024-10-11 12:23:25 -0600
committerTom Rini <trini@konsulko.com>2024-10-11 12:23:25 -0600
commit47e544f576699ca4630e20448db6a05178960697 (patch)
treef31951120512ac41f145dc0fcf6b0bbdfe5b9c01 /doc
parent5d899fc58c44fe5623e31524da2205d8597a53d1 (diff)
parent0220a68c25cbfdfa495927f83abf0b1d4ebd823b (diff)
downloadu-boot-master.zip
u-boot-master.tar.gz
u-boot-master.tar.bz2
Merge patch series "Tidy up use of 'SPL' and CONFIG_SPL_BUILD"HEADmaster
Simon Glass <sjg@chromium.org> says: When the SPL build-phase was first created it was designed to solve a particular problem (the need to init SDRAM so that U-Boot proper could be loaded). It has since expanded to become an important part of U-Boot, with three phases now present: TPL, VPL and SPL Due to this history, the term 'SPL' is used to mean both a particular phase (the one before U-Boot proper) and all the non-proper phases. This has become confusing. For a similar reason CONFIG_SPL_BUILD is set to 'y' for all 'SPL' phases, not just SPL. So code which can only be compiled for actual SPL, for example, must use something like this: #if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) In Makefiles we have similar issues. SPL_ has been used as a variable which expands to either SPL_ or nothing, to chose between options like CONFIG_BLK and CONFIG_SPL_BLK. When TPL appeared, a new SPL_TPL variable was created which expanded to 'SPL_', 'TPL_' or nothing. Later it was updated to support 'VPL_' as well. This series starts a change in terminology and usage to resolve the above issues: - The word 'xPL' is used instead of 'SPL' to mean a non-proper build - A new CONFIG_XPL_BUILD define indicates that the current build is an 'xPL' build - The existing CONFIG_SPL_BUILD is changed to mean SPL; it is not now defined for TPL and VPL phases - The existing SPL_ Makefile variable is renamed to SPL_ - The existing SPL_TPL Makefile variable is renamed to PHASE_ It should be noted that xpl_phase() can generally be used instead of the above CONFIGs without a code-space or run-time penalty. This series does not attempt to convert all of U-Boot to use this new terminology but it makes a start. In particular, renaming spl.h and common/spl seems like a bridge too far at this point. The series is fully bisectable. It has also been checked to ensure there are no code-size changes on any commit.
Diffstat (limited to 'doc')
-rw-r--r--doc/develop/distro.rst4
-rw-r--r--doc/develop/index.rst1
-rw-r--r--doc/develop/init.rst93
-rw-r--r--doc/develop/logging.rst2
-rw-r--r--doc/develop/qconfig.rst2
-rw-r--r--doc/develop/spl.rst83
-rw-r--r--doc/develop/tests_sandbox.rst2
-rw-r--r--doc/develop/tests_writing.rst6
-rw-r--r--doc/device-tree-bindings/bootph.yaml2
9 files changed, 147 insertions, 48 deletions
diff --git a/doc/develop/distro.rst b/doc/develop/distro.rst
index 9e715b2..637bc27 100644
--- a/doc/develop/distro.rst
+++ b/doc/develop/distro.rst
@@ -189,7 +189,7 @@ TO BE UPDATED:
In your board configuration file, include the following::
- #ifndef CONFIG_SPL_BUILD
+ #ifndef CONFIG_XPL_BUILD
#include <config_distro_bootcmd.h>
#endif
@@ -316,7 +316,7 @@ that it supports the correct set of possible boot device types. To provide this
configuration, simply define macro BOOT_TARGET_DEVICES prior to including
<config_distro_bootcmd.h>. For example::
- #ifndef CONFIG_SPL_BUILD
+ #ifndef CONFIG_XPL_BUILD
#define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 1) \
func(MMC, mmc, 0) \
diff --git a/doc/develop/index.rst b/doc/develop/index.rst
index cbea38d..c23192c 100644
--- a/doc/develop/index.rst
+++ b/doc/develop/index.rst
@@ -39,6 +39,7 @@ Implementation
distro
driver-model/index
environment
+ init
expo
cedit
event
diff --git a/doc/develop/init.rst b/doc/develop/init.rst
new file mode 100644
index 0000000..ce98578
--- /dev/null
+++ b/doc/develop/init.rst
@@ -0,0 +1,93 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Board Initialisation Flow
+-------------------------
+
+This is the intended start-up flow for boards. This should apply for both
+xPL and U-Boot proper (i.e. they both follow the same rules).
+
+Note: "xPL" stands for "any Program Loader", including SPL (Secondary
+Program Loader), TPL (Tertiary Program Loader) and VPL (Verifying Program
+Loader). The boot sequence is TPL->VPL->SPL->U-Boot proper
+
+At present, xPL mostly uses a separate code path, but the function names
+and roles of each function are the same. Some boards or architectures
+may not conform to this. At least most ARM boards which use
+CONFIG_xPL_FRAMEWORK conform to this.
+
+Execution typically starts with an architecture-specific (and possibly
+CPU-specific) start.S file, such as:
+
+- arch/arm/cpu/armv7/start.S
+- arch/powerpc/cpu/mpc83xx/start.S
+- arch/mips/cpu/start.S
+
+and so on. From there, three functions are called; the purpose and
+limitations of each of these functions are described below.
+
+lowlevel_init()
+~~~~~~~~~~~~~~~
+
+- purpose: essential init to permit execution to reach board_init_f()
+- no global_data or BSS
+- there is no stack (ARMv7 may have one but it will soon be removed)
+- must not set up SDRAM or use console
+- must only do the bare minimum to allow execution to continue to
+ board_init_f()
+- this is almost never needed
+- return normally from this function
+
+board_init_f()
+~~~~~~~~~~~~~~
+
+- purpose: set up the machine ready for running board_init_r():
+ i.e. SDRAM and serial UART
+- global_data is available
+- stack is in SRAM
+- BSS is not available, so you cannot use global/static variables,
+ only stack variables and global_data
+
+Non-xPL-specific notes:
+
+ - dram_init() is called to set up DRAM. If already done in xPL this
+ can do nothing
+
+xPL-specific notes:
+
+ - you can override the entire board_init_f() function with your own
+ version as needed.
+ - preloader_console_init() can be called here in extremis
+ - should set up SDRAM, and anything needed to make the UART work
+ - there is no need to clear BSS, it will be done by crt0.S
+ - for specific scenarios on certain architectures an early BSS *can*
+ be made available (via CONFIG_SPL_EARLY_BSS by moving the clearing
+ of BSS prior to entering board_init_f()) but doing so is discouraged.
+ Instead it is strongly recommended to architect any code changes
+ or additions such to not depend on the availability of BSS during
+ board_init_f() as indicated in other sections of this README to
+ maintain compatibility and consistency across the entire code base.
+ - must return normally from this function (don't call board_init_r()
+ directly)
+
+Here the BSS is cleared. For xPL, if CONFIG_xPL_STACK_R is defined, then at
+this point the stack and global_data are relocated to below
+CONFIG_xPL_STACK_R_ADDR. For non-xPL, U-Boot is relocated to run at the top of
+memory.
+
+board_init_r()
+~~~~~~~~~~~~~~
+
+ - purpose: main execution, common code
+ - global_data is available
+ - SDRAM is available
+ - BSS is available, all static/global variables can be used
+ - execution eventually continues to main_loop()
+
+Non-xPL-specific notes:
+
+ - U-Boot is relocated to the top of memory and is now running from
+ there.
+
+xPL-specific notes:
+
+ - stack is optionally in SDRAM, if CONFIG_xPL_STACK_R is defined
diff --git a/doc/develop/logging.rst b/doc/develop/logging.rst
index 704a6bf..d7a40c9 100644
--- a/doc/develop/logging.rst
+++ b/doc/develop/logging.rst
@@ -292,7 +292,7 @@ Convert debug() statements in the code to log() statements
Convert error() statements in the code to log() statements
-Figure out what to do with BUG(), BUG_ON() and warn_non_spl()
+Figure out what to do with BUG(), BUG_ON() and warn_non_xpl()
Add a way to browse log records
diff --git a/doc/develop/qconfig.rst b/doc/develop/qconfig.rst
index 123779e..a18f324 100644
--- a/doc/develop/qconfig.rst
+++ b/doc/develop/qconfig.rst
@@ -226,7 +226,7 @@ Available options
Look for moved config options in spl/include/autoconf.mk instead of
include/autoconf.mk. This is useful for moving options for SPL build
because SPL related options (mostly prefixed with CONFIG_SPL\_) are
- sometimes blocked by CONFIG_SPL_BUILD ifdef conditionals.
+ sometimes blocked by CONFIG_XPL_BUILD ifdef conditionals.
-j, --jobs
Specify the number of threads to run simultaneously. If not specified,
diff --git a/doc/develop/spl.rst b/doc/develop/spl.rst
index 4bb48e6..aa6d28f 100644
--- a/doc/develop/spl.rst
+++ b/doc/develop/spl.rst
@@ -1,11 +1,12 @@
-Generic SPL framework
+Generic xPL framework
=====================
Overview
--------
-To unify all existing implementations for a secondary program loader (SPL)
-and to allow simply adding of new implementations this generic SPL framework
+To unify all existing implementations for secondary/tertiary program loaders
+(generically called xPL)
+and to allow simply adding of new implementations this generic xPL framework
has been created. With this framework almost all source files for a board
can be reused. No code duplication or symlinking is necessary anymore.
@@ -13,36 +14,39 @@ can be reused. No code duplication or symlinking is necessary anymore.
How it works
------------
-The object files for SPL are built separately and placed in the "spl" directory.
-The final binaries which are generated are u-boot-spl, u-boot-spl.bin and
-u-boot-spl.map.
+The object files for xPL are built separately and placed in a subdirectory
+("spl", "tpl" or "vpl").
+The final binaries which are generated for SPL are u-boot-spl, u-boot-spl.bin
+and u-boot-spl.map
-A config option named CONFIG_SPL_BUILD is enabled by Kconfig for SPL.
-Source files can therefore be compiled for SPL with different settings.
+A config option named CONFIG_XPL_BUILD is enabled by Kconfig for xPL builds.
+Source files can therefore be compiled for xPL with different settings.
For example::
- ifeq ($(CONFIG_SPL_BUILD),y)
+ ifeq ($(CONFIG_XPL_BUILD),y)
obj-y += board_spl.o
else
obj-y += board.o
endif
- obj-$(CONFIG_SPL_BUILD) += foo.o
+ obj-$(CONFIG_XPL_BUILD) += foo.o
- #ifdef CONFIG_SPL_BUILD
+ if (IS_ENABLED(CONFIG_XPL_BUILD))
foo();
- #endif
+ if (xpl_phase() == PHASE_TPL)
+ bar();
-The building of SPL images can be enabled by CONFIG_SPL option in Kconfig.
+The building of xPL images can be enabled by CONFIG_SPL (etc.) options in
+Kconfig.
-Because SPL images normally have a different text base, one has to be
-configured by defining CONFIG_SPL_TEXT_BASE. The linker script has to be
-defined with CONFIG_SPL_LDSCRIPT.
+Because xPL images normally have a different text base, one has to be
+configured by defining CONFIG_xPL_TEXT_BASE. The linker script has to be
+defined with CONFIG_xPL_LDSCRIPT.
-To support generic U-Boot libraries and drivers in the SPL binary one can
-optionally define CONFIG_SPL_XXX_SUPPORT. Currently following options
+To support generic U-Boot libraries and drivers in the xPL binary one can
+optionally define CONFIG_xPL_XXX_SUPPORT. Currently following options
are supported:
CONFIG_SPL_LIBCOMMON_SUPPORT (common/libcommon.o)
@@ -75,7 +79,7 @@ CONFIG_SPL_DM_GPIO (drivers/gpio/gpio-uclass.o)
CONFIG_SPL_BMP (drivers/video/bmp.o)
CONFIG_SPL_BLOBLIST (common/bloblist.o)
-Adding SPL-specific code
+Adding xPL-specific code
------------------------
To check whether a feature is enabled, use CONFIG_IS_ENABLED()::
@@ -90,7 +94,7 @@ U-Boot Boot Phases
------------------
U-Boot goes through the following boot phases where TPL, VPL, SPL are optional.
-While many boards use SPL, less use TPL.
+While many boards use SPL, fewer use TPL.
TPL
Very early init, as tiny as possible. This loads SPL (or VPL if enabled).
@@ -117,7 +121,7 @@ Further usages of U-Boot SPL comprise:
Checking the boot phase
-----------------------
-Use `spl_phase()` to find the current U-Boot phase, e.g. `PHASE_SPL`. You can
+Use `xpl_phase()` to find the current U-Boot phase, e.g. `PHASE_SPL`. You can
also find the previous and next phase and get the phase name.
@@ -177,29 +181,30 @@ files instead introduces another set of headaches. These warnings are
not usually important to understanding the flow, however.
-Reserving memory in SPL
+Reserving memory in xPL
-----------------------
-If memory needs to be reserved in RAM during SPL stage with the requirement that
-the SPL reserved memory remains preserved across further boot stages too
+If memory needs to be reserved in RAM during an xPL phase with the requirement
+that the xPL reserved memory remains preserved across further boot phases too
then it needs to be reserved mandatorily starting from end of RAM. This is to
-ensure that further stages can simply skip this region before carrying out
+ensure that further phases can simply skip this region before carrying out
further reservations or updating the relocation address.
-Also out of these regions which are to be preserved across further stages of
+Also out of these regions which are to be preserved across further phases of
boot, video framebuffer memory region must be reserved first starting from
-end of RAM for which helper function spl_reserve_video_from_ram_top is provided
-which makes sure that video memory is placed at top of reservation area with
+end of RAM for which the helper function spl_reserve_video_from_ram_top() is
+provided
+which makes sure that video memory is placed at the top of reservation area with
further reservations below it.
-The corresponding information of reservation for those regions can be passed to
-further boot stages using a bloblist. For e.g. the information for
-framebuffer area reserved by SPL can be passed onto U-boot using
-BLOBLISTT_U_BOOT_VIDEO.
-
-The further boot stages need to parse each of the bloblist passed from SPL stage
-starting from video bloblist and skip this whole SPL reserved memory area from
-end of RAM as per the bloblists received, before carrying out further
-reservations or updating the relocation address. For e.g, U-boot proper uses
-function "setup_relocaddr_from_bloblist" to parse the bloblists passed from
-previous stage and skip the memory reserved from previous stage accordingly.
+The reservation information for these regions can be passed to the
+further boot phases using a bloblist. For e.g. the information for the
+framebuffer area reserved by xPL can be passed onto U-Boot using
+BLOBLISTT_U_BOOT_VIDEO
+
+The further boot phases need to parse each of the blobs passed from xPL phase
+starting from video bloblist and skip this whole xPL reserved-memory area from
+end of RAM as per the blobs received, before carrying out further
+reservations or updating the relocation address. For e.g, U-Boot proper uses
+function setup_relocaddr_from_bloblist() to parse the bloblist passed from
+previous phase and skip the memory reserved from previous phase accordingly.
diff --git a/doc/develop/tests_sandbox.rst b/doc/develop/tests_sandbox.rst
index 7292307..0630180 100644
--- a/doc/develop/tests_sandbox.rst
+++ b/doc/develop/tests_sandbox.rst
@@ -278,7 +278,7 @@ Whatever sandbox build is used, which tests are present is determined by which
source files are built. For sandbox_spl, the of_platdata tests are built
because of the build rule in test/dm/Makefile::
- ifeq ($(CONFIG_SPL_BUILD),y)
+ ifeq ($(CONFIG_XPL_BUILD),y)
obj-$(CONFIG_SPL_OF_PLATDATA) += of_platdata.o
else
...other tests for non-spl
diff --git a/doc/develop/tests_writing.rst b/doc/develop/tests_writing.rst
index a328ebf..54efb7e 100644
--- a/doc/develop/tests_writing.rst
+++ b/doc/develop/tests_writing.rst
@@ -321,15 +321,15 @@ to control that.
Finally, add the test to the build by adding to the Makefile in the same
directory::
- obj-$(CONFIG_$(SPL_)CMDLINE) += wibble.o
+ obj-$(CONFIG_$(XPL_)CMDLINE) += wibble.o
Note that CMDLINE is never enabled in SPL, so this test will only be present in
U-Boot proper. See below for how to do SPL tests.
As before, you can add an extra Kconfig check if needed::
- ifneq ($(CONFIG_$(SPL_)WIBBLE),)
- obj-$(CONFIG_$(SPL_)CMDLINE) += wibble.o
+ ifneq ($(CONFIG_$(XPL_)WIBBLE),)
+ obj-$(CONFIG_$(XPL_)CMDLINE) += wibble.o
endif
diff --git a/doc/device-tree-bindings/bootph.yaml b/doc/device-tree-bindings/bootph.yaml
index a3ccf06..a364b3f 100644
--- a/doc/device-tree-bindings/bootph.yaml
+++ b/doc/device-tree-bindings/bootph.yaml
@@ -83,6 +83,6 @@ properties:
bootph-all:
type: boolean
description:
- Include this node in all phases (for U-Boot see enum u_boot_phase).
+ Include this node in all phases (for U-Boot see enum xpl_phase_t).
additionalProperties: true