Commit fdc4fda3 authored by Tom Rini's avatar Tom Rini
Browse files

Merge tag 'efi-2021-10-rc2-2' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2021-10-rc2-2

Documentation:

* Require Sphinx >= 2.4.4 for 'make htmldocs'
* Move devicetree documentation to restructured text and update it
* Document stm32mp1 devicetree bindings

UEFI

* Extend measurement to UEFI variables and ExitBootServices()
* Support Uri() node in devicetree to text protocol
* Add Linux magic token to RISC-V EFI test binaries
parents 85ccbf66 61ee7803
......@@ -33,7 +33,10 @@
.globl ImageBase
ImageBase:
.short IMAGE_DOS_SIGNATURE /* 'MZ' */
.skip 58 /* 'MZ' + pad + offset == 64 */
.skip 46 /* 'MZ' + pad + offset == 64 */
.long 0x43534952 /* Linux magic "RISCV */
.long 0x00000056
.long 0x05435352 /* Linux magic2 "RSC\x05*/
.long pe_header - ImageBase /* Offset to the PE header */
pe_header:
.long IMAGE_NT_SIGNATURE /* 'PE' */
......@@ -72,7 +75,7 @@ extra_header_fields:
.long 0x8 /* FileAlignment */
.short 0 /* MajorOperatingSystemVersion */
.short 0 /* MinorOperatingSystemVersion */
.short 0 /* MajorImageVersion */
.short 1 /* MajorImageVersion */
.short 0 /* MinorImageVersion */
.short 0 /* MajorSubsystemVersion */
.short 0 /* MinorSubsystemVersion */
......
......@@ -6,4 +6,5 @@ STMicroelectronics
.. toctree::
:maxdepth: 2
st
stm32mp1
.. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
.. sectionauthor:: Patrick Delaunay <patrick.delaunay@st.com>
U-Boot device tree bindings
----------------------------
The U-Boot specific bindings are defined in the U-Boot directory:
doc/device-tree-bindings
* clock
- :download:`clock/st,stm32mp1.txt <../../device-tree-bindings/clock/st,stm32mp1.txt>`
* ram
- :download:`memory-controllers/st,stm32mp1-ddr.txt <../../device-tree-bindings/memory-controllers/st,stm32mp1-ddr.txt>`
All the other device tree bindings used in U-Boot are specified in Linux
kernel. Please refer dt bindings from below specified paths in the Linux
kernel binding directory = Documentation/devicetree/bindings/
* acd
- iio/adc/st,stm32-adc.yaml
* clock
- clock/st,stm32-rcc.txt
- clock/st,stm32h7-rcc.txt
- clock/st,stm32mp1-rcc.yaml
* display
- display/st,stm32-dsi.yaml
- display/st,stm32-ltdc.yaml
* gpio
- pinctrl/st,stm32-pinctrl.yaml
* hwlock
- hwlock/st,stm32-hwspinlock.yaml
* i2c
- i2c/st,stm32-i2c.yaml
* mailbox
- mailbox/st,stm32-ipcc.yaml
* mmc
- mmc/arm,pl18x.yaml
* nand
- mtd/st,stm32-fmc2-nand.yaml
- memory-controllers/st,stm32-fmc2-ebi.yaml
* net
- net/stm32-dwmac.yaml
* nvmem
- nvmem/st,stm32-romem.yaml
* remoteproc
- remoteproc/st,stm32-rproc.yaml
* regulator
- regulator/st,stm32mp1-pwr-reg.yaml
- regulator/st,stm32-vrefbuf.yaml
* reset
- reset/st,stm32-rcc.txt
- reset/st,stm32mp1-rcc.txt
* rng
- rng/st,stm32-rng.yaml
* rtc
- rtc/st,stm32-rtc.yaml
* serial
- serial/st,stm32-uart.yaml
* spi
- spi/st,stm32-spi.yaml
- spi/st,stm32-qspi.yaml
* syscon
- arm/stm32/st,stm32-syscon.yaml
* usb
- phy/phy-stm32-usbphyc.yaml
- usb/dwc2.yaml
* watchdog
- watchdog/st,stm32-iwdg.yaml
......@@ -26,8 +26,8 @@ Depending on the build targets further packages maybe needed
sudo apt-get install bc bison build-essential coccinelle \
device-tree-compiler dfu-util efitools flex gdisk graphviz imagemagick \
liblz4-tool libguestfs-tools libncurses-dev libpython3-dev libsdl2-dev \
libssl-dev lz4 lzma lzma-alone openssl python3 python3-coverage \
python3-pycryptodome python3-pyelftools python3-pytest \
libssl-dev lz4 lzma lzma-alone openssl pkg-config python3 \
python3-coverage python3-pycryptodome python3-pyelftools python3-pytest \
python3-sphinxcontrib.apidoc python3-sphinx-rtd-theme python3-virtualenv \
swig
......
......@@ -31,7 +31,7 @@ from load_config import loadConfig
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = '1.3'
needs_sphinx = '2.4.4'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
......@@ -118,19 +118,12 @@ if major >= 3:
else:
extensions.append('cdomain')
if major == 1 and minor < 7:
sys.stderr.write('WARNING: Sphinx 1.7 or greater will be required as of '
'the v2021.04 release\n')
# Ensure that autosectionlabel will produce unique names
autosectionlabel_prefix_document = True
autosectionlabel_maxdepth = 2
# The name of the math extension changed on Sphinx 1.4
if (major == 1 and minor > 3) or (major > 1):
extensions.append("sphinx.ext.imgmath")
else:
extensions.append("sphinx.ext.pngmath")
extensions.append("sphinx.ext.imgmath")
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
......@@ -345,27 +338,34 @@ htmlhelp_basename = 'TheUBootdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
'papersize': 'a4paper',
# The paper size ('letterpaper' or 'a4paper').
'papersize': 'a4paper',
# The font size ('10pt', '11pt' or '12pt').
'pointsize': '11pt',
# The font size ('10pt', '11pt' or '12pt').
'pointsize': '11pt',
# Latex figure (float) alignment
#'figure_align': 'htbp',
# Latex figure (float) alignment
#'figure_align': 'htbp',
# Don't mangle with UTF-8 chars
'inputenc': '',
'utf8extra': '',
# Don't mangle with UTF-8 chars
'inputenc': '',
'utf8extra': '',
# Set document margins
'sphinxsetup': '''
hmargin=0.5in, vmargin=1in,
parsedliteralwraps=true,
verbatimhintsturnover=false,
''',
# Additional stuff for the LaTeX preamble.
# Additional stuff for the LaTeX preamble.
'preamble': '''
% Use some font with UTF-8 support with XeLaTeX
% Use some font with UTF-8 support with XeLaTeX
\\usepackage{fontspec}
\\setsansfont{DejaVu Sans}
\\setromanfont{DejaVu Serif}
\\setmonofont{DejaVu Sans Mono}
'''
''',
}
# At least one book (translations) may have Asian characters
......@@ -380,72 +380,6 @@ if cjk_cmd.find("Noto Sans CJK SC") >= 0:
\\setCJKmainfont{Noto Sans CJK SC}
'''
# Fix reference escape troubles with Sphinx 1.4.x
if major == 1 and minor > 3:
latex_elements['preamble'] += '\\renewcommand*{\\DUrole}[2]{ #2 }\n'
if major == 1 and minor <= 4:
latex_elements['preamble'] += '\\usepackage[margin=0.5in, top=1in, bottom=1in]{geometry}'
elif major == 1 and (minor > 5 or (minor == 5 and patch >= 3)):
latex_elements['sphinxsetup'] = 'hmargin=0.5in, vmargin=1in'
latex_elements['preamble'] += '\\fvset{fontsize=auto}\n'
# Customize notice background colors on Sphinx < 1.6:
if major == 1 and minor < 6:
latex_elements['preamble'] += '''
\\usepackage{ifthen}
% Put notes in color and let them be inside a table
\\definecolor{NoteColor}{RGB}{204,255,255}
\\definecolor{WarningColor}{RGB}{255,204,204}
\\definecolor{AttentionColor}{RGB}{255,255,204}
\\definecolor{ImportantColor}{RGB}{192,255,204}
\\definecolor{OtherColor}{RGB}{204,204,204}
\\newlength{\\mynoticelength}
\\makeatletter\\newenvironment{coloredbox}[1]{%
\\setlength{\\fboxrule}{1pt}
\\setlength{\\fboxsep}{7pt}
\\setlength{\\mynoticelength}{\\linewidth}
\\addtolength{\\mynoticelength}{-2\\fboxsep}
\\addtolength{\\mynoticelength}{-2\\fboxrule}
\\begin{lrbox}{\\@tempboxa}\\begin{minipage}{\\mynoticelength}}{\\end{minipage}\\end{lrbox}%
\\ifthenelse%
{\\equal{\\py@noticetype}{note}}%
{\\colorbox{NoteColor}{\\usebox{\\@tempboxa}}}%
{%
\\ifthenelse%
{\\equal{\\py@noticetype}{warning}}%
{\\colorbox{WarningColor}{\\usebox{\\@tempboxa}}}%
{%
\\ifthenelse%
{\\equal{\\py@noticetype}{attention}}%
{\\colorbox{AttentionColor}{\\usebox{\\@tempboxa}}}%
{%
\\ifthenelse%
{\\equal{\\py@noticetype}{important}}%
{\\colorbox{ImportantColor}{\\usebox{\\@tempboxa}}}%
{\\colorbox{OtherColor}{\\usebox{\\@tempboxa}}}%
}%
}%
}%
}\\makeatother
\\makeatletter
\\renewenvironment{notice}[2]{%
\\def\\py@noticetype{#1}
\\begin{coloredbox}{#1}
\\bf\\it
\\par\\strong{#2}
\\csname py@noticestart@#1\\endcsname
}
{
\\csname py@noticeend@\\py@noticetype\\endcsname
\\end{coloredbox}
}
\\makeatother
'''
# With Sphinx 1.6, it is possible to change the Bg color directly
# by using:
# \definecolor{sphinxnoteBgColor}{RGB}{204,255,255}
......
# SPDX-License-Identifier: GPL-2.0+
#
# Copyright (c) 2011 The Chromium OS Authors.
.. SPDX-License-Identifier: GPL-2.0+
.. sectionauthor:: Copyright 2011 The Chromium OS Authors
Device Tree Control in U-Boot
=============================
Devicetree Control in U-Boot
============================
This feature provides for run-time configuration of U-Boot via a flat
device tree (fdt). U-Boot configuration has traditionally been done
using CONFIG options in the board config file. This feature aims to
make it possible for a single U-Boot binary to support multiple boards,
with the exact configuration of each board controlled by a flat device
tree (fdt). This is the approach recently taken by the ARM Linux kernel
and has been used by PowerPC for some time.
This feature provides for run-time configuration of U-Boot via a flattened
devicetree (fdt).
This feature aims to make it possible for a single U-Boot binary to support
multiple boards, with the exact configuration of each board controlled by
a flattened devicetree (fdt). This is the approach taken by Linux kernel for
ARM and RISC-V and has been used by PowerPC for some time.
The fdt is a convenient vehicle for implementing run-time configuration
for three reasons. Firstly it is easy to use, being a simple text file.
It is extensible since it consists of nodes and properties in a nice
hierarchical format.
for three reasons:
Finally, there is already excellent infrastructure for the fdt: a
compiler checks the text file and converts it to a compact binary
format, and a library is already available in U-Boot (libfdt) for
handling this format.
- There is already excellent infrastructure for the fdt: a compiler checks
the text file and converts it to a compact binary format, and a library
is already available in U-Boot (libfdt) for handling this format
- It is extensible since it consists of nodes and properties in a nice
hierarchical format
- It is fairly efficient to read incrementally
The dts directory contains a Makefile for building the device tree blob
and embedding it in your U-Boot image. This is useful since it allows
The arch/<arch>/dts directories contains a Makefile for building the devicetree
blob and embedding it in the U-Boot image. This is useful since it allows
U-Boot to configure itself according to what it finds there. If you have
a number of similar boards with different peripherals, you can describe
the features of each board in the device tree file, and have a single
the features of each board in the devicetree file, and have a single
generic source base.
To enable this feature, add CONFIG_OF_CONTROL to your board config file.
What is a Flat Device Tree?
---------------------------
What is a Flattened Devicetree?
-------------------------------
An fdt can be specified in source format as a text file. To read about
the fdt syntax, take a look at the specification here:
https://www.power.org/resources/downloads/Power_ePAPR_APPROVED_v1.0.pdf
You also might find this section of the Linux kernel documentation
useful: (access this in the Linux kernel source code)
Documentation/devicetree/booting-without-of.txt
the fdt syntax, take a look at the specification (dtspec_).
There is also a mailing list:
There is also a mailing list (dtlist_) for the compiler and associated
tools.
http://lists.ozlabs.org/listinfo/devicetree-discuss
In case you are wondering, OF stands for Open Firmware.
In case you are wondering, OF stands for Open Firmware. This follows the
convention used in Linux.
Tools
-----
To use this feature you will need to get the device tree compiler. This is
To create flattened device trees the device tree compiler is used. This is
provided by U-Boot automatically. If you have a system version of dtc
(typically in the 'device-tree-compiler' package), it is currently not used.
If you want to build your own dtc, it is kept here:
git://git.kernel.org/pub/scm/utils/dtc/dtc.git
(typically in the 'device-tree-compiler' package), that system version is
currently not used.
For example:
If you want to build your own dtc, it is kept here::
$ git clone git://git.kernel.org/pub/scm/utils/dtc/dtc.git
$ cd dtc
$ make
$ sudo make install
git://git.kernel.org/pub/scm/utils/dtc/dtc.git
Then run the compiler (your version will vary):
You can decode a binary file with::
$ dtc -v
Version: DTC 1.2.0-g2cb4b51f
$ make tests
$ cd tests
$ ./run_tests.sh
********** TEST SUMMARY
* Total testcases: 1371
* PASS: 1371
* FAIL: 0
* Bad configuration: 0
* Strange test result: 0
dtc -I dtb -O dts <filename.dtb>
You will also find a useful fdtdump utility for decoding a binary file, as
well as fdtget/fdtput for reading and writing properties in a binary file.
That repo also includes `fdtget`/`fdtput` for reading and writing properties in
a binary file. U-Boot adds its own `fdtgrep` for creating subsets of the file.
Where do I get an fdt file for my board?
----------------------------------------
Where do I get a devicetree file for my board?
----------------------------------------------
You may find that the Linux kernel has a suitable file. Look in the
kernel source in arch/<arch>/boot/dts.
......@@ -105,48 +81,44 @@ Failing that, you could write one from scratch yourself!
Configuration
-------------
Use:
Use::
#define CONFIG_DEFAULT_DEVICE_TREE "<name>"
#define CONFIG_DEFAULT_DEVICE_TREE "<name>"
to set the filename of the device tree source. Then put your device tree
file into
to set the filename of the devicetree source. Then put your devicetree
file into::
board/<vendor>/dts/<name>.dts
arch/<arch>/dts/<name>.dts
This should include your CPU or SOC's device tree file, placed in
arch/<arch>/dts, and then make any adjustments required.
This should include your CPU or SOC's devicetree file, placed in
`arch/<arch>/dts`, and then make any adjustments required using a u-boot-dtsi
file for your board.
If CONFIG_OF_EMBED is defined, then it will be picked up and built into
the U-Boot image (including u-boot.bin). This is suitable for debugging
and development only and is not recommended for production devices.
If CONFIG_OF_SEPARATE is defined, then it will be built and placed in
a u-boot.dtb file alongside u-boot-nodtb.bin. A common approach is then to
join the two:
cat u-boot-nodtb.bin u-boot.dtb >image.bin
and then flash image.bin onto your board. Note that U-Boot creates
u-boot-dtb.bin which does the above step for you also. Resulting
u-boot.bin is a copy of u-boot-dtb.bin in this case. If you are using
CONFIG_SPL_FRAMEWORK, then u-boot.img will be built to include the device
a u-boot.dtb file alongside u-boot-nodtb.bin with the combined result placed
in u-boot.bin so you can still just flash u-boot,bin onto your board. If you are
using CONFIG_SPL_FRAMEWORK, then u-boot.img will be built to include the device
tree binary.
If CONFIG_OF_BOARD is defined, a board-specific routine will provide the
device tree at runtime, for example if an earlier bootloader stage creates
devicetree at runtime, for example if an earlier bootloader stage creates
it and passes it to U-Boot.
If CONFIG_OF_HOSTFILE is defined, then it will be read from a file on
startup. This is only useful for sandbox. Use the -d flag to U-Boot to
specify the file to read.
specify the file to read, -D for the default and -T for the test devicetree,
used to run sandbox unit tests.
You cannot use more than one of these options at the same time.
To use a device tree file that you have compiled yourself, pass
EXT_DTB=<filename> to 'make', as in:
To use a devicetree file that you have compiled yourself, pass
EXT_DTB=<filename> to 'make', as in::
make EXT_DTB=boot/am335x-boneblack-pubkey.dtb
make EXT_DTB=boot/am335x-boneblack-pubkey.dtb
Then U-Boot will copy that file to u-boot.dtb, put it in the .img file
if used, and u-boot-dtb.bin.
......@@ -162,25 +134,61 @@ variable will be set to the address of the newly relocated fdt blob.
It is read-only and cannot be changed. It can optionally be used to
control the boot process of Linux with bootm/bootz commands.
To use this, put something like this in your board header file:
To use this, put something like this in your board header file::
#define CONFIG_EXTRA_ENV_SETTINGS "fdtcontroladdr=10000\0"
#define CONFIG_EXTRA_ENV_SETTINGS "fdtcontroladdr=10000\0"
Build:
After board configuration is done, fdt supported u-boot can be build in two ways:
1) build the default dts which is defined from CONFIG_DEFAULT_DEVICE_TREE
After the board configuration is done, fdt supported u-boot can be built in two
ways:
# build the default dts which is defined from CONFIG_DEFAULT_DEVICE_TREE::
$ make
2) build the user specified dts file
# build the user specified dts file::
$ make DEVICE_TREE=<dts-file-name>
.. _dttweaks:
Adding tweaks for U-Boot
------------------------
It is strongly recommended that devicetree files in U-Boot are an exact copy of
those in Linux, so that it is easy to sync them up from time to time.
U-Boot is of course a very different project from Linux, e.g. it operates under
much more restrictive memory and code-size constraints. Where Linux may use a
full clock driver with Common Clock Format (CCF) to find the input clock to the
UART, U-Boot typically wants to output a banner as early as possible before too
much code has run.
A second difference is that U-Boot includes different phases. For SPL,
constraints are even more extreme and the devicetree is shrunk to remove
unwanted nodes, or even turned into C code to avoid access overhead.
U-Boot automatically looks for and includes a file with updates to the standard
devicetree for your board, searching for them in the same directory as the
main file, in this order::
<orig_filename>-u-boot.dtsi
<CONFIG_SYS_SOC>-u-boot.dtsi
<CONFIG_SYS_CPU>-u-boot.dtsi
<CONFIG_SYS_VENDOR>-u-boot.dtsi
u-boot.dtsi
Only one of these is selected but of course you can #include another one within
that file, to create a hierarchy of shared files.
Relocation, SPL and TPL
-----------------------
U-Boot can be divided into three phases: TPL, SPL and U-Boot proper.
The full device tree is available to U-Boot proper, but normally only a subset
The full devicetree is available to U-Boot proper, but normally only a subset
(or none at all) is available to TPL and SPL. See 'Pre-Relocation Support' and
'SPL Support' in doc/driver-model/design.rst for more details.
......@@ -199,24 +207,24 @@ If board_fit_config_name_match() relies on DM (DM driver to access an EEPROM
containing the board ID for example), it possible to start with a generic DTB
and then switch over to the right DTB after the detection. For this purpose,
the platform code must call fdtdec_resetup(). Based on the returned flag, the
platform may have to re-initiliaze the DM subusystem using dm_uninit() and
platform may have to re-initialise the DM subsystem using dm_uninit() and
dm_init_and_scan().
Limitations
-----------
U-Boot is designed to build with a single architecture type and CPU
Devicetrees can help reduce the complexity of supporting variants of boards
which use the same SOC / CPU.
However U-Boot is designed to build for a single architecture type and CPU
type. So for example it is not possible to build a single ARM binary
which runs on your AT91 and OMAP boards, relying on an fdt to configure
the various features. This is because you must select one of
the CPU families within arch/arm/cpu/arm926ejs (omap or at91) at build
time. Similarly you cannot build for multiple cpu types or
time. Similarly U-Boot cannot be built for multiple cpu types or
architectures.
That said the complexity reduction by using fdt to support variants of
boards which use the same SOC / CPU can be substantial.
It is important to understand that the fdt only selects options
available in the platform / drivers. It cannot add new drivers (yet). So
you must still have the CONFIG option to enable the driver. For example,
......@@ -225,6 +233,19 @@ but can use the fdt to specific the UART clock, peripheral address, etc.
In very broad terms, the CONFIG options in general control *what* driver
files are pulled in, and the fdt controls *how* those files work.
--
Simon Glass <sjg@chromium.org>
1-Sep-11
History
-------
U-Boot configuration was previous done using CONFIG options in the board
config file. This eventually got out of hand with nearly 10,000 options.
U-Boot adopted devicetrees around the same time as Linux and early boards
used it before Linux (e.g. snow). The two projects developed in parallel
and there are still some differences in the bindings for certain boards.
While there has been discussion of having a separate repository for devicetree
files, in practice the Linux kernel Git repository has become the place where
these are stored, with U-Boot taking copies and adding tweaks with u-boot.dtsi
files.
.. _dtspec: https://www.devicetree.org/specifications/
.. _dtlist: https://www.spinics.net/lists/devicetree-compiler/
.. SPDX-License-Identifier: GPL-2.0+
Devicetree in U-Boot
====================
The following holds information on how U-Boot makes use of devicetree for
build-time and runtime configuration.
.. toctree::
:maxdepth: 2
intro
control
.. SPDX-License-Identifier: GPL-2.0+
Devicetree Introduction
=======================
U-Boot uses a devicetree for configuration. This includes the devices used by
the board, the format of the image created with binman, which UART to use for
the console, public keys used for secure boot and many other things.
See :doc:`control` for more information.
Why does U-Boot put <thing> in the devicetree?
----------------------------------------------
This question comes up a lot with people new to U-Boot, particular those coming
from Linux who are used to quite strict rules about what can go into the
devicetree.
U-Boot uses the same devicetree as Linux but adds more things necessary for the
bootloader environment (see :ref:`dttweaks`).
U-Boot does not have a user space to provide policy and configuration. It cannot
do what Linux does and run programs and look up filesystems to figure out how to
boot. So configuration and runtime information goes into the devicetree in
U-Boot.
Of course it is possible to:
- add tables into the rodata section of the U-Boot binary
- append some info to the end of U-Boot in a different format
- modify the linker script to bring in a file with some info in it
- put things in ACPI tables
- link in a UEFI hand-off block structure and put things in there
but *please don't*. In general, devicetree is the sane place to hold U-Boot's
configuration.
So, please, do NOT ask why U-Boot puts <thing> in the devicetree. It is the only
place it can go. It is a highly suitable data structure for just about anything
that U-Boot needs to know at runtime.
Note, it is possible to use platdata directly so drivers avoid devicetreee in
SPL. But of-platdata is the modern way of avoiding devicetree overhead, so
please use that instead.
......@@ -11,6 +11,7 @@ Implementation
ci_testing
commands
devicetree/index