sunxi: add NetCube Nagami support and T113 secure boot enablement
Subsystems (5)
cover sunxi: add NetCube Nagami support and T113 secure boot enablement
This series adds support for the NetCube Systems Nagami T113-based system-on-module and its associated carrier boards, along with the sunxi changes needed to boot signed FIT images from SPL in secure mode on R528/T113.
The Nagami module is based on the Allwinner T113-S3/T113-S4 family and the included defconfigs cover the basic carrier, keypad carrier, and a secure boot example configuration for the basic carrier.
To support the secure boot flow in SPL, the series adds the missing sunxi pieces for R528/T113: I2C3 pinmux support, early SPC setup for non-secure peripheral handoff, non-DM SPL FIT signature verification, and signed SPL image generation in the sunxi binman/FIT description.
The SID MAC fallback handling is also cleaned up. The original fix used a board-level check for whether nvmem-cells were present in the DT. This version moves the fallback into the EMAC drivers instead of env_setup, so both sunxi EMAC variants share a generic implementation.
Lukas Schmid (6):
sunxi: move SID MAC fallback from board env setup to EMAC
read_rom_hwaddr
pinctrl: sunxi: add I2C3 mux for D1/T113-s3 (PG10/PG11)
sunxi: add SPC setup for R528/T113 secure boot handoff
boot: allow SPL FIT signature verification without DM
sunxi: extend binman FIT description for signed SPL images
sunxi: add support for NetCube Systems Nagami and associated carrier
boards
arch/arm/cpu/armv7/sunxi/Makefile | 1 + arch/arm/cpu/armv7/sunxi/spc.c | 20 ++++++ arch/arm/dts/sunxi-u-boot.dtsi | 68 +++++++++++++++++-- .../include/asm/arch-sunxi/cpu_sunxi_ncat2.h | 27 ++++++++ arch/arm/include/asm/arch-sunxi/sys_proto.h | 14 ++++ arch/arm/mach-sunxi/board.c | 1 + arch/arm/mach-sunxi/clock_sun50i_h6.c | 8 +++ arch/arm/mach-sunxi/cpu_info.c | 44 ++++++++++++ board/sunxi/board.c | 57 +--------------- boot/Kconfig | 1 - .../netcube_nagami_basic_carrier_defconfig | 43 ++++++++++++ ..._nagami_basic_carrier_secureboot_defconfig | 52 ++++++++++++++ .../netcube_nagami_keypad_carrier_defconfig | 43 ++++++++++++ drivers/net/sun8i_emac.c | 15 ++++ drivers/net/sunxi_emac.c | 15 ++++ drivers/pinctrl/sunxi/pinctrl-sunxi.c | 1 + lib/rsa/rsa-verify.c | 16 +++-- 17 files changed, 359 insertions(+), 67 deletions(-) create mode 100644 arch/arm/cpu/armv7/sunxi/spc.c create mode 100644 configs/netcube_nagami_basic_carrier_defconfig create mode 100644 configs/netcube_nagami_basic_carrier_secureboot_defconfig create mode 100644 configs/netcube_nagami_keypad_carrier_defconfig
Signature · 1 line
2.47.3
PATCH 1/6 sunxi: move SID MAC fallback from board env setup to EMAC read_rom_hwaddr
sunxi currently seeds ethaddr/ethXaddr in setup_environment() from SID. That happens before Ethernet probe, so even with a clean persisted environment we can populate env with a generated MAC and later get a mismatch warning when DM Ethernet reads a different MAC from DT/NVMEM.
Stop generating Ethernet MAC env variables in setup_environment() and provide SID-derived fallback addresses through read_rom_hwaddr in the sunxi EMAC drivers instead.
Also move the SID uniqueness/MAC derivation logic into shared sunxi arch helpers so board code and drivers use one implementation and keep legacy algorithm compatibility across SoCs.
This keeps the generic MAC source order (DT/NVMEM first, fallback second), avoids board-level MAC policy special-casing, and prevents same-boot env-vs-NVMEM mismatch warnings caused by early env seeding.
--- arch/arm/include/asm/arch-sunxi/sys_proto.h | 6 +++ arch/arm/mach-sunxi/cpu_info.c | 44 ++++++++++++++++ board/sunxi/board.c | 57 +-------------------- drivers/net/sun8i_emac.c | 15 ++++++ drivers/net/sunxi_emac.c | 15 ++++++ 5 files changed, 81 insertions(+), 56 deletions(-)
arch/arm/include/asm/arch-sunxi/sys_proto.h +6 -0
@@ -12,6 +12,12 @@void sdelay (unsigned long ); +/* Read SID and apply legacy/newer-SoC normalization for uniqueness. */ +bool sunxi_get_unique_sid (unsigned int *sid); + +/* Build legacy-compatible SID-derived locally administered MAC address. */ +bool sunxi_get_sid_mac_addr (int index,u8 mac[6 ]); +/* return_to_fel() - Return to BROM from SPL * * This returns back into the BROM after U-Boot SPL has performed its initial
arch/arm/mach-sunxi/cpu_info.c +44 -0
55 lines not on this page · raw message
board/sunxi/board.c +1 -56
79 lines not on this page · raw message
drivers/net/sun8i_emac.c +15 -0
@@ -13,6 +13,7 @@#include <cpu_func.h> #include <log.h> #include <asm/cache.h> +#include <asm/arch/sys_proto.h> #include <asm/global_data.h> #include <asm/gpio.h> #include <asm/io.h>
@@ -259,6 +260,19 @@ static int sun8i_eth_write_hwaddr(struct udevice *dev)return 0 ; } +static int sun8i_eth_read_rom_hwaddr (struct udevice *dev) +{ +struct eth_pdata *pdata =dev_get_plat (dev); +u8 mac[ARP_HLEN ]; + +if (!sunxi_get_sid_mac_addr (dev_seq (dev), mac)) +return -ENODEV ; + +memcpy (pdata->enetaddr, mac,ARP_HLEN ); + +return 0 ; +} +static void sun8i_adjust_link (struct emac_eth_dev *priv,struct phy_device *phydev) {
@@ -715,6 +729,7 @@ static int sun8i_emac_eth_probe(struct udevice *dev)static const struct eth_ops sun8i_emac_eth_ops = { .start = sun8i_emac_eth_start, + .read_rom_hwaddr = sun8i_eth_read_rom_hwaddr, .write_hwaddr = sun8i_eth_write_hwaddr, .send = sun8i_emac_eth_send, .recv = sun8i_emac_eth_recv,
drivers/net/sunxi_emac.c +15 -0
@@ -15,6 +15,7 @@#include <miiphy.h> #include <net.h> #include <asm/io.h> +#include <asm/arch/sys_proto.h> #include <asm/arch/clock.h> #include <power/regulator.h>
@@ -539,6 +540,19 @@ static int sunxi_emac_eth_send(struct udevice *dev, void *packet, int length)return _sunxi_emac_eth_send (priv, packet, length); } +static int sunxi_emac_read_rom_hwaddr (struct udevice *dev) +{ +struct eth_pdata *pdata =dev_get_plat (dev); +u8 mac[ARP_HLEN ]; + +if (!sunxi_get_sid_mac_addr (dev_seq (dev), mac)) +return -ENODEV ; + +memcpy (pdata->enetaddr, mac,ARP_HLEN ); + +return 0 ; +} +static int sunxi_emac_eth_recv (struct udevice *dev,int flags,uchar **packetp) {struct emac_eth_dev *priv =dev_get_priv (dev);
@@ -581,6 +595,7 @@ static int sunxi_emac_eth_probe(struct udevice *dev)static const struct eth_ops sunxi_emac_eth_ops = { .start = sunxi_emac_eth_start, + .read_rom_hwaddr = sunxi_emac_read_rom_hwaddr, .send = sunxi_emac_eth_send, .recv = sunxi_emac_eth_recv, .stop = sunxi_emac_eth_stop,
Signature · 1 line
2.47.3
Re: [PATCH 1/6] sunxi: move SID MAC fallback from board env setup to EMAC read_rom_hwaddr
Hi Lukas,
Quoted 9 lines · Lukas Schmid
sunxi currently seeds ethaddr/ethXaddr in
setup_environment()from SID. That happens before Ethernet probe, so even with a clean persisted environment we can populate env with a generated MAC and later get a mismatch warning when DM Ethernet reads a different MAC from DT/NVMEM.Stop generating Ethernet MAC env variables in
setup_environment()and provide SID-derived fallback addresses throughread_rom_hwaddrin the sunxi EMAC drivers instead.
Quoted 8 lines
Also move the SID uniqueness/MAC derivation logic into shared sunxi arch helpers so board code and drivers use one implementation and keep legacy algorithm compatibility across SoCs.
This keeps the generic MAC source order (DT/NVMEM first, fallback second), avoids board-level MAC policy special-casing, and prevents same-boot env-vs-NVMEM mismatch warnings caused by early env seeding.
Many thanks for reworking this, it looks indeed much better now! I was a bit uneasy first about selling the SID based MAC generation as a "MAC ROM read", but I now thinks that somehow fits, since it's some kind of ROM inside the "network chip" (SoC in this case). The only problem is that there is a third MAC in use by Allwinner chips: SUN7I_GMAC, using the ETH_DESIGNWARE/designware.c driver.
So we can add the same read_rom_hwaddr there, and guard this with an IS_ENABLED(CONFIG_ARCH_SUNXI), but then the sunxi_get_sid_mac_addr() prototype needs to either move into a different header, or we find some other solution without (too many) #ifdef's. Try "Bananapi_defconfig" for an Allwinner board using this MAC, and say rock-pi-s-rk3308_defconfig for an example outside of Allwinner, to test this.
Quoted 122 lines
Signed-off-by Lukas Schmid <[email protected]>--- arch/arm/include/asm/arch-sunxi/sys_proto.h | 6 +++ arch/arm/mach-sunxi/cpu_info.c | 44 ++++++++++++++++ board/sunxi/board.c | 57 +-------------------- drivers/net/sun8i_emac.c | 15 ++++++ drivers/net/sunxi_emac.c | 15 ++++++ 5 files changed, 81 insertions(+), 56 deletions(-)arch/arm/include/asm/arch-sunxi/sys_proto.h +6
-0@@ -12,6 +12,12 @@void sdelay (unsigned long ); +/* Read SID and apply legacy/newer-SoC normalization for uniqueness. */ +bool sunxi_get_unique_sid (unsigned int *sid); + +/* Build legacy-compatible SID-derived locally administered MAC address. */ +bool sunxi_get_sid_mac_addr (int index,u8 mac[6 ]); +/* return_to_fel() - Return to BROM from SPL * * This returns back into the BROM after U-Boot SPL has performed its initial arch/arm/mach-sunxi/cpu_info.c +44
-0@@ -9,8 +9,10 @@#include <asm/io.h> #include <asm/arch/cpu.h> #include <asm/arch/clock.h> +#include <asm/arch/sys_proto.h> #include <axp_pmic.h> #include <errno.h> +#include <u-boot/crc.h> #ifdef CONFIG_MACH_SUN6I int sunxi_get_ss_bonding_id (void )@@ -175,3 +177,45 @@ int sunxi_get_sid(unsigned int *sid)return -ENODEV ;#endif } + +bool sunxi_get_unique_sid (unsigned int *sid) +{ +if (sunxi_get_sid (sid) !=0 ) +return false; + +if (!sid[0 ]) +return false; + +/* +* On newer SoCs use a CRC over SID words 1..3 for better uniqueness, +* while keeping the long-standing algorithm on older SoCs. +*/ +#if !defined(CONFIG_MACH_SUN4I ) && !defined(CONFIG_MACH_SUN5I ) && \ + !defined(CONFIG_MACH_SUN6I ) && !defined(CONFIG_MACH_SUN7I ) && \ + !defined(CONFIG_MACH_SUN8I_A23 ) && !defined(CONFIG_MACH_SUN8I_A33 ) + sid[3 ] =crc32 (0 , (unsigned char *)&sid[1 ],12 ); +#endif + +/* Ensure the NIC-specific bytes are not all 0. */ +if ((sid[3 ] &0xffffff ) ==0 ) + sid[3 ] |=0x800000 ; + +return true; +} + +bool sunxi_get_sid_mac_addr (int index,u8 mac[6 ]) +{ +unsigned int sid[4 ]; + +if (!sunxi_get_unique_sid (sid)) +return false; + + mac[0 ] = ((index &0xf ) <<4 ) |0x02 ; + mac[1 ] = (sid[0 ] >>0 ) &0xff ; + mac[2 ] = (sid[3 ] >>24 ) &0xff ; + mac[3 ] = (sid[3 ] >>16 ) &0xff ; + mac[4 ] = (sid[3 ] >>8 ) &0xff ; + mac[5 ] = (sid[3 ] >>0 ) &0xff ; + +return true; +}board/sunxi/board.c +0
-20@@ -41,7 +41,6 @@#include <asm/gpio.h> #include <sunxi_gpio.h> #include <asm/io.h> -#include <u-boot/crc.h> #include <env_internal.h> #include <linux/libfdt.h> #include <fdt_support.h> @@ -750,34 +749,7 @@ static void parse_spl_header(const uint32_t spl_addr)static bool get_unique_sid (unsigned int *sid) { -if (sunxi_get_sid (sid) !=0 ) -return false; - -if (!sid[0 ]) -return false; - -/* -* The single words 1 - 3 of the SID have quite a few bits -* which are the same on many models, so we take a crc32 -* of all 3 words, to get a more unique value. -* -* Note we only do this on newer SoCs as we cannot change -* the algorithm on older SoCs since those have been using -* fixed mac-addresses based on only using word 3 for a -* long time and changing a fixed mac-address with an -* u-boot update is not good. -*/ -#if !defined(CONFIG_MACH_SUN4I) && !defined(CONFIG_MACH_SUN5I) && \ - !defined(CONFIG_MACH_SUN6I) && !defined(CONFIG_MACH_SUN7I) && \
board/sunxi/board.c static void parse_spl_header(const uint32_t spl_addr) · line 752
Quoted 10 lines
board/sunxi/board.c +1
-9- !defined (CONFIG_MACH_SUN8I_A23 ) && !defined (CONFIG_MACH_SUN8I_A33 ) - sid[3] = crc32(0, (unsigned char *)&sid[1], 12); -#endif - -/* Ensure the NIC specific bytes of the mac are not all 0 */ -if ((sid[3 ] &0xffffff ) ==0 ) - sid[3 ] |=0x800000 ; - -return true; +return sunxi_get_unique_sid (sid);
So why do we need this extra get_unique_sid() function still? The prototyp is the same, so can't we just change all callers to use the new, external function?
Cheers,
Andre
Quoted 121 lines
board/sunxi/board.c +0
-27}/* @@ -788,37 +760,10 @@ static void setup_environment(const void *fdt) {char serial_string[17 ] = {0 };unsigned int sid[4 ]; -uint8_t mac_addr[6 ]; -char ethaddr[16 ]; -int i;if (!get_unique_sid (sid))return ; -for (i =0 ; i <4 ; i++) { -sprintf (ethaddr,"ethernet%d" , i); -if (!fdt_get_alias (fdt, ethaddr)) -continue ; - -if (i ==0 ) -strcpy (ethaddr,"ethaddr" ); -else -sprintf (ethaddr,"eth%daddr" , i); - -if (env_get (ethaddr)) -continue ; - -/* Non OUI / registered MAC address */ - mac_addr[0 ] = (i <<4 ) |0x02 ; - mac_addr[1 ] = (sid[0 ] >>0 ) &0xff ; - mac_addr[2 ] = (sid[3 ] >>24 ) &0xff ; - mac_addr[3 ] = (sid[3 ] >>16 ) &0xff ; - mac_addr[4 ] = (sid[3 ] >>8 ) &0xff ; - mac_addr[5 ] = (sid[3 ] >>0 ) &0xff ; - -eth_env_set_enetaddr (ethaddr, mac_addr); - } -if (!env_get ("serial#" )) {snprintf (serial_string,sizeof (serial_string),"%08x%08x" , sid[0 ], sid[3 ]);drivers/net/sun8i_emac.c +15
-0@@ -13,6 +13,7 @@#include <cpu_func.h> #include <log.h> #include <asm/cache.h> +#include <asm/arch/sys_proto.h> #include <asm/global_data.h> #include <asm/gpio.h> #include <asm/io.h> @@ -259,6 +260,19 @@ static int sun8i_eth_write_hwaddr(struct udevice *dev)return 0 ; } +static int sun8i_eth_read_rom_hwaddr (struct udevice *dev) +{ +struct eth_pdata *pdata =dev_get_plat (dev); +u8 mac[ARP_HLEN ]; + +if (!sunxi_get_sid_mac_addr (dev_seq (dev), mac)) +return -ENODEV ; + +memcpy (pdata->enetaddr, mac,ARP_HLEN ); + +return 0 ; +} +static void sun8i_adjust_link (struct emac_eth_dev *priv,struct phy_device *phydev) {@@ -715,6 +729,7 @@ static int sun8i_emac_eth_probe(struct udevice *dev)static const struct eth_ops sun8i_emac_eth_ops = { .start = sun8i_emac_eth_start, + .read_rom_hwaddr = sun8i_eth_read_rom_hwaddr, .write_hwaddr = sun8i_eth_write_hwaddr, .send = sun8i_emac_eth_send, .recv = sun8i_emac_eth_recv,drivers/net/sunxi_emac.c +15
-0@@ -15,6 +15,7 @@#include <miiphy.h> #include <net.h> #include <asm/io.h> +#include <asm/arch/sys_proto.h> #include <asm/arch/clock.h> #include <power/regulator.h> @@ -539,6 +540,19 @@ static int sunxi_emac_eth_send(struct udevice *dev, void *packet, int length)return _sunxi_emac_eth_send (priv, packet, length); } +static int sunxi_emac_read_rom_hwaddr (struct udevice *dev) +{ +struct eth_pdata *pdata =dev_get_plat (dev); +u8 mac[ARP_HLEN ]; + +if (!sunxi_get_sid_mac_addr (dev_seq (dev), mac)) +return -ENODEV ; + +memcpy (pdata->enetaddr, mac,ARP_HLEN ); + +return 0 ; +} +static int sunxi_emac_eth_recv (struct udevice *dev,int flags,uchar **packetp) {struct emac_eth_dev *priv =dev_get_priv (dev);@@ -581,6 +595,7 @@ static int sunxi_emac_eth_probe(struct udevice *dev)static const struct eth_ops sunxi_emac_eth_ops = { .start = sunxi_emac_eth_start, + .read_rom_hwaddr = sunxi_emac_read_rom_hwaddr, .send = sunxi_emac_eth_send, .recv = sunxi_emac_eth_recv, .stop = sunxi_emac_eth_stop,
PATCH 2/6 pinctrl: sunxi: add I2C3 mux for D1/T113-s3 (PG10/PG11)
In reply to Lukas SchmidBoards based on the Allwinner D1/T113-s3, such as the NetCube Systems Nagami, can expose a third I2C controller on PG10/PG11. However, the sun20i_d1 pinctrl function table lacked an entry for this mux.
Add the "i2c3" function with mux value 3 on PG10/PG11, allowing device trees to enable the I2C3 controller.
--- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/sunxi/pinctrl-sunxi.c +1 -0
@@ -603,6 +603,7 @@ static const struct sunxi_pinctrl_function sun20i_d1_pinctrl_functions[] = { { "gpio_in", 0 }, { "gpio_out", 1 }, { "i2c0", 4 }, /* PB10-PB11 */ + { "i2c3", 3 }, /* PG10-PG11 */ { "mmc0", 2 }, /* PF0-PF5 */ { "mmc1", 2 }, /* PG0-PG5 */ { "mmc2", 3 }, /* PC2-PC7 */
Signature · 1 line
2.47.3
Re: [PATCH 2/6] pinctrl: sunxi: add I2C3 mux for D1/T113-s3 (PG10/PG11)
Hi,
Quoted 9 lines · Lukas Schmid
Boards based on the Allwinner D1/T113-s3, such as the NetCube Systems Nagami, can expose a third I2C controller on PG10/PG11. However, the
sun20i_d1pinctrl function table lacked an entry for this mux.Add the "i2c3" function with mux value 3 on PG10/PG11, allowing device trees to enable the I2C3 controller.
Signed-off-by Lukas Schmid <[email protected]>
Cheers,
Andre
Quoted 16 lines
--- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 1 + 1 file changed, 1 insertion(+)drivers/pinctrl/sunxi/pinctrl-sunxi.c +1
-0@@ -603,6 +603,7 @@ static const struct sunxi_pinctrl_function sun20i_d1_pinctrl_functions[] = { { "gpio_in", 0 }, { "gpio_out", 1 }, { "i2c0", 4 }, /* PB10-PB11 */ + { "i2c3", 3 }, /* PG10-PG11 */ { "mmc0", 2 }, /* PF0-PF5 */ { "mmc1", 2 }, /* PG0-PG5 */ { "mmc2", 3 }, /* PC2-PC7 */
PATCH 3/6 sunxi: add SPC setup for R528/T113 secure boot handoff
In reply to Lukas SchmidThe R528/T113 family protects peripheral access through the SPC, and also uses security switch registers in the CCU, PRCM and DMA controller.
Configure these blocks during early platform init so Linux can access the peripherals after U-Boot hands off control when booting in secure mode. Add an R528/T113-specific SPC init step alongside the existing early security controller setup, allow non-secure DMA access there, and switch the CCU and PRCM buses to non-secure access in clock_init_sec().
--- arch/arm/cpu/armv7/sunxi/Makefile | 1 + arch/arm/cpu/armv7/sunxi/spc.c | 20 ++++++++++++++ .../include/asm/arch-sunxi/cpu_sunxi_ncat2.h | 27 +++++++++++++++++++ arch/arm/include/asm/arch-sunxi/sys_proto.h | 8 ++++++ arch/arm/mach-sunxi/board.c | 1 + arch/arm/mach-sunxi/clock_sun50i_h6.c | 8 ++++++ 6 files changed, 65 insertions(+) create mode 100644 arch/arm/cpu/armv7/sunxi/spc.c
arch/arm/cpu/armv7/sunxi/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_MACH_SUN6I) += tzpc.o obj-$(CONFIG_MACH_SUN8I_H3) += tzpc.o +obj-$(CONFIG_MACH_SUN8I_R528) += spc.o obj-$(CONFIG_MACH_SUN6I) += sram.o obj-$(CONFIG_MACH_SUN8I) += sram.o
arch/arm/cpu/armv7/sunxi/spc.c new file +20 -0
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2015 Chen-Yu Tsai <[email protected]> +* (C) Copyright 2026 Lukas Schmid <[email protected]> +*/ + +#include <asm/io.h> +#include <asm/arch/cpu.h> +#include <asm/arch/sys_proto.h> + +void spc_init (void ) +{ +struct sunxi_spc *spc = (struct sunxi_spc *)SUNXI_SPC_BASE ; +int i; + +for (i =0 ; i <SUNXI_SPC_NUM_PORTS ; i++) +writel (SUNXI_SPC_DECPORT_MASK , &spc->decport[i].set); + +writel (SUNXI_DMA_SEC_MASK ,SUNXI_DMA_BASE +SUNXI_DMA_SEC_REG ); +}
arch/arm/include/asm/arch-sunxi/cpu_sunxi_ncat2.h +27 -0
@@ -7,6 +7,7 @@#ifndef _SUNXI_CPU_SUNXI_NCAT2_H#define _SUNXI_CPU_SUNXI_NCAT2_H +#define SUNXI_SPC_BASE 0x02000800#define SUNXI_CCM_BASE 0x02001000#define SUNXI_TIMER_BASE 0x02050000
@@ -16,6 +17,7 @@#define SUNXI_TWI3_BASE 0x02502C00#define SUNXI_SRAMC_BASE 0x03000000 +#define SUNXI_DMA_BASE 0x03002000/* SID address space starts at 0x03006000, but e-fuse is at offset 0x200 */ #define SUNXI_SIDC_BASE 0x03006000#define SUNXI_SID_BASE 0x03006200
@@ -50,7 +52,32 @@#define SUNXI_CPU_PLL_CFG_BASE 0x08817000 +#ifdef CONFIG_MACH_SUN8I_R528 +#define SUNXI_CCM_SEC_SWITCH_REG (SUNXI_CCM_BASE + 0x0f00) +#define SUNXI_CCM_SEC_SWITCH_NONSEC 0x7 +#define SUNXI_PRCM_SEC_SWITCH_REG (SUNXI_PRCM_BASE + 0x0290) +#define SUNXI_PRCM_SEC_SWITCH_NONSEC 0x1 +#define SUNXI_SPC_DECPORT_STA_REG (p) (SUNXI_SPC_BASE + 0x0000 + 0x10 * (p)) +#define SUNXI_SPC_DECPORT_SET_REG (p) (SUNXI_SPC_BASE + 0x0004 + 0x10 * (p)) +#define SUNXI_SPC_DECPORT_CLR_REG (p) (SUNXI_SPC_BASE + 0x0008 + 0x10 * (p)) +#define SUNXI_SPC_NUM_PORTS 13 +#define SUNXI_SPC_DECPORT_MASK 0xffffffff +#define SUNXI_DMA_SEC_REG 0x20 +#define SUNXI_DMA_SEC_MASK 0xffff +#endif +#ifndef __ASSEMBLY__ +struct sunxi_spc_decport { +u32 status; +u32 set; +u32 clear; +u32 reserved; +}; + +struct sunxi_spc { +struct sunxi_spc_decport decport[SUNXI_SPC_NUM_PORTS ]; +}; +void sunxi_board_init (void );void sunxi_reset (void );int sunxi_get_sid (unsigned int *sid);
arch/arm/include/asm/arch-sunxi/sys_proto.h +8 -0
@@ -18,6 +18,14 @@ bool sunxi_get_unique_sid(unsigned int *sid);/* Build legacy-compatible SID-derived locally administered MAC address. */ bool sunxi_get_sid_mac_addr (int index,u8 mac[6 ]); +#ifdef CONFIG_MACH_SUN8I_R528 +void spc_init (void ); +#else +static inline void spc_init (void ) +{ +} +#endif +/* return_to_fel() - Return to BROM from SPL * * This returns back into the BROM after U-Boot SPL has performed its initial
arch/arm/mach-sunxi/board.c +1 -0
@@ -475,6 +475,7 @@ void board_init_f(ulong dummy)/* Enable non-secure access to some peripherals */ tzpc_init (); +spc_init ();timer_init ();clock_init ();
arch/arm/mach-sunxi/clock_sun50i_h6.c +8 -0
@@ -74,6 +74,14 @@ void clock_init_safe(void) } } +void clock_init_sec (void ) +{ +if (IS_ENABLED (CONFIG_MACH_SUN8I_R528 )) { +writel (SUNXI_CCM_SEC_SWITCH_NONSEC ,SUNXI_CCM_SEC_SWITCH_REG ); +writel (SUNXI_PRCM_SEC_SWITCH_NONSEC ,SUNXI_PRCM_SEC_SWITCH_REG ); + } +} +void clock_init_uart (void ) {void *const ccm = (void *)SUNXI_CCM_BASE ;
Signature · 1 line
2.47.3
PATCH 4/6 boot: allow SPL FIT signature verification without DM
In reply to Lukas SchmidSPL FIT verification was effectively tied to Driver Model. The RSA verifier assumed a DM-backed modexp device, and SPL_FIT_SIGNATURE depended on SPL_DM. This prevents non-DM SPL platforms from using FIT signature verification even though the software modular exponent fallback is already available.
Drop the hard SPL_DM dependency and only look up the modexp device when DM is enabled. Non-DM SPL builds then fall back to the software implementation and can enable signed FIT verification.
--- boot/Kconfig | 1 - lib/rsa/rsa-verify.c | 16 ++++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-)
boot/Kconfig +0 -1
@@ -202,7 +202,6 @@ config SPL_FIT_FULL_CHECK config SPL_FIT_SIGNATURE bool "Enable signature verification of FIT firmware within SPL" - depends on SPL_DM depends on SPL_LOAD_FIT select FIT_SIGNATURE select SPL_FIT
lib/rsa/rsa-verify.c +10 -6
@@ -355,13 +355,17 @@ static int rsa_verify_key(struct image_sign_info *info, hash_len = checksum->checksum_len;#if !defined(USE_HOSTCC ) - ret =uclass_get_device (UCLASS_MOD_EXP ,0 , &mod_exp_dev); -if (ret) { -printf ("RSA: Can't find Modular Exp implementation\n" ); -return -EINVAL ; - } +if (CONFIG_IS_ENABLED (DM )) { + ret =uclass_get_device (UCLASS_MOD_EXP ,0 , &mod_exp_dev); +if (ret) { +printf ("RSA: Can't find Modular Exp implementation\n" ); +return -EINVAL ; + } - ret =rsa_mod_exp (mod_exp_dev, sig, sig_len, prop, buf); + ret =rsa_mod_exp (mod_exp_dev, sig, sig_len, prop, buf); + }else { + ret =rsa_mod_exp_sw (sig, sig_len, prop, buf); + }#else ret =rsa_mod_exp_sw (sig, sig_len, prop, buf);#endif
Signature · 1 line
2.47.3
PATCH 5/6 sunxi: extend binman FIT description for signed SPL images
In reply to Lukas SchmidExtend the sunxi binman/FIT description to support signed SPL FIT images. Add an SPL public-key DTB image, per-image hash nodes, fit,sign support, and a configuration signature that covers firmware, loadables and the selected FDT.
Handle TOC0 SPL output as well by adding the required filename and mkimage wrapping so the generated sunxi image remains verifiable.
--- arch/arm/dts/sunxi-u-boot.dtsi | 68 ++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-)
arch/arm/dts/sunxi-u-boot.dtsi +64 -4
@@ -27,6 +27,38 @@ #endif &binman { +#ifdef CONFIG_SPL_FIT_SIGNATURE + spl { +#ifdef CONFIG_SPL_IMAGE_TYPE_SUNXI_TOC0 + filename = "spl/u-boot-spl.bin"; +#else + filename = "spl/sunxi-spl.bin"; +#endif + + u-boot-spl-nodtb { + }; + + u-boot-spl-pubkey-dtb { + algo = "sha256,rsa2048"; + required = "conf"; + key-name-hint = "dev"; + }; + }; + +#ifdef CONFIG_SPL_IMAGE_TYPE_SUNXI_TOC0 + image { + filename = "spl/sunxi-spl.bin"; + + mkimage { + args = "-a 0x20060 -T sunxi_toc0"; + data-to-imagename; + + u-boot-spl { + }; + }; + }; +#endif +#endif u-boot-sunxi-with-spl { filename = "u-boot-sunxi-with-spl.bin"; pad-byte = <0xff>;
@@ -45,6 +77,9 @@ description = "Configuration to load U-Boot and firmware"; #address-cells = <1>; fit,fdt-list = "of-list"; +#ifdef CONFIG_SPL_FIT_SIGNATURE + fit,sign; +#endif images { uboot {
@@ -60,6 +95,11 @@ u-boot-nodtb { }; +#ifdef CONFIG_SPL_FIT_SIGNATURE + hash { + algo = "sha256"; + }; +#endif }; #if CONFIG_SUNXI_BL31_BASE
@@ -76,6 +116,11 @@ filename = "bl31.bin"; missing-msg = "atf-bl31-sunxi"; }; +#ifdef CONFIG_SPL_FIT_SIGNATURE + hash { + algo = "sha256"; + }; +#endif }; #endif
@@ -92,6 +137,11 @@ missing-msg = "scp-sunxi"; optional; }; +#ifdef CONFIG_SPL_FIT_SIGNATURE + hash { + algo = "sha256"; + }; +#endif }; #endif
@@ -99,6 +149,11 @@ description = "NAME"; type = "flat_dt"; compression = "none"; +#ifdef CONFIG_SPL_FIT_SIGNATURE + hash { + algo = "sha256"; + }; +#endif }; };
@@ -108,16 +163,21 @@ @config-SEQ { description = "NAME"; #if CONFIG_SUNXI_BL31_BASE - firmware = "atf"; + firmware = "atf", "uboot"; #else firmware = "uboot"; #endif #if CONFIG_SUNXI_SCP_BASE - loadables = "scp", "uboot"; -#else - loadables = "uboot"; + loadables = "scp"; #endif fdt = "fdt-SEQ"; +#ifdef CONFIG_SPL_FIT_SIGNATURE + signature { + algo = "sha256,rsa2048"; + key-name-hint = "dev"; + sign-images = "firmware", "loadables", "fdt"; + }; +#endif }; }; };
Signature · 1 line
2.47.3
PATCH 6/6 sunxi: add support for NetCube Systems Nagami and associated carrier boards
In reply to Lukas SchmidNetCube Systems Nagami is a system-on-module based on the Allwinner T113-S3 and T113-S4 series chips.
Its features include:
* Dual ARM Cortex-A7 @ 1.2 GHz
* 128/256 MiB DDR3 memory, 4 GiB eMMC
* 10/100 Ethernet PHY
* 1x USB 2.0 OTG, 1x USB 2.0 host
* 1x SPI interface with HOLD/WP
* Up to 5 UARTs (2 with RTS/CTS)
* Up to 4 I2C interfaces
* Up to 2 CAN 2.0B interfaces
* Up to 2 I2S/PCM interfaces
* Up to 1 SPDIF input and output
* I2C extension interface with INT
Add defconfigs for the basic carrier and keypad carrier variants, plus a secure-boot example defconfig for the basic carrier.
The basic carrier brings out the SD interface to a microSD slot, the USB host to USB-A, and USB OTG to micro-B. It has an Ethernet MagJack and exposes CAN, I2C, SPI, I2S and GPIO signals on pin headers.
The keypad carrier adds an I2C-connected PN532 NFC reader, a 4x3 keypad, Ethernet with PoE, a USB mini-B diagnostics port, and a two-colour status LED.
--- .../netcube_nagami_basic_carrier_defconfig | 43 +++++++++++++++ ..._nagami_basic_carrier_secureboot_defconfig | 52 +++++++++++++++++++ .../netcube_nagami_keypad_carrier_defconfig | 43 +++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 configs/netcube_nagami_basic_carrier_defconfig create mode 100644 configs/netcube_nagami_basic_carrier_secureboot_defconfig create mode 100644 configs/netcube_nagami_keypad_carrier_defconfig
configs/netcube_nagami_basic_carrier_defconfig new file +43 -0
@@ -0,0 +1,43 @@ +CONFIG_ARM=y +CONFIG_ARCH_SUNXI=y +CONFIG_DEFAULT_DEVICE_TREE="allwinner/sun8i-t113s-netcube-nagami-basic-carrier" +CONFIG_DRAM_CLK=792 +CONFIG_SPL=y +CONFIG_DRAM_SUNXI_ODT_EN=0 +CONFIG_DRAM_SUNXI_TPR0=0x004a2195 +CONFIG_DRAM_SUNXI_TPR11=0x340000 +CONFIG_DRAM_SUNXI_TPR12=0x46 +CONFIG_DRAM_SUNXI_TPR13=0x34000100 +CONFIG_MACH_SUN8I_R528=y +CONFIG_DRAM_ZQ=8092667 +CONFIG_SUNXI_MINIMUM_DRAM_MB=128 +CONFIG_MMC_SUNXI_SLOT_EXTRA=2 +# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +CONFIG_BOOTDELAY=1 +CONFIG_PREBOOT="gpio set PD9" +# CONFIG_SYS_DEVICE_NULLDEV is not set +# CONFIG_SYS_MMCSD_FS_BOOT is not set +CONFIG_SYS_PROMPT="Nagami> " +CONFIG_CMD_EEPROM=y +CONFIG_SYS_I2C_EEPROM_BUS=1 +CONFIG_CMD_I2C=y +CONFIG_CMD_USB_MASS_STORAGE=y +CONFIG_ENV_IS_IN_MMC=y +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y +CONFIG_USE_HOSTNAME=y +CONFIG_HOSTNAME="nagami" +CONFIG_VERSION_VARIABLE=y +# CONFIG_USB_FUNCTION_FASTBOOT is not set +CONFIG_SYS_I2C_MVTWSI=y +CONFIG_MISC=y +CONFIG_NVMEM=y +CONFIG_I2C_EEPROM=y +CONFIG_SYS_I2C_EEPROM_ADDR=0x50 +CONFIG_SUPPORT_EMMC_BOOT=y +CONFIG_RMII=y +CONFIG_SUN8I_EMAC=y +CONFIG_CONS_INDEX=4 +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_OHCI_HCD=y +CONFIG_USB_MUSB_GADGET=y +CONFIG_USB_GADGET_DOWNLOAD=y
configs/netcube_nagami_basic_carrier_secureboot_defconfig new file +52 -0
52 lines not on this page · raw message
configs/netcube_nagami_keypad_carrier_defconfig new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
2.47.3