[PATCH v4 0/9] sunxi: binman fixes and SCP firmware support

This is a rework of my previous patch series adding SCP firmware support for system suspend, on top of the binman rewrite of mksunxi_fit_atf.sh.
This patch series is based on u-boot-dm/next.
- The first two patches apply to binman FIT support generally. - The third patch is unchanged from previous versions. - Patches 4-6 fix small issues in the new sunxi binman description. - Patches 7-9 implement the same functionality as previous versions of this series, but using binman instead of a shell script.
Changes v3->v4: - Added a test for the SCP firmware entry type.
Samuel Holland (9): Makefile: Only define u-boot.itb rule when applicable binman: Only write FDT once per node spl: fit: Minimally parse OS properties with FIT_IMAGE_TINY sunxi: binman: Fix spacing between nodes sunxi: binman: Provide a default BL31 filename sunxi: binman: Use a macro for the BL31 load address sunxi: binman: Update FIT component descriptions binman: Add support for SCP firmware sunxi: binman: Add support for including SCP firmware
Makefile | 4 +++- arch/arm/dts/sunxi-u-boot.dtsi | 42 +++++++++++++++++++++++++-------- board/sunxi/README.sunxi64 | 43 ++++++++++++++++++++++++++++------ common/spl/Kconfig | 4 +--- common/spl/spl_fit.c | 17 +++++++++++++- tools/binman/README.entries | 4 ++-- tools/binman/etype/fit.py | 12 +++++----- tools/binman/etype/scp.py | 19 +++++++++++++++ tools/binman/ftest.py | 7 ++++++ tools/binman/test/172_scp.dts | 16 +++++++++++++ 10 files changed, 138 insertions(+), 30 deletions(-) create mode 100644 tools/binman/etype/scp.py create mode 100644 tools/binman/test/172_scp.dts

If neither CONFIG_SPL_FIT_SOURCE nor CONFIG_USE_SPL_FIT_GENERATOR is enabled, U_BOOT_ITS will be undefined, and attempting to make u-boot.itb will pass invalid arguments to mkimage, causing it to print its help message.
Remove the rule in that case, so it is more obvious that u-boot.itb is not something that can be made. This will reduce confusion as platforms move away from CONFIG_USE_SPL_FIT_GENERATOR, as u-boot.itb was previously a valid goal for those platforms.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Samuel Holland samuel@sholland.org --- Makefile | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/Makefile b/Makefile index 65024c74089..d5aa8605c0a 100644 --- a/Makefile +++ b/Makefile @@ -1438,11 +1438,13 @@ else MKIMAGEFLAGS_u-boot.itb = -E endif
+ifdef U_BOOT_ITS u-boot.itb: u-boot-nodtb.bin \ $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_OF_HOSTFILE),dts/dt.dtb) \ $(U_BOOT_ITS) FORCE $(call if_changed,mkfitimage) $(BOARD_SIZE_CHECK) +endif
u-boot-spl.kwb: u-boot.img spl/u-boot-spl.bin FORCE $(call if_changed,mkimage)

Due to an extra level of indentation, the "data" property containing the FDT was being written repeatedly after every other property in the node. Move the block up one level, so the property is added exactly once.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Samuel Holland samuel@sholland.org --- tools/binman/etype/fit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index c291eb26bad..01fa51367e6 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -179,10 +179,10 @@ class Entry_fit(Entry): b'SEQ', tools.ToBytes(str(seq + 1))) fsw.property(pname, val)
- # Add data for 'fdt' nodes (but not 'config') - if depth == 1 and in_images: - fsw.property('data', - tools.ReadFile(fname)) + # Add data for 'fdt' nodes (but not 'config') + if depth == 1 and in_images: + fsw.property('data', + tools.ReadFile(fname)) else: if self._fdts is None: if self._fit_list_prop:

Some boards, specifically 64-bit Allwinner boards (sun50i), are extremely limited on SPL size. One strategy that was used to make space was to remove the FIT "os" property parsing code, because it uses a rather large lookup table.
However, this forces the legacy FIT parsing code path, which requires the "firmware" entry in the FIT to reference the U-Boot binary, even if U-Boot is not the next binary in the boot sequence (for example, on sun50i boards, ATF is run first).
This prevents the same FIT image from being used with a SPL with CONFIG_SPL_FIT_IMAGE_TINY=n and CONFIG_SPL_ATF=y, because the boot method selection code looks at `spl_image.os`, which is only set from the "firmware" entry's "os" property.
To be able to use CONFIG_SPL_ATF=y, the "firmware" entry in the FIT must be ATF, and U-Boot must be a loadable. For this to work, we need to parse the "os" property just enough to tell U-Boot from other images, so we can find it in the loadables list to append the FDT, and so we don't try to append the FDT to ATF (which could clobber adjacent firmware).
So add the minimal code necessary to distinguish U-Boot/non-U-Boot loadables with CONFIG_SPL_FIT_IMAGE_TINY=y. This adds about 300 bytes, much less than the 7400 bytes added by CONFIG_SPL_FIT_IMAGE_TINY=n.
Acked-by: Patrick Wildt patrick@blueri.se Signed-off-by: Samuel Holland samuel@sholland.org --- common/spl/Kconfig | 4 +--- common/spl/spl_fit.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index af8255a8d6a..041b47244bd 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -465,9 +465,7 @@ config SPL_FIT_IMAGE_TINY Enable this to reduce the size of the FIT image loading code in SPL, if space for the SPL binary is very tight.
- This removes the detection of image types (which forces the - first image to be treated as having a U-Boot style calling - convention) and skips the recording of each loaded payload + This skips the recording of each loaded payload (i.e. loadable) into the FDT (modifying the loaded FDT to ensure this information is available to the next image invoked). diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 365104fe028..a31ab6c5992 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -466,7 +466,22 @@ static int spl_fit_record_loadable(const void *fit, int images, int index, static int spl_fit_image_get_os(const void *fit, int noffset, uint8_t *os) { #if CONFIG_IS_ENABLED(FIT_IMAGE_TINY) && !defined(CONFIG_SPL_OS_BOOT) - return -ENOTSUPP; + const char *name = fdt_getprop(fit, noffset, FIT_OS_PROP, NULL); + + if (!name) + return -ENOENT; + + /* + * We don't care what the type of the image actually is, + * only whether or not it is U-Boot. This saves some + * space by omitting the large table of OS types. + */ + if (!strcmp(name, "u-boot")) + *os = IH_OS_U_BOOT; + else + *os = IH_OS_INVALID; + + return 0; #else return fit_image_get_os(fit, noffset, os); #endif

Nodes should have a blank line separating them from sibling nodes and properties. Add the necessary lines.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Samuel Holland samuel@sholland.org --- arch/arm/dts/sunxi-u-boot.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi index 1d1c3691099..82b97a9503f 100644 --- a/arch/arm/dts/sunxi-u-boot.dtsi +++ b/arch/arm/dts/sunxi-u-boot.dtsi @@ -14,9 +14,11 @@ u-boot-sunxi-with-spl { filename = "u-boot-sunxi-with-spl.bin"; pad-byte = <0xff>; + blob { filename = "spl/sunxi-spl.bin"; }; + #ifdef CONFIG_ARM64 fit { description = "Configuration to load ATF before U-Boot"; @@ -34,6 +36,7 @@ u-boot-nodtb { }; }; + atf { description = "ARM Trusted Firmware"; type = "firmware"; @@ -47,6 +50,7 @@ load = <0x44000>; entry = <0x44000>; #endif + atf-bl31 { }; }; @@ -60,6 +64,7 @@
configurations { default = "config-1"; + @config-SEQ { description = "NAME"; firmware = "uboot";

Prior to commit 7f7f8aca8257 ("sunxi: Convert 64-bit boards to use binman"), if the BL31 environment variable was not defined, the firmware would be loaded from a file "bl31.bin" in the current directory. Restore that behavior by providing that as the default filename in case no entry arg is provided, which will be the case if the environment variable is unset.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Samuel Holland samuel@sholland.org --- arch/arm/dts/sunxi-u-boot.dtsi | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi index 82b97a9503f..6ab0c783ba5 100644 --- a/arch/arm/dts/sunxi-u-boot.dtsi +++ b/arch/arm/dts/sunxi-u-boot.dtsi @@ -52,6 +52,7 @@ #endif
atf-bl31 { + filename = "bl31.bin"; }; };

Hi Samuel,
On Sun, Sep 13, 2020 at 3:05 AM Samuel Holland samuel@sholland.org wrote:
Prior to commit 7f7f8aca8257 ("sunxi: Convert 64-bit boards to use binman"), if the BL31 environment variable was not defined, the firmware would be loaded from a file "bl31.bin" in the current directory. Restore that behavior by providing that as the default filename in case no entry arg is provided, which will be the case if the environment variable is unset.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Samuel Holland samuel@sholland.org
arch/arm/dts/sunxi-u-boot.dtsi | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi index 82b97a9503f..6ab0c783ba5 100644 --- a/arch/arm/dts/sunxi-u-boot.dtsi +++ b/arch/arm/dts/sunxi-u-boot.dtsi @@ -52,6 +52,7 @@ #endif
atf-bl31 {
filename = "bl31.bin";
I have dropped missing-msg = "atf-bl31-sunxi"; and used filename section as above.
Build showing below messages.
MKIMAGE u-boot.img MKIMAGE u-boot-dtb.img BINMAN all Image 'main-section' is missing external blobs and is non-functional: scp
Some images are invalid
Cannot we make scp as optional for the build?
Jagan.

On 10/21/20 1:49 PM, Jagan Teki wrote:
Hi Samuel,
On Sun, Sep 13, 2020 at 3:05 AM Samuel Holland samuel@sholland.org wrote:
Prior to commit 7f7f8aca8257 ("sunxi: Convert 64-bit boards to use binman"), if the BL31 environment variable was not defined, the firmware would be loaded from a file "bl31.bin" in the current directory. Restore that behavior by providing that as the default filename in case no entry arg is provided, which will be the case if the environment variable is unset.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Samuel Holland samuel@sholland.org
arch/arm/dts/sunxi-u-boot.dtsi | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi index 82b97a9503f..6ab0c783ba5 100644 --- a/arch/arm/dts/sunxi-u-boot.dtsi +++ b/arch/arm/dts/sunxi-u-boot.dtsi @@ -52,6 +52,7 @@ #endif
atf-bl31 {
filename = "bl31.bin";
I have dropped missing-msg = "atf-bl31-sunxi"; and used filename section as above.
Build showing below messages.
MKIMAGE u-boot.img MKIMAGE u-boot-dtb.img BINMAN all Image 'main-section' is missing external blobs and is non-functional: scp
Some images are invalid
Cannot we make scp as optional for the build?
It already is optional. Even with that warning message, u-boot-sunxi-with-spl.bin is still created and will still boot.
Now that the missing-msg is merged to mainline, I will add one for SCP firmware saying it is optional. However, I cannot control the existing binman warning. I will also explain in the documentation how to silence the warning (with an empty file).
Jagan.
Cheers, Samuel

This consolidates the SoC-specific part at the top of the file to avoid cluttering it up with preprocessor conditions.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Samuel Holland samuel@sholland.org --- arch/arm/dts/sunxi-u-boot.dtsi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi index 6ab0c783ba5..4d599720382 100644 --- a/arch/arm/dts/sunxi-u-boot.dtsi +++ b/arch/arm/dts/sunxi-u-boot.dtsi @@ -1,5 +1,11 @@ #include <config.h>
+#ifdef CONFIG_MACH_SUN50I_H6 +#define BL31_ADDR 0x104000 +#else +#define BL31_ADDR 0x44000 +#endif + / { aliases { mmc1 = &mmc2; @@ -42,14 +48,8 @@ type = "firmware"; arch = "arm64"; compression = "none"; -/* TODO: Do this with an overwrite in this board's dtb? */ -#ifdef CONFIG_MACH_SUN50I_H6 - load = <0x104000>; - entry = <0x104000>; -#else - load = <0x44000>; - entry = <0x44000>; -#endif + load = <BL31_ADDR>; + entry = <BL31_ADDR>;
atf-bl31 { filename = "bl31.bin";

Since commit d879616e9e64 ("spl: fit: simplify logic for FDT loading for non-OS boots"), the SPL looks at the "os" properties of FIT images to determine where to append the FDT.
The "os" property of the "firmware" image also determines how to execute the next stage of the boot process, as in 1d3790905d9c ("spl: atf: introduce spl_invoke_atf and make bl31_entry private"). For this reason, the next stage must be specified in "firmware", not in "loadables".
To support this additional functionality, and to properly model the boot process, where ATF runs before U-Boot, add the "os" properties and swap the firmware/loadable images in the FIT image.
Since this description was copied as an example in commit 70248d6a2916 ("binman: Support generating FITs with multiple dtbs"), update those examples as well for correctness and consistency.
Acked-by: Patrick Wildt patrick@blueri.se Signed-off-by: Samuel Holland samuel@sholland.org --- arch/arm/dts/sunxi-u-boot.dtsi | 6 ++++-- tools/binman/README.entries | 4 ++-- tools/binman/etype/fit.py | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi index 4d599720382..ff3fff599f4 100644 --- a/arch/arm/dts/sunxi-u-boot.dtsi +++ b/arch/arm/dts/sunxi-u-boot.dtsi @@ -35,6 +35,7 @@ uboot { description = "U-Boot (64-bit)"; type = "standalone"; + os = "u-boot"; arch = "arm64"; compression = "none"; load = <0x4a000000>; @@ -46,6 +47,7 @@ atf { description = "ARM Trusted Firmware"; type = "firmware"; + os = "arm-trusted-firmware"; arch = "arm64"; compression = "none"; load = <BL31_ADDR>; @@ -68,8 +70,8 @@
@config-SEQ { description = "NAME"; - firmware = "uboot"; - loadables = "atf"; + firmware = "atf"; + loadables = "uboot"; fdt = "fdt-SEQ"; }; }; diff --git a/tools/binman/README.entries b/tools/binman/README.entries index d2628dffd5d..c45aed0a681 100644 --- a/tools/binman/README.entries +++ b/tools/binman/README.entries @@ -385,8 +385,8 @@ You can create config nodes in a similar way: default = "@config-DEFAULT-SEQ"; @config-SEQ { description = "NAME"; - firmware = "uboot"; - loadables = "atf"; + firmware = "atf"; + loadables = "uboot"; fdt = "fdt-SEQ"; }; }; diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 01fa51367e6..73793ecda31 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -73,8 +73,8 @@ class Entry_fit(Entry): default = "@config-DEFAULT-SEQ"; @config-SEQ { description = "NAME"; - firmware = "uboot"; - loadables = "atf"; + firmware = "atf"; + loadables = "uboot"; fdt = "fdt-SEQ"; }; };

Add an entry type for a firmware blob for a Sytem Control Processor, given by an entry arg. This firmware is a raw binary blob.
Signed-off-by: Samuel Holland samuel@sholland.org --- Makefile | 2 +- tools/binman/etype/scp.py | 19 +++++++++++++++++++ tools/binman/ftest.py | 7 +++++++ tools/binman/test/172_scp.dts | 16 ++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tools/binman/etype/scp.py create mode 100644 tools/binman/test/172_scp.dts
diff --git a/Makefile b/Makefile index d5aa8605c0a..5a6681f129e 100644 --- a/Makefile +++ b/Makefile @@ -1328,7 +1328,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \ build -u -d u-boot.dtb -O . -m --allow-missing \ -I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \ -I arch/$(ARCH)/dts -a of-list=$(CONFIG_OF_LIST) \ - -a atf-bl31-path=${BL31} \ + -a atf-bl31-path=${BL31} -a scp-path=${SCP} \ $(BINMAN_$(@F))
OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex diff --git a/tools/binman/etype/scp.py b/tools/binman/etype/scp.py new file mode 100644 index 00000000000..93f8787d2d7 --- /dev/null +++ b/tools/binman/etype/scp.py @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2020 Samuel Holland samuel@sholland.org +# +# Entry-type module for System Control Processor (SCP) firmware blob +# + +from binman.etype.blob_named_by_arg import Entry_blob_named_by_arg + +class Entry_scp(Entry_blob_named_by_arg): + """Entry containing a System Control Processor (SCP) firmware blob + + Properties / Entry arguments: + - scp-path: Filename of file to read into the entry, typically scp.bin + + This entry holds firmware for an external platform-specific coprocessor. + """ + def __init__(self, section, etype, node): + super().__init__(section, etype, node, 'scp') + self.external = True diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 78d0e9c2b93..72e738913eb 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -75,6 +75,7 @@ FSP_M_DATA = b'fsp_m' FSP_S_DATA = b'fsp_s' FSP_T_DATA = b'fsp_t' ATF_BL31_DATA = b'bl31' +SCP_DATA = b'scp' TEST_FDT1_DATA = b'fdt1' TEST_FDT2_DATA = b'test-fdt2'
@@ -174,6 +175,7 @@ class TestFunctional(unittest.TestCase):
TestFunctional._MakeInputFile('compress', COMPRESS_DATA) TestFunctional._MakeInputFile('bl31.bin', ATF_BL31_DATA) + TestFunctional._MakeInputFile('scp.bin', SCP_DATA)
# Add a few .dtb files for testing TestFunctional._MakeInputFile('%s/test-fdt1.dtb' % TEST_FDT_SUBDIR, @@ -3575,6 +3577,11 @@ class TestFunctional(unittest.TestCase): data = self._DoReadFile('169_atf_bl31.dts') self.assertEqual(ATF_BL31_DATA, data[:len(ATF_BL31_DATA)])
+ def testPackScp(self): + """Test that an image with an SCP binary can be created""" + data = self._DoReadFile('172_scp.dts') + self.assertEqual(SCP_DATA, data[:len(SCP_DATA)]) + def testFitFdt(self): """Test an image with an FIT with multiple FDT images""" def _CheckFdt(seq, expected_data): diff --git a/tools/binman/test/172_scp.dts b/tools/binman/test/172_scp.dts new file mode 100644 index 00000000000..354e4ef17df --- /dev/null +++ b/tools/binman/test/172_scp.dts @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + size = <16>; + + scp { + filename = "scp.bin"; + }; + }; +};

On Sat, 12 Sep 2020 at 15:35, Samuel Holland samuel@sholland.org wrote:
Add an entry type for a firmware blob for a Sytem Control Processor, given by an entry arg. This firmware is a raw binary blob.
Signed-off-by: Samuel Holland samuel@sholland.org
Makefile | 2 +- tools/binman/etype/scp.py | 19 +++++++++++++++++++ tools/binman/ftest.py | 7 +++++++ tools/binman/test/172_scp.dts | 16 ++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tools/binman/etype/scp.py create mode 100644 tools/binman/test/172_scp.dts
Reviewed-by: Simon Glass sjg@chromium.org

Allwinner sun50i SoCs contain an OpenRISC 1000 CPU that functions as a System Control Processor, or SCP. ARM Trusted Firmware (ATF) communicates with the SCP over SCPI to implement the PSCI system suspend, shutdown and reset functionality. Currently, SCP firmware is optional; the system will boot and run without it, but system suspend will be unavailable.
Since all communication with the SCP is mediated by ATF, the only thing U-Boot needs to do is load the firmware into SRAM. The SCP firmware occupies the last 16KiB of SRAM A2, immediately following ATF.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Samuel Holland samuel@sholland.org --- arch/arm/dts/sunxi-u-boot.dtsi | 16 ++++++++++++- board/sunxi/README.sunxi64 | 43 ++++++++++++++++++++++++++++------ 2 files changed, 51 insertions(+), 8 deletions(-)
diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi index ff3fff599f4..5ab7c6c23b7 100644 --- a/arch/arm/dts/sunxi-u-boot.dtsi +++ b/arch/arm/dts/sunxi-u-boot.dtsi @@ -2,8 +2,10 @@
#ifdef CONFIG_MACH_SUN50I_H6 #define BL31_ADDR 0x104000 +#define SCP_ADDR 0x114000 #else #define BL31_ADDR 0x44000 +#define SCP_ADDR 0x50000 #endif
/ { @@ -58,6 +60,18 @@ }; };
+ scp { + description = "SCP firmware"; + type = "firmware"; + arch = "or1k"; + compression = "none"; + load = <SCP_ADDR>; + + scp { + filename = "scp.bin"; + }; + }; + @fdt-SEQ { description = "NAME"; type = "flat_dt"; @@ -71,7 +85,7 @@ @config-SEQ { description = "NAME"; firmware = "atf"; - loadables = "uboot"; + loadables = "scp", "uboot"; fdt = "fdt-SEQ"; }; }; diff --git a/board/sunxi/README.sunxi64 b/board/sunxi/README.sunxi64 index 258921af22d..9a67e5301eb 100644 --- a/board/sunxi/README.sunxi64 +++ b/board/sunxi/README.sunxi64 @@ -14,8 +14,12 @@ Quick Start / Overview - Build the ARM Trusted Firmware binary (see "ARM Trusted Firmware (ATF)" below) $ cd /src/arm-trusted-firmware $ make PLAT=sun50i_a64 DEBUG=1 bl31 +- Build the SCP firmware binary (see "SCP firmware (Crust)" below) + $ cd /src/crust + $ make pine64_plus_defconfig && make -j5 scp - Build U-Boot (see "SPL/U-Boot" below) $ export BL31=/path/to/bl31.bin + $ export SCP=/src/crust/build/scp/scp.bin $ make pine64_plus_defconfig && make -j5 - Transfer to an uSD card (see "microSD card" below) $ dd if=u-boot-sunxi-with-spl.bin of=/dev/sdx bs=8k seek=1 @@ -24,13 +28,17 @@ Quick Start / Overview Building the firmware =====================
-The Allwinner A64/H5 firmware consists of three parts: U-Boot's SPL, an -ARM Trusted Firmware (ATF) build and the U-Boot proper. -The SPL will load both ATF and U-Boot proper along with the right device -tree blob (.dtb) and will pass execution to ATF (in EL3), which in turn will -drop into the U-Boot proper (in EL2). -As the ATF binary will become part of the U-Boot image file, you will need -to build it first. +The Allwinner A64/H5/H6 firmware consists of several parts: U-Boot's SPL, +ARM Trusted Firmware (ATF), optional System Control Processor (SCP) firmware +(e.g. Crust), and the U-Boot proper. + +The SPL will load all of the other firmware binaries into RAM, along with the +right device tree blob (.dtb), and will pass execution to ATF (in EL3). If SCP +firmware was loaded, ATF will power on the SCP and wait for it to boot. +ATF will then drop into U-Boot proper (in EL2). + +As the ATF binary and SCP firmware will become part of the U-Boot image file, +you will need to build them first.
ARM Trusted Firmware (ATF) ---------------------------- @@ -53,6 +61,27 @@ As sometimes the ATF build process is a bit picky about the toolchain used, or if you can't be bothered with building ATF, there are known working binaries in the firmware repository[3], purely for convenience reasons.
+ SCP firmware (Crust) +---------------------- +SCP firmware is responsible for implementing system suspend/resume, and (on +boards without a PMIC) soft poweroff/on. ATF contains fallback code for CPU +power control, so SCP firmware is optional if you don't need either of these +features. It runs on the AR100, with is an or1k CPU, not ARM, so it needs a +different cross toolchain. + +There is one SCP firmware implementation currently available, Crust: +$ git clone https://github.com/crust-firmware/crust +$ cd crust +$ export CROSS_COMPILE=or1k-linux-musl- +$ make pine64_plus_defconfig +$ make scp + +The same configuration generally works on any board with the same SoC (A64, H5, +or H6), so if there is no config for your board, use one for a similar board. + +Like for ATF, U-Boot finds the SCP firmware binary via an environment variable: +$ export SCP=/src/crust/build/scp/scp.bin + SPL/U-Boot ------------ Both U-Boot proper and the SPL are using the 64-bit mode. As the boot ROM
participants (3)
-
Jagan Teki
-
Samuel Holland
-
Simon Glass