[PATCH v2] clk: rockchip: rk3588: Set SPLL frequency during SPL stage
From: Heiko Stuebner All parts expect the SPLL to run at 702MHz. In U-Boot it's the SPLL_HZ declaring this rate and in the kernel it's a fixed clock definition. While everything is expecting 702MHz, the SPLL is not running that frequency when coming from the bootrom though, instead it's running at 351MHz and the vendor-u-boot just sets it to the expected frequency. The SPLL itself is located inside the secure-BUSCRU and in theory accessible as an SCMI clock, though this requires an unknown amount of cooperation from trusted-firmware to set at a later stage, though during the SPL stage we can still access the relevant CRU directly. The SPLL is for example necessary for the DSI controllers to produce output. As the SPLL is "just" another rk3588 pll, just set the desired rate directly during the SPL stage. Tested on rk3588-rock5b and rk3588-tiger by reading back the PLL rate and also observing working DSI output with this change. Fixes: 6737771600d4 ("rockchip: rk3588: Add support for sdmmc clocks in SPL") Suggested-by: Andy Yan Signed-off-by: Heiko Stuebner Cc: Jonas Karlman Cc: Quentin Schulz --- changes in v2: - use correct name for SBUSCRU - use dedicated constants for SBUSCRU registers - add comment to make it explicit that the SPLL is in a different CRU .../include/asm/arch-rockchip/cru_rk3588.h| 4 +++ drivers/clk/rockchip/clk_rk3588.c | 30 +-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3588.h b/arch/arm/include/asm/arch-rockchip/cru_rk3588.h index a4507e5fdd7..a0e54d39654 100644 --- a/arch/arm/include/asm/arch-rockchip/cru_rk3588.h +++ b/arch/arm/include/asm/arch-rockchip/cru_rk3588.h @@ -29,6 +29,7 @@ enum rk3588_pll_id { V0PLL, AUPLL, PPLL, + SPLL, PLL_COUNT, }; @@ -150,6 +151,9 @@ struct pll_rate_table { #define RK3588_DSU_CLKGATE_CON(x) ((x) * 0x4 + RK3588_DSU_CRU_BASE + 0x800) #define RK3588_DSU_SOFTRST_CON(x) ((x) * 0x4 + RK3588_DSU_CRU_BASE + 0xa00) +#define RK3588_SBUSCRU_SPLL_CON(x) ((x) * 0x4 + 0x220) +#define RK3588_SBUSCRU_MODE_CON0 0x280 + enum { /* CRU_CLK_SEL8_CON */ ACLK_LOW_TOP_ROOT_SRC_SEL_SHIFT = 14, diff --git a/drivers/clk/rockchip/clk_rk3588.c b/drivers/clk/rockchip/clk_rk3588.c index 4c611a39049..c41c9be6aa3 100644 --- a/drivers/clk/rockchip/clk_rk3588.c +++ b/drivers/clk/rockchip/clk_rk3588.c @@ -37,6 +37,7 @@ static struct rockchip_pll_rate_table rk3588_pll_rates[] = { RK3588_PLL_RATE(78600, 1, 131, 2, 0), RK3588_PLL_RATE(74250, 4, 495, 2, 0), RK3588_PLL_RATE(722534400, 8, 963, 2, 24850), + RK3588_PLL_RATE(70200, 3, 351, 2, 0), RK3588_PLL_RATE(6, 2, 200, 2, 0), RK3588_PLL_RATE(59400, 2, 198, 2, 0), RK3588_PLL_RATE(2, 3, 400, 4, 0), @@ -65,6 +66,15 @@ static struct rockchip_pll_clock rk3588_pll_clks[] = { RK3588_MODE_CON0, 0, 15, 0, rk3588_pll_rates), [PPLL] = PLL(pll_rk3588, PLL_PPLL, RK3588_PMU_PLL_CON(128), RK3588_MODE_CON0, 10, 15, 0, rk3588_pll_rates), +#ifdef CONFIG_SPL_BUILD + /* +* The SPLL is part of the SBUSCRU, not the main CRU and as +* such only directly accessible during the SPL stage. +*/ + [SPLL] = PLL(pll_rk3588, 0, RK3588_SBUSCRU_SPLL_CON(0), +RK3588_SBUSCRU_MODE_CON0, 0, 15, 0, rk3588_pll_rates), +#endif + }; #ifndef CONFIG_SPL_BUILD @@ -2044,6 +2054,7 @@ U_BOOT_DRIVER(rockchip_rk3588_cru) = { #ifdef CONFIG_SPL_BUILD #define SCRU_BASE 0xfd7d +#define SBUSCRU_BASE 0xfd7d8000 static ulong rk3588_scru_clk_get_rate(struct clk *clk) { @@ -2118,15 +2129,28 @@ static ulong rk3588_scru_clk_set_rate(struct clk *clk, ulong rate) return rk3588_scru_clk_get_rate(clk); } +static int rk3588_scru_clk_probe(struct udevice *dev) +{ + int ret; + + ret = rockchip_pll_set_rate(_pll_clks[SPLL], + (void *)SBUSCRU_BASE, SPLL, SPLL_HZ); + if (ret) + debug("%s setting spll rate failed %d\n", __func__, ret); + + return 0; +} + static const struct clk_ops rk3588_scru_clk_ops = { .get_rate = rk3588_scru_clk_get_rate, .set_rate = rk3588_scru_clk_set_rate, }; U_BOOT_DRIVER(rockchip_rk3588_scru) = { - .name = "rockchip_rk3588_scru", - .id = UCLASS_CLK, - .ops = _scru_clk_ops, + .name = "rockchip_rk3588_scru", + .id = UCLASS_CLK, + .ops= _scru_clk_ops, + .probe = rk3588_scru_clk_probe, }; static int rk3588_scmi_spl_glue_bind(struct udevice *dev) -- 2.39.2
[PATCH RESEND] clk: rockchip: rk3588: Set SPLL frequency during SPL stage
From: Heiko Stuebner All parts expect the SPLL to run at 702MHz. In U-Boot it's the SPLL_HZ declaring this rate and in the kernel it's a fixed clock definition. While everything is expecting 702MHz, the SPLL is not running that frequency when coming from the bootrom though, instead it's running at 351MHz and the vendor-u-boot just sets it to the expected frequency. The SPLL itself is located inside the secure-BUSCRU and in theory accessible as an SCMI clock, though this requires an unknown amount of cooperation from trusted-firmware to set at a later stage, though during the SPL stage we can still access the relevant CRU directly. The SPLL is for example necessary for the DSI controllers to produce output. As the SPLL is "just" another rk3588 pll, just set the desired rate directly during the SPL stage. Tested on rk3588-rock5b and rk3588-tiger by reading back the PLL rate and also observing working DSI output with this change. Fixes: 6737771600d4 ("rockchip: rk3588: Add support for sdmmc clocks in SPL") Suggested-by: Andy Yan Signed-off-by: Heiko Stuebner Cc: Jonas Karlman --- Resend, because I forgot the u-boot list .../include/asm/arch-rockchip/cru_rk3588.h| 1 + drivers/clk/rockchip/clk_rk3588.c | 26 --- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3588.h b/arch/arm/include/asm/arch-rockchip/cru_rk3588.h index a4507e5fdd7..85b4da0bc2c 100644 --- a/arch/arm/include/asm/arch-rockchip/cru_rk3588.h +++ b/arch/arm/include/asm/arch-rockchip/cru_rk3588.h @@ -29,6 +29,7 @@ enum rk3588_pll_id { V0PLL, AUPLL, PPLL, + SPLL, PLL_COUNT, }; diff --git a/drivers/clk/rockchip/clk_rk3588.c b/drivers/clk/rockchip/clk_rk3588.c index 4c611a39049..5384b3213f5 100644 --- a/drivers/clk/rockchip/clk_rk3588.c +++ b/drivers/clk/rockchip/clk_rk3588.c @@ -37,6 +37,7 @@ static struct rockchip_pll_rate_table rk3588_pll_rates[] = { RK3588_PLL_RATE(78600, 1, 131, 2, 0), RK3588_PLL_RATE(74250, 4, 495, 2, 0), RK3588_PLL_RATE(722534400, 8, 963, 2, 24850), + RK3588_PLL_RATE(70200, 3, 351, 2, 0), RK3588_PLL_RATE(6, 2, 200, 2, 0), RK3588_PLL_RATE(59400, 2, 198, 2, 0), RK3588_PLL_RATE(2, 3, 400, 4, 0), @@ -65,6 +66,11 @@ static struct rockchip_pll_clock rk3588_pll_clks[] = { RK3588_MODE_CON0, 0, 15, 0, rk3588_pll_rates), [PPLL] = PLL(pll_rk3588, PLL_PPLL, RK3588_PMU_PLL_CON(128), RK3588_MODE_CON0, 10, 15, 0, rk3588_pll_rates), +#ifdef CONFIG_SPL_BUILD + /* SBUSCRU MODE_CON has the same register offset as the main MODE_CON */ + [SPLL] = PLL(pll_rk3588, 0, RK3588_PLL_CON(136), +RK3588_MODE_CON0, 0, 15, 0, rk3588_pll_rates), +#endif }; #ifndef CONFIG_SPL_BUILD @@ -2044,6 +2050,7 @@ U_BOOT_DRIVER(rockchip_rk3588_cru) = { #ifdef CONFIG_SPL_BUILD #define SCRU_BASE 0xfd7d +#define BUSSCRU_BASE 0xfd7d8000 static ulong rk3588_scru_clk_get_rate(struct clk *clk) { @@ -2118,15 +2125,28 @@ static ulong rk3588_scru_clk_set_rate(struct clk *clk, ulong rate) return rk3588_scru_clk_get_rate(clk); } +static int rk3588_scru_clk_probe(struct udevice *dev) +{ + int ret; + + ret = rockchip_pll_set_rate(_pll_clks[SPLL], + (void *)BUSSCRU_BASE, SPLL, SPLL_HZ); + if (ret) + debug("%s setting spll rate failed %d\n", __func__, ret); + + return 0; +} + static const struct clk_ops rk3588_scru_clk_ops = { .get_rate = rk3588_scru_clk_get_rate, .set_rate = rk3588_scru_clk_set_rate, }; U_BOOT_DRIVER(rockchip_rk3588_scru) = { - .name = "rockchip_rk3588_scru", - .id = UCLASS_CLK, - .ops = _scru_clk_ops, + .name = "rockchip_rk3588_scru", + .id = UCLASS_CLK, + .ops= _scru_clk_ops, + .probe = rk3588_scru_clk_probe, }; static int rk3588_scmi_spl_glue_bind(struct udevice *dev) -- 2.39.2
[PATCH] arm: dts: rk3399-puma: re-add vdd_log for uboot
The rk3399-puma board needs a 950mV vdd_log to work stable. This was already added in commit 77012e79ffc3 ("rockchip: rk3399-puma: Set VDD_LOG to 950 mV") but lost again with commit 167efc2c7a46 ("arm64: dts: rk3399: Sync v5.7-rc1 from Linux") So to make puma stable again re-add the vdd_log pwm regulator. As it is not part of the mainline Linux dts right now, add it to the -u-boot dtsi for puma. Fixes: 167efc2c7a46 ("arm64: dts: rk3399: Sync v5.7-rc1 from Linux") Signed-off-by: Heiko Stuebner --- arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi index 29846c4b00..76eb51d2d7 100644 --- a/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi +++ b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi @@ -49,6 +49,17 @@ regulator-min-microvolt = <180>; regulator-max-microvolt = <180>; }; + + vdd_log: vdd-log { + compatible = "pwm-regulator"; + pwms = < 0 25000 1>; + regulator-name = "vdd_log"; + regulator-min-microvolt = <80>; + regulator-max-microvolt = <140>; + regulator-always-on; + regulator-boot-on; + regulator-init-microvolt = <95>; + }; }; { -- 2.30.2
Re: [PATCH] rockchip: rk3399-puma: Increase environment size to 16 kiB.
Am Freitag, 19. Februar 2021, 01:30:02 CET schrieb Christoph Muellner: > On Puma we have the environment at an offset of 16 kiB. > On the eMMC this gives us 16 kiB for the environment before the SPL starts. > On the SPI NOR we also have 16 kiB until end of flash. > So let's increase the environment size from 8 kiB to its maximum > of 16 kiB for both MMC and SPI NOR. > > Signed-off-by: Christoph Muellner as that area would otherwise be simply wasted, this looks like a nice addition Reviewed-by: Heiko Stuebner > --- > > board/theobroma-systems/puma_rk3399/Kconfig | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/board/theobroma-systems/puma_rk3399/Kconfig > b/board/theobroma-systems/puma_rk3399/Kconfig > index e82623a1701..21946d984da 100644 > --- a/board/theobroma-systems/puma_rk3399/Kconfig > +++ b/board/theobroma-systems/puma_rk3399/Kconfig > @@ -13,7 +13,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy > def_bool y > > config ENV_SIZE > - default 0x2000 > + default 0x4000 > > config ENV_OFFSET > default 0x3fc000 if ENV_IS_IN_SPI_FLASH >
Re: [PATCH] rockchip: rk3399-puma: Restore correct VDD_LOG supply.
Am Freitag, 19. Februar 2021, 01:29:48 CET schrieb Christoph Muellner: > A commit from last year re-imported the DTS files form the upstream kernel. > By doing so the VDD_LOG regulator in the board's DTS was dropped. > Let's restore this, but move it into the u-boot overlay to prevent this > issue in the future. > > Fixes: 167efc2c7a46 ("arm64: dts: rk3399: Sync v5.7-rc1 from Linux") > Signed-off-by: Christoph Muellner Reviewed-by: Heiko Stuebner > > --- > > arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi | 12 > 1 file changed, 12 insertions(+) > > diff --git a/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi > b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi > index e7a1aea3a56..e0476ab25c9 100644 > --- a/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi > +++ b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi > @@ -48,6 +48,18 @@ > regulator-min-microvolt = <180>; > regulator-max-microvolt = <180>; > }; > + > + vdd_log: vdd-log { > + compatible = "pwm-regulator"; > + pwms = < 0 25000 1>; > + regulator-name = "vdd_log"; > + regulator-always-on; > + regulator-boot-on; > + regulator-min-microvolt = <80>; > + regulator-max-microvolt = <140>; > + regulator-init-microvolt = <95>; > + vin-supply = <_sys>; > + }; > }; > > { >
Re: [PATCH] odroid-go2: remove setting SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
Hi Tom, Am Mittwoch, 17. Februar 2021, 03:21:25 CET schrieb Tom Rini: > On Wed, Feb 17, 2021 at 02:42:21AM +0100, Heiko Stuebner wrote: > > Hi Tom, > > > > Am Dienstag, 16. Februar 2021, 15:26:52 CET schrieb Tom Rini: > > > On Sat, Feb 13, 2021 at 11:45:50PM +0100, Heiko Stuebner wrote: > > > > Hi Roger, > > > > > > > > Am Samstag, 13. Februar 2021, 16:59:01 CET schrieb Roger Pau Monne: > > > > > From: Roger Pau Monné > > > > > > > > > > Using a non-default SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR setting makes the > > > > > resulting u-boot-rockchip.bin unbootable, as it gets stuck after SPL. > > > > > Removing the setting from the defconfig allows U-Boot to load > > > > > successfully. > > > > > > > > Hmm, I'd disagree slightly. > > > > > > > > In the rockchip-common.h the CONFIG_SPL_PAD_TO is defined as > > > > > > > > /* ((CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR - 64) * 512) */ > > > > #define CONFIG_SPL_PAD_TO 8355840 > > > > > > > > so it's a static value but based on the MMCSD_RAW_MODE... config option. > > > > > > > > So instead of mandating one specific MMCSD_RAW_MODE... value > > > > that CONFIG_SPL_PAD_TO should be defined based on the the > > > > actual config value of CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR > > > > and not some static number that then gets enforced for all boards. > > > > > > So, what does CONFIG_SPL_PAD_TO actually mean, in this case? And > > > SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR ? What I'm getting at is that we > > > generally have some required to be fixed (by the SoC/ROM/etc) locations > > > some parts of our SPL/TPL/U-Boot need to be at and then the rest of the > > > values are (supposed to be) well and carefully chosen offsets and not > > > changed around. So with the above comment in the code to explain where > > > 8355840 came from, it also shouldn't and nor should > > > CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR be changed without a compelling > > > reason. > > > > Normally Rockchip platforms have two loader binaries: > > > > - idbLoader.img (tpl + spl, or only spl), loving at offset 64 of a sd-card > > This is mandated by the bootrom > > - u-boot.itb (u-boot, atf, etc) living at SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR > > As SPL will load from the location specified in the config, this location > > can be set depending on emmc/sd-card/whatever needs. > > > > It looks like recently a new binary creating method was added that creates > > a u-boot-rockchip.bin combining these somewhat automatically: > > > > idbLoader.img > > + SPL_PAD_TO > > + u-boot.itb > > > > So that only that binary needs to be flashed to the boot medium > > instead of two. > > > > So the SPL_PAD_TO essentially would mandate one specific > > SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR for every board. > > > > > > For the odroid-go2 itself it doesn't really matter I guess, but there are > > other boards with different requirements, so mandating one specific place > > for the main uboot for all boards that will ever exist seems a bit counter- > > intuitive to me. > > I would say that yes, it's quite intentional that all boards for a given > SoC (or SoC family) would use the same value for > SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR and NOT leave it up to be per-board. > It should be a matter of kilobytes being potentially wasted which is > (often or most likely) worth sacrificing in the name of consistency and > ease of future use / development. In other cases this ends up being > something around "ROM will only load something of $X size, round that up > a little bit, place U-Boot there, as it's the next thing to load". Ok ... then I'guess I'll not stand in the way ;-) . Though we're in the megabyte range with CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR being 0x4000 * 512 . But I guess with current emmc sizes that might not matter too much. But should there be some sort of warning when the CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR doesn't match the expected value? Because for example rk3399-puma and rk3368-lion historical use that 0x200 instead of 0x4000 block offset and I think at least their default firmware also expects u-boot to not reach that far into the emmc. Heiko
Re: [PATCH] odroid-go2: remove setting SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
Hi Tom, Am Dienstag, 16. Februar 2021, 15:26:52 CET schrieb Tom Rini: > On Sat, Feb 13, 2021 at 11:45:50PM +0100, Heiko Stuebner wrote: > > Hi Roger, > > > > Am Samstag, 13. Februar 2021, 16:59:01 CET schrieb Roger Pau Monne: > > > From: Roger Pau Monné > > > > > > Using a non-default SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR setting makes the > > > resulting u-boot-rockchip.bin unbootable, as it gets stuck after SPL. > > > Removing the setting from the defconfig allows U-Boot to load > > > successfully. > > > > Hmm, I'd disagree slightly. > > > > In the rockchip-common.h the CONFIG_SPL_PAD_TO is defined as > > > > /* ((CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR - 64) * 512) */ > > #define CONFIG_SPL_PAD_TO 8355840 > > > > so it's a static value but based on the MMCSD_RAW_MODE... config option. > > > > So instead of mandating one specific MMCSD_RAW_MODE... value > > that CONFIG_SPL_PAD_TO should be defined based on the the > > actual config value of CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR > > and not some static number that then gets enforced for all boards. > > So, what does CONFIG_SPL_PAD_TO actually mean, in this case? And > SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR ? What I'm getting at is that we > generally have some required to be fixed (by the SoC/ROM/etc) locations > some parts of our SPL/TPL/U-Boot need to be at and then the rest of the > values are (supposed to be) well and carefully chosen offsets and not > changed around. So with the above comment in the code to explain where > 8355840 came from, it also shouldn't and nor should > CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR be changed without a compelling > reason. Normally Rockchip platforms have two loader binaries: - idbLoader.img (tpl + spl, or only spl), loving at offset 64 of a sd-card This is mandated by the bootrom - u-boot.itb (u-boot, atf, etc) living at SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR As SPL will load from the location specified in the config, this location can be set depending on emmc/sd-card/whatever needs. It looks like recently a new binary creating method was added that creates a u-boot-rockchip.bin combining these somewhat automatically: idbLoader.img + SPL_PAD_TO + u-boot.itb So that only that binary needs to be flashed to the boot medium instead of two. So the SPL_PAD_TO essentially would mandate one specific SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR for every board. For the odroid-go2 itself it doesn't really matter I guess, but there are other boards with different requirements, so mandating one specific place for the main uboot for all boards that will ever exist seems a bit counter- intuitive to me. Heiko
Re: [PATCH] odroid-go2: remove setting SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
Hi Roger, Am Samstag, 13. Februar 2021, 16:59:01 CET schrieb Roger Pau Monne: > From: Roger Pau Monné > > Using a non-default SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR setting makes the > resulting u-boot-rockchip.bin unbootable, as it gets stuck after SPL. > Removing the setting from the defconfig allows U-Boot to load > successfully. Hmm, I'd disagree slightly. In the rockchip-common.h the CONFIG_SPL_PAD_TO is defined as /* ((CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR - 64) * 512) */ #define CONFIG_SPL_PAD_TO 8355840 so it's a static value but based on the MMCSD_RAW_MODE... config option. So instead of mandating one specific MMCSD_RAW_MODE... value that CONFIG_SPL_PAD_TO should be defined based on the the actual config value of CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR and not some static number that then gets enforced for all boards. Heiko > > Signed-off-by: Roger Pau Monné > --- > Cc: Heiko Stuebner > --- > configs/odroid-go2_defconfig | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/configs/odroid-go2_defconfig b/configs/odroid-go2_defconfig > index 853890901a..5632b15611 100644 > --- a/configs/odroid-go2_defconfig > +++ b/configs/odroid-go2_defconfig > @@ -33,7 +33,6 @@ CONFIG_SPL_BOOTROM_SUPPORT=y > # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set > CONFIG_SPL_STACK_R=y > # CONFIG_TPL_BANNER_PRINT is not set > -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x200 > CONFIG_SPL_CRC32_SUPPORT=y > CONFIG_SPL_I2C_SUPPORT=y > CONFIG_SPL_POWER_SUPPORT=y >
[PATCH 6/8] rockchip: rk3368: sync main rk3368 dtsi from Linux
From: Heiko Stuebner This is the state as of v5.10 + the recently added timer0 phandle targetted at the 5.12 merge window. With this the non-mainline nodes like the dmc move to a separate rk3368-u-boot.dtsi that is included from the board-specific -u-boot.dtsi files, similar to how rk3399 does this. Signed-off-by: Heiko Stuebner --- arch/arm/dts/rk3368-geekbox-u-boot.dtsi | 2 + arch/arm/dts/rk3368-lion-u-boot.dtsi| 2 + arch/arm/dts/rk3368-px5-evb-u-boot.dtsi | 3 + arch/arm/dts/rk3368-sheep-u-boot.dtsi | 2 + arch/arm/dts/rk3368-u-boot.dtsi | 27 ++ arch/arm/dts/rk3368.dtsi| 578 ++-- 6 files changed, 383 insertions(+), 231 deletions(-) create mode 100644 arch/arm/dts/rk3368-u-boot.dtsi diff --git a/arch/arm/dts/rk3368-geekbox-u-boot.dtsi b/arch/arm/dts/rk3368-geekbox-u-boot.dtsi index 30ea9e433a..0b724fa45f 100644 --- a/arch/arm/dts/rk3368-geekbox-u-boot.dtsi +++ b/arch/arm/dts/rk3368-geekbox-u-boot.dtsi @@ -3,6 +3,8 @@ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH */ +#include "rk3368-u-boot.dtsi" + { u-boot,dm-pre-reloc; }; diff --git a/arch/arm/dts/rk3368-lion-u-boot.dtsi b/arch/arm/dts/rk3368-lion-u-boot.dtsi index 6d54214de9..9bd6352755 100644 --- a/arch/arm/dts/rk3368-lion-u-boot.dtsi +++ b/arch/arm/dts/rk3368-lion-u-boot.dtsi @@ -3,6 +3,8 @@ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH */ +#include "rk3368-u-boot.dtsi" + / { config { u-boot,spl-payload-offset = <0x4>; /* @ 256KB */ diff --git a/arch/arm/dts/rk3368-px5-evb-u-boot.dtsi b/arch/arm/dts/rk3368-px5-evb-u-boot.dtsi index 936ce55727..264fb7adf0 100644 --- a/arch/arm/dts/rk3368-px5-evb-u-boot.dtsi +++ b/arch/arm/dts/rk3368-px5-evb-u-boot.dtsi @@ -2,6 +2,9 @@ /* * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH */ + +#include "rk3368-u-boot.dtsi" + / { chosen { u-boot,spl-boot-order = diff --git a/arch/arm/dts/rk3368-sheep-u-boot.dtsi b/arch/arm/dts/rk3368-sheep-u-boot.dtsi index 30ea9e433a..0b724fa45f 100644 --- a/arch/arm/dts/rk3368-sheep-u-boot.dtsi +++ b/arch/arm/dts/rk3368-sheep-u-boot.dtsi @@ -3,6 +3,8 @@ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH */ +#include "rk3368-u-boot.dtsi" + { u-boot,dm-pre-reloc; }; diff --git a/arch/arm/dts/rk3368-u-boot.dtsi b/arch/arm/dts/rk3368-u-boot.dtsi new file mode 100644 index 00..2767c2678d --- /dev/null +++ b/arch/arm/dts/rk3368-u-boot.dtsi @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + */ + +#include + +/ { + dmc: dmc@ff61 { + compatible = "rockchip,rk3368-dmc", "syscon"; + rockchip,cru = <>; + rockchip,grf = <>; + rockchip,msch = <_msch>; + reg = <0 0xff61 0 0x400 + 0 0xff62 0 0x400>; + }; + + service_msch: syscon@ffac { + compatible = "rockchip,rk3368-msch", "syscon"; + reg = <0x0 0xffac 0x0 0x2000>; + }; + + sgrf: syscon@ff74 { + compatible = "rockchip,rk3368-sgrf", "syscon"; + reg = <0x0 0xff74 0x0 0x1000>; + }; +}; diff --git a/arch/arm/dts/rk3368.dtsi b/arch/arm/dts/rk3368.dtsi index b4f4f6139d..cd2c322071 100644 --- a/arch/arm/dts/rk3368.dtsi +++ b/arch/arm/dts/rk3368.dtsi @@ -1,43 +1,6 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) /* * Copyright (c) 2015 Heiko Stuebner - * - * This file is dual-licensed: you can use it either under the terms - * of the GPL or the X11 license, at your option. Note that this dual - * licensing only applies to this file, and not this project as a - * whole. - * - * a) This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Or, alternatively, - * - * b) Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the - *
[PATCH 8/8] rockchip: lion: update board defconfig
From: Heiko Stuebner Adds the needed target option and drivers needed for correct bringup. Signed-off-by: Heiko Stuebner --- configs/lion-rk3368_defconfig | 16 ++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/configs/lion-rk3368_defconfig b/configs/lion-rk3368_defconfig index f547875dee..6d6b73d977 100644 --- a/configs/lion-rk3368_defconfig +++ b/configs/lion-rk3368_defconfig @@ -9,6 +9,7 @@ CONFIG_ROCKCHIP_SPL_RESERVE_IRAM=0x0 CONFIG_TPL_LIBCOMMON_SUPPORT=y CONFIG_TPL_LIBGENERIC_SUPPORT=y CONFIG_SPL_DRIVERS_MISC_SUPPORT=y +CONFIG_TARGET_LION_RK3368=y CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xFF18 CONFIG_DEBUG_UART_CLOCK=2400 @@ -39,6 +40,8 @@ CONFIG_TPL=y CONFIG_TPL_DRIVERS_MISC_SUPPORT=y CONFIG_CMD_GPIO=y CONFIG_CMD_MMC=y +CONFIG_CMD_SPI=y +CONFIG_CMD_USB=y CONFIG_CMD_BOOTSTAGE=y CONFIG_CMD_REGULATOR=y CONFIG_CMD_MTDPARTS=y @@ -62,14 +65,15 @@ CONFIG_CLK=y CONFIG_SPL_CLK=y CONFIG_TPL_CLK=y CONFIG_ROCKCHIP_GPIO=y +CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MMC_DW=y CONFIG_MMC_DW_ROCKCHIP=y CONFIG_MTD=y CONFIG_SPI_FLASH_MACRONIX=y CONFIG_SPI_FLASH_WINBOND=y -CONFIG_PHY_MICREL=y -CONFIG_PHY_MICREL_KSZ90X1=y +CONFIG_PHY_MSCC=y CONFIG_DM_ETH=y +CONFIG_DM_ETH_PHY=y CONFIG_ETH_DESIGNWARE=y CONFIG_RGMII=y CONFIG_GMAC_ROCKCHIP=y @@ -78,6 +82,7 @@ CONFIG_SPL_PINCTRL=y CONFIG_DM_PMIC=y CONFIG_PMIC_RK8XX=y CONFIG_DM_REGULATOR_FIXED=y +CONFIG_REGULATOR_RK8XX=y CONFIG_RAM=y CONFIG_SPL_RAM=y CONFIG_TPL_RAM=y @@ -88,6 +93,13 @@ CONFIG_ROCKCHIP_SPI=y CONFIG_SYSINFO=y CONFIG_SYSINFO_SMBIOS=y CONFIG_SYSRESET=y +CONFIG_USB=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_EHCI_GENERIC=y +CONFIG_USB_DWC2=y +CONFIG_ROCKCHIP_USB2_PHY=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_DWC2_OTG=y CONFIG_SPL_TINY_MEMSET=y CONFIG_LZO=y CONFIG_ERRNO_STR=y -- 2.29.2
[PATCH 7/8] rockchip: rk3368: sync down rk3368-lion board devicetree from Linux
From: Heiko Stuebner This brings the actual rk3368-lion devicetree files from Linux 5.10 instead of using something separate. Signed-off-by: Heiko Stuebner --- arch/arm/dts/Makefile | 2 +- ...ot.dtsi => rk3368-lion-haikou-u-boot.dtsi} | 4 + arch/arm/dts/rk3368-lion-haikou.dts | 140 + .../dts/{rk3368-lion.dts => rk3368-lion.dtsi} | 271 +- configs/lion-rk3368_defconfig | 2 + 5 files changed, 351 insertions(+), 68 deletions(-) rename arch/arm/dts/{rk3368-lion-u-boot.dtsi => rk3368-lion-haikou-u-boot.dtsi} (98%) create mode 100644 arch/arm/dts/rk3368-lion-haikou.dts rename arch/arm/dts/{rk3368-lion.dts => rk3368-lion.dtsi} (54%) diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index fd47e408f8..fa2e8b5ef7 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -115,7 +115,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3328) += \ rk3328-rock-pi-e.dtb dtb-$(CONFIG_ROCKCHIP_RK3368) += \ - rk3368-lion.dtb \ + rk3368-lion-haikou.dtb \ rk3368-sheep.dtb \ rk3368-geekbox.dtb \ rk3368-px5-evb.dtb \ diff --git a/arch/arm/dts/rk3368-lion-u-boot.dtsi b/arch/arm/dts/rk3368-lion-haikou-u-boot.dtsi similarity index 98% rename from arch/arm/dts/rk3368-lion-u-boot.dtsi rename to arch/arm/dts/rk3368-lion-haikou-u-boot.dtsi index 9bd6352755..7826d1e70b 100644 --- a/arch/arm/dts/rk3368-lion-u-boot.dtsi +++ b/arch/arm/dts/rk3368-lion-haikou-u-boot.dtsi @@ -38,6 +38,10 @@ }; }; + { + u-boot,dm-pre-reloc; +}; + { u-boot,dm-pre-reloc; }; diff --git a/arch/arm/dts/rk3368-lion-haikou.dts b/arch/arm/dts/rk3368-lion-haikou.dts new file mode 100644 index 00..7fcb1eacea --- /dev/null +++ b/arch/arm/dts/rk3368-lion-haikou.dts @@ -0,0 +1,140 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2018 Theobroma Systems Design und Consulting GmbH + */ + +/dts-v1/; +#include "rk3368-lion.dtsi" + +/ { + model = "Theobroma Systems RK3368-uQ7 Baseboard"; + compatible = "tsd,rk3368-lion-haikou", "rockchip,rk3368"; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + i2cmux2 { + i2c@0 { + eeprom: eeprom@50 { + compatible = "atmel,24c01"; + pagesize = <8>; + reg = <0x50>; + }; + }; + }; + + leds { + pinctrl-0 = <_led_pins>, <_card_led_pin>; + + sd_card_led: led-3 { + label = "sd_card_led"; + gpios = < RK_PD2 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "mmc0"; + }; + }; + + dc_12v: dc-12v { + compatible = "regulator-fixed"; + regulator-name = "dc_12v"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1200>; + regulator-max-microvolt = <1200>; + }; + + vcc3v3_baseboard: vcc3v3-baseboard { + compatible = "regulator-fixed"; + regulator-name = "vcc3v3_baseboard"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <330>; + regulator-max-microvolt = <330>; + vin-supply = <_12v>; + }; + + vcc5v0_otg: vcc5v0-otg-regulator { + compatible = "regulator-fixed"; + enable-active-high; + gpio = < RK_PD4 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <_vbus_drv>; + regulator-name = "vcc5v0_otg"; + regulator-always-on; + }; +}; + + { + bus-width = <4>; + cap-mmc-highspeed; + cap-sd-highspeed; + cd-gpios = < RK_PB3 GPIO_ACTIVE_LOW>; + disable-wp; + max-frequency = <2500>; + pinctrl-names = "default"; + pinctrl-0 = <_clk _cmd _bus4>; + rockchip,default-sample-phase = <90>; + vmmc-supply = <_baseboard>; + status = "okay"; +}; + + { + cs-gpios = <0>, < RK_PC3 GPIO_ACTIVE_LOW>; + status = "okay"; +}; + +_otg { + dr_mode = "otg"; + status = "okay"; +}; + + { + pinctrl-names = "default"; + pinctrl-0 = <_xfer _cts _rts>; + status = "okay"; +}; + + { + /* alternate function of GPIO5/6 */ + status = "disabled"; +}; + + { + pinctrl-names = &
[PATCH 2/8] rockchip: rk3368: set CONFIG_SYS_BOOTM_LEN to 64MB
From: Heiko Stuebner Mimicing for example the rk3399, set the SYS_BOOTM_LEN to 64MB so that regular kernel images can get loaded without problems. Signed-off-by: Heiko Stuebner --- include/configs/rk3368_common.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/configs/rk3368_common.h b/include/configs/rk3368_common.h index 86498b4c82..fbbb8cf267 100644 --- a/include/configs/rk3368_common.h +++ b/include/configs/rk3368_common.h @@ -31,6 +31,8 @@ #define CONFIG_SPL_BSS_MAX_SIZE 0x2 #define CONFIG_SPL_STACK0x00188000 +#define CONFIG_SYS_BOOTM_LEN (64 << 20) /* 64M */ + #ifndef CONFIG_SPL_BUILD #define ENV_MEM_LAYOUT_SETTINGS \ "scriptaddr=0x0050\0" \ -- 2.29.2
[PATCH 5/8] rockchip: rk3368: sync clock dt-binding header from Linux
From: Heiko Stuebner This is the state as of v5.10 in Linux. Signed-off-by: Heiko Stuebner --- include/dt-bindings/clock/rk3368-cru.h | 31 -- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/include/dt-bindings/clock/rk3368-cru.h b/include/dt-bindings/clock/rk3368-cru.h index 9c5dd9ba2f..0a06c5f514 100644 --- a/include/dt-bindings/clock/rk3368-cru.h +++ b/include/dt-bindings/clock/rk3368-cru.h @@ -1,15 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (c) 2015 Heiko Stuebner - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #ifndef _DT_BINDINGS_CLK_ROCKCHIP_RK3368_H @@ -44,13 +35,12 @@ #define SCLK_I2S_8CH 82 #define SCLK_SPDIF_8CH 83 #define SCLK_I2S_2CH 84 -#define SCLK_TIMER085 -#define SCLK_TIMER186 -#define SCLK_TIMER287 -#define SCLK_TIMER388 -#define SCLK_TIMER489 -#define SCLK_TIMER590 -#define SCLK_TIMER691 +#define SCLK_TIMER00 85 +#define SCLK_TIMER01 86 +#define SCLK_TIMER02 87 +#define SCLK_TIMER03 88 +#define SCLK_TIMER04 89 +#define SCLK_TIMER05 90 #define SCLK_OTGPHY0 93 #define SCLK_OTG_ADP 96 #define SCLK_HSICPHY480M 97 @@ -82,6 +72,12 @@ #define SCLK_SFC 126 #define SCLK_MAC 127 #define SCLK_MACREF_OUT128 +#define SCLK_TIMER10 133 +#define SCLK_TIMER11 134 +#define SCLK_TIMER12 135 +#define SCLK_TIMER13 136 +#define SCLK_TIMER14 137 +#define SCLK_TIMER15 138 #define DCLK_VOP 190 #define MCLK_CRYPTO191 @@ -151,6 +147,7 @@ #define PCLK_ISP 366 #define PCLK_VIP 367 #define PCLK_WDT 368 +#define PCLK_EFUSE256 369 /* hclk gates */ #define HCLK_SFC 448 -- 2.29.2
[PATCH 1/8] rockchip: rk3368: adjust CONFIG_SYS_LOAD_ADDR
From: Heiko Stuebner CONFIG_SYS_LOAD_ADDR currently is at 0x0028 which is only 512KB behind the area where we load u-boot to, which depending on u-boot size may overlap at some point. So for safety just pick the same value rk3399 has and set CONFIG_SYS_LOAD_ADDR to 0x00800800 on rk3368 as well. Signed-off-by: Heiko Stuebner --- include/configs/rk3368_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/configs/rk3368_common.h b/include/configs/rk3368_common.h index f178a06945..86498b4c82 100644 --- a/include/configs/rk3368_common.h +++ b/include/configs/rk3368_common.h @@ -24,7 +24,7 @@ #define CONFIG_IRAM_BASE 0xff8c #define CONFIG_SYS_INIT_SP_ADDR0x0030 -#define CONFIG_SYS_LOAD_ADDR 0x0028 +#define CONFIG_SYS_LOAD_ADDR 0x00800800 #define CONFIG_SPL_MAX_SIZE 0x4 #define CONFIG_SPL_BSS_START_ADDR 0x40 -- 2.29.2
[PATCH 0/8] rockchip: resurrect rk3368 functionality and make lion bootable again
From: Heiko Stuebner With current u-boot (and probably for some time now) rk3368-lion can't boot anymore. As the patches indicate, that is partially on the lion support but also on general rk3368-support not fitting current expectations anymore. So this series, adapts options to what other Rockchip SoCs do and makes lion also bootable again. Heiko Stuebner (8): rockchip: rk3368: adjust CONFIG_SYS_LOAD_ADDR rockchip: rk3368: set CONFIG_SYS_BOOTM_LEN to 64MB rockchip: rk3368: increase SYS_MALLOC_F_LEN to 0x4000 rockchip: rk3368: move STACK_R_ADDR address and into Kconfig rockchip: rk3368: sync clock dt-binding header from Linux rockchip: rk3368: sync main rk3368 dtsi from Linux rockchip: rk3368: sync down rk3368-lion board devicetree from Linux rockchip: lion: update board defconfig arch/arm/dts/Makefile | 2 +- arch/arm/dts/rk3368-geekbox-u-boot.dtsi | 2 + ...ot.dtsi => rk3368-lion-haikou-u-boot.dtsi} | 6 + arch/arm/dts/rk3368-lion-haikou.dts | 140 + .../dts/{rk3368-lion.dts => rk3368-lion.dtsi} | 271 ++-- arch/arm/dts/rk3368-px5-evb-u-boot.dtsi | 3 + arch/arm/dts/rk3368-sheep-u-boot.dtsi | 2 + arch/arm/dts/rk3368-u-boot.dtsi | 27 + arch/arm/dts/rk3368.dtsi | 578 +++--- arch/arm/mach-rockchip/rk3368/Kconfig | 5 +- configs/lion-rk3368_defconfig | 19 +- include/configs/rk3368_common.h | 4 +- include/dt-bindings/clock/rk3368-cru.h| 31 +- 13 files changed, 769 insertions(+), 321 deletions(-) rename arch/arm/dts/{rk3368-lion-u-boot.dtsi => rk3368-lion-haikou-u-boot.dtsi} (96%) create mode 100644 arch/arm/dts/rk3368-lion-haikou.dts rename arch/arm/dts/{rk3368-lion.dts => rk3368-lion.dtsi} (54%) create mode 100644 arch/arm/dts/rk3368-u-boot.dtsi -- 2.29.2
[PATCH 3/8] rockchip: rk3368: increase SYS_MALLOC_F_LEN to 0x4000
From: Heiko Stuebner To prevent running out of memory, increase SYS_MALLOC_F_LEN to 0x4000 similar to what rk3399 uses. Signed-off-by: Heiko Stuebner --- arch/arm/mach-rockchip/rk3368/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-rockchip/rk3368/Kconfig b/arch/arm/mach-rockchip/rk3368/Kconfig index d6ca5f1d24..c31915e7dc 100644 --- a/arch/arm/mach-rockchip/rk3368/Kconfig +++ b/arch/arm/mach-rockchip/rk3368/Kconfig @@ -49,7 +49,7 @@ config SYS_SOC default "rk3368" config SYS_MALLOC_F_LEN - default 0x2000 + default 0x4000 config SPL_LIBCOMMON_SUPPORT default y -- 2.29.2
[PATCH 4/8] rockchip: rk3368: move STACK_R_ADDR address and into Kconfig
From: Heiko Stuebner With the STACK_R_ADDR at 0x60 (6MB) we're competing with with the loading address of either u-boot or atf parts, so move that away to 0x400 (64MB) similar to rk3399. Only lion currently sets that at all but not sheep the second rk3368 board, so just move that to the Kconfig for rk3368 similar to rk3399 as well. Signed-off-by: Heiko Stuebner --- arch/arm/mach-rockchip/rk3368/Kconfig | 3 +++ configs/lion-rk3368_defconfig | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-rockchip/rk3368/Kconfig b/arch/arm/mach-rockchip/rk3368/Kconfig index c31915e7dc..78eb96df3d 100644 --- a/arch/arm/mach-rockchip/rk3368/Kconfig +++ b/arch/arm/mach-rockchip/rk3368/Kconfig @@ -65,6 +65,9 @@ source "board/rockchip/evb_px5/Kconfig" config SPL_LDSCRIPT default "arch/arm/cpu/armv8/u-boot-spl.lds" +config SPL_STACK_R_ADDR + default 0x0400 + config TPL_MAX_SIZE default 28672 diff --git a/configs/lion-rk3368_defconfig b/configs/lion-rk3368_defconfig index 583dd44da3..b409715060 100644 --- a/configs/lion-rk3368_defconfig +++ b/configs/lion-rk3368_defconfig @@ -9,7 +9,6 @@ CONFIG_ROCKCHIP_SPL_RESERVE_IRAM=0x0 CONFIG_TPL_LIBCOMMON_SUPPORT=y CONFIG_TPL_LIBGENERIC_SUPPORT=y CONFIG_SPL_DRIVERS_MISC_SUPPORT=y -CONFIG_SPL_STACK_R_ADDR=0x60 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xFF18 CONFIG_DEBUG_UART_CLOCK=2400 -- 2.29.2
[PATCH] ram: rockchip: px30: add a config-based ddr selection
From: Heiko Stuebner The SRAM on the PX30 is not big enough to hold multiple DDR configs so it needs to be selected during build. So far simply the DDR3 config was always selected and getting DDR4 or LPDDR2/3 initialized would require a code modification. So add Kconfig options similar to RK3399 to allow selecting the DDR4 and LPDDR2/3 options instead, while DDR3 stays the default as before. Signed-off-by: Heiko Stuebner --- drivers/ram/rockchip/Kconfig | 21 + drivers/ram/rockchip/sdram_px30.c | 8 2 files changed, 29 insertions(+) diff --git a/drivers/ram/rockchip/Kconfig b/drivers/ram/rockchip/Kconfig index 8e97c2f49e..c459bbf5e2 100644 --- a/drivers/ram/rockchip/Kconfig +++ b/drivers/ram/rockchip/Kconfig @@ -22,6 +22,27 @@ config RAM_ROCKCHIP_DEBUG This is an option for developers to understand the ram drivers initialization, configurations and etc. +config RAM_PX30_DDR4 + bool "DDR3 support for Rockchip PX30" + depends on RAM_ROCKCHIP && ROCKCHIP_PX30 + help + This enables DDR4 sdram support instead of the default DDR3 support + on Rockchip PC30 SoCs. + +config RAM_PX30_LPDDR2 + bool "LPDDR2 support for Rockchip PX30" + depends on RAM_ROCKCHIP && ROCKCHIP_PX30 + help + This enables LPDDR2 sdram support instead of the default DDR3 support + on Rockchip PC30 SoCs. + +config RAM_PX30_LPDDR3 + bool "LPDDR3 support for Rockchip PX30" + depends on RAM_ROCKCHIP && ROCKCHIP_PX30 + help + This enables LPDDR3 sdram support instead of the default DDR3 support + on Rockchip PC30 SoCs. + config RAM_RK3399_LPDDR4 bool "LPDDR4 support for Rockchip RK3399" depends on RAM_ROCKCHIP && ROCKCHIP_RK3399 diff --git a/drivers/ram/rockchip/sdram_px30.c b/drivers/ram/rockchip/sdram_px30.c index fd5763d0a0..2f1f6e9c0c 100644 --- a/drivers/ram/rockchip/sdram_px30.c +++ b/drivers/ram/rockchip/sdram_px30.c @@ -125,7 +125,15 @@ u32 addrmap[][8] = { struct dram_info dram_info; struct px30_sdram_params sdram_configs[] = { +#if defined(CONFIG_RAM_PX30_DDR4) +#include "sdram-px30-ddr4-detect-333.inc" +#elif defined(CONFIG_RAM_PX30_LPDDR2) +#include "sdram-px30-lpddr2-detect-333.inc" +#elif defined(CONFIG_RAM_PX30_LPDDR3) +#include "sdram-px30-lpddr3-detect-333.inc" +#else #include "sdram-px30-ddr3-detect-333.inc" +#endif }; struct ddr_phy_skew skew = { -- 2.28.0
[PATCH 1/3] rockchip: px30: sync the main rk3326 dtsi from mainline
From: Heiko Stuebner The rk3326 is just a trimmed down px30 from a software perspective, so the mainline rk3326 dtsi also ist just a tiny addition. Signed-off-by: Heiko Stuebner --- arch/arm/dts/rk3326.dtsi | 15 +++ 1 file changed, 15 insertions(+) create mode 100644 arch/arm/dts/rk3326.dtsi diff --git a/arch/arm/dts/rk3326.dtsi b/arch/arm/dts/rk3326.dtsi new file mode 100644 index 00..2ba6da1251 --- /dev/null +++ b/arch/arm/dts/rk3326.dtsi @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2020 Fuzhou Rockchip Electronics Co., Ltd + */ + +#include "px30.dtsi" + +_subsystem { + ports = <_out>; +}; + +/delete-node/ _in_vopl; +/delete-node/ _vopl_in; +/delete-node/ +/delete-node/ _mmu; -- 2.26.2
[PATCH 3/3] rockchip: board: add Hardkernel Odroid Go2 board
From: Heiko Stuebner Also known as Odroid Go Advance but named Go2 internally by the vendor it seems. Signed-off-by: Heiko Stuebner --- arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi | 72 + arch/arm/mach-rockchip/px30/Kconfig| 4 + board/hardkernel/odroid_go2/Kconfig| 15 +++ board/hardkernel/odroid_go2/MAINTAINERS| 6 ++ board/hardkernel/odroid_go2/Makefile | 7 ++ board/hardkernel/odroid_go2/go2.c | 4 + configs/odroid-go2_defconfig | 119 + include/configs/odroid_go2.h | 17 +++ 8 files changed, 244 insertions(+) create mode 100644 arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi create mode 100644 board/hardkernel/odroid_go2/Kconfig create mode 100644 board/hardkernel/odroid_go2/MAINTAINERS create mode 100644 board/hardkernel/odroid_go2/Makefile create mode 100644 board/hardkernel/odroid_go2/go2.c create mode 100644 configs/odroid-go2_defconfig create mode 100644 include/configs/odroid_go2.h diff --git a/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi b/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi new file mode 100644 index 00..34c9e62025 --- /dev/null +++ b/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + */ + +/ { + chosen { + u-boot,spl-boot-order = + }; +}; + + { + u-boot,dm-pre-reloc; +}; + + { + u-boot,dm-pre-reloc; +}; + + { + u-boot,dm-pre-reloc; +}; + + { + u-boot,dm-pre-reloc; +}; + + { + u-boot,dm-pre-reloc; +}; + + { + u-boot,dm-pre-reloc; +}; + + { + u-boot,dm-pre-reloc; +}; + + { + u-boot,dm-pre-reloc; +}; + + { + u-boot,dm-pre-reloc; +}; + + { + u-boot,dm-pre-reloc; + status = "okay"; +}; + + { + u-boot,dm-pre-reloc; + + /* mmc to sram can't do dma, prevent aborts transfering TF-A parts */ + u-boot,spl-fifo-mode; +}; + + { + clock-frequency = <2400>; + u-boot,dm-pre-reloc; +}; + + { + clock-frequency = <2400>; + u-boot,dm-pre-reloc; +}; + + { + u-boot,dm-pre-reloc; +}; diff --git a/arch/arm/mach-rockchip/px30/Kconfig b/arch/arm/mach-rockchip/px30/Kconfig index 9f3ad4f623..f5373c6f9f 100644 --- a/arch/arm/mach-rockchip/px30/Kconfig +++ b/arch/arm/mach-rockchip/px30/Kconfig @@ -3,6 +3,9 @@ if ROCKCHIP_PX30 config TARGET_EVB_PX30 bool "EVB_PX30" +config TARGET_ODROID_GO2 + bool "ODROID_GO2" + config ROCKCHIP_BOOT_MODE_REG default 0xff010200 @@ -36,6 +39,7 @@ config DEBUG_UART_CHANNEL For using the UART for early debugging the route to use needs to be declared (0 or 1). +source "board/hardkernel/odroid_go2/Kconfig" source "board/rockchip/evb_px30/Kconfig" endif diff --git a/board/hardkernel/odroid_go2/Kconfig b/board/hardkernel/odroid_go2/Kconfig new file mode 100644 index 00..cf3f7c91d9 --- /dev/null +++ b/board/hardkernel/odroid_go2/Kconfig @@ -0,0 +1,15 @@ +if TARGET_ODROID_GO2 + +config SYS_BOARD + default "odroid_go2" + +config SYS_VENDOR + default "hardkernel" + +config SYS_CONFIG_NAME + default "odroid_go2" + +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + +endif diff --git a/board/hardkernel/odroid_go2/MAINTAINERS b/board/hardkernel/odroid_go2/MAINTAINERS new file mode 100644 index 00..eab622a70b --- /dev/null +++ b/board/hardkernel/odroid_go2/MAINTAINERS @@ -0,0 +1,6 @@ +GO2 +M: Heiko Stuebner +S: Maintained +F: board/odroid/go2 +F: include/configs/odroid_go2.h +F: configs/odroid-go2_defconfig diff --git a/board/hardkernel/odroid_go2/Makefile b/board/hardkernel/odroid_go2/Makefile new file mode 100644 index 00..51b9d24cfb --- /dev/null +++ b/board/hardkernel/odroid_go2/Makefile @@ -0,0 +1,7 @@ +# +# Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += go2.o diff --git a/board/hardkernel/odroid_go2/go2.c b/board/hardkernel/odroid_go2/go2.c new file mode 100644 index 00..29464ae63e --- /dev/null +++ b/board/hardkernel/odroid_go2/go2.c @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2019 Rockchip Electronics Co., Ltd + */ diff --git a/configs/odroid-go2_defconfig b/configs/odroid-go2_defconfig new file mode 100644 index 00..6eb85a97f7 --- /dev/null +++ b/configs/odroid-go2_defconfig @@ -0,0 +1,119 @@ +CONFIG_ARM=y +CONFIG_ARCH_ROCKCHIP=y +CONFIG_SYS_TEXT_BASE=0x0020 +CONFIG_SPL_LIBCOMMON_SUPPORT=y +CONFIG_SPL_LIBGENERIC_SUPPORT=y +CONFIG_SYS_MALLOC_F_LEN=0x2000 +CONFIG_ENV_SIZE=0x4000 +CONFIG_ENV_OFFSET=0x4000 +CONFIG_ROCKCHIP_PX30=y +CONFIG_TARGET_ODROID_GO2=y +CONFIG_TPL_LIBGENERIC_SUPPORT=y +CONFIG_SPL_DRIVERS_MISC_SUPPORT=y +CONFIG_SPL_STACK_R_ADDR=
[PATCH 2/3] rockchip: px30: sync Odroid Go Advance devicetree from Linux
From: Heiko Stuebner Get the devicetree from mainline Linux and include it for U-Boot uses. Signed-off-by: Heiko Stuebner --- arch/arm/dts/Makefile | 3 +- arch/arm/dts/rk3326-odroid-go2.dts | 716 + 2 files changed, 718 insertions(+), 1 deletion(-) create mode 100644 arch/arm/dts/rk3326-odroid-go2.dts diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index db7859cd6c..f274c1232a 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -71,7 +71,8 @@ dtb-$(CONFIG_MACH_S700) += \ dtb-$(CONFIG_ROCKCHIP_PX30) += \ px30-evb.dtb \ - px30-firefly.dtb + px30-firefly.dtb \ + rk3326-odroid-go2.dtb dtb-$(CONFIG_ROCKCHIP_RK3036) += \ rk3036-sdk.dtb diff --git a/arch/arm/dts/rk3326-odroid-go2.dts b/arch/arm/dts/rk3326-odroid-go2.dts new file mode 100644 index 00..8cd4688c49 --- /dev/null +++ b/arch/arm/dts/rk3326-odroid-go2.dts @@ -0,0 +1,716 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 Hardkernel Co., Ltd + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + */ + +/dts-v1/; +#include +#include +#include +#include "rk3326.dtsi" + +/ { + model = "ODROID-GO Advance"; + compatible = "hardkernel,rk3326-odroid-go2", "rockchip,rk3326"; + + chosen { + stdout-path = "serial2:115200n8"; + }; + + backlight: backlight { + compatible = "pwm-backlight"; + power-supply = <_bl>; + pwms = < 0 25000 0>; + }; + + adc-joystick { + compatible = "adc-joystick"; + io-channels = < 1>, + < 2>; + #address-cells = <1>; + #size-cells = <0>; + + axis@0 { + reg = <0>; + abs-range = <172 772>; + abs-fuzz = <10>; + abs-flat = <10>; + linux,code = ; + }; + + axis@1 { + reg = <1>; + abs-range = <278 815>; + abs-fuzz = <10>; + abs-flat = <10>; + linux,code = ; + }; + }; + + gpio-keys { + compatible = "gpio-keys"; + pinctrl-names = "default"; + pinctrl-0 = <_pins>; + + /* +* *** ODROIDGO2-Advance Switch layout *** +* || +* | sw15 sw16 | +* || +* | sw1 |---| sw8| +* | sw3 sw4 | | sw7 sw5 | +* | sw2 |LCD Display| sw6| +* | | | | +* | |---| | +* | sw9 sw10 sw11 sw12 sw13 sw14 | +* || +*/ + + sw1 { + gpios = < RK_PB4 GPIO_ACTIVE_LOW>; + label = "DPAD-UP"; + linux,code = ; + }; + sw2 { + gpios = < RK_PB5 GPIO_ACTIVE_LOW>; + label = "DPAD-DOWN"; + linux,code = ; + }; + sw3 { + gpios = < RK_PB6 GPIO_ACTIVE_LOW>; + label = "DPAD-LEFT"; + linux,code = ; + }; + sw4 { + gpios = < RK_PB7 GPIO_ACTIVE_LOW>; + label = "DPAD-RIGHT"; + linux,code = ; + }; + sw5 { + gpios = < RK_PA2 GPIO_ACTIVE_LOW>; + label = "BTN-A"; + linux,code = ; + }; + sw6 { + gpios = < RK_PA5 GPIO_ACTIVE_LOW>; + label = "BTN-B"; + linux,code = ; + }; + sw7 { + gpios = < RK_PA6 GPIO_ACTIVE_LOW>; + label = "BTN-Y"; + linux,code = ; + }; + sw8 { + gpios = < RK_PA7 GPIO_ACTIVE_LOW>; + label = "BTN-X"; + linux,code = ; +
[PATCH v2] cmd: add a panic command
From: Heiko Stuebner Even in boot scripts it may be needed to "panic" when all options are exhausted and the device specification specifies hanging instead of resetting the board. So add a new panic command that just wraps around the core panic call in U-Boot and can take an optional message. Signed-off-by: Heiko Stuebner Reviewed-by: Simon Glass --- changes in v2: - add blank line before return (Simon) - fix U-Boot spelling (Simon) cmd/Makefile | 1 + cmd/panic.c | 23 +++ 2 files changed, 24 insertions(+) create mode 100644 cmd/panic.c diff --git a/cmd/Makefile b/cmd/Makefile index ac843b4b16..027fa9083a 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -8,6 +8,7 @@ ifndef CONFIG_SPL_BUILD obj-y += boot.o obj-$(CONFIG_CMD_BOOTM) += bootm.o obj-y += help.o +obj-y += panic.o obj-y += version.o # command diff --git a/cmd/panic.c b/cmd/panic.c new file mode 100644 index 00..329231fb66 --- /dev/null +++ b/cmd/panic.c @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + */ + +#include +#include + +static int do_panic(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + char *text = (argc < 2) ? "" : argv[1]; + + panic(text); + + return CMD_RET_SUCCESS; +} + +U_BOOT_CMD( + panic, 2, 1, do_panic, + "Panic with optional message", + "[message]" +); -- 2.26.2
[PATCH] cmd: add a panic command
From: Heiko Stuebner Even in boot scripts it may be needed to "panic" when all options are exhausted and the device specification specifies hanging instead of resetting the board. So add a new panic command that just wraps around the core panic call in uboot and can take an optional message. Signed-off-by: Heiko Stuebner --- cmd/Makefile | 1 + cmd/panic.c | 22 ++ 2 files changed, 23 insertions(+) create mode 100644 cmd/panic.c diff --git a/cmd/Makefile b/cmd/Makefile index ac843b4b16..027fa9083a 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -8,6 +8,7 @@ ifndef CONFIG_SPL_BUILD obj-y += boot.o obj-$(CONFIG_CMD_BOOTM) += bootm.o obj-y += help.o +obj-y += panic.o obj-y += version.o # command diff --git a/cmd/panic.c b/cmd/panic.c new file mode 100644 index 00..696b4c73a3 --- /dev/null +++ b/cmd/panic.c @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + */ + +#include +#include + +static int do_panic(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + char *text = (argc < 2) ? "" : argv[1]; + + panic(text); + return CMD_RET_SUCCESS; +} + +U_BOOT_CMD( + panic, 2, 1, do_panic, + "Panic with optional message", + "[message]" +); -- 2.26.2
Re: [PATCH v3 0/5] rockchip: make it possible to sign the u-boot.itb
Hi Kever, Am Sonntag, 31. Mai 2020, 10:28:45 CEST schrieb Kever Yang: > This patch set make rk3288 series board build fail. Could you help > to check again? the additional patch in v4 adding the ifdef CONFIG_SPL_FIT clamp, should hopefully fix this Heiko > On 2020/5/26 下午6:44, Heiko Stuebner wrote: > > From: Heiko Stuebner > > > > This series makes it possible to sign a generated u-boot.itb automatically > > even if the its-source got created by a generator script. > > > > To let the SPL know about the key, the -K option for mkimage points > > to the dts/dt-spl.dtb which can then get included into the spl binary. > > > > Tested on Rockchip PX30 with a TPL -> SPL -> U-Boot.itb bootchain. > > > > I've split out the the rsa/crypto fixes into a separate series > > starting at [0]. > > > > [0] > > https://patchwork.ozlabs.org/project/uboot/patch/20200522141937.3523692-1-he...@sntech.de/ > > > > > > changes in v3: > > - add patch to fix imx make_fit_atf.sh error handling > > - split out rsa fixes into separate series > > changes in v2.1: > > - depend on $(CONFIG_SPL_FIT_SIGNATURE)$(U_BOOT_ITS) > >instead of only $(CONFIG_SPL_FIT_GENERATOR) > > changes in v2: > > - add received reviews > > - fix commit message typo > > - add doc snippet explaining CONFIG_SPL_FIT_GENERATOR_KEY_HINT > > > > Heiko Stuebner (5): > >imx: mkimage_fit_atf: Fix FIT image if BL31.bin missing > >mkimage: fit_image: handle multiple errors when writing signatures > >spl: fit: enable signing a generated u-boot.itb > >spl: fit: add Kconfig option to specify key-hint for fit_generator > >rockchip: make_fit_atf: add signature handling > > > > Kconfig| 16 > > Makefile | 11 +- > > arch/arm/mach-imx/mkimage_fit_atf.sh | 4 +- > > arch/arm/mach-rockchip/make_fit_atf.py | 51 +- > > doc/uImage.FIT/howto.txt | 13 +++ > > tools/image-host.c | 2 +- > > 6 files changed, 92 insertions(+), 5 deletions(-) > > > > >
Re: [PATCH v3 2/5] mkimage: fit_image: handle multiple errors when writing signatures
Am Sonntag, 31. Mai 2020, 16:07:56 CEST schrieb Simon Glass: > Hi Heiko, > > On Tue, 26 May 2020 at 04:44, Heiko Stuebner wrote: > > > > From: Heiko Stuebner > > > > fit_image_write_sig() contains mostly functions from libfdt that > > return FDT_ERR_foo errors but also a call to fit_set_timestamp() > > which returns a regular error. > > > > When handling the size increase via multiple iterations, check > > for both -FDT_ERR_NOSPACE but also for -ENOSPC. > > > > There is no real conflict, as FDT_ERR_NOSPACE = 3 = ESRCH > > (No such process) and ENOSPC = 28 which is above any FDT_ERR_*. > > > > Signed-off-by: Heiko Stuebner > > Reviewed-by: Simon Glass > > Reviewed-by: Kever Yang > > --- > > tools/image-host.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > Changing my mind on this - I wonder if we can change > fit_image_write_sig() to always return an errno code, never an FDT > code? Could be a follow-on patch. I'll take that suggestion and do a followup with this suggestion, simply because this may open up additional discussion. Heiko > > diff --git a/tools/image-host.c b/tools/image-host.c > > index 9a83b7f675..baf9590f3b 100644 > > --- a/tools/image-host.c > > +++ b/tools/image-host.c > > @@ -241,7 +241,7 @@ static int fit_image_process_sig(const char *keydir, > > void *keydest, > > ret = fit_image_write_sig(fit, noffset, value, value_len, comment, > > NULL, 0, cmdname); > > if (ret) { > > - if (ret == -FDT_ERR_NOSPACE) > > + if (ret == -FDT_ERR_NOSPACE || ret == -ENOSPC) > > return -ENOSPC; > > printf("Can't write signature for '%s' signature node in > > '%s' conf node: %s\n", > >node_name, image_name, fdt_strerror(ret)); > > -- > > 2.25.1 > > > > Regards, > Simon >
[PATCH v4 0/6] rockchip: make it possible to sign the u-boot.itb
From: Heiko Stuebner This series makes it possible to sign a generated u-boot.itb automatically even if the its-source got created by a generator script. To let the SPL know about the key, the -K option for mkimage points to the dts/dt-spl.dtb which can then get included into the spl binary. Tested on Rockchip PX30 with a TPL -> SPL -> U-Boot.itb bootchain. I've split out the the rsa/crypto fixes into a separate series starting at [0]. Simon asked for fit_image_write_sig() to always return an errno code, never an FDT code and suggested that this could be a follow-on patch. So I've kept code that way and will provide a follow up series to convert the return code handling. [0] https://patchwork.ozlabs.org/project/uboot/patch/20200522141937.3523692-1-he...@sntech.de/ changes in v4: - add patch to fix the always defined U_BOOT_ITS in Makefile - adapt Rockchip make_fit_atf to both python2+3 caused by the different crypto-implementations changes in v3: - add patch to fix imx make_fit_atf.sh error handling - split out rsa fixes into separate series changes in v2.1: - depend on $(CONFIG_SPL_FIT_SIGNATURE)$(U_BOOT_ITS) instead of only $(CONFIG_SPL_FIT_GENERATOR) changes in v2: - add received reviews - fix commit message typo - add doc snippet explaining CONFIG_SPL_FIT_GENERATOR_KEY_HINT Heiko Stuebner (6): imx: mkimage_fit_atf: Fix FIT image if BL31.bin missing mkimage: fit_image: handle multiple errors when writing signatures spl: fit: dont set U_BOOT_ITS var if not build SPL_FIT support spl: fit: enable signing a generated u-boot.itb spl: fit: add Kconfig option to specify key-hint for fit_generator rockchip: make_fit_atf: add signature handling Kconfig| 16 Makefile | 13 +- arch/arm/mach-imx/mkimage_fit_atf.sh | 4 +- arch/arm/mach-rockchip/make_fit_atf.py | 57 +- doc/uImage.FIT/howto.txt | 13 ++ tools/image-host.c | 2 +- 6 files changed, 100 insertions(+), 5 deletions(-) -- 2.26.2
[PATCH v4 1/6] imx: mkimage_fit_atf: Fix FIT image if BL31.bin missing
From: Heiko Stuebner Right now if its bl31.bin is missing, the imx make_fit_atf.sh does return "sucessful" without generating an .its source file, which makes autobuilders unhappy. So this change is similar to Tom Rini's commit 4c78028737c3 ("mksunxi_fit_atf.sh: Allow for this to complete when bl31.bin is missing") in that it changes the behaviour to a warning and still lets the script generate a usable u-boot.its and thus also lets the u-boot.itb get build successfully Signed-off-by: Heiko Stuebner Reviewed-by: Peng Fan --- arch/arm/mach-imx/mkimage_fit_atf.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/mkimage_fit_atf.sh b/arch/arm/mach-imx/mkimage_fit_atf.sh index fe12b7bb4b..2f77c6d70d 100755 --- a/arch/arm/mach-imx/mkimage_fit_atf.sh +++ b/arch/arm/mach-imx/mkimage_fit_atf.sh @@ -12,8 +12,8 @@ [ -z "$BL33_LOAD_ADDR" ] && BL33_LOAD_ADDR="0x4020" if [ ! -f $BL31 ]; then - echo "ERROR: BL31 file $BL31 NOT found" >&2 - exit 0 + echo "WARNING: BL31 file $BL31 NOT found, resulting binary is not-functional" >&2 + BL31=/dev/null else echo "$BL31 size: " >&2 ls -lct $BL31 | awk '{print $5}' >&2 -- 2.26.2
[PATCH v4 6/6] rockchip: make_fit_atf: add signature handling
From: Heiko Stuebner If the newly added fit-generator key-options are found, append needed signature nodes to all generated image blocks, so that they can get signed when mkimage later compiles the .itb from the generated .its. Signed-off-by: Heiko Stuebner --- arch/arm/mach-rockchip/make_fit_atf.py | 57 +- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-rockchip/make_fit_atf.py b/arch/arm/mach-rockchip/make_fit_atf.py index d15c32b303..de7dc19d11 100755 --- a/arch/arm/mach-rockchip/make_fit_atf.py +++ b/arch/arm/mach-rockchip/make_fit_atf.py @@ -14,6 +14,14 @@ import sys import getopt import logging import struct +try: + # in python3 Cryptodome succeeds Crypto + import Cryptodome + from Cryptodome.PublicKey import RSA +except: + import Crypto + from Crypto.PublicKey import RSA + DT_HEADER = """ /* @@ -37,7 +45,9 @@ DT_UBOOT = """ arch = "arm64"; compression = "none"; load = <0x%08x>; - }; +""" + +DT_UBOOT_NODE_END = """}; """ @@ -47,6 +57,46 @@ DT_IMAGES_NODE_END = """ }; DT_END = "};" +def append_signature(file): +if not os.path.exists("u-boot.cfg"): +return + +config = {} +with open("u-boot.cfg") as fd: +for line in fd: +line = line.strip() +values = line[8:].split(' ', 1) +if len(values) > 1: +key, value = values +value = value.strip('"') +else: +key = values[0] +value = '1' +if not key.startswith('CONFIG_'): +continue +config[key] = value + +try: +keyhint = config["CONFIG_SPL_FIT_GENERATOR_KEY_HINT"] +except KeyError: +return + +try: +keyfile = os.path.join(config["CONFIG_SPL_FIT_SIGNATURE_KEY_DIR"], keyhint) +except KeyError: +keyfile = keyhint + +if not os.path.exists('%s.key' % keyfile): +return + +f = open('%s.key' % keyfile,'r') +key = RSA.importKey(f.read()) + +file.write('\t\t\tsignature {\n') +file.write('\t\t\t\talgo = "sha256,rsa%s";\n' % key.n.bit_length()) +file.write('\t\t\t\tkey-name-hint = "%s";\n' % keyhint) +file.write('\t\t\t};\n') + def append_bl31_node(file, atf_index, phy_addr, elf_entry): # Append BL31 DT node to input FIT dts file. data = 'bl31_0x%08x.bin' % phy_addr @@ -60,6 +110,7 @@ def append_bl31_node(file, atf_index, phy_addr, elf_entry): file.write('\t\t\tload = <0x%08x>;\n' % phy_addr) if atf_index == 1: file.write('\t\t\tentry = <0x%08x>;\n' % elf_entry) +append_signature(file); file.write('\t\t};\n') file.write('\n') @@ -75,6 +126,7 @@ def append_tee_node(file, atf_index, phy_addr, elf_entry): file.write('\t\t\tcompression = "none";\n') file.write('\t\t\tload = <0x%08x>;\n' % phy_addr) file.write('\t\t\tentry = <0x%08x>;\n' % elf_entry) +append_signature(file); file.write('\t\t};\n') file.write('\n') @@ -88,6 +140,7 @@ def append_fdt_node(file, dtbs): file.write('\t\t\tdata = /incbin/("%s");\n' % dtb) file.write('\t\t\ttype = "flat_dt";\n') file.write('\t\t\tcompression = "none";\n') +append_signature(file); file.write('\t\t};\n') file.write('\n') cnt = cnt + 1 @@ -129,6 +182,8 @@ def generate_atf_fit_dts_uboot(fit_file, uboot_file_name): raise ValueError("Invalid u-boot ELF image '%s'" % uboot_file_name) index, entry, p_paddr, data = segments[0] fit_file.write(DT_UBOOT % p_paddr) +append_signature(fit_file) +fit_file.write(DT_UBOOT_NODE_END) def generate_atf_fit_dts_bl31(fit_file, bl31_file_name, tee_file_name, dtbs_file_name): segments = unpack_elf(bl31_file_name) -- 2.26.2
[PATCH v4 5/6] spl: fit: add Kconfig option to specify key-hint for fit_generator
From: Heiko Stuebner The u-boot.itb can be generated either from a static .its that can simply include the needed signature nodes with key-hints or from a fit-generator script referenced in CONFIG_SPL_FIT_GENERATOR. In the script-case it will need to know what key to include for the key-hint and specified algorithm, so add an option for that key-name. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- Kconfig | 8 doc/uImage.FIT/howto.txt | 13 + 2 files changed, 21 insertions(+) diff --git a/Kconfig b/Kconfig index 05a13d1836..de144ae430 100644 --- a/Kconfig +++ b/Kconfig @@ -548,6 +548,14 @@ config SPL_FIT_GENERATOR passed a list of supported device tree file stub names to include in the generated image. +config SPL_FIT_GENERATOR_KEY_HINT + string "key hint for signing U-Boot FIT image" + depends on SPL_FIT_SIGNATURE + default "dev" + help + The key hint to store in both the generated .its file as well as + u-boot-key.dtb generated separately and embedded into the SPL. + endif # SPL endif # FIT diff --git a/doc/uImage.FIT/howto.txt b/doc/uImage.FIT/howto.txt index 8592719685..f409b3770e 100644 --- a/doc/uImage.FIT/howto.txt +++ b/doc/uImage.FIT/howto.txt @@ -66,6 +66,19 @@ can point to a script which generates this image source file during the build process. It gets passed a list of device tree files (taken from the CONFIG_OF_LIST symbol). +Signing u-boot.itb with SPL_FIT_GENERATOR +- + +u-boot.itb can be signed to verify the integrity of its components. +When CONFIG_SPL_FIT_SIGNATURE is enabled the CONFIG_SPL_FIT_SIGNATURE_KEY_DIR +option can be used to specifiy the key directory - either a relative or +absolute path. + +See signature.txt for general signature handling, but when +CONFIG_SPL_FIT_GENERATOR is used the option CONFIG_SPL_FIT_GENERATOR_KEY_HINT +can be used to specify the key-hint that should be included into the +created u-boot.its by the generator. + Example 1 -- old-style (non-FDT) kernel booting --- -- 2.26.2
[PATCH v4 2/6] mkimage: fit_image: handle multiple errors when writing signatures
From: Heiko Stuebner fit_image_write_sig() contains mostly functions from libfdt that return FDT_ERR_foo errors but also a call to fit_set_timestamp() which returns a regular error. When handling the size increase via multiple iterations, check for both -FDT_ERR_NOSPACE but also for -ENOSPC. There is no real conflict, as FDT_ERR_NOSPACE = 3 = ESRCH (No such process) and ENOSPC = 28 which is above any FDT_ERR_*. Signed-off-by: Heiko Stuebner Reviewed-by: Simon Glass --- tools/image-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/image-host.c b/tools/image-host.c index 9a83b7f675..baf9590f3b 100644 --- a/tools/image-host.c +++ b/tools/image-host.c @@ -241,7 +241,7 @@ static int fit_image_process_sig(const char *keydir, void *keydest, ret = fit_image_write_sig(fit, noffset, value, value_len, comment, NULL, 0, cmdname); if (ret) { - if (ret == -FDT_ERR_NOSPACE) + if (ret == -FDT_ERR_NOSPACE || ret == -ENOSPC) return -ENOSPC; printf("Can't write signature for '%s' signature node in '%s' conf node: %s\n", node_name, image_name, fdt_strerror(ret)); -- 2.26.2
[PATCH v4 4/6] spl: fit: enable signing a generated u-boot.itb
From: Heiko Stuebner With SPL_FIT_SIGNATURE enabled we will likely want a generated u-boot.itb to be signed and the key stores so that the spl can reach it. So add a SPL_FIT_SIGNATURE_KEY_DIR option and suitable hooks into the Makefile to have mkimage sign the .itb and store the used key into the spl dtb file. The added dependencies should make sure that the u-boot.itb gets generated before the spl-binary gets build, so that there is the necessary space for the key to get included. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich Reviewed-by: Simon Glass --- Kconfig | 8 Makefile | 11 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Kconfig b/Kconfig index b34fbf5827..05a13d1836 100644 --- a/Kconfig +++ b/Kconfig @@ -465,6 +465,14 @@ config SPL_FIT_SIGNATURE select SPL_RSA_VERIFY select SPL_IMAGE_SIGN_INFO +config SPL_FIT_SIGNATURE_KEY_DIR + string "key directory for signing U-Boot FIT image" + depends on SPL_FIT_SIGNATURE + default "keys" + help + The directory to give to mkimage to retrieve keys from when + generating a signed U-Boot FIT image. + config SPL_LOAD_FIT bool "Enable SPL loading U-Boot as a FIT (basic fitImage features)" select SPL_FIT diff --git a/Makefile b/Makefile index 1cc7e37c37..d19f556a04 100644 --- a/Makefile +++ b/Makefile @@ -1409,6 +1409,14 @@ MKIMAGEFLAGS_u-boot.itb = else MKIMAGEFLAGS_u-boot.itb = -E endif +ifdef CONFIG_SPL_FIT_SIGNATURE +ifdef CONFIG_SPL_OF_CONTROL +MKIMAGEFLAGS_u-boot.itb += -K dts/dt-spl.dtb -r +ifneq ($(CONFIG_SPL_FIT_SIGNATURE_KEY_DIR),"") +MKIMAGEFLAGS_u-boot.itb += -k $(CONFIG_SPL_FIT_SIGNATURE_KEY_DIR) +endif +endif +endif u-boot.itb: u-boot-nodtb.bin \ $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_OF_HOSTFILE),dts/dt.dtb) \ @@ -1924,7 +1932,8 @@ spl/u-boot-spl.bin: spl/u-boot-spl spl/u-boot-spl: tools prepare \ $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb) \ - $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_TPL_OF_PLATDATA),dts/dt.dtb) + $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_TPL_OF_PLATDATA),dts/dt.dtb) \ + $(if $(CONFIG_SPL_FIT_SIGNATURE)$(U_BOOT_ITS),u-boot.itb FORCE) $(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all spl/sunxi-spl.bin: spl/u-boot-spl -- 2.26.2
[PATCH v4 3/6] spl: fit: dont set U_BOOT_ITS var if not build SPL_FIT support
From: Heiko Stuebner Both CONFIG_SPL_FIT_SOURCE and CONFIG_SPL_FIT_GENERATOR depend on CONFIG_SPL_FIT, so U_BOOT_ITS should only be defined if one of them is set. When undefined, the ifneq ($(CONFIG_SPL_FIT_SOURCE),"") seems to evaluate to true all the time though, setting U_BOOT_ITS to u-boot.its, even if no FIT support gets build. This may prove cumbersome if later parts want to check against "do we need an U_BOOT_ITS", so to fix that just wrap the whole block in a "ifdef CONFIG_SPL_FIT" which needs to be defined if any SPL_FIT_* options get used. Signed-off-by: Heiko Stuebner --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 149f839948..1cc7e37c37 100644 --- a/Makefile +++ b/Makefile @@ -1320,6 +1320,7 @@ endif # Boards with more complex image requirements can provide an .its source file # or a generator script +ifdef CONFIG_SPL_FIT ifneq ($(CONFIG_SPL_FIT_SOURCE),"") U_BOOT_ITS := u-boot.its $(U_BOOT_ITS): $(subst ",,$(CONFIG_SPL_FIT_SOURCE)) @@ -1338,6 +1339,7 @@ $(U_BOOT_ITS): $(U_BOOT_ITS_DEPS) FORCE $(patsubst %,arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) > $@ endif endif +endif ifdef CONFIG_SPL_LOAD_FIT MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \ -- 2.26.2
[PATCH v6 5/8] lib: rsa: free local arrays after use in rsa_gen_key_prop()
From: Heiko Stuebner n, rr and rrtmp are used for internal calculations, but in the end the results are copied into separately allocated elements of the actual key_prop, so the n, rr and rrtmp elements are not used anymore when returning from the function and should of course be freed. Signed-off-by: Heiko Stuebner --- changes in v4: - new patch lib/rsa/rsa-keyprop.c | 19 +-- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/rsa/rsa-keyprop.c b/lib/rsa/rsa-keyprop.c index 83b942615f..195ce30181 100644 --- a/lib/rsa/rsa-keyprop.c +++ b/lib/rsa/rsa-keyprop.c @@ -654,17 +654,17 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) { struct rsa_key rsa_key; uint32_t *n = NULL, *rr = NULL, *rrtmp = NULL; - int rlen, i, ret; + int rlen, i, ret = 0; *prop = calloc(sizeof(**prop), 1); if (!(*prop)) { ret = -ENOMEM; - goto err; + goto out; } ret = rsa_parse_pub_key(_key, key, keylen); if (ret) - goto err; + goto out; /* modulus */ /* removing leading 0's */ @@ -674,7 +674,7 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) (*prop)->modulus = malloc(rsa_key.n_sz - i); if (!(*prop)->modulus) { ret = -ENOMEM; - goto err; + goto out; } memcpy((void *)(*prop)->modulus, _key.n[i], rsa_key.n_sz - i); @@ -690,7 +690,7 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) (*prop)->public_exponent = calloc(1, sizeof(uint64_t)); if (!(*prop)->public_exponent) { ret = -ENOMEM; - goto err; + goto out; } memcpy((void *)(*prop)->public_exponent + sizeof(uint64_t) - rsa_key.e_sz, @@ -714,16 +714,15 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) (*prop)->rr = malloc(rlen); if (!(*prop)->rr) { ret = -ENOMEM; - goto err; + goto out; } br_i32_encode((void *)(*prop)->rr, rlen, rr); - return 0; - -err: +out: free(n); free(rr); free(rrtmp); - rsa_free_key_prop(*prop); + if (ret < 0) + rsa_free_key_prop(*prop); return ret; } -- 2.26.2
[PATCH v6 8/8] spl: fit: select SPL_CRYPTO_SUPPORT for SPL_FIT_SIGNATURE
From: Heiko Stuebner Verifying FIT images obviously needs the rsa parts of crypto support and while main uboot always compiles crypto support, it's optional for SPL and we should thus select the necessary option to not end up in compile errors like: u-boot/lib/rsa/rsa-verify.c:328: undefined reference to `rsa_mod_exp' So select SPL_CRYPTO_SUPPORT in SPL_FIT_SIGNATURE. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/Kconfig b/Kconfig index 091c500ecc..b34fbf5827 100644 --- a/Kconfig +++ b/Kconfig @@ -459,6 +459,7 @@ config SPL_FIT_SIGNATURE bool "Enable signature verification of FIT firmware within SPL" depends on SPL_DM select SPL_FIT + select SPL_CRYPTO_SUPPORT select SPL_HASH_SUPPORT select SPL_RSA select SPL_RSA_VERIFY -- 2.26.2
[PATCH v6 6/8] lib: rsa: add documentation to padding_pss_verify to document limitations
From: Heiko Stuebner padding_pss_verify only works with the default pss salt setting of -2 (length to be automatically determined based on the PSS block structure) not -1 (salt length set to the maximum permissible value), which makes verifications of signatures with that saltlen fail. Until this gets implemented at least document this behaviour. Signed-off-by: Heiko Stuebner --- changes in v4: - new patch lib/rsa/rsa-verify.c | 13 + 1 file changed, 13 insertions(+) diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 048f1ab789..61d98e6e2d 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -194,6 +194,19 @@ out: return ret; } +/* + * padding_pss_verify() - verify the pss padding of a signature + * + * Only works with a rsa_pss_saltlen:-2 (default value) right now + * saltlen:-1 "set the salt length to the digest length" is currently + * not supported. + * + * @info: Specifies key and FIT information + * @msg: byte array of message, len equal to msg_len + * @msg_len: Message length + * @hash: Pointer to the expected hash + * @hash_len: Length of the hash + */ int padding_pss_verify(struct image_sign_info *info, uint8_t *msg, int msg_len, const uint8_t *hash, int hash_len) -- 2.26.2
[PATCH v6 4/8] lib: rsa: fix allocated size for rr and rrtmp in rsa_gen_key_prop()
From: Heiko Stuebner When calculating rrtmp/rr rsa_gen_key_prop() tries to make (((rlen + 31) >> 5) + 1) steps in the rr uint32_t array and (((rlen + 7) >> 3) + 1) / 4 steps in uint32_t rrtmp[] with rlen being num_bits * 2 On a 4096bit key this comes down to to 257 uint32_t elements in rr and 256 elements in rrtmp but with the current allocation rr and rrtmp only have 129 uint32_t elements. On 2048bit keys this works by chance as the defined max_rsa_size=4096 allocates a suitable number of elements, but with an actual 4096bit key this results in other memory parts getting overwritten. So as suggested by Heinrich Schuchardt just use the actual bis-size of the key as base for the size calculation, in turn making the code compatible to any future keysizes. Suggested-by: Heinrich Schuchardt Signed-off-by: Heiko Stuebner --- changes in v6: - drop max_rsa_size and use the keysize as base changes in v4: - new patch lib/rsa/rsa-keyprop.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/rsa/rsa-keyprop.c b/lib/rsa/rsa-keyprop.c index 4b54db44c4..83b942615f 100644 --- a/lib/rsa/rsa-keyprop.c +++ b/lib/rsa/rsa-keyprop.c @@ -654,14 +654,10 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) { struct rsa_key rsa_key; uint32_t *n = NULL, *rr = NULL, *rrtmp = NULL; - const int max_rsa_size = 4096; int rlen, i, ret; *prop = calloc(sizeof(**prop), 1); - n = calloc(sizeof(uint32_t), 1 + (max_rsa_size >> 5)); - rr = calloc(sizeof(uint32_t), 1 + (max_rsa_size >> 5)); - rrtmp = calloc(sizeof(uint32_t), 1 + (max_rsa_size >> 5)); - if (!(*prop) || !n || !rr || !rrtmp) { + if (!(*prop)) { ret = -ENOMEM; goto err; } @@ -682,6 +678,14 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) } memcpy((void *)(*prop)->modulus, _key.n[i], rsa_key.n_sz - i); + n = calloc(sizeof(uint32_t), 1 + ((*prop)->num_bits >> 5)); + rr = calloc(sizeof(uint32_t), 1 + (((*prop)->num_bits * 2) >> 5)); + rrtmp = calloc(sizeof(uint32_t), 1 + (((*prop)->num_bits * 2) >> 5)); + if (!n || !rr || !rrtmp) { + ret = -ENOMEM; + goto out; + } + /* exponent */ (*prop)->public_exponent = calloc(1, sizeof(uint64_t)); if (!(*prop)->public_exponent) { -- 2.26.2
[PATCH v6 7/8] spl: fit: select SPL_HASH_SUPPORT for SPL_FIT_SIGNATURE
From: Heiko Stuebner rsa-checsum needs support for hash functions or else will run into compile errors like: u-boot/lib/rsa/rsa-checksum.c:28: undefined reference to `hash_progressive_lookup_algo' So similar to the main FIT_SIGNATURE entry selects HASH, select SPL_HASH_SUPPORT for SPL_FIT_SIGNATURE. Cc: Heinrich Schuchardt Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/Kconfig b/Kconfig index 8f3fba085a..091c500ecc 100644 --- a/Kconfig +++ b/Kconfig @@ -459,6 +459,7 @@ config SPL_FIT_SIGNATURE bool "Enable signature verification of FIT firmware within SPL" depends on SPL_DM select SPL_FIT + select SPL_HASH_SUPPORT select SPL_RSA select SPL_RSA_VERIFY select SPL_IMAGE_SIGN_INFO -- 2.26.2
[PATCH v6 2/8] lib: rsa: take spl/non-spl into account when building rsa_verify_with_pkey()
From: Heiko Stuebner Right now in multiple places there are only checks for the full CONFIG_RSA_VERIFY_WITH_PKEY option, not split into main,spl,tpl variants. This breaks when the rsa functions get enabled for SPL, for example to verify u-boot proper from spl. So fix this by using the existing helpers to distinguis between build-steps. Signed-off-by: Heiko Stuebner --- changes in v5: - include the additional config-check that landed in patch 1/8 in v4 changes in v3.1: - drop changeid changes in v3: - new patch with another build issue lib/rsa/Makefile | 2 +- lib/rsa/rsa-verify.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rsa/Makefile b/lib/rsa/Makefile index c61ebfd79e..8b75d41f04 100644 --- a/lib/rsa/Makefile +++ b/lib/rsa/Makefile @@ -6,5 +6,5 @@ # Wolfgang Denk, DENX Software Engineering, w...@denx.de. obj-$(CONFIG_$(SPL_TPL_)RSA_VERIFY) += rsa-verify.o rsa-checksum.o -obj-$(CONFIG_RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o +obj-$(CONFIG_$(SPL_TPL_)RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o obj-$(CONFIG_RSA_SOFTWARE_EXP) += rsa-mod-exp.o diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 1d55b997e3..048f1ab789 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -285,7 +285,7 @@ out: } #endif -#if CONFIG_IS_ENABLED(FIT_SIGNATURE) || IS_ENABLED(CONFIG_RSA_VERIFY_WITH_PKEY) +#if CONFIG_IS_ENABLED(FIT_SIGNATURE) || CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) /** * rsa_verify_key() - Verify a signature against some data using RSA Key * @@ -359,7 +359,7 @@ static int rsa_verify_key(struct image_sign_info *info, } #endif -#ifdef CONFIG_RSA_VERIFY_WITH_PKEY +#if CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) /** * rsa_verify_with_pkey() - Verify a signature against some data using * only modulus and exponent as RSA key properties. @@ -492,7 +492,7 @@ int rsa_verify(struct image_sign_info *info, return -EINVAL; } - if (IS_ENABLED(CONFIG_RSA_VERIFY_WITH_PKEY) && !info->fdt_blob) { + if (CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) && !info->fdt_blob) { /* don't rely on fdt properties */ ret = rsa_verify_with_pkey(info, hash, sig, sig_len); -- 2.26.2
[PATCH v6 3/8] lib: rsa: bring exp_len in line when generating a key_prop
From: Heiko Stuebner The exponent field of struct key_prop gets allocated an uint64_t, and the contents are positioned from the back, so an exponent of "0x01 0x00 0x01" becomes 0x0 0x0 0x0 0x0 0x0 0x1 0x0 0x1" Right now rsa_gen_key_prop() allocates a uint64_t but sets exp_len to the size returned from the parser, while on the other hand the when getting the key from the devicetree exp_len always gets set to sizeof(uint64_t). So bring that in line with the established code. Signed-off-by: Heiko Stuebner --- changes in v4: - new patch lib/rsa/rsa-keyprop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rsa/rsa-keyprop.c b/lib/rsa/rsa-keyprop.c index 9464df0093..4b54db44c4 100644 --- a/lib/rsa/rsa-keyprop.c +++ b/lib/rsa/rsa-keyprop.c @@ -691,7 +691,7 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) memcpy((void *)(*prop)->public_exponent + sizeof(uint64_t) - rsa_key.e_sz, rsa_key.e, rsa_key.e_sz); - (*prop)->exp_len = rsa_key.e_sz; + (*prop)->exp_len = sizeof(uint64_t); /* n0 inverse */ br_i32_decode(n, _key.n[i], rsa_key.n_sz - i); -- 2.26.2
[PATCH v6 1/8] lib: rsa: distinguish between tpl and spl for CONFIG_RSA_VERIFY
From: Heiko Stuebner While the SPL may want to do signature checking this won't be the case for TPL in all cases, as TPL is mostly used when the amount of initial memory is not enough for a full SPL. So on a system where SPL uses DM but TPL does not we currently end up with a TPL compile error of: lib/rsa/rsa-verify.c:48:25: error: dereferencing pointer to incomplete type ‘struct checksum_algo’ To prevent that change the $(SPL_) to $(SPL_TPL_) to distinguish between both. If someone really needs FIT signature checking in TPL as well, a new TPL_RSA_VERIFY config symbol needs to be added. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- changes in v5: - drop change that belongs in patch 2/8 changes in v4: - amound -> amount - found another entry to handle changes in v2: - fix typo "distinguis(h)" lib/rsa/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rsa/Makefile b/lib/rsa/Makefile index 14ed3cb401..c61ebfd79e 100644 --- a/lib/rsa/Makefile +++ b/lib/rsa/Makefile @@ -5,6 +5,6 @@ # (C) Copyright 2000-2007 # Wolfgang Denk, DENX Software Engineering, w...@denx.de. -obj-$(CONFIG_$(SPL_)RSA_VERIFY) += rsa-verify.o rsa-checksum.o +obj-$(CONFIG_$(SPL_TPL_)RSA_VERIFY) += rsa-verify.o rsa-checksum.o obj-$(CONFIG_RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o obj-$(CONFIG_RSA_SOFTWARE_EXP) += rsa-mod-exp.o -- 2.26.2
[PATCH 2/2] net: phy: mscc: sync rx/tx delay settings with Linux on vsc85xx
From: Heiko Stuebner The Linux kernel does set the clock delays to - 0.2 ns (their default, and lowest, hardware value) if delays should not be enabled - 2.0 ns (which causes the data to be sampled at exactly half way between clock transitions at 1000 Mbps) if delays should be enabled depending on the interface mode See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/phy/mscc/mscc_main.c#n523 So instead of using arbitrary delay values like now, mimic this behaviour. The behaviour is the same for all of vsc8530/8531/8540/8541 so move that to a shared function while at it. Signed-off-by: Heiko Stuebner --- drivers/net/phy/mscc.c | 70 +++--- 1 file changed, 46 insertions(+), 24 deletions(-) diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c index 64e9093827..d1a643cf5a 100644 --- a/drivers/net/phy/mscc.c +++ b/drivers/net/phy/mscc.c @@ -1176,6 +1176,9 @@ static int vsc8531_vsc8541_mac_config(struct phy_device *phydev) rx_clk_out = RX_CLK_OUT_NORMAL; break; + case PHY_INTERFACE_MODE_RGMII_TXID: + case PHY_INTERFACE_MODE_RGMII_RXID: + case PHY_INTERFACE_MODE_RGMII_ID: case PHY_INTERFACE_MODE_RGMII: /* Set Reg23.12:11=2 */ mac_if = MAC_IF_SELECTION_RGMII; @@ -1259,13 +1262,43 @@ static int vsc8531_vsc8541_clkout_config(struct phy_device *phydev) return 0; } +static int vsc8531_vsc8541_clk_skew_config(struct phy_device *phydev) +{ + enum vsc_phy_rgmii_skew rx_clk_skew = VSC_PHY_RGMII_DELAY_200_PS; + enum vsc_phy_rgmii_skew tx_clk_skew = VSC_PHY_RGMII_DELAY_200_PS; + u16 reg_val; + + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID || + phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) + rx_clk_skew = VSC_PHY_RGMII_DELAY_2000_PS; + + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID || + phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) + tx_clk_skew = VSC_PHY_RGMII_DELAY_2000_PS; + + phy_write(phydev, MDIO_DEVAD_NONE, MSCC_EXT_PAGE_ACCESS, + MSCC_PHY_PAGE_EXT2); + reg_val = phy_read(phydev, MDIO_DEVAD_NONE, MSCC_PHY_RGMII_CNTL_REG); + + /* Reg20E2 - Update RGMII RX_Clk Skews. */ + reg_val = bitfield_replace(reg_val, RGMII_RX_CLK_DELAY_POS, + RGMII_RX_CLK_DELAY_WIDTH, rx_clk_skew); + /* Reg20E2 - Update RGMII TX_Clk Skews. */ + reg_val = bitfield_replace(reg_val, RGMII_TX_CLK_DELAY_POS, + RGMII_TX_CLK_DELAY_WIDTH, tx_clk_skew); + + phy_write(phydev, MDIO_DEVAD_NONE, MSCC_PHY_RGMII_CNTL_REG, reg_val); + phy_write(phydev, MDIO_DEVAD_NONE, MSCC_EXT_PAGE_ACCESS, + MSCC_PHY_PAGE_STD); + + return 0; +} + static int vsc8531_config(struct phy_device *phydev) { int retval = -EINVAL; u16 reg_val; u16 rmii_clk_out; - enum vsc_phy_rgmii_skew rx_clk_skew = VSC_PHY_RGMII_DELAY_1700_PS; - enum vsc_phy_rgmii_skew tx_clk_skew = VSC_PHY_RGMII_DELAY_800_PS; enum vsc_phy_clk_slewedge_rate = VSC_PHY_CLK_SLEW_RATE_4; /* For VSC8530/31 and VSC8540/41 the init scripts are the same */ @@ -1275,6 +1308,9 @@ static int vsc8531_config(struct phy_device *phydev) switch (phydev->interface) { case PHY_INTERFACE_MODE_RMII: case PHY_INTERFACE_MODE_RGMII: + case PHY_INTERFACE_MODE_RGMII_TXID: + case PHY_INTERFACE_MODE_RGMII_RXID: + case PHY_INTERFACE_MODE_RGMII_ID: retval = vsc8531_vsc8541_mac_config(phydev); if (retval != 0) return retval; @@ -1291,19 +1327,12 @@ static int vsc8531_config(struct phy_device *phydev) /* Default RMII Clk Output to 0=OFF/1=ON */ rmii_clk_out = 0; + retval = vsc8531_vsc8541_clk_skew_config(phydev); + if (retval != 0) + return retval; + phy_write(phydev, MDIO_DEVAD_NONE, MSCC_EXT_PAGE_ACCESS, MSCC_PHY_PAGE_EXT2); - reg_val = phy_read(phydev, MDIO_DEVAD_NONE, MSCC_PHY_RGMII_CNTL_REG); - - /* Reg20E2 - Update RGMII RX_Clk Skews. */ - reg_val = bitfield_replace(reg_val, RGMII_RX_CLK_DELAY_POS, - RGMII_RX_CLK_DELAY_WIDTH, rx_clk_skew); - /* Reg20E2 - Update RGMII TX_Clk Skews. */ - reg_val = bitfield_replace(reg_val, RGMII_TX_CLK_DELAY_POS, - RGMII_TX_CLK_DELAY_WIDTH, tx_clk_skew); - - phy_write(phydev, MDIO_DEVAD_NONE, MSCC_PHY_RGMII_CNTL_REG, reg_val); - reg_val = phy_read(phydev, MDIO_DEVAD_NONE, MSCC_PHY_WOL_MAC_CONTROL); /* Reg27E2 - Update Clk Slew Rate. */ reg_val = bitfield_replace(reg_val, EDGE_RATE_CNTL_POS, @@ -1329,8 +1358,6 @@ static int vsc8541_config(struct phy_device *phydev) int retval = -EINV
[PATCH 1/2] net: phy: mscc: make clock-output configurable on vsc85xx
From: Heiko Stuebner The vsc8530/8531/8540/8541 phys have a configurable clock output that can emit 25, 50 and 125 MHz rates, which in turn may be needed for stable network connections. This follows a similar change introduced into the Linux kernel at https://lore.kernel.org/netdev/20200609133140.1421109-2-he...@sntech.de Signed-off-by: Heiko Stuebner --- drivers/net/phy/mscc.c | 59 ++ 1 file changed, 59 insertions(+) diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c index 709979f48c..64e9093827 100644 --- a/drivers/net/phy/mscc.c +++ b/drivers/net/phy/mscc.c @@ -157,6 +157,14 @@ #define INT_MEM_DATA_M GENMASK(7, 0) #define INT_MEM_DATA(x)(INT_MEM_DATA_M & (x)) +/* Extended page GPIO register 13G */ +#define MSCC_CLKOUT_CNTL 13 +#define CLKOUT_ENABLE BIT(15) +#define CLKOUT_FREQ_MASK GENMASK(14, 13) +#define CLKOUT_FREQ_25M(0x0 << 13) +#define CLKOUT_FREQ_50M(0x1 << 13) +#define CLKOUT_FREQ_125M (0x2 << 13) + /* Extended page GPIO register 18G */ #define MSCC_PHY_PROC_CMD18 #define PROC_CMD_NCOMPLETED BIT(15) @@ -1210,6 +1218,47 @@ static int vsc8531_vsc8541_mac_config(struct phy_device *phydev) return 0; } +static int vsc8531_vsc8541_clkout_config(struct phy_device *phydev) +{ + struct ofnode_phandle_args phandle_args; + u32 clkout_rate = 0; + u16 reg_val; + int retval; + + retval = dev_read_phandle_with_args(phydev->dev, "phy-handle", NULL, + 0, 0, _args); + if (!retval) + clkout_rate = ofnode_read_u32_default(phandle_args.node, + "vsc8531,clk-out-frequency", 0); + + switch (clkout_rate) { + case 0: + reg_val = 0; + break; + case 2500: + reg_val = CLKOUT_FREQ_25M | CLKOUT_ENABLE; + break; + case 5000: + reg_val = CLKOUT_FREQ_50M | CLKOUT_ENABLE; + break; + case 12500: + reg_val = CLKOUT_FREQ_125M | CLKOUT_ENABLE; + break; + default: + printf("PHY 8530/31 invalid clkout rate %u\n", + clkout_rate); + return -EINVAL; + } + + phy_write(phydev, MDIO_DEVAD_NONE, MSCC_EXT_PAGE_ACCESS, + MSCC_PHY_PAGE_GPIO); + phy_write(phydev, MDIO_DEVAD_NONE, MSCC_CLKOUT_CNTL, reg_val); + phy_write(phydev, MDIO_DEVAD_NONE, MSCC_EXT_PAGE_ACCESS, + MSCC_PHY_PAGE_STD); + + return 0; +} + static int vsc8531_config(struct phy_device *phydev) { int retval = -EINVAL; @@ -1267,6 +1316,11 @@ static int vsc8531_config(struct phy_device *phydev) phy_write(phydev, MDIO_DEVAD_NONE, MSCC_EXT_PAGE_ACCESS, MSCC_PHY_PAGE_STD); + /* Configure the clk output */ + retval = vsc8531_vsc8541_clkout_config(phydev); + if (retval != 0) + return retval; + return genphy_config_aneg(phydev); } @@ -1327,6 +1381,11 @@ static int vsc8541_config(struct phy_device *phydev) phy_write(phydev, MDIO_DEVAD_NONE, MSCC_EXT_PAGE_ACCESS, MSCC_PHY_PAGE_STD); + /* Configure the clk output */ + retval = vsc8531_vsc8541_clkout_config(phydev); + if (retval != 0) + return retval; + return genphy_config_aneg(phydev); } -- 2.26.2
[PATCH v3 3/8] rockchip: puma: fix indentation for -u-boot.dtsi
From: Heiko Stuebner Tabs not spaces, so transform it to the common styling. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich Reviewed-by: Kever Yang --- arch/arm/dts/rk3399-puma-u-boot.dtsi | 30 ++-- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/arm/dts/rk3399-puma-u-boot.dtsi b/arch/arm/dts/rk3399-puma-u-boot.dtsi index 3ad1139833..ddb5fa6e76 100644 --- a/arch/arm/dts/rk3399-puma-u-boot.dtsi +++ b/arch/arm/dts/rk3399-puma-u-boot.dtsi @@ -2,24 +2,24 @@ #include "rk3399-u-boot.dtsi" / { - config { - u-boot,spl-payload-offset = <0x4>; /* @ 256KB */ - u-boot,mmc-env-offset = <0x4000>; /* @ 16KB */ - u-boot,efi-partition-entries-offset = <0x20>; /* 2MB */ - u-boot,boot-led = "module_led"; - sysreset-gpio = < RK_PA6 GPIO_ACTIVE_HIGH>; - }; + config { + u-boot,spl-payload-offset = <0x4>; /* @ 256KB */ + u-boot,mmc-env-offset = <0x4000>; /* @ 16KB */ + u-boot,efi-partition-entries-offset = <0x20>; /* 2MB */ + u-boot,boot-led = "module_led"; + sysreset-gpio = < RK_PA6 GPIO_ACTIVE_HIGH>; + }; - chosen { - stdout-path = "serial0:115200n8"; - u-boot,spl-boot-order = \ + chosen { + stdout-path = "serial0:115200n8"; + u-boot,spl-boot-order = \ "same-as-spl", , , - }; + }; - aliases { - spi0 = - spi1 = - }; + aliases { + spi0 = + spi1 = + }; /* * The Qseven BIOS_DISABLE signal on the RK3399-Q7 keeps the on-module -- 2.26.2
[PATCH v3 2/8] arm64: dts: rk3399-puma: fix gpio levels for vcc5v0-host regulator
From: Heiko Stuebner The regulator enable-gpio uses opposite values for the declaration vs. the enable_active_low property, breaking the regulator enablement. Make the usbhost-supply work again by bringing them in sync again. This mimics the upstream Linux change found on: http://lore.kernel.org/r/20200604091239.424318-1-he...@sntech.de Signed-off-by: Heiko Stuebner Reviewed-by: Kever Yang --- arch/arm/dts/rk3399-puma.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/dts/rk3399-puma.dtsi b/arch/arm/dts/rk3399-puma.dtsi index 531520e771..72c06abd27 100644 --- a/arch/arm/dts/rk3399-puma.dtsi +++ b/arch/arm/dts/rk3399-puma.dtsi @@ -101,7 +101,7 @@ vcc5v0_host: vcc5v0-host-regulator { compatible = "regulator-fixed"; - gpio = < RK_PA3 GPIO_ACTIVE_HIGH>; + gpio = < RK_PA3 GPIO_ACTIVE_LOW>; enable-active-low; pinctrl-names = "default"; pinctrl-0 = <_host_en>; -- 2.26.2
[PATCH v3 1/8] arm64: dts: rk3399-puma: fix gpio levels for gmac reset pin
From: Heiko Stuebner The gmac reset has opposite values for the gpio declaration and the separate reset-active, bring this in line to make u-boot also find the ethernet-phy. This mimics the upstream Linux commit found on https://lore.kernel.org/r/20200603132836.362519-1-he...@sntech.de Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich Reviewed-by: Kever Yang --- arch/arm/dts/rk3399-puma.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/dts/rk3399-puma.dtsi b/arch/arm/dts/rk3399-puma.dtsi index 07694b196f..531520e771 100644 --- a/arch/arm/dts/rk3399-puma.dtsi +++ b/arch/arm/dts/rk3399-puma.dtsi @@ -157,7 +157,7 @@ phy-mode = "rgmii"; pinctrl-names = "default"; pinctrl-0 = <_pins>; - snps,reset-gpio = < RK_PC0 GPIO_ACTIVE_HIGH>; + snps,reset-gpio = < RK_PC0 GPIO_ACTIVE_LOW>; snps,reset-active-low; snps,reset-delays-us = <0 1 5>; tx_delay = <0x10>; -- 2.26.2
[PATCH v3 8/8] rockchip: puma: enable new usb config options
From: Heiko Stuebner With recently added changes we get support for usb3 including handling of the phys (type-c and inno-usb2), so enable the necessary config options on puma. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich Reviewed-by: Kever Yang --- configs/puma-rk3399_defconfig | 5 + 1 file changed, 5 insertions(+) diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig index 31d4eb3471..6b7d2ee6b8 100644 --- a/configs/puma-rk3399_defconfig +++ b/configs/puma-rk3399_defconfig @@ -59,6 +59,8 @@ CONFIG_PHY_MICREL_KSZ90X1=y CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_GMAC_ROCKCHIP=y +CONFIG_PHY_ROCKCHIP_INNO_USB2=y +CONFIG_PHY_ROCKCHIP_TYPEC=y CONFIG_DM_PMIC_FAN53555=y CONFIG_PMIC_RK8XX=y CONFIG_SPL_DM_REGULATOR=y @@ -67,6 +69,7 @@ CONFIG_SPL_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y CONFIG_REGULATOR_RK8XX=y CONFIG_PWM_ROCKCHIP=y +CONFIG_DM_RESET=y CONFIG_DM_RTC=y CONFIG_RTC_ISL1208=y CONFIG_DEBUG_UART_SHIFT=2 @@ -77,6 +80,8 @@ CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y +CONFIG_USB_DWC3=y +CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_HOST_ETHER=y CONFIG_USB_ETHER_ASIX=y CONFIG_USB_ETHER_ASIX88179=y -- 2.26.2
[PATCH v3 7/8] rockchip: puma: drop special handling of usb host regulator
From: Heiko Stuebner With the current usb stack in u-boot, all host ports on puma work flawlessly without any additional special handling, so drop that usb hub hacking from the puma board. Tested with mass-storage and usb-ethernet on both usb3 and usb2 ports. Signed-off-by: Heiko Stuebner Reviewed-by: Kever Yang --- .../puma_rk3399/puma-rk3399.c | 67 --- 1 file changed, 67 deletions(-) diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c index 65bb2ad6f2..deeba3084a 100644 --- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c +++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c @@ -152,70 +152,3 @@ void get_board_serial(struct tag_serialnr *serialnr) serialnr->low = (u32)(serial & 0x); } #endif - -/** - * Switch power at an external regulator (for our root hub). - * - * @param ctrl pointer to the xHCI controller - * @param port port number as in the control message (one-based) - * @param enable boolean indicating whether to enable or disable power - * @return returns 0 on success, an error-code on failure - */ -static int board_usb_port_power_set(struct udevice *dev, int port, - bool enable) -{ -#if CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(DM_REGULATOR) - /* We start counting ports at 0, while USB counts from 1. */ - int index = port - 1; - const char *regname = NULL; - struct udevice *regulator; - const char *prop = "tsd,usb-port-power"; - int ret; - - debug("%s: ctrl '%s' port %d enable %s\n", __func__, - dev_read_name(dev), port, enable ? "true" : "false"); - - ret = dev_read_string_index(dev, prop, index, ); - if (ret < 0) { - debug("%s: ctrl '%s' port %d: no entry in '%s'\n", - __func__, dev_read_name(dev), port, prop); - return ret; - } - - ret = regulator_get_by_platname(regname, ); - if (ret) { - debug("%s: ctrl '%s' port %d: could not get regulator '%s'\n", - __func__, dev_read_name(dev), port, regname); - return ret; - } - - regulator_set_enable(regulator, enable); - return 0; -#else - return -ENOTSUPP; -#endif -} - -void usb_hub_reset_devices(struct usb_hub_device *hub, int port) -{ - struct udevice *dev = hub->pusb_dev->dev; - struct udevice *ctrl; - - /* We are only interested in our root-hubs */ - if (usb_hub_is_root_hub(dev) == false) - return; - - ctrl = usb_get_bus(dev); - if (!ctrl) { - debug("%s: could not retrieve ctrl for hub\n", __func__); - return; - } - - /* -* To work around an incompatibility between the single-threaded -* USB stack in U-Boot and (a strange low-power mode of) the USB -* hub we have on-module, we need to delay powering on the hub -* until the first time the port is probed. -*/ - board_usb_port_power_set(ctrl, port, true); -} -- 2.26.2
[PATCH v3 6/8] rockchip: puma: remove separate fit generator
From: Heiko Stuebner The introduction of the puma-specific generator was mainly a way to split the pmu firmware from the ATF binary and not having to distribute that 4GB (sparse) image that was created before moving to the bl31.elf as base. Looking at the publically available repository for that separate pmu firmware https://git.theobroma-systems.com/rk3399-cortex-m0.git/ there is also no activity for 3 years and apart from some build customizations no other changes were done. And even then, if changes need to be made, this can very well also happen in the atf context itself, so there is no real need to diverge from the established build procedure and we can just go back to using the main make_fit_atf.py script. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich Reviewed-by: Kever Yang --- .../puma_rk3399/fit_spl_atf.sh| 94 --- configs/puma-rk3399_defconfig | 1 - 2 files changed, 95 deletions(-) delete mode 100755 board/theobroma-systems/puma_rk3399/fit_spl_atf.sh diff --git a/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh b/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh deleted file mode 100755 index c9396577a9..00 --- a/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh -# -# SPDX-License-Identifier: GPL-2.0+ -# -# Copyright (C) 2019 Jagan Teki -# -# Based on the board/sunxi/mksunxi_fit_atf.sh -# -# Script to generate FIT image source for 64-bit puma boards with -# U-Boot proper, ATF, PMU firmware and devicetree. -# -# usage: $0 [ [&2 - echo "Please read Building section in doc/README.rockchip" >&2 - BL31=/dev/null -fi - -[ -z "$PMUM0" ] && PMUM0="rk3399m0.bin" - -if [ ! -f $PMUM0 ]; then - echo "WARNING: PMUM0 file $PMUM0 NOT found, resulting binary is non-functional" >&2 - echo "Please read Building section in doc/README.rockchip" >&2 - PMUM0=/dev/null -fi - -cat << __HEADER_EOF -/* SPDX-License-Identifier: GPL-2.0+ OR X11 */ -/* - * Copyright (C) 2017 Theobroma Systems Design und Consulting GmbH - * - * Minimal dts for a SPL FIT image payload. - */ - -/dts-v1/; - -/ { - description = "FIT image with U-Boot proper, ATF bl31, M0 Firmware, DTB"; - #address-cells = <1>; - - images { - uboot { - description = "U-Boot (64-bit)"; - data = /incbin/("u-boot-nodtb.bin"); - type = "standalone"; - arch = "arm64"; - compression = "none"; - load = <0x4a00>; - }; - atf { - description = "ARM Trusted Firmware"; - data = /incbin/("$BL31"); - type = "firmware"; - arch = "arm64"; - os = "arm-trusted-firmware"; - compression = "none"; - load = <0x1000>; - entry = <0x1000>; - }; - pmu { - description = "Cortex-M0 firmware"; - data = /incbin/("$PMUM0"); - type = "pmu-firmware"; - compression = "none"; - load = <0x18>; -}; - fdt { - description = "RK3399-Q7 (Puma) flat device-tree"; - data = /incbin/("$1"); - type = "flat_dt"; - compression = "none"; - }; -__HEADER_EOF - -cat << __CONF_HEADER_EOF - }; - - configurations { - default = "conf"; - conf { - description = "Theobroma Systems RK3399-Q7 (Puma) SoM"; - firmware = "atf"; - loadables = "uboot", "pmu"; - fdt = "fdt"; - }; -__CONF_HEADER_EOF - -cat << __ITS_EOF - }; -}; -__ITS_EOF diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig index 47a60930b6..31d4eb3471 100644 --- a/configs/puma-rk3399_defconfig +++ b/configs/puma-rk3399_defconfig @@ -14,7 +14,6 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI_SUPPORT=y CONFIG_SPL_TEXT_BASE=0xff8c2000 CONFIG_DEBUG_UART=y -CONFIG_SPL_FIT_GENERATOR="board/theobroma-systems/puma_rk3399/fit_spl_atf.sh" CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-puma-haikou.dtb" CONFIG_MISC_INIT_R=y CONFIG_DISPLAY_BOARDINFO_LATE=y -- 2.26.2
[PATCH v3 0/8] revive Theobroma-Systems puma board
From: Heiko Stuebner This revives the puma boards and makes them boot again with mainline uboot. Main points may be going back to the general fit script and cleaning up the devicetree situation that got completely broken by the recent sync from mainline linux. changes in v3: - use automatic include of $BOARD-u-boot.dtsi instead of adding a include to the synced board dts (Kever) changes in v2: - patch subject fixes (Kever) - make usb work again - remove usb regulator special handling Heiko Stuebner (8): arm64: dts: rk3399-puma: fix gpio levels for gmac reset pin arm64: dts: rk3399-puma: fix gpio levels for vcc5v0-host regulator rockchip: puma: fix indentation for -u-boot.dtsi rockchip: puma: fix indentation of misc_init_r rockchip: puma: reorganize devicetrees to actually work and match upstream rockchip: puma: remove separate fit generator rockchip: puma: drop special handling of usb host regulator rockchip: puma: enable new usb config options arch/arm/dts/Makefile | 4 +- arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1333.dts | 8 - arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1600.dts | 9 - arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1866.dts | 8 - ...ot.dtsi => rk3399-puma-haikou-u-boot.dtsi} | 43 +-- arch/arm/dts/rk3399-puma-haikou.dts | 271 ++ arch/arm/dts/rk3399-puma.dtsi | 4 +- board/theobroma-systems/puma_rk3399/Kconfig | 15 + .../puma_rk3399/fit_spl_atf.sh| 94 -- .../puma_rk3399/puma-rk3399.c | 93 +- configs/puma-rk3399_defconfig | 8 +- 14 files changed, 335 insertions(+), 234 deletions(-) delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333.dts delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600.dts delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866.dts rename arch/arm/dts/{rk3399-puma-u-boot.dtsi => rk3399-puma-haikou-u-boot.dtsi} (53%) create mode 100644 arch/arm/dts/rk3399-puma-haikou.dts delete mode 100755 board/theobroma-systems/puma_rk3399/fit_spl_atf.sh -- 2.26.2
[PATCH v3 5/8] rockchip: puma: reorganize devicetrees to actually work and match upstream
From: Heiko Stuebner So far the puma dts files only just included the main puma dtsi without handling the actual baseboard and rk3399-puma.dtsi was very much detached from the variant in the mainline Linux kernel. Recent changes resulted in a strange situation with nonworking puma boards. Commit ab800e5a6f28 ("arm: dts: rockchip: puma: move U-Boot specific bits to u-boot.dtsi") moved the sdram include from rk3399-puma-ddrX.dts to new files rk3399-puma-ddrx-u-boot.dtsi which were never included anywhere though. Commit 167efc2c7a46 ("arm64: dts: rk3399: Sync v5.7-rc1 from Linux") replaced the rk3399-puma.dtsi nearly completely, but in the kernel it definitly depends on a baseboard dts to actually enable peripherals like sd-slot, uarts, etc. So to untagle this and bring the whole thing more in line with mainline Linux, bring the rk3399-puma-haikou.dts over as well, drop the separate DDR-option devicetrees and instead replace them with a puma Kconfig option to select and include the needed DDR variant. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- arch/arm/dts/Makefile | 4 +- arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1333.dts | 8 - arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1600.dts | 9 - arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1866.dts | 8 - ...ot.dtsi => rk3399-puma-haikou-u-boot.dtsi} | 11 + arch/arm/dts/rk3399-puma-haikou.dts | 271 ++ board/theobroma-systems/puma_rk3399/Kconfig | 15 + configs/puma-rk3399_defconfig | 2 +- 11 files changed, 299 insertions(+), 41 deletions(-) delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333.dts delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600.dts delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866.dts rename arch/arm/dts/{rk3399-puma-u-boot.dtsi => rk3399-puma-haikou-u-boot.dtsi} (80%) create mode 100644 arch/arm/dts/rk3399-puma-haikou.dts diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index c6af87cf5e..a66bdb439d 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -130,9 +130,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3399) += \ rk3399-nanopi-neo4.dtb \ rk3399-orangepi.dtb \ rk3399-pinebook-pro.dtb \ - rk3399-puma-ddr1333.dtb \ - rk3399-puma-ddr1600.dtb \ - rk3399-puma-ddr1866.dtb \ + rk3399-puma-haikou.dtb \ rk3399-roc-pc.dtb \ rk3399-roc-pc-mezzanine.dtb \ rk3399-rock-pi-4.dtb \ diff --git a/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi deleted file mode 100644 index 39d3927f49..00 --- a/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi +++ /dev/null @@ -1,4 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ - -#include "rk3399-puma-u-boot.dtsi" -#include "rk3399-sdram-ddr3-1333.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1333.dts b/arch/arm/dts/rk3399-puma-ddr1333.dts deleted file mode 100644 index 80f27699f4..00 --- a/arch/arm/dts/rk3399-puma-ddr1333.dts +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ OR X11 -/* - * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH - */ - -/dts-v1/; - -#include "rk3399-puma.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi deleted file mode 100644 index be58311dc4..00 --- a/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi +++ /dev/null @@ -1,4 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ - -#include "rk3399-puma-u-boot.dtsi" -#include "rk3399-sdram-ddr3-1600.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1600.dts b/arch/arm/dts/rk3399-puma-ddr1600.dts deleted file mode 100644 index cb76b0165c..00 --- a/arch/arm/dts/rk3399-puma-ddr1600.dts +++ /dev/null @@ -1,9 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ OR X11 -/* - * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH - */ - -/dts-v1/; - -#include "rk3399-puma.dtsi" -#include "rk3399-u-boot.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi deleted file mode 100644 index 48da076329..00 --- a/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi +++ /dev/null @@ -1,4 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ - -#include "rk3399-puma-u-boot.dtsi" -#include "rk3399-sdram-ddr3-1866.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1866.dts b/arch/arm/dts/rk3399-puma-ddr1866.dts deleted file mode 100644 index 80f27699f4..00 --- a/arch/arm/dts/rk3399-puma-ddr1866.dts +++ /dev/null
[PATCH v3 4/8] rockchip: puma: fix indentation of misc_init_r
From: Heiko Stuebner The commit moving puma to the generic cpuid/macaddr helpers used 7 spaces as indentation, so correct that by moving to the required tabs. Fixes: fa177ff0208b ("board: puma: Use rockchip_* helpers to setup cpuid and macaddr") Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich Reviewed-by: Kever Yang --- .../puma_rk3399/puma-rk3399.c | 32 +-- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c index f7f08ae617..65bb2ad6f2 100644 --- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c +++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c @@ -114,22 +114,22 @@ static int setup_boottargets(void) int misc_init_r(void) { - const u32 cpuid_offset = 0x7; - const u32 cpuid_length = 0x10; - u8 cpuid[cpuid_length]; - int ret; - - ret = rockchip_cpuid_from_efuse(cpuid_offset, cpuid_length, cpuid); - if (ret) - return ret; - - ret = rockchip_cpuid_set(cpuid, cpuid_length); - if (ret) - return ret; - - ret = rockchip_setup_macaddr(); - if (ret) - return ret; + const u32 cpuid_offset = 0x7; + const u32 cpuid_length = 0x10; + u8 cpuid[cpuid_length]; + int ret; + + ret = rockchip_cpuid_from_efuse(cpuid_offset, cpuid_length, cpuid); + if (ret) + return ret; + + ret = rockchip_cpuid_set(cpuid, cpuid_length); + if (ret) + return ret; + + ret = rockchip_setup_macaddr(); + if (ret) + return ret; setup_iodomain(); setup_boottargets(); -- 2.26.2
[PATCH v2 1/8] arm64: dts: rk3399-puma: fix gpio levels for gmac reset pin
From: Heiko Stuebner The gmac reset has opposite values for the gpio declaration and the separate reset-active, bring this in line to make u-boot also find the ethernet-phy. This mimics the upstream Linux commit found on https://lore.kernel.org/r/20200603132836.362519-1-he...@sntech.de Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- arch/arm/dts/rk3399-puma.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/dts/rk3399-puma.dtsi b/arch/arm/dts/rk3399-puma.dtsi index 07694b196f..531520e771 100644 --- a/arch/arm/dts/rk3399-puma.dtsi +++ b/arch/arm/dts/rk3399-puma.dtsi @@ -157,7 +157,7 @@ phy-mode = "rgmii"; pinctrl-names = "default"; pinctrl-0 = <_pins>; - snps,reset-gpio = < RK_PC0 GPIO_ACTIVE_HIGH>; + snps,reset-gpio = < RK_PC0 GPIO_ACTIVE_LOW>; snps,reset-active-low; snps,reset-delays-us = <0 1 5>; tx_delay = <0x10>; -- 2.25.1
[PATCH v2 7/8] rockchip: puma: drop special handling of usb host regulator
From: Heiko Stuebner With the current usb stack in u-boot, all host ports on puma work flawlessly without any additional special handling, so drop that usb hub hacking from the puma board. Tested with mass-storage and usb-ethernet on both usb3 and usb2 ports. Signed-off-by: Heiko Stuebner --- .../puma_rk3399/puma-rk3399.c | 67 --- 1 file changed, 67 deletions(-) diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c index 65bb2ad6f2..deeba3084a 100644 --- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c +++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c @@ -152,70 +152,3 @@ void get_board_serial(struct tag_serialnr *serialnr) serialnr->low = (u32)(serial & 0x); } #endif - -/** - * Switch power at an external regulator (for our root hub). - * - * @param ctrl pointer to the xHCI controller - * @param port port number as in the control message (one-based) - * @param enable boolean indicating whether to enable or disable power - * @return returns 0 on success, an error-code on failure - */ -static int board_usb_port_power_set(struct udevice *dev, int port, - bool enable) -{ -#if CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(DM_REGULATOR) - /* We start counting ports at 0, while USB counts from 1. */ - int index = port - 1; - const char *regname = NULL; - struct udevice *regulator; - const char *prop = "tsd,usb-port-power"; - int ret; - - debug("%s: ctrl '%s' port %d enable %s\n", __func__, - dev_read_name(dev), port, enable ? "true" : "false"); - - ret = dev_read_string_index(dev, prop, index, ); - if (ret < 0) { - debug("%s: ctrl '%s' port %d: no entry in '%s'\n", - __func__, dev_read_name(dev), port, prop); - return ret; - } - - ret = regulator_get_by_platname(regname, ); - if (ret) { - debug("%s: ctrl '%s' port %d: could not get regulator '%s'\n", - __func__, dev_read_name(dev), port, regname); - return ret; - } - - regulator_set_enable(regulator, enable); - return 0; -#else - return -ENOTSUPP; -#endif -} - -void usb_hub_reset_devices(struct usb_hub_device *hub, int port) -{ - struct udevice *dev = hub->pusb_dev->dev; - struct udevice *ctrl; - - /* We are only interested in our root-hubs */ - if (usb_hub_is_root_hub(dev) == false) - return; - - ctrl = usb_get_bus(dev); - if (!ctrl) { - debug("%s: could not retrieve ctrl for hub\n", __func__); - return; - } - - /* -* To work around an incompatibility between the single-threaded -* USB stack in U-Boot and (a strange low-power mode of) the USB -* hub we have on-module, we need to delay powering on the hub -* until the first time the port is probed. -*/ - board_usb_port_power_set(ctrl, port, true); -} -- 2.25.1
[PATCH v2 5/8] rockchip: puma: reorganize devicetrees to actually work and match upstream
From: Heiko Stuebner So far the puma dts files only just included the main puma dtsi without handling the actual baseboard and rk3399-puma.dtsi was very much detached from the variant in the mainline Linux kernel. Recent changes resulted in a strange situation with nonworking puma boards. Commit ab800e5a6f28 ("arm: dts: rockchip: puma: move U-Boot specific bits to u-boot.dtsi") moved the sdram include from rk3399-puma-ddrX.dts to new files rk3399-puma-ddrx-u-boot.dtsi which were never included anywhere though. Commit 167efc2c7a46 ("arm64: dts: rk3399: Sync v5.7-rc1 from Linux") replaced the rk3399-puma.dtsi nearly completely, but in the kernel it definitly depends on a baseboard dts to actually enable peripherals like sd-slot, uarts, etc. So to untagle this and bring the whole thing more in line with mainline Linux, bring the rk3399-puma-haikou.dts over as well, drop the separate DDR-option devicetrees and instead replace them with a puma Kconfig option to select and include the needed DDR variant. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- arch/arm/dts/Makefile| 4 +- arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1333.dts | 8 - arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1600.dts | 9 - arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1866.dts | 8 - arch/arm/dts/rk3399-puma-haikou.dts | 272 +++ arch/arm/dts/rk3399-puma-u-boot.dtsi | 11 + board/theobroma-systems/puma_rk3399/Kconfig | 15 + configs/puma-rk3399_defconfig| 2 +- 11 files changed, 300 insertions(+), 41 deletions(-) delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333.dts delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600.dts delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866.dts create mode 100644 arch/arm/dts/rk3399-puma-haikou.dts diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index c6af87cf5e..a66bdb439d 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -130,9 +130,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3399) += \ rk3399-nanopi-neo4.dtb \ rk3399-orangepi.dtb \ rk3399-pinebook-pro.dtb \ - rk3399-puma-ddr1333.dtb \ - rk3399-puma-ddr1600.dtb \ - rk3399-puma-ddr1866.dtb \ + rk3399-puma-haikou.dtb \ rk3399-roc-pc.dtb \ rk3399-roc-pc-mezzanine.dtb \ rk3399-rock-pi-4.dtb \ diff --git a/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi deleted file mode 100644 index 39d3927f49..00 --- a/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi +++ /dev/null @@ -1,4 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ - -#include "rk3399-puma-u-boot.dtsi" -#include "rk3399-sdram-ddr3-1333.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1333.dts b/arch/arm/dts/rk3399-puma-ddr1333.dts deleted file mode 100644 index 80f27699f4..00 --- a/arch/arm/dts/rk3399-puma-ddr1333.dts +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ OR X11 -/* - * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH - */ - -/dts-v1/; - -#include "rk3399-puma.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi deleted file mode 100644 index be58311dc4..00 --- a/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi +++ /dev/null @@ -1,4 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ - -#include "rk3399-puma-u-boot.dtsi" -#include "rk3399-sdram-ddr3-1600.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1600.dts b/arch/arm/dts/rk3399-puma-ddr1600.dts deleted file mode 100644 index cb76b0165c..00 --- a/arch/arm/dts/rk3399-puma-ddr1600.dts +++ /dev/null @@ -1,9 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ OR X11 -/* - * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH - */ - -/dts-v1/; - -#include "rk3399-puma.dtsi" -#include "rk3399-u-boot.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi deleted file mode 100644 index 48da076329..00 --- a/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi +++ /dev/null @@ -1,4 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ - -#include "rk3399-puma-u-boot.dtsi" -#include "rk3399-sdram-ddr3-1866.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1866.dts b/arch/arm/dts/rk3399-puma-ddr1866.dts deleted file mode 100644 index 80f27699f4..00 --- a/arch/arm/dts/rk3399-puma-ddr1866.dts +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ OR X11 -/* - * (C) Copyright 2017 Theobroma System
[PATCH v2 0/8] revive Theobroma-Systems puma board
From: Heiko Stuebner This revives the puma boards and makes them boot again with mainline uboot. Main points may be going back to the general fit script and cleaning up the devicetree situation that got completely broken by the recent sync from mainline linux. changes in v2: - patch subject fixes (Kever) - make usb work again - remove usb regulator special handling Heiko Stuebner (8): arm64: dts: rk3399-puma: fix gpio levels for gmac reset pin arm64: dts: rk3399-puma: fix gpio levels for vcc5v0-host regulator rockchip: puma: fix indentation for -u-boot.dtsi rockchip: puma: fix indentation of misc_init_r rockchip: puma: reorganize devicetrees to actually work and match upstream rockchip: puma: remove separate fit generator rockchip: puma: drop special handling of usb host regulator rockchip: puma: enable new usb config options arch/arm/dts/Makefile | 4 +- arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1333.dts | 8 - arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1600.dts | 9 - arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1866.dts | 8 - arch/arm/dts/rk3399-puma-haikou.dts | 272 ++ arch/arm/dts/rk3399-puma-u-boot.dtsi | 43 +-- arch/arm/dts/rk3399-puma.dtsi | 4 +- board/theobroma-systems/puma_rk3399/Kconfig | 15 + .../puma_rk3399/fit_spl_atf.sh| 94 -- .../puma_rk3399/puma-rk3399.c | 93 +- configs/puma-rk3399_defconfig | 8 +- 14 files changed, 336 insertions(+), 234 deletions(-) delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333.dts delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600.dts delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866.dts create mode 100644 arch/arm/dts/rk3399-puma-haikou.dts delete mode 100755 board/theobroma-systems/puma_rk3399/fit_spl_atf.sh -- 2.25.1
[PATCH v2 4/8] rockchip: puma: fix indentation of misc_init_r
From: Heiko Stuebner The commit moving puma to the generic cpuid/macaddr helpers used 7 spaces as indentation, so correct that by moving to the required tabs. Fixes: fa177ff0208b ("board: puma: Use rockchip_* helpers to setup cpuid and macaddr") Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- .../puma_rk3399/puma-rk3399.c | 32 +-- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c index f7f08ae617..65bb2ad6f2 100644 --- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c +++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c @@ -114,22 +114,22 @@ static int setup_boottargets(void) int misc_init_r(void) { - const u32 cpuid_offset = 0x7; - const u32 cpuid_length = 0x10; - u8 cpuid[cpuid_length]; - int ret; - - ret = rockchip_cpuid_from_efuse(cpuid_offset, cpuid_length, cpuid); - if (ret) - return ret; - - ret = rockchip_cpuid_set(cpuid, cpuid_length); - if (ret) - return ret; - - ret = rockchip_setup_macaddr(); - if (ret) - return ret; + const u32 cpuid_offset = 0x7; + const u32 cpuid_length = 0x10; + u8 cpuid[cpuid_length]; + int ret; + + ret = rockchip_cpuid_from_efuse(cpuid_offset, cpuid_length, cpuid); + if (ret) + return ret; + + ret = rockchip_cpuid_set(cpuid, cpuid_length); + if (ret) + return ret; + + ret = rockchip_setup_macaddr(); + if (ret) + return ret; setup_iodomain(); setup_boottargets(); -- 2.25.1
[PATCH v2 6/8] rockchip: puma: remove separate fit generator
From: Heiko Stuebner The introduction of the puma-specific generator was mainly a way to split the pmu firmware from the ATF binary and not having to distribute that 4GB (sparse) image that was created before moving to the bl31.elf as base. Looking at the publically available repository for that separate pmu firmware https://git.theobroma-systems.com/rk3399-cortex-m0.git/ there is also no activity for 3 years and apart from some build customizations no other changes were done. And even then, if changes need to be made, this can very well also happen in the atf context itself, so there is no real need to diverge from the established build procedure and we can just go back to using the main make_fit_atf.py script. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- .../puma_rk3399/fit_spl_atf.sh| 94 --- configs/puma-rk3399_defconfig | 1 - 2 files changed, 95 deletions(-) delete mode 100755 board/theobroma-systems/puma_rk3399/fit_spl_atf.sh diff --git a/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh b/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh deleted file mode 100755 index c9396577a9..00 --- a/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh -# -# SPDX-License-Identifier: GPL-2.0+ -# -# Copyright (C) 2019 Jagan Teki -# -# Based on the board/sunxi/mksunxi_fit_atf.sh -# -# Script to generate FIT image source for 64-bit puma boards with -# U-Boot proper, ATF, PMU firmware and devicetree. -# -# usage: $0 [ [&2 - echo "Please read Building section in doc/README.rockchip" >&2 - BL31=/dev/null -fi - -[ -z "$PMUM0" ] && PMUM0="rk3399m0.bin" - -if [ ! -f $PMUM0 ]; then - echo "WARNING: PMUM0 file $PMUM0 NOT found, resulting binary is non-functional" >&2 - echo "Please read Building section in doc/README.rockchip" >&2 - PMUM0=/dev/null -fi - -cat << __HEADER_EOF -/* SPDX-License-Identifier: GPL-2.0+ OR X11 */ -/* - * Copyright (C) 2017 Theobroma Systems Design und Consulting GmbH - * - * Minimal dts for a SPL FIT image payload. - */ - -/dts-v1/; - -/ { - description = "FIT image with U-Boot proper, ATF bl31, M0 Firmware, DTB"; - #address-cells = <1>; - - images { - uboot { - description = "U-Boot (64-bit)"; - data = /incbin/("u-boot-nodtb.bin"); - type = "standalone"; - arch = "arm64"; - compression = "none"; - load = <0x4a00>; - }; - atf { - description = "ARM Trusted Firmware"; - data = /incbin/("$BL31"); - type = "firmware"; - arch = "arm64"; - os = "arm-trusted-firmware"; - compression = "none"; - load = <0x1000>; - entry = <0x1000>; - }; - pmu { - description = "Cortex-M0 firmware"; - data = /incbin/("$PMUM0"); - type = "pmu-firmware"; - compression = "none"; - load = <0x18>; -}; - fdt { - description = "RK3399-Q7 (Puma) flat device-tree"; - data = /incbin/("$1"); - type = "flat_dt"; - compression = "none"; - }; -__HEADER_EOF - -cat << __CONF_HEADER_EOF - }; - - configurations { - default = "conf"; - conf { - description = "Theobroma Systems RK3399-Q7 (Puma) SoM"; - firmware = "atf"; - loadables = "uboot", "pmu"; - fdt = "fdt"; - }; -__CONF_HEADER_EOF - -cat << __ITS_EOF - }; -}; -__ITS_EOF diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig index 47a60930b6..31d4eb3471 100644 --- a/configs/puma-rk3399_defconfig +++ b/configs/puma-rk3399_defconfig @@ -14,7 +14,6 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI_SUPPORT=y CONFIG_SPL_TEXT_BASE=0xff8c2000 CONFIG_DEBUG_UART=y -CONFIG_SPL_FIT_GENERATOR="board/theobroma-systems/puma_rk3399/fit_spl_atf.sh" CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-puma-haikou.dtb" CONFIG_MISC_INIT_R=y CONFIG_DISPLAY_BOARDINFO_LATE=y -- 2.25.1
[PATCH v2 3/8] rockchip: puma: fix indentation for -u-boot.dtsi
From: Heiko Stuebner Tabs not spaces, so transform it to the common styling. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- arch/arm/dts/rk3399-puma-u-boot.dtsi | 30 ++-- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/arm/dts/rk3399-puma-u-boot.dtsi b/arch/arm/dts/rk3399-puma-u-boot.dtsi index 3ad1139833..ddb5fa6e76 100644 --- a/arch/arm/dts/rk3399-puma-u-boot.dtsi +++ b/arch/arm/dts/rk3399-puma-u-boot.dtsi @@ -2,24 +2,24 @@ #include "rk3399-u-boot.dtsi" / { - config { - u-boot,spl-payload-offset = <0x4>; /* @ 256KB */ - u-boot,mmc-env-offset = <0x4000>; /* @ 16KB */ - u-boot,efi-partition-entries-offset = <0x20>; /* 2MB */ - u-boot,boot-led = "module_led"; - sysreset-gpio = < RK_PA6 GPIO_ACTIVE_HIGH>; - }; + config { + u-boot,spl-payload-offset = <0x4>; /* @ 256KB */ + u-boot,mmc-env-offset = <0x4000>; /* @ 16KB */ + u-boot,efi-partition-entries-offset = <0x20>; /* 2MB */ + u-boot,boot-led = "module_led"; + sysreset-gpio = < RK_PA6 GPIO_ACTIVE_HIGH>; + }; - chosen { - stdout-path = "serial0:115200n8"; - u-boot,spl-boot-order = \ + chosen { + stdout-path = "serial0:115200n8"; + u-boot,spl-boot-order = \ "same-as-spl", , , - }; + }; - aliases { - spi0 = - spi1 = - }; + aliases { + spi0 = + spi1 = + }; /* * The Qseven BIOS_DISABLE signal on the RK3399-Q7 keeps the on-module -- 2.25.1
[PATCH v2 2/8] arm64: dts: rk3399-puma: fix gpio levels for vcc5v0-host regulator
From: Heiko Stuebner The regulator enable-gpio uses opposite values for the declaration vs. the enable_active_low property, breaking the regulator enablement. Make the usbhost-supply work again by bringing them in sync again. This mimics the upstream Linux change found on: http://lore.kernel.org/r/20200604091239.424318-1-he...@sntech.de Signed-off-by: Heiko Stuebner --- arch/arm/dts/rk3399-puma.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/dts/rk3399-puma.dtsi b/arch/arm/dts/rk3399-puma.dtsi index 531520e771..72c06abd27 100644 --- a/arch/arm/dts/rk3399-puma.dtsi +++ b/arch/arm/dts/rk3399-puma.dtsi @@ -101,7 +101,7 @@ vcc5v0_host: vcc5v0-host-regulator { compatible = "regulator-fixed"; - gpio = < RK_PA3 GPIO_ACTIVE_HIGH>; + gpio = < RK_PA3 GPIO_ACTIVE_LOW>; enable-active-low; pinctrl-names = "default"; pinctrl-0 = <_host_en>; -- 2.25.1
[PATCH v2 8/8] rockchip: puma: enable new usb config options
From: Heiko Stuebner With recently added changes we get support for usb3 including handling of the phys (type-c and inno-usb2), so enable the necessary config options on puma. Signed-off-by: Heiko Stuebner --- configs/puma-rk3399_defconfig | 5 + 1 file changed, 5 insertions(+) diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig index 31d4eb3471..6b7d2ee6b8 100644 --- a/configs/puma-rk3399_defconfig +++ b/configs/puma-rk3399_defconfig @@ -59,6 +59,8 @@ CONFIG_PHY_MICREL_KSZ90X1=y CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_GMAC_ROCKCHIP=y +CONFIG_PHY_ROCKCHIP_INNO_USB2=y +CONFIG_PHY_ROCKCHIP_TYPEC=y CONFIG_DM_PMIC_FAN53555=y CONFIG_PMIC_RK8XX=y CONFIG_SPL_DM_REGULATOR=y @@ -67,6 +69,7 @@ CONFIG_SPL_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y CONFIG_REGULATOR_RK8XX=y CONFIG_PWM_ROCKCHIP=y +CONFIG_DM_RESET=y CONFIG_DM_RTC=y CONFIG_RTC_ISL1208=y CONFIG_DEBUG_UART_SHIFT=2 @@ -77,6 +80,8 @@ CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y +CONFIG_USB_DWC3=y +CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_HOST_ETHER=y CONFIG_USB_ETHER_ASIX=y CONFIG_USB_ETHER_ASIX88179=y -- 2.25.1
[PATCH 3/6] board: puma: reorganize devicetrees to actually work and match upstream
From: Heiko Stuebner So far the puma dts files only just included the main puma dtsi without handling the actual baseboard and rk3399-puma.dtsi was very much detached from the variant in the mainline Linux kernel. Recent changes resulted in a strange situation with nonworking puma boards. Commit ab800e5a6f28 ("arm: dts: rockchip: puma: move U-Boot specific bits to u-boot.dtsi") moved the sdram include from rk3399-puma-ddrX.dts to new files rk3399-puma-ddrx-u-boot.dtsi which were never included anywhere though. Commit 167efc2c7a46 ("arm64: dts: rk3399: Sync v5.7-rc1 from Linux") replaced the rk3399-puma.dtsi nearly completely, but in the kernel it definitly depends on a baseboard dts to actually enable peripherals like sd-slot, uarts, etc. So to untagle this and bring the whole thing more in line with mainline Linux, bring the rk3399-puma-haikou.dts over as well, drop the separate DDR-option devicetrees and instead replace them with a puma Kconfig option to select and include the needed DDR variant. Signed-off-by: Heiko Stuebner --- arch/arm/dts/Makefile| 4 +- arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1333.dts | 8 - arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1600.dts | 9 - arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1866.dts | 8 - arch/arm/dts/rk3399-puma-haikou.dts | 272 +++ arch/arm/dts/rk3399-puma-u-boot.dtsi | 11 + board/theobroma-systems/puma_rk3399/Kconfig | 15 + configs/puma-rk3399_defconfig| 2 +- 11 files changed, 300 insertions(+), 41 deletions(-) delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333.dts delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600.dts delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866.dts create mode 100644 arch/arm/dts/rk3399-puma-haikou.dts diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index c6af87cf5e..a66bdb439d 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -130,9 +130,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3399) += \ rk3399-nanopi-neo4.dtb \ rk3399-orangepi.dtb \ rk3399-pinebook-pro.dtb \ - rk3399-puma-ddr1333.dtb \ - rk3399-puma-ddr1600.dtb \ - rk3399-puma-ddr1866.dtb \ + rk3399-puma-haikou.dtb \ rk3399-roc-pc.dtb \ rk3399-roc-pc-mezzanine.dtb \ rk3399-rock-pi-4.dtb \ diff --git a/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi deleted file mode 100644 index 39d3927f49..00 --- a/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi +++ /dev/null @@ -1,4 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ - -#include "rk3399-puma-u-boot.dtsi" -#include "rk3399-sdram-ddr3-1333.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1333.dts b/arch/arm/dts/rk3399-puma-ddr1333.dts deleted file mode 100644 index 80f27699f4..00 --- a/arch/arm/dts/rk3399-puma-ddr1333.dts +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ OR X11 -/* - * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH - */ - -/dts-v1/; - -#include "rk3399-puma.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi deleted file mode 100644 index be58311dc4..00 --- a/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi +++ /dev/null @@ -1,4 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ - -#include "rk3399-puma-u-boot.dtsi" -#include "rk3399-sdram-ddr3-1600.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1600.dts b/arch/arm/dts/rk3399-puma-ddr1600.dts deleted file mode 100644 index cb76b0165c..00 --- a/arch/arm/dts/rk3399-puma-ddr1600.dts +++ /dev/null @@ -1,9 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ OR X11 -/* - * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH - */ - -/dts-v1/; - -#include "rk3399-puma.dtsi" -#include "rk3399-u-boot.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi deleted file mode 100644 index 48da076329..00 --- a/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi +++ /dev/null @@ -1,4 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ - -#include "rk3399-puma-u-boot.dtsi" -#include "rk3399-sdram-ddr3-1866.dtsi" diff --git a/arch/arm/dts/rk3399-puma-ddr1866.dts b/arch/arm/dts/rk3399-puma-ddr1866.dts deleted file mode 100644 index 80f27699f4..00 --- a/arch/arm/dts/rk3399-puma-ddr1866.dts +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ OR X11 -/* - * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH - *
[PATCH 6/6] board: puma: remove separate fit generator
From: Heiko Stuebner The introduction of the puma-specific generator was mainly a way to split the pmu firmware from the ATF binary and not having to distribute that 4GB (sparse) image that was created before moving to the bl31.elf as base. Looking at the publically available repository for that separate pmu firmware https://git.theobroma-systems.com/rk3399-cortex-m0.git/ there is also no activity for 3 years and apart from some build customizations no other changes were done. And even then, if changes need to be made, this can very well also happen in the atf context itself, so there is no real need to diverge from the established build procedure and we can just go back to using the main make_fit_atf.py script. Signed-off-by: Heiko Stuebner --- .../puma_rk3399/fit_spl_atf.sh| 94 --- configs/puma-rk3399_defconfig | 1 - 2 files changed, 95 deletions(-) delete mode 100755 board/theobroma-systems/puma_rk3399/fit_spl_atf.sh diff --git a/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh b/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh deleted file mode 100755 index c9396577a9..00 --- a/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh -# -# SPDX-License-Identifier: GPL-2.0+ -# -# Copyright (C) 2019 Jagan Teki -# -# Based on the board/sunxi/mksunxi_fit_atf.sh -# -# Script to generate FIT image source for 64-bit puma boards with -# U-Boot proper, ATF, PMU firmware and devicetree. -# -# usage: $0 [ [&2 - echo "Please read Building section in doc/README.rockchip" >&2 - BL31=/dev/null -fi - -[ -z "$PMUM0" ] && PMUM0="rk3399m0.bin" - -if [ ! -f $PMUM0 ]; then - echo "WARNING: PMUM0 file $PMUM0 NOT found, resulting binary is non-functional" >&2 - echo "Please read Building section in doc/README.rockchip" >&2 - PMUM0=/dev/null -fi - -cat << __HEADER_EOF -/* SPDX-License-Identifier: GPL-2.0+ OR X11 */ -/* - * Copyright (C) 2017 Theobroma Systems Design und Consulting GmbH - * - * Minimal dts for a SPL FIT image payload. - */ - -/dts-v1/; - -/ { - description = "FIT image with U-Boot proper, ATF bl31, M0 Firmware, DTB"; - #address-cells = <1>; - - images { - uboot { - description = "U-Boot (64-bit)"; - data = /incbin/("u-boot-nodtb.bin"); - type = "standalone"; - arch = "arm64"; - compression = "none"; - load = <0x4a00>; - }; - atf { - description = "ARM Trusted Firmware"; - data = /incbin/("$BL31"); - type = "firmware"; - arch = "arm64"; - os = "arm-trusted-firmware"; - compression = "none"; - load = <0x1000>; - entry = <0x1000>; - }; - pmu { - description = "Cortex-M0 firmware"; - data = /incbin/("$PMUM0"); - type = "pmu-firmware"; - compression = "none"; - load = <0x18>; -}; - fdt { - description = "RK3399-Q7 (Puma) flat device-tree"; - data = /incbin/("$1"); - type = "flat_dt"; - compression = "none"; - }; -__HEADER_EOF - -cat << __CONF_HEADER_EOF - }; - - configurations { - default = "conf"; - conf { - description = "Theobroma Systems RK3399-Q7 (Puma) SoM"; - firmware = "atf"; - loadables = "uboot", "pmu"; - fdt = "fdt"; - }; -__CONF_HEADER_EOF - -cat << __ITS_EOF - }; -}; -__ITS_EOF diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig index 47a60930b6..31d4eb3471 100644 --- a/configs/puma-rk3399_defconfig +++ b/configs/puma-rk3399_defconfig @@ -14,7 +14,6 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI_SUPPORT=y CONFIG_SPL_TEXT_BASE=0xff8c2000 CONFIG_DEBUG_UART=y -CONFIG_SPL_FIT_GENERATOR="board/theobroma-systems/puma_rk3399/fit_spl_atf.sh" CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-puma-haikou.dtb" CONFIG_MISC_INIT_R=y CONFIG_DISPLAY_BOARDINFO_LATE=y -- 2.25.1
[PATCH 0/6] revive Theobroma-Systems puma board
From: Heiko Stuebner This revives the puma boards and makes them boot again with mainline uboot. Main points may be going back to the general fit script and cleaning up the devicetree situation that got completely broken by the recent sync from mainline linux. Heiko Stuebner (6): arm64: dts: rk3399-puma: fix gpio levels for gmac reset pin board: puma: fix indentation for -u-boot.dtsi board: puma: reorganize devicetrees to actually work and match upstream board: puma: fix indentation of misc_init_r board: puma: allow building with TPL as well board: puma: remove separate fit generator arch/arm/dts/Makefile | 4 +- arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1333.dts | 8 - arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1600.dts | 9 - arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi | 4 - arch/arm/dts/rk3399-puma-ddr1866.dts | 8 - arch/arm/dts/rk3399-puma-haikou.dts | 272 ++ arch/arm/dts/rk3399-puma-u-boot.dtsi | 43 +-- arch/arm/dts/rk3399-puma.dtsi | 2 +- board/theobroma-systems/puma_rk3399/Kconfig | 15 + .../puma_rk3399/fit_spl_atf.sh| 94 -- .../puma_rk3399/puma-rk3399.c | 30 +- configs/puma-rk3399_defconfig | 3 +- 14 files changed, 334 insertions(+), 166 deletions(-) delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333.dts delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600.dts delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866.dts create mode 100644 arch/arm/dts/rk3399-puma-haikou.dts delete mode 100755 board/theobroma-systems/puma_rk3399/fit_spl_atf.sh -- 2.25.1
[PATCH 1/6] arm64: dts: rk3399-puma: fix gpio levels for gmac reset pin
From: Heiko Stuebner The gmac reset has opposite values for the gpio declaration and the separate reset-active, bring this in line to make u-boot also find the ethernet-phy. This mimics the upstream Linus commit found on https://lore.kernel.org/r/20200603132836.362519-1-he...@sntech.de Signed-off-by: Heiko Stuebner --- arch/arm/dts/rk3399-puma.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/dts/rk3399-puma.dtsi b/arch/arm/dts/rk3399-puma.dtsi index 07694b196f..531520e771 100644 --- a/arch/arm/dts/rk3399-puma.dtsi +++ b/arch/arm/dts/rk3399-puma.dtsi @@ -157,7 +157,7 @@ phy-mode = "rgmii"; pinctrl-names = "default"; pinctrl-0 = <_pins>; - snps,reset-gpio = < RK_PC0 GPIO_ACTIVE_HIGH>; + snps,reset-gpio = < RK_PC0 GPIO_ACTIVE_LOW>; snps,reset-active-low; snps,reset-delays-us = <0 1 5>; tx_delay = <0x10>; -- 2.25.1
[PATCH 5/6] board: puma: allow building with TPL as well
From: Heiko Stuebner Right now puma-u-boot can fit everything into SPL but that may overflow easily for example with more extensive debug options. By adding CONFIG_TPL and removing the CONFIG_SPL_TEXT_BASE it is easy to enable a TPL build as well. Only obstacle is the usb-specific handling for the puma regulator, so make this conditional on actual usb options being enabled in SPL and U-Boot proper. Signed-off-by: Heiko Stuebner --- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 4 1 file changed, 4 insertions(+) diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c index 65bb2ad6f2..31ac27c6f5 100644 --- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c +++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c @@ -153,6 +153,9 @@ void get_board_serial(struct tag_serialnr *serialnr) } #endif +#if !defined(CONFIG_TPL_BUILD) && \ +(defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_USB_HOST_SUPPORT)) || \ +(!defined(CONFIG_SPL_BUILD) && defined(CONFIG_USB)) /** * Switch power at an external regulator (for our root hub). * @@ -219,3 +222,4 @@ void usb_hub_reset_devices(struct usb_hub_device *hub, int port) */ board_usb_port_power_set(ctrl, port, true); } +#endif -- 2.25.1
[PATCH 2/6] board: puma: fix indentation for -u-boot.dtsi
From: Heiko Stuebner Tabs not spaces, so transform it to the common styling. Signed-off-by: Heiko Stuebner --- arch/arm/dts/rk3399-puma-u-boot.dtsi | 30 ++-- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/arm/dts/rk3399-puma-u-boot.dtsi b/arch/arm/dts/rk3399-puma-u-boot.dtsi index 3ad1139833..ddb5fa6e76 100644 --- a/arch/arm/dts/rk3399-puma-u-boot.dtsi +++ b/arch/arm/dts/rk3399-puma-u-boot.dtsi @@ -2,24 +2,24 @@ #include "rk3399-u-boot.dtsi" / { - config { - u-boot,spl-payload-offset = <0x4>; /* @ 256KB */ - u-boot,mmc-env-offset = <0x4000>; /* @ 16KB */ - u-boot,efi-partition-entries-offset = <0x20>; /* 2MB */ - u-boot,boot-led = "module_led"; - sysreset-gpio = < RK_PA6 GPIO_ACTIVE_HIGH>; - }; + config { + u-boot,spl-payload-offset = <0x4>; /* @ 256KB */ + u-boot,mmc-env-offset = <0x4000>; /* @ 16KB */ + u-boot,efi-partition-entries-offset = <0x20>; /* 2MB */ + u-boot,boot-led = "module_led"; + sysreset-gpio = < RK_PA6 GPIO_ACTIVE_HIGH>; + }; - chosen { - stdout-path = "serial0:115200n8"; - u-boot,spl-boot-order = \ + chosen { + stdout-path = "serial0:115200n8"; + u-boot,spl-boot-order = \ "same-as-spl", , , - }; + }; - aliases { - spi0 = - spi1 = - }; + aliases { + spi0 = + spi1 = + }; /* * The Qseven BIOS_DISABLE signal on the RK3399-Q7 keeps the on-module -- 2.25.1
[PATCH 4/6] board: puma: fix indentation of misc_init_r
From: Heiko Stuebner The commit moving puma to the generic cpuid/macaddr helpers used 7 spaces as indentation, so correct that by moving to the required tabs. Fixes: fa177ff0208b ("board: puma: Use rockchip_* helpers to setup cpuid and macaddr") Signed-off-by: Heiko Stuebner --- .../puma_rk3399/puma-rk3399.c | 32 +-- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c index f7f08ae617..65bb2ad6f2 100644 --- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c +++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c @@ -114,22 +114,22 @@ static int setup_boottargets(void) int misc_init_r(void) { - const u32 cpuid_offset = 0x7; - const u32 cpuid_length = 0x10; - u8 cpuid[cpuid_length]; - int ret; - - ret = rockchip_cpuid_from_efuse(cpuid_offset, cpuid_length, cpuid); - if (ret) - return ret; - - ret = rockchip_cpuid_set(cpuid, cpuid_length); - if (ret) - return ret; - - ret = rockchip_setup_macaddr(); - if (ret) - return ret; + const u32 cpuid_offset = 0x7; + const u32 cpuid_length = 0x10; + u8 cpuid[cpuid_length]; + int ret; + + ret = rockchip_cpuid_from_efuse(cpuid_offset, cpuid_length, cpuid); + if (ret) + return ret; + + ret = rockchip_cpuid_set(cpuid, cpuid_length); + if (ret) + return ret; + + ret = rockchip_setup_macaddr(); + if (ret) + return ret; setup_iodomain(); setup_boottargets(); -- 2.25.1
Re: [PATCH v6 13/16] driver: usb: drop legacy rockchip xhci driver
Am Dienstag, 26. Mai 2020, 05:34:32 CEST schrieb Frank Wang: > We have changed to use dwc3 generic driver for usb3.0 host, so the > legacy Rockchip's xHCI driver is not needed, and drop it. > > Signed-off-by: Frank Wang > Reviewed-by: Jagan Teki > Reviewed-by: Kever Yang this needs to be adapted for commit f7ae49fc4f36 ("common: Drop log.h from common header") which added a #include to xhci-rockchip.c Heiko
[PATCH v3 3/5] spl: fit: enable signing a generated u-boot.itb
From: Heiko Stuebner With SPL_FIT_SIGNATURE enabled we will likely want a generated u-boot.itb to be signed and the key stores so that the spl can reach it. So add a SPL_FIT_SIGNATURE_KEY_DIR option and suitable hooks into the Makefile to have mkimage sign the .itb and store the used key into the spl dtb file. The added dependencies should make sure that the u-boot.itb gets generated before the spl-binary gets build, so that there is the necessary space for the key to get included. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- changes in v2.1: - depend on $(CONFIG_SPL_FIT_SIGNATURE)$(U_BOOT_ITS) instead of only $(CONFIG_SPL_FIT_GENERATOR) Kconfig | 8 Makefile | 11 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Kconfig b/Kconfig index 0c184f7f06..bab7c4f3ee 100644 --- a/Kconfig +++ b/Kconfig @@ -465,6 +465,14 @@ config SPL_FIT_SIGNATURE select SPL_RSA_VERIFY select SPL_IMAGE_SIGN_INFO +config SPL_FIT_SIGNATURE_KEY_DIR + string "key directory for signing U-Boot FIT image" + depends on SPL_FIT_SIGNATURE + default "keys" + help + The directory to give to mkimage to retrieve keys from when + generating a signed U-Boot FIT image. + config SPL_LOAD_FIT bool "Enable SPL loading U-Boot as a FIT (basic fitImage features)" select SPL_FIT diff --git a/Makefile b/Makefile index 463fa72e3f..b8f7536940 100644 --- a/Makefile +++ b/Makefile @@ -1407,6 +1407,14 @@ MKIMAGEFLAGS_u-boot.itb = else MKIMAGEFLAGS_u-boot.itb = -E endif +ifdef CONFIG_SPL_FIT_SIGNATURE +ifdef CONFIG_SPL_OF_CONTROL +MKIMAGEFLAGS_u-boot.itb += -K dts/dt-spl.dtb -r +ifneq ($(CONFIG_SPL_FIT_SIGNATURE_KEY_DIR),"") +MKIMAGEFLAGS_u-boot.itb += -k $(CONFIG_SPL_FIT_SIGNATURE_KEY_DIR) +endif +endif +endif u-boot.itb: u-boot-nodtb.bin \ $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_OF_HOSTFILE),dts/dt.dtb) \ @@ -1929,7 +1937,8 @@ spl/u-boot-spl.bin: spl/u-boot-spl spl/u-boot-spl: tools prepare \ $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb) \ - $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_TPL_OF_PLATDATA),dts/dt.dtb) + $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_TPL_OF_PLATDATA),dts/dt.dtb) \ + $(if $(CONFIG_SPL_FIT_SIGNATURE)$(U_BOOT_ITS),u-boot.itb FORCE) $(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all spl/sunxi-spl.bin: spl/u-boot-spl -- 2.25.1
[PATCH v3 1/5] imx: mkimage_fit_atf: Fix FIT image if BL31.bin missing
From: Heiko Stuebner Right now if its bl31.bin is missing, the imx make_fit_atf.sh does return "sucessful" without generating an .its source file, which makes autobuilders unhappy. So this change is similar to Tom Rini's commit 4c78028737c3 ("mksunxi_fit_atf.sh: Allow for this to complete when bl31.bin is missing") in that it changes the behaviour to a warning and still lets the script generate a usable u-boot.its and thus also lets the u-boot.itb get build successfully Cc: Stefano Babic Cc: Fabio Estevam Cc: uboot-...@nxp.com Signed-off-by: Heiko Stuebner --- changes in v3: - new patch arch/arm/mach-imx/mkimage_fit_atf.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/mkimage_fit_atf.sh b/arch/arm/mach-imx/mkimage_fit_atf.sh index dd1ca5ad3f..2224d85281 100755 --- a/arch/arm/mach-imx/mkimage_fit_atf.sh +++ b/arch/arm/mach-imx/mkimage_fit_atf.sh @@ -12,8 +12,8 @@ [ -z "$BL33_LOAD_ADDR" ] && BL33_LOAD_ADDR="0x4020" if [ ! -f $BL31 ]; then - echo "ERROR: BL31 file $BL31 NOT found" >&2 - exit 0 + echo "WARNING: BL31 file $BL31 NOT found, resulting binary is not-functional" >&2 + BL31=/dev/null else echo "$BL31 size: " >&2 ls -lct $BL31 | awk '{print $5}' >&2 -- 2.25.1
[PATCH v3 4/5] spl: fit: add Kconfig option to specify key-hint for fit_generator
From: Heiko Stuebner The u-boot.itb can be generated either from a static .its that can simply include the needed signature nodes with key-hints or from a fit-generator script referenced in CONFIG_SPL_FIT_GENERATOR. In the script-case it will need to know what key to include for the key-hint and specified algorithm, so add an option for that key-name. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich Reviewed-by: Simon Glass Reviewed-by: Kever Yang --- changes in v2: - add doc snippet explaining the option Kconfig | 8 doc/uImage.FIT/howto.txt | 13 + 2 files changed, 21 insertions(+) diff --git a/Kconfig b/Kconfig index bab7c4f3ee..6a9bf8d865 100644 --- a/Kconfig +++ b/Kconfig @@ -548,6 +548,14 @@ config SPL_FIT_GENERATOR passed a list of supported device tree file stub names to include in the generated image. +config SPL_FIT_GENERATOR_KEY_HINT + string "key hint for signing U-Boot FIT image" + depends on SPL_FIT_SIGNATURE + default "dev" + help + The key hint to store in both the generated .its file as well as + u-boot-key.dtb generated separately and embedded into the SPL. + endif # SPL endif # FIT diff --git a/doc/uImage.FIT/howto.txt b/doc/uImage.FIT/howto.txt index 8592719685..f409b3770e 100644 --- a/doc/uImage.FIT/howto.txt +++ b/doc/uImage.FIT/howto.txt @@ -66,6 +66,19 @@ can point to a script which generates this image source file during the build process. It gets passed a list of device tree files (taken from the CONFIG_OF_LIST symbol). +Signing u-boot.itb with SPL_FIT_GENERATOR +- + +u-boot.itb can be signed to verify the integrity of its components. +When CONFIG_SPL_FIT_SIGNATURE is enabled the CONFIG_SPL_FIT_SIGNATURE_KEY_DIR +option can be used to specifiy the key directory - either a relative or +absolute path. + +See signature.txt for general signature handling, but when +CONFIG_SPL_FIT_GENERATOR is used the option CONFIG_SPL_FIT_GENERATOR_KEY_HINT +can be used to specify the key-hint that should be included into the +created u-boot.its by the generator. + Example 1 -- old-style (non-FDT) kernel booting --- -- 2.25.1
[PATCH v3 0/5] rockchip: make it possible to sign the u-boot.itb
From: Heiko Stuebner This series makes it possible to sign a generated u-boot.itb automatically even if the its-source got created by a generator script. To let the SPL know about the key, the -K option for mkimage points to the dts/dt-spl.dtb which can then get included into the spl binary. Tested on Rockchip PX30 with a TPL -> SPL -> U-Boot.itb bootchain. I've split out the the rsa/crypto fixes into a separate series starting at [0]. [0] https://patchwork.ozlabs.org/project/uboot/patch/20200522141937.3523692-1-he...@sntech.de/ changes in v3: - add patch to fix imx make_fit_atf.sh error handling - split out rsa fixes into separate series changes in v2.1: - depend on $(CONFIG_SPL_FIT_SIGNATURE)$(U_BOOT_ITS) instead of only $(CONFIG_SPL_FIT_GENERATOR) changes in v2: - add received reviews - fix commit message typo - add doc snippet explaining CONFIG_SPL_FIT_GENERATOR_KEY_HINT Heiko Stuebner (5): imx: mkimage_fit_atf: Fix FIT image if BL31.bin missing mkimage: fit_image: handle multiple errors when writing signatures spl: fit: enable signing a generated u-boot.itb spl: fit: add Kconfig option to specify key-hint for fit_generator rockchip: make_fit_atf: add signature handling Kconfig| 16 Makefile | 11 +- arch/arm/mach-imx/mkimage_fit_atf.sh | 4 +- arch/arm/mach-rockchip/make_fit_atf.py | 51 +- doc/uImage.FIT/howto.txt | 13 +++ tools/image-host.c | 2 +- 6 files changed, 92 insertions(+), 5 deletions(-) -- 2.25.1
[PATCH v3 5/5] rockchip: make_fit_atf: add signature handling
From: Heiko Stuebner If the newly added fit-generator key-options are found, append needed signature nodes to all generated image blocks, so that they can get signed when mkimage later compiles the .itb from the generated .its. Signed-off-by: Heiko Stuebner Reviewed-by: Kever Yang --- arch/arm/mach-rockchip/make_fit_atf.py | 51 +- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-rockchip/make_fit_atf.py b/arch/arm/mach-rockchip/make_fit_atf.py index d15c32b303..5b353f9d0a 100755 --- a/arch/arm/mach-rockchip/make_fit_atf.py +++ b/arch/arm/mach-rockchip/make_fit_atf.py @@ -14,6 +14,8 @@ import sys import getopt import logging import struct +import Crypto +from Crypto.PublicKey import RSA DT_HEADER = """ /* @@ -37,7 +39,9 @@ DT_UBOOT = """ arch = "arm64"; compression = "none"; load = <0x%08x>; - }; +""" + +DT_UBOOT_NODE_END = """}; """ @@ -47,6 +51,46 @@ DT_IMAGES_NODE_END = """ }; DT_END = "};" +def append_signature(file): +if not os.path.exists("u-boot.cfg"): +return + +config = {} +with open("u-boot.cfg") as fd: +for line in fd: +line = line.strip() +values = line[8:].split(' ', 1) +if len(values) > 1: +key, value = values +value = value.strip('"') +else: +key = values[0] +value = '1' +if not key.startswith('CONFIG_'): +continue +config[key] = value + +try: +keyhint = config["CONFIG_SPL_FIT_GENERATOR_KEY_HINT"] +except KeyError: +return + +try: +keyfile = os.path.join(config["CONFIG_SPL_FIT_SIGNATURE_KEY_DIR"], keyhint) +except KeyError: +keyfile = keyhint + +if not os.path.exists('%s.key' % keyfile): +return + +f = open('%s.key' % keyfile,'r') +key = RSA.importKey(f.read()) + +file.write('\t\t\tsignature {\n') +file.write('\t\t\t\talgo = "sha256,rsa%s";\n' % key.n.bit_length()) +file.write('\t\t\t\tkey-name-hint = "%s";\n' % keyhint) +file.write('\t\t\t};\n') + def append_bl31_node(file, atf_index, phy_addr, elf_entry): # Append BL31 DT node to input FIT dts file. data = 'bl31_0x%08x.bin' % phy_addr @@ -60,6 +104,7 @@ def append_bl31_node(file, atf_index, phy_addr, elf_entry): file.write('\t\t\tload = <0x%08x>;\n' % phy_addr) if atf_index == 1: file.write('\t\t\tentry = <0x%08x>;\n' % elf_entry) +append_signature(file); file.write('\t\t};\n') file.write('\n') @@ -75,6 +120,7 @@ def append_tee_node(file, atf_index, phy_addr, elf_entry): file.write('\t\t\tcompression = "none";\n') file.write('\t\t\tload = <0x%08x>;\n' % phy_addr) file.write('\t\t\tentry = <0x%08x>;\n' % elf_entry) +append_signature(file); file.write('\t\t};\n') file.write('\n') @@ -88,6 +134,7 @@ def append_fdt_node(file, dtbs): file.write('\t\t\tdata = /incbin/("%s");\n' % dtb) file.write('\t\t\ttype = "flat_dt";\n') file.write('\t\t\tcompression = "none";\n') +append_signature(file); file.write('\t\t};\n') file.write('\n') cnt = cnt + 1 @@ -129,6 +176,8 @@ def generate_atf_fit_dts_uboot(fit_file, uboot_file_name): raise ValueError("Invalid u-boot ELF image '%s'" % uboot_file_name) index, entry, p_paddr, data = segments[0] fit_file.write(DT_UBOOT % p_paddr) +append_signature(fit_file) +fit_file.write(DT_UBOOT_NODE_END) def generate_atf_fit_dts_bl31(fit_file, bl31_file_name, tee_file_name, dtbs_file_name): segments = unpack_elf(bl31_file_name) -- 2.25.1
[PATCH v3 2/5] mkimage: fit_image: handle multiple errors when writing signatures
From: Heiko Stuebner fit_image_write_sig() contains mostly functions from libfdt that return FDT_ERR_foo errors but also a call to fit_set_timestamp() which returns a regular error. When handling the size increase via multiple iterations, check for both -FDT_ERR_NOSPACE but also for -ENOSPC. There is no real conflict, as FDT_ERR_NOSPACE = 3 = ESRCH (No such process) and ENOSPC = 28 which is above any FDT_ERR_*. Signed-off-by: Heiko Stuebner Reviewed-by: Simon Glass Reviewed-by: Kever Yang --- tools/image-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/image-host.c b/tools/image-host.c index 9a83b7f675..baf9590f3b 100644 --- a/tools/image-host.c +++ b/tools/image-host.c @@ -241,7 +241,7 @@ static int fit_image_process_sig(const char *keydir, void *keydest, ret = fit_image_write_sig(fit, noffset, value, value_len, comment, NULL, 0, cmdname); if (ret) { - if (ret == -FDT_ERR_NOSPACE) + if (ret == -FDT_ERR_NOSPACE || ret == -ENOSPC) return -ENOSPC; printf("Can't write signature for '%s' signature node in '%s' conf node: %s\n", node_name, image_name, fdt_strerror(ret)); -- 2.25.1
[PATCH v2 2/2] spl: add fixed memory node in target fdt also when loading ATF
From: Heiko Stuebner In a loading chain SPL -> ATF (->OP-TEE) -> U-Boot, ATF and a subsequent OP-TEE will re-use the same fdt as the U-Boot target and may need the information about usable memory ranges. Especially OP-TEE needs this to initialize dynamic shared memory (the only type U-Boot implements when talking to OP-TEE). So allow spl_fixup_fdt() to take a fdt_blob argument, falling back to the existing CONFIG_SYS_SPL_ARGS_ADDR if needed and call it from the ATF path as well. Signed-off-by: Heiko Stuebner Reviewed-by: Kever Yang --- changes in v2: - dropped changeid - added Kever's review common/spl/spl.c | 19 +-- 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index b0f0e1557b..90d8bfd058 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -58,7 +58,8 @@ static bd_t bdata __attribute__ ((section(".data"))); */ __weak void show_boot_progress(int val) {} -#if defined(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF) +#if defined(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF) || \ +defined(CONFIG_SPL_ATF) /* weak, default platform-specific function to initialize dram banks */ __weak int dram_init_banksize(void) { @@ -100,12 +101,14 @@ void __weak spl_perform_fixups(struct spl_image_info *spl_image) { } -void spl_fixup_fdt(void) +void spl_fixup_fdt(void *fdt_blob) { -#if defined(CONFIG_SPL_OF_LIBFDT) && defined(CONFIG_SYS_SPL_ARGS_ADDR) - void *fdt_blob = (void *)CONFIG_SYS_SPL_ARGS_ADDR; +#if defined(CONFIG_SPL_OF_LIBFDT) int err; + if (!fdt_blob) + return; + err = fdt_check_header(fdt_blob); if (err < 0) { printf("fdt_root: %s\n", fdt_strerror(err)); @@ -638,7 +641,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2) initr_watchdog(); #endif - if (IS_ENABLED(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF)) + if (IS_ENABLED(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF) || + IS_ENABLED(CONFIG_SPL_ATF)) dram_init_banksize(); bootcount_inc(); @@ -680,6 +684,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) #if CONFIG_IS_ENABLED(ATF) case IH_OS_ARM_TRUSTED_FIRMWARE: debug("Jumping to U-Boot via ARM Trusted Firmware\n"); + spl_fixup_fdt(spl_image.fdt_addr); spl_invoke_atf(_image); break; #endif @@ -699,7 +704,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2) #ifdef CONFIG_SPL_OS_BOOT case IH_OS_LINUX: debug("Jumping to Linux\n"); - spl_fixup_fdt(); +#if defined(CONFIG_SYS_SPL_ARGS_ADDR) + spl_fixup_fdt((void *)CONFIG_SYS_SPL_ARGS_ADDR); +#endif spl_board_prepare_for_linux(); jump_to_image_linux(_image); #endif -- 2.25.1
[PATCH v2 1/2] rockchip: spl: do full dram_init instead of only probing
From: Heiko Stuebner Parts of later SPL may need RAM information as well, so do full dram_init() call, which includes the existing dram probing but also initializes the ram information in gd. dram_init() from sdram.c does the following steps: - uclass_get_device(UCLASS_RAM, ...) like the current code - ret = ram_get_info(dev, ); - gd->ram_size = ram.size; CONFIG_SPL_RAM already makes sure that sdram.c gets compiled and thus no other variant of dram_init() can exist. So it's the same functionality as before and only adds that the SPL now aquires knowledge about the amount of available ram, which it didn't know about before. Signed-off-by: Heiko Stuebner --- changes in v2: - dropped changeid - expanded commit message on how this does not change functionality arch/arm/mach-rockchip/spl.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c index 0b76af6080..0eda2c3485 100644 --- a/arch/arm/mach-rockchip/spl.c +++ b/arch/arm/mach-rockchip/spl.c @@ -135,13 +135,15 @@ void board_init_f(ulong dummy) /* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */ timer_init(); #endif -#if !defined(CONFIG_TPL) || defined(CONFIG_SPL_OS_BOOT) +#if !defined(CONFIG_TPL) || defined(CONFIG_SPL_RAM) debug("\nspl:init dram\n"); - ret = uclass_get_device(UCLASS_RAM, 0, ); + ret = dram_init(); if (ret) { printf("DRAM init failed: %d\n", ret); return; } + gd->ram_top = gd->ram_base + get_effective_memsize(); + gd->ram_top = board_get_usable_ram_top(gd->ram_size); #endif preloader_console_init(); } -- 2.25.1
[PATCH] lib: rsa: function to verify a signature against a hash
From: Heiko Stuebner rsa_verify() expects a memory region and wants to do the hashing itself, but there may be cases where the hashing is done via other means, like hashing a squashfs rootfs. So add rsa_verify_hash() to allow verifiying a signature against an existing hash. As this entails the same verification routines we can just move the relevant code over from rsa_verify() and also call rsa_verify_hash() from there. Signed-off-by: Heiko Stuebner --- Patch depends on at least lib: rsa: take spl/non-spl into account when building rsa_verify_with_pkey() include/u-boot/rsa.h | 21 + lib/rsa/rsa-verify.c | 56 +--- 2 files changed, 53 insertions(+), 24 deletions(-) diff --git a/include/u-boot/rsa.h b/include/u-boot/rsa.h index 2d3024d8b7..a0bae495f0 100644 --- a/include/u-boot/rsa.h +++ b/include/u-boot/rsa.h @@ -82,6 +82,20 @@ static inline int rsa_add_verify_data(struct image_sign_info *info, #endif #if IMAGE_ENABLE_VERIFY +/** + * rsa_verify_hash() - Verify a signature against a hash + * + * Verify a RSA PKCS1.5 signature against an expected hash. + * + * @info: Specifies key and FIT information + * @hash: Hash according to algorithm specified in @info + * @sig: Signature + * @sig_len: Number of bytes in signature + * @return 0 if verified, -ve on error + */ +int rsa_verify_hash(struct image_sign_info *info, + const uint8_t *hash, uint8_t *sig, uint sig_len); + /** * rsa_verify() - Verify a signature against some data * @@ -108,6 +122,13 @@ int padding_pss_verify(struct image_sign_info *info, const uint8_t *hash, int hash_len); #endif /* CONFIG_FIT_ENABLE_RSASSA_PSS_SUPPORT */ #else +static inline int rsa_verify_hash(struct image_sign_info *info, + const uint8_t *hash, + uint8_t *sig, uint sig_len) +{ + return -ENXIO; +} + static inline int rsa_verify(struct image_sign_info *info, const struct image_region region[], int region_count, uint8_t *sig, uint sig_len) diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 61d98e6e2d..6c4bbc4625 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -478,33 +478,11 @@ static int rsa_verify_with_keynode(struct image_sign_info *info, } #endif -int rsa_verify(struct image_sign_info *info, - const struct image_region region[], int region_count, - uint8_t *sig, uint sig_len) +int rsa_verify_hash(struct image_sign_info *info, + const uint8_t *hash, uint8_t *sig, uint sig_len) { - /* Reserve memory for maximum checksum-length */ - uint8_t hash[info->crypto->key_len]; int ret = -EACCES; - /* -* Verify that the checksum-length does not exceed the -* rsa-signature-length -*/ - if (info->checksum->checksum_len > - info->crypto->key_len) { - debug("%s: invlaid checksum-algorithm %s for %s\n", - __func__, info->checksum->name, info->crypto->name); - return -EINVAL; - } - - /* Calculate checksum with checksum-algorithm */ - ret = info->checksum->calculate(info->checksum->name, - region, region_count, hash); - if (ret < 0) { - debug("%s: Error in checksum calculation\n", __func__); - return -EINVAL; - } - if (CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) && !info->fdt_blob) { /* don't rely on fdt properties */ ret = rsa_verify_with_pkey(info, hash, sig, sig_len); @@ -555,3 +533,33 @@ int rsa_verify(struct image_sign_info *info, return ret; } + +int rsa_verify(struct image_sign_info *info, + const struct image_region region[], int region_count, + uint8_t *sig, uint sig_len) +{ + /* Reserve memory for maximum checksum-length */ + uint8_t hash[info->crypto->key_len]; + int ret = -EACCES; + + /* +* Verify that the checksum-length does not exceed the +* rsa-signature-length +*/ + if (info->checksum->checksum_len > + info->crypto->key_len) { + debug("%s: invlaid checksum-algorithm %s for %s\n", + __func__, info->checksum->name, info->crypto->name); + return -EINVAL; + } + + /* Calculate checksum with checksum-algorithm */ + ret = info->checksum->calculate(info->checksum->name, + region, region_count, hash); + if (ret < 0) { + debug("%s: Error in checksum calculation\n", __func__); + return -EINVAL; + } + + return rsa_verify_hash(info, hash, sig, sig_len); +} -- 2.25.1
[PATCH v5 7/8] spl: fit: select SPL_HASH_SUPPORT for SPL_FIT_SIGNATURE
From: Heiko Stuebner rsa-checsum needs support for hash functions or else will run into compile errors like: u-boot/lib/rsa/rsa-checksum.c:28: undefined reference to `hash_progressive_lookup_algo' So similar to the main FIT_SIGNATURE entry selects HASH, select SPL_HASH_SUPPORT for SPL_FIT_SIGNATURE. Cc: Heinrich Schuchardt Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/Kconfig b/Kconfig index 0e7ccc0b07..482f39c66f 100644 --- a/Kconfig +++ b/Kconfig @@ -459,6 +459,7 @@ config SPL_FIT_SIGNATURE bool "Enable signature verification of FIT firmware within SPL" depends on SPL_DM select SPL_FIT + select SPL_HASH_SUPPORT select SPL_RSA select SPL_RSA_VERIFY select SPL_IMAGE_SIGN_INFO -- 2.25.1
[PATCH v5 8/8] spl: fit: select SPL_CRYPTO_SUPPORT for SPL_FIT_SIGNATURE
From: Heiko Stuebner Verifying FIT images obviously needs the rsa parts of crypto support and while main uboot always compiles crypto support, it's optional for SPL and we should thus select the necessary option to not end up in compile errors like: u-boot/lib/rsa/rsa-verify.c:328: undefined reference to `rsa_mod_exp' So select SPL_CRYPTO_SUPPORT in SPL_FIT_SIGNATURE. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/Kconfig b/Kconfig index 482f39c66f..0c184f7f06 100644 --- a/Kconfig +++ b/Kconfig @@ -459,6 +459,7 @@ config SPL_FIT_SIGNATURE bool "Enable signature verification of FIT firmware within SPL" depends on SPL_DM select SPL_FIT + select SPL_CRYPTO_SUPPORT select SPL_HASH_SUPPORT select SPL_RSA select SPL_RSA_VERIFY -- 2.25.1
[PATCH v5 4/8] lib: rsa: fix allocated size for rr and rrtmp in rsa_gen_key_prop()
From: Heiko Stuebner When calculating rrtmp/rr rsa_gen_key_prop() tries to make (((rlen + 31) >> 5) + 1) steps in the rr uint32_t array and (((rlen + 7) >> 3) + 1) / 4 steps in uint32_t rrtmp[] with rlen being num_bits * 2 On a 4096bit key this comes down to to 257 uint32_t elements in rr and 256 elements in rrtmp but with the current allocation rr and rrtmp only have 129 uint32_t elements. On 2048bit keys this works by chance as the defined max_rsa_size=4096 allocates a suitable number of elements, but with an actual 4096bit key this results in other memory parts getting overwritten. so double the number of elements in rr and rrtmp so that it matches the needed number and should increase nicely if max_rsa_size gets increased in the future. Signed-off-by: Heiko Stuebner --- changes in v4: - new patch lib/rsa/rsa-keyprop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rsa/rsa-keyprop.c b/lib/rsa/rsa-keyprop.c index 4b54db44c4..e28fbb7472 100644 --- a/lib/rsa/rsa-keyprop.c +++ b/lib/rsa/rsa-keyprop.c @@ -659,8 +659,8 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) *prop = calloc(sizeof(**prop), 1); n = calloc(sizeof(uint32_t), 1 + (max_rsa_size >> 5)); - rr = calloc(sizeof(uint32_t), 1 + (max_rsa_size >> 5)); - rrtmp = calloc(sizeof(uint32_t), 1 + (max_rsa_size >> 5)); + rr = calloc(sizeof(uint32_t), 1 + ((max_rsa_size * 2) >> 5)); + rrtmp = calloc(sizeof(uint32_t), 1 + ((max_rsa_size * 2) >> 5)); if (!(*prop) || !n || !rr || !rrtmp) { ret = -ENOMEM; goto err; -- 2.25.1
[PATCH v5 5/8] lib: rsa: free local arrays after use in rsa_gen_key_prop()
From: Heiko Stuebner n, rr and rrtmp are used for internal calculations, but in the end the results are copied into separately allocated elements of the actual key_prop, so the n, rr and rrtmp elements are not used anymore when returning from the function and should of course be freed. Signed-off-by: Heiko Stuebner --- changes in v4: - new patch lib/rsa/rsa-keyprop.c | 19 +-- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/rsa/rsa-keyprop.c b/lib/rsa/rsa-keyprop.c index e28fbb7472..ac33b35ff9 100644 --- a/lib/rsa/rsa-keyprop.c +++ b/lib/rsa/rsa-keyprop.c @@ -655,7 +655,7 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) struct rsa_key rsa_key; uint32_t *n = NULL, *rr = NULL, *rrtmp = NULL; const int max_rsa_size = 4096; - int rlen, i, ret; + int rlen, i, ret = 0; *prop = calloc(sizeof(**prop), 1); n = calloc(sizeof(uint32_t), 1 + (max_rsa_size >> 5)); @@ -663,12 +663,12 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) rrtmp = calloc(sizeof(uint32_t), 1 + ((max_rsa_size * 2) >> 5)); if (!(*prop) || !n || !rr || !rrtmp) { ret = -ENOMEM; - goto err; + goto out; } ret = rsa_parse_pub_key(_key, key, keylen); if (ret) - goto err; + goto out; /* modulus */ /* removing leading 0's */ @@ -678,7 +678,7 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) (*prop)->modulus = malloc(rsa_key.n_sz - i); if (!(*prop)->modulus) { ret = -ENOMEM; - goto err; + goto out; } memcpy((void *)(*prop)->modulus, _key.n[i], rsa_key.n_sz - i); @@ -686,7 +686,7 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) (*prop)->public_exponent = calloc(1, sizeof(uint64_t)); if (!(*prop)->public_exponent) { ret = -ENOMEM; - goto err; + goto out; } memcpy((void *)(*prop)->public_exponent + sizeof(uint64_t) - rsa_key.e_sz, @@ -710,16 +710,15 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) (*prop)->rr = malloc(rlen); if (!(*prop)->rr) { ret = -ENOMEM; - goto err; + goto out; } br_i32_encode((void *)(*prop)->rr, rlen, rr); - return 0; - -err: +out: free(n); free(rr); free(rrtmp); - rsa_free_key_prop(*prop); + if (ret < 0) + rsa_free_key_prop(*prop); return ret; } -- 2.25.1
[PATCH v5 6/8] lib: rsa: add documentation to padding_pss_verify to document limitations
From: Heiko Stuebner padding_pss_verify only works with the default pss salt setting of -2 (length to be automatically determined based on the PSS block structure) not -1 (salt length set to the maximum permissible value), which makes verifications of signatures with that saltlen fail. Until this gets implemented at least document this behaviour. Signed-off-by: Heiko Stuebner --- change in v4: - new patch lib/rsa/rsa-verify.c | 13 + 1 file changed, 13 insertions(+) diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 048f1ab789..61d98e6e2d 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -194,6 +194,19 @@ out: return ret; } +/* + * padding_pss_verify() - verify the pss padding of a signature + * + * Only works with a rsa_pss_saltlen:-2 (default value) right now + * saltlen:-1 "set the salt length to the digest length" is currently + * not supported. + * + * @info: Specifies key and FIT information + * @msg: byte array of message, len equal to msg_len + * @msg_len: Message length + * @hash: Pointer to the expected hash + * @hash_len: Length of the hash + */ int padding_pss_verify(struct image_sign_info *info, uint8_t *msg, int msg_len, const uint8_t *hash, int hash_len) -- 2.25.1
[PATCH v5 2/8] lib: rsa: take spl/non-spl into account when building rsa_verify_with_pkey()
From: Heiko Stuebner Right now in multiple places there are only checks for the full CONFIG_RSA_VERIFY_WITH_PKEY option, not split into main,spl,tpl variants. This breaks when the rsa functions get enabled for SPL, for example to verify u-boot proper from spl. So fix this by using the existing helpers to distinguis between build-steps. Signed-off-by: Heiko Stuebner --- changes in v5: - include the additional config-check that landed in patch 1/8 in v4 changes in v3.1: - drop changeid changes in v3: - new patch with another build issue lib/rsa/Makefile | 2 +- lib/rsa/rsa-verify.c | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rsa/Makefile b/lib/rsa/Makefile index c61ebfd79e..8b75d41f04 100644 --- a/lib/rsa/Makefile +++ b/lib/rsa/Makefile @@ -6,5 +6,5 @@ # Wolfgang Denk, DENX Software Engineering, w...@denx.de. obj-$(CONFIG_$(SPL_TPL_)RSA_VERIFY) += rsa-verify.o rsa-checksum.o -obj-$(CONFIG_RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o +obj-$(CONFIG_$(SPL_TPL_)RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o obj-$(CONFIG_RSA_SOFTWARE_EXP) += rsa-mod-exp.o diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index a19867742f..048f1ab789 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -285,7 +285,7 @@ out: } #endif -#if CONFIG_IS_ENABLED(FIT_SIGNATURE) || IS_ENABLED(CONFIG_RSA_VERIFY_WITH_PKEY) +#if CONFIG_IS_ENABLED(FIT_SIGNATURE) || CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) /** * rsa_verify_key() - Verify a signature against some data using RSA Key * @@ -359,7 +359,7 @@ static int rsa_verify_key(struct image_sign_info *info, } #endif -#ifdef CONFIG_RSA_VERIFY_WITH_PKEY +#if CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) /** * rsa_verify_with_pkey() - Verify a signature against some data using * only modulus and exponent as RSA key properties. @@ -492,7 +492,7 @@ int rsa_verify(struct image_sign_info *info, return -EINVAL; } - if (IS_ENABLED(CONFIG_RSA_VERIFY_WITH_PKEY) && !info->fdt_blob) { + if (CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) && !info->fdt_blob) { /* don't rely on fdt properties */ ret = rsa_verify_with_pkey(info, hash, sig, sig_len); -- 2.25.1
[PATCH v5 1/8] lib: rsa: distinguish between tpl and spl for CONFIG_RSA_VERIFY
From: Heiko Stuebner While the SPL may want to do signature checking this won't be the case for TPL in all cases, as TPL is mostly used when the amount of initial memory is not enough for a full SPL. So on a system where SPL uses DM but TPL does not we currently end up with a TPL compile error of: lib/rsa/rsa-verify.c:48:25: error: dereferencing pointer to incomplete type ‘struct checksum_algo’ To prevent that change the $(SPL_) to $(SPL_TPL_) to distinguish between both. If someone really needs FIT signature checking in TPL as well, a new TPL_RSA_VERIFY config symbol needs to be added. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- changes in v5: - drop change that belongs in patch 2/8 changes in v4: - amound -> amount - found another entry to handle changes in v2: - fix typo "distinguis(h)" lib/rsa/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rsa/Makefile b/lib/rsa/Makefile index 14ed3cb401..c61ebfd79e 100644 --- a/lib/rsa/Makefile +++ b/lib/rsa/Makefile @@ -5,6 +5,6 @@ # (C) Copyright 2000-2007 # Wolfgang Denk, DENX Software Engineering, w...@denx.de. -obj-$(CONFIG_$(SPL_)RSA_VERIFY) += rsa-verify.o rsa-checksum.o +obj-$(CONFIG_$(SPL_TPL_)RSA_VERIFY) += rsa-verify.o rsa-checksum.o obj-$(CONFIG_RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o obj-$(CONFIG_RSA_SOFTWARE_EXP) += rsa-mod-exp.o -- 2.25.1
[PATCH v5 3/8] lib: rsa: bring exp_len in line when generating a key_prop
From: Heiko Stuebner The exponent field of struct key_prop gets allocated an uint64_t, and the contents are positioned from the back, so an exponent of "0x01 0x00 0x01" becomes 0x0 0x0 0x0 0x0 0x0 0x1 0x0 0x1" Right now rsa_gen_key_prop() allocates a uint64_t but sets exp_len to the size returned from the parser, while on the other hand the when getting the key from the devicetree exp_len always gets set to sizeof(uint64_t). So bring that in line with the established code. Signed-off-by: Heiko Stuebner --- changes in v4: - new patch lib/rsa/rsa-keyprop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rsa/rsa-keyprop.c b/lib/rsa/rsa-keyprop.c index 9464df0093..4b54db44c4 100644 --- a/lib/rsa/rsa-keyprop.c +++ b/lib/rsa/rsa-keyprop.c @@ -691,7 +691,7 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) memcpy((void *)(*prop)->public_exponent + sizeof(uint64_t) - rsa_key.e_sz, rsa_key.e, rsa_key.e_sz); - (*prop)->exp_len = rsa_key.e_sz; + (*prop)->exp_len = sizeof(uint64_t); /* n0 inverse */ br_i32_decode(n, _key.n[i], rsa_key.n_sz - i); -- 2.25.1
[PATCH v4 2/8] lib: rsa: take spl/non-spl into account when building rsa_verify_with_pkey()
From: Heiko Stuebner Right now in multiple places there are only checks for the full CONFIG_RSA_VERIFY_WITH_PKEY option, not split into main,spl,tpl variants. This breaks when the rsa functions get enabled for SPL, for example to verify u-boot proper from spl. So fix this by using the existing helpers to distinguis between build-steps. Signed-off-by: Heiko Stuebner --- changes in v3.1: - drop changeid changes in v3: - new patch with another build issue lib/rsa/Makefile | 2 +- lib/rsa/rsa-verify.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rsa/Makefile b/lib/rsa/Makefile index c61ebfd79e..8b75d41f04 100644 --- a/lib/rsa/Makefile +++ b/lib/rsa/Makefile @@ -6,5 +6,5 @@ # Wolfgang Denk, DENX Software Engineering, w...@denx.de. obj-$(CONFIG_$(SPL_TPL_)RSA_VERIFY) += rsa-verify.o rsa-checksum.o -obj-$(CONFIG_RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o +obj-$(CONFIG_$(SPL_TPL_)RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o obj-$(CONFIG_RSA_SOFTWARE_EXP) += rsa-mod-exp.o diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index a19867742f..048f1ab789 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -285,7 +285,7 @@ out: } #endif -#if CONFIG_IS_ENABLED(FIT_SIGNATURE) || IS_ENABLED(CONFIG_RSA_VERIFY_WITH_PKEY) +#if CONFIG_IS_ENABLED(FIT_SIGNATURE) || CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) /** * rsa_verify_key() - Verify a signature against some data using RSA Key * @@ -359,7 +359,7 @@ static int rsa_verify_key(struct image_sign_info *info, } #endif -#ifdef CONFIG_RSA_VERIFY_WITH_PKEY +#if CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) /** * rsa_verify_with_pkey() - Verify a signature against some data using * only modulus and exponent as RSA key properties. -- 2.25.1
[PATCH v4 5/8] lib: rsa: free local arrays after use in rsa_gen_key_prop()
From: Heiko Stuebner n, rr and rrtmp are used for internal calculations, but in the end the results are copied into separately allocated elements of the actual key_prop, so the n, rr and rrtmp elements are not used anymore when returning from the function and should of course be freed. Signed-off-by: Heiko Stuebner --- changes in v4: - new patch lib/rsa/rsa-keyprop.c | 19 +-- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/rsa/rsa-keyprop.c b/lib/rsa/rsa-keyprop.c index e28fbb7472..ac33b35ff9 100644 --- a/lib/rsa/rsa-keyprop.c +++ b/lib/rsa/rsa-keyprop.c @@ -655,7 +655,7 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) struct rsa_key rsa_key; uint32_t *n = NULL, *rr = NULL, *rrtmp = NULL; const int max_rsa_size = 4096; - int rlen, i, ret; + int rlen, i, ret = 0; *prop = calloc(sizeof(**prop), 1); n = calloc(sizeof(uint32_t), 1 + (max_rsa_size >> 5)); @@ -663,12 +663,12 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) rrtmp = calloc(sizeof(uint32_t), 1 + ((max_rsa_size * 2) >> 5)); if (!(*prop) || !n || !rr || !rrtmp) { ret = -ENOMEM; - goto err; + goto out; } ret = rsa_parse_pub_key(_key, key, keylen); if (ret) - goto err; + goto out; /* modulus */ /* removing leading 0's */ @@ -678,7 +678,7 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) (*prop)->modulus = malloc(rsa_key.n_sz - i); if (!(*prop)->modulus) { ret = -ENOMEM; - goto err; + goto out; } memcpy((void *)(*prop)->modulus, _key.n[i], rsa_key.n_sz - i); @@ -686,7 +686,7 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) (*prop)->public_exponent = calloc(1, sizeof(uint64_t)); if (!(*prop)->public_exponent) { ret = -ENOMEM; - goto err; + goto out; } memcpy((void *)(*prop)->public_exponent + sizeof(uint64_t) - rsa_key.e_sz, @@ -710,16 +710,15 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) (*prop)->rr = malloc(rlen); if (!(*prop)->rr) { ret = -ENOMEM; - goto err; + goto out; } br_i32_encode((void *)(*prop)->rr, rlen, rr); - return 0; - -err: +out: free(n); free(rr); free(rrtmp); - rsa_free_key_prop(*prop); + if (ret < 0) + rsa_free_key_prop(*prop); return ret; } -- 2.25.1
[PATCH v4 8/8] spl: fit: select SPL_CRYPTO_SUPPORT for SPL_FIT_SIGNATURE
From: Heiko Stuebner Verifying FIT images obviously needs the rsa parts of crypto support and while main uboot always compiles crypto support, it's optional for SPL and we should thus select the necessary option to not end up in compile errors like: u-boot/lib/rsa/rsa-verify.c:328: undefined reference to `rsa_mod_exp' So select SPL_CRYPTO_SUPPORT in SPL_FIT_SIGNATURE. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/Kconfig b/Kconfig index 482f39c66f..0c184f7f06 100644 --- a/Kconfig +++ b/Kconfig @@ -459,6 +459,7 @@ config SPL_FIT_SIGNATURE bool "Enable signature verification of FIT firmware within SPL" depends on SPL_DM select SPL_FIT + select SPL_CRYPTO_SUPPORT select SPL_HASH_SUPPORT select SPL_RSA select SPL_RSA_VERIFY -- 2.25.1
[PATCH v4 3/8] lib: rsa: bring exp_len in line when generating a key_prop
From: Heiko Stuebner The exponent field of struct key_prop gets allocated an uint64_t, and the contents are positioned from the back, so an exponent of "0x01 0x00 0x01" becomes 0x0 0x0 0x0 0x0 0x0 0x1 0x0 0x1" Right now rsa_gen_key_prop() allocates a uint64_t but sets exp_len to the size returned from the parser, while on the other hand the when getting the key from the devicetree exp_len always gets set to sizeof(uint64_t). So bring that in line with the established code. Signed-off-by: Heiko Stuebner --- changes in v4: - new patch lib/rsa/rsa-keyprop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rsa/rsa-keyprop.c b/lib/rsa/rsa-keyprop.c index 9464df0093..4b54db44c4 100644 --- a/lib/rsa/rsa-keyprop.c +++ b/lib/rsa/rsa-keyprop.c @@ -691,7 +691,7 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) memcpy((void *)(*prop)->public_exponent + sizeof(uint64_t) - rsa_key.e_sz, rsa_key.e, rsa_key.e_sz); - (*prop)->exp_len = rsa_key.e_sz; + (*prop)->exp_len = sizeof(uint64_t); /* n0 inverse */ br_i32_decode(n, _key.n[i], rsa_key.n_sz - i); -- 2.25.1
[PATCH v4 6/8] lib: rsa: add documentation to padding_pss_verify to document limitations
From: Heiko Stuebner padding_pss_verify only works with the default pss salt setting of -2 (length to be automatically determined based on the PSS block structure) not -1 (salt length set to the maximum permissible value), which makes verifications of signatures with that saltlen fail. Until this gets implemented at least document this behaviour. Signed-off-by: Heiko Stuebner --- change in v4: - new patch lib/rsa/rsa-verify.c | 13 + 1 file changed, 13 insertions(+) diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 048f1ab789..61d98e6e2d 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -194,6 +194,19 @@ out: return ret; } +/* + * padding_pss_verify() - verify the pss padding of a signature + * + * Only works with a rsa_pss_saltlen:-2 (default value) right now + * saltlen:-1 "set the salt length to the digest length" is currently + * not supported. + * + * @info: Specifies key and FIT information + * @msg: byte array of message, len equal to msg_len + * @msg_len: Message length + * @hash: Pointer to the expected hash + * @hash_len: Length of the hash + */ int padding_pss_verify(struct image_sign_info *info, uint8_t *msg, int msg_len, const uint8_t *hash, int hash_len) -- 2.25.1
[PATCH v4 7/8] spl: fit: select SPL_HASH_SUPPORT for SPL_FIT_SIGNATURE
From: Heiko Stuebner rsa-checsum needs support for hash functions or else will run into compile errors like: u-boot/lib/rsa/rsa-checksum.c:28: undefined reference to `hash_progressive_lookup_algo' So similar to the main FIT_SIGNATURE entry selects HASH, select SPL_HASH_SUPPORT for SPL_FIT_SIGNATURE. Cc: Heinrich Schuchardt Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/Kconfig b/Kconfig index 0e7ccc0b07..482f39c66f 100644 --- a/Kconfig +++ b/Kconfig @@ -459,6 +459,7 @@ config SPL_FIT_SIGNATURE bool "Enable signature verification of FIT firmware within SPL" depends on SPL_DM select SPL_FIT + select SPL_HASH_SUPPORT select SPL_RSA select SPL_RSA_VERIFY select SPL_IMAGE_SIGN_INFO -- 2.25.1
[PATCH v4 1/8] lib: rsa: distinguish between tpl and spl for CONFIG_RSA_VERIFY
From: Heiko Stuebner While the SPL may want to do signature checking this won't be the case for TPL in all cases, as TPL is mostly used when the amount of initial memory is not enough for a full SPL. So on a system where SPL uses DM but TPL does not we currently end up with a TPL compile error of: lib/rsa/rsa-verify.c:48:25: error: dereferencing pointer to incomplete type ‘struct checksum_algo’ To prevent that change the $(SPL_) to $(SPL_TPL_) to distinguish between both. If someone really needs FIT signature checking in TPL as well, a new TPL_RSA_VERIFY config symbol needs to be added. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich --- changes in v4: - amound -> amount - found another entry to handle changes in v2: - fix typo "distinguis(h)" lib/rsa/Makefile | 2 +- lib/rsa/rsa-verify.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rsa/Makefile b/lib/rsa/Makefile index 14ed3cb401..c61ebfd79e 100644 --- a/lib/rsa/Makefile +++ b/lib/rsa/Makefile @@ -5,6 +5,6 @@ # (C) Copyright 2000-2007 # Wolfgang Denk, DENX Software Engineering, w...@denx.de. -obj-$(CONFIG_$(SPL_)RSA_VERIFY) += rsa-verify.o rsa-checksum.o +obj-$(CONFIG_$(SPL_TPL_)RSA_VERIFY) += rsa-verify.o rsa-checksum.o obj-$(CONFIG_RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o obj-$(CONFIG_RSA_SOFTWARE_EXP) += rsa-mod-exp.o diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 1d55b997e3..a19867742f 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -492,7 +492,7 @@ int rsa_verify(struct image_sign_info *info, return -EINVAL; } - if (IS_ENABLED(CONFIG_RSA_VERIFY_WITH_PKEY) && !info->fdt_blob) { + if (CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) && !info->fdt_blob) { /* don't rely on fdt properties */ ret = rsa_verify_with_pkey(info, hash, sig, sig_len); -- 2.25.1
[PATCH v4 4/8] lib: rsa: fix allocated size for rr and rrtmp in rsa_gen_key_prop()
From: Heiko Stuebner When calculating rrtmp/rr rsa_gen_key_prop() tries to make (((rlen + 31) >> 5) + 1) steps in the rr uint32_t array and (((rlen + 7) >> 3) + 1) / 4 steps in uint32_t rrtmp[] with rlen being num_bits * 2 On a 4096bit key this comes down to to 257 uint32_t elements in rr and 256 elements in rrtmp but with the current allocation rr and rrtmp only have 129 uint32_t elements. On 2048bit keys this works by chance as the defined max_rsa_size=4096 allocates a suitable number of elements, but with an actual 4096bit key this results in other memory parts getting overwritten. so double the number of elements in rr and rrtmp so that it matches the needed number and should increase nicely if max_rsa_size gets increased in the future. Signed-off-by: Heiko Stuebner --- changes in v4: - new patch lib/rsa/rsa-keyprop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rsa/rsa-keyprop.c b/lib/rsa/rsa-keyprop.c index 4b54db44c4..e28fbb7472 100644 --- a/lib/rsa/rsa-keyprop.c +++ b/lib/rsa/rsa-keyprop.c @@ -659,8 +659,8 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop) *prop = calloc(sizeof(**prop), 1); n = calloc(sizeof(uint32_t), 1 + (max_rsa_size >> 5)); - rr = calloc(sizeof(uint32_t), 1 + (max_rsa_size >> 5)); - rrtmp = calloc(sizeof(uint32_t), 1 + (max_rsa_size >> 5)); + rr = calloc(sizeof(uint32_t), 1 + ((max_rsa_size * 2) >> 5)); + rrtmp = calloc(sizeof(uint32_t), 1 + ((max_rsa_size * 2) >> 5)); if (!(*prop) || !n || !rr || !rrtmp) { ret = -ENOMEM; goto err; -- 2.25.1
[PATCH v3.1 2/4] lib: rsa: take spl/non-spl into account when building rsa_verify_with_pkey()
From: Heiko Stuebner Right now in multiple places there are only checks for the full CONFIG_RSA_VERIFY_WITH_PKEY option, not split into main,spl,tpl variants. This breaks when the rsa functions get enabled for SPL, for example to verify u-boot proper from spl. So fix this by using the existing helpers to distinguis between build-steps. Signed-off-by: Heiko Stuebner --- changes in v3.1: - drop changeid changes in v3: - new patch with another build issue lib/rsa/Makefile | 2 +- lib/rsa/rsa-verify.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rsa/Makefile b/lib/rsa/Makefile index c61ebfd79e..8b75d41f04 100644 --- a/lib/rsa/Makefile +++ b/lib/rsa/Makefile @@ -6,5 +6,5 @@ # Wolfgang Denk, DENX Software Engineering, w...@denx.de. obj-$(CONFIG_$(SPL_TPL_)RSA_VERIFY) += rsa-verify.o rsa-checksum.o -obj-$(CONFIG_RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o +obj-$(CONFIG_$(SPL_TPL_)RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o obj-$(CONFIG_RSA_SOFTWARE_EXP) += rsa-mod-exp.o diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index f7ae174cb0..681b53eeb9 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -284,7 +284,7 @@ out: } #endif -#if CONFIG_IS_ENABLED(FIT_SIGNATURE) || IS_ENABLED(CONFIG_RSA_VERIFY_WITH_PKEY) +#if CONFIG_IS_ENABLED(FIT_SIGNATURE) || CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) /** * rsa_verify_key() - Verify a signature against some data using RSA Key * @@ -358,7 +358,7 @@ static int rsa_verify_key(struct image_sign_info *info, } #endif -#ifdef CONFIG_RSA_VERIFY_WITH_PKEY +#if CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) /** * rsa_verify_with_pkey() - Verify a signature against some data using * only modulus and exponent as RSA key properties. -- 2.25.1
[PATCH v3 3/4] spl: fit: select SPL_HASH_SUPPORT for SPL_FIT_SIGNATURE
From: Heiko Stuebner rsa-checksum needs support for hash functions or else will run into compile errors like: u-boot/lib/rsa/rsa-checksum.c:28: undefined reference to `hash_progressive_lookup_algo' So similar to the main FIT_SIGNATURE entry selects HASH, select SPL_HASH_SUPPORT for SPL_FIT_SIGNATURE. Cc: Heinrich Schuchardt Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich Reviewed-by: Kever Yang --- Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/Kconfig b/Kconfig index 0e7ccc0b07..482f39c66f 100644 --- a/Kconfig +++ b/Kconfig @@ -459,6 +459,7 @@ config SPL_FIT_SIGNATURE bool "Enable signature verification of FIT firmware within SPL" depends on SPL_DM select SPL_FIT + select SPL_HASH_SUPPORT select SPL_RSA select SPL_RSA_VERIFY select SPL_IMAGE_SIGN_INFO -- 2.25.1
[PATCH v3 2/4] lib: rsa: take spl/non-spl into account when building rsa_verify_with_pkey()
From: Heiko Stuebner Right now in multiple places there are only checks for the full CONFIG_RSA_VERIFY_WITH_PKEY option, not split into main,spl,tpl variants. This breaks when the rsa functions get enabled for SPL, for example to verify u-boot proper from spl. So fix this by using the existing helpers to distinguis between build-steps. Signed-off-by: Heiko Stuebner Change-Id: Idbd112b8544befa9bf809279d819d5fb444f0125 --- changes in v3: - new patch with another build issue lib/rsa/Makefile | 2 +- lib/rsa/rsa-verify.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rsa/Makefile b/lib/rsa/Makefile index c61ebfd79e..8b75d41f04 100644 --- a/lib/rsa/Makefile +++ b/lib/rsa/Makefile @@ -6,5 +6,5 @@ # Wolfgang Denk, DENX Software Engineering, w...@denx.de. obj-$(CONFIG_$(SPL_TPL_)RSA_VERIFY) += rsa-verify.o rsa-checksum.o -obj-$(CONFIG_RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o +obj-$(CONFIG_$(SPL_TPL_)RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o obj-$(CONFIG_RSA_SOFTWARE_EXP) += rsa-mod-exp.o diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index f7ae174cb0..681b53eeb9 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -284,7 +284,7 @@ out: } #endif -#if CONFIG_IS_ENABLED(FIT_SIGNATURE) || IS_ENABLED(CONFIG_RSA_VERIFY_WITH_PKEY) +#if CONFIG_IS_ENABLED(FIT_SIGNATURE) || CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) /** * rsa_verify_key() - Verify a signature against some data using RSA Key * @@ -358,7 +358,7 @@ static int rsa_verify_key(struct image_sign_info *info, } #endif -#ifdef CONFIG_RSA_VERIFY_WITH_PKEY +#if CONFIG_IS_ENABLED(RSA_VERIFY_WITH_PKEY) /** * rsa_verify_with_pkey() - Verify a signature against some data using * only modulus and exponent as RSA key properties. -- 2.25.1
[PATCH v3 1/4] lib: rsa: distinguish between tpl and spl for CONFIG_RSA_VERIFY
From: Heiko Stuebner While the SPL may want to do signature checking this won't be the case for TPL in all cases, as TPL is mostly used when the amound of initial memory is not enough for a full SPL. So on a system where SPL uses DM but TPL does not we currently end up with a TPL compile error of: lib/rsa/rsa-verify.c:48:25: error: dereferencing pointer to incomplete type ‘struct checksum_algo’ To prevent that change the $(SPL_) to $(SPL_TPL_) to distinguish between both. If someone really needs FIT signature checking in TPL as well, a new TPL_RSA_VERIFY config symbol needs to be added. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich Reviewed-by: Kever Yang --- changes in v2: - fix typo "distinguis(h)" I've split out the build fixes from the signature series. It would be cool to get these applied already, as they do fix actual issues to be seen when enabling signature support in spl. lib/rsa/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rsa/Makefile b/lib/rsa/Makefile index 14ed3cb401..c61ebfd79e 100644 --- a/lib/rsa/Makefile +++ b/lib/rsa/Makefile @@ -5,6 +5,6 @@ # (C) Copyright 2000-2007 # Wolfgang Denk, DENX Software Engineering, w...@denx.de. -obj-$(CONFIG_$(SPL_)RSA_VERIFY) += rsa-verify.o rsa-checksum.o +obj-$(CONFIG_$(SPL_TPL_)RSA_VERIFY) += rsa-verify.o rsa-checksum.o obj-$(CONFIG_RSA_VERIFY_WITH_PKEY) += rsa-keyprop.o obj-$(CONFIG_RSA_SOFTWARE_EXP) += rsa-mod-exp.o -- 2.25.1
[PATCH v3 4/4] spl: fit: select SPL_CRYPTO_SUPPORT for SPL_FIT_SIGNATURE
From: Heiko Stuebner Verifying FIT images obviously needs the rsa parts of crypto support and while main uboot always compiles crypto support, it's optional for SPL and we should thus select the necessary option to not end up in compile errors like: u-boot/lib/rsa/rsa-verify.c:328: undefined reference to `rsa_mod_exp' So select SPL_CRYPTO_SUPPORT in SPL_FIT_SIGNATURE. Signed-off-by: Heiko Stuebner Reviewed-by: Philipp Tomsich Reviewed-by: Kever Yang --- Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/Kconfig b/Kconfig index 482f39c66f..0c184f7f06 100644 --- a/Kconfig +++ b/Kconfig @@ -459,6 +459,7 @@ config SPL_FIT_SIGNATURE bool "Enable signature verification of FIT firmware within SPL" depends on SPL_DM select SPL_FIT + select SPL_CRYPTO_SUPPORT select SPL_HASH_SUPPORT select SPL_RSA select SPL_RSA_VERIFY -- 2.25.1
[PATCH 2/2] spl: add fixed memory node in target fdt also when loading ATF
From: Heiko Stuebner In a loading chain SPL -> ATF (->OP-TEE) -> U-Boot, ATF and a subsequent OP-TEE will re-use the same fdt as the U-Boot target and may need the information about usable memory ranges. Especially OP-TEE needs this to initialize dynamic shared memory (the only type U-Boot implements when talking to OP-TEE). So allow spl_fixup_fdt() to take a fdt_blob argument, falling back to the existing CONFIG_SYS_SPL_ARGS_ADDR if needed and call it from the ATF path as well. Signed-off-by: Heiko Stuebner Change-Id: I95d555e170534ad7fd03b183773e0b1f2d90d486 --- common/spl/spl.c | 19 +-- 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index b0f0e1557b..90d8bfd058 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -58,7 +58,8 @@ static bd_t bdata __attribute__ ((section(".data"))); */ __weak void show_boot_progress(int val) {} -#if defined(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF) +#if defined(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF) || \ +defined(CONFIG_SPL_ATF) /* weak, default platform-specific function to initialize dram banks */ __weak int dram_init_banksize(void) { @@ -100,12 +101,14 @@ void __weak spl_perform_fixups(struct spl_image_info *spl_image) { } -void spl_fixup_fdt(void) +void spl_fixup_fdt(void *fdt_blob) { -#if defined(CONFIG_SPL_OF_LIBFDT) && defined(CONFIG_SYS_SPL_ARGS_ADDR) - void *fdt_blob = (void *)CONFIG_SYS_SPL_ARGS_ADDR; +#if defined(CONFIG_SPL_OF_LIBFDT) int err; + if (!fdt_blob) + return; + err = fdt_check_header(fdt_blob); if (err < 0) { printf("fdt_root: %s\n", fdt_strerror(err)); @@ -638,7 +641,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2) initr_watchdog(); #endif - if (IS_ENABLED(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF)) + if (IS_ENABLED(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF) || + IS_ENABLED(CONFIG_SPL_ATF)) dram_init_banksize(); bootcount_inc(); @@ -680,6 +684,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) #if CONFIG_IS_ENABLED(ATF) case IH_OS_ARM_TRUSTED_FIRMWARE: debug("Jumping to U-Boot via ARM Trusted Firmware\n"); + spl_fixup_fdt(spl_image.fdt_addr); spl_invoke_atf(_image); break; #endif @@ -699,7 +704,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2) #ifdef CONFIG_SPL_OS_BOOT case IH_OS_LINUX: debug("Jumping to Linux\n"); - spl_fixup_fdt(); +#if defined(CONFIG_SYS_SPL_ARGS_ADDR) + spl_fixup_fdt((void *)CONFIG_SYS_SPL_ARGS_ADDR); +#endif spl_board_prepare_for_linux(); jump_to_image_linux(_image); #endif -- 2.25.1
[PATCH 1/2] rockchip: spl: do full dram_init instead of only probing
From: Heiko Stuebner Parts of later SPL may need RAM information as well, so do full dram_init() call, which includes the existing dram probing but also initializes the ram information in gd. All Rockchip SoCs use a TPL+SPL combination now, so that's ok for all of them. Signed-off-by: Heiko Stuebner Change-Id: I2c7496f2d88d65a9f80f74d2139bf307bb4b442b --- arch/arm/mach-rockchip/spl.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c index 0b76af6080..0eda2c3485 100644 --- a/arch/arm/mach-rockchip/spl.c +++ b/arch/arm/mach-rockchip/spl.c @@ -135,13 +135,15 @@ void board_init_f(ulong dummy) /* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */ timer_init(); #endif -#if !defined(CONFIG_TPL) || defined(CONFIG_SPL_OS_BOOT) +#if !defined(CONFIG_TPL) || defined(CONFIG_SPL_RAM) debug("\nspl:init dram\n"); - ret = uclass_get_device(UCLASS_RAM, 0, ); + ret = dram_init(); if (ret) { printf("DRAM init failed: %d\n", ret); return; } + gd->ram_top = gd->ram_base + get_effective_memsize(); + gd->ram_top = board_get_usable_ram_top(gd->ram_size); #endif preloader_console_init(); } -- 2.25.1