Re: [RFC PATCH 0/4] mtd: ubi: Enable accessing RO filesystems in UBI vols
Hello Sam, sorry for the late reply... On 07.09.23 23:46, Sam Edwards wrote: > Hi Heiko and Simon, > > Thought I'd follow-up to keep this discussion going. The main thing I would > like to decide first (as > it lets me start relying on it in boot scripts) would be the UBI access > syntax: > > => ls ubi 0:rootfs /boot > => ls ubi 0:2 /boot Looks perfect for me. > Do those look good? Should I be trying to mimic the accepted syntax of > fs/ubifs/super.c:open_ubi()? > Perhaps "ubi 0!rootfs" and/or "ubi 0_2"? Not using ':' leaves open the > possibility for logical > volumes (LVM2/UBI) to contain partitions - not that I expect anyone will want > that. :) Good question... You never know... so from my side, yes it would be good to allow both options ... so "ubi 0:2" and "ubi 0_2", something like if ":" is in use "ubi 0:2" else try "ubi 0_2" Please rebase your patchset when 2023.10 is out, thanks! bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de
Re: [PATCH v5 00/20] x86: efi: Fixes and improvements for coreboot
Hi Simon, On Thu, Sep 21, 2023 at 1:27 PM Bin Meng wrote: > > Hi Simon, > > On Wed, Sep 20, 2023 at 11:00 AM Simon Glass wrote: > > > > This little series fixes various bugs and annoyances in coreboot and > > coreboot64. > > > > With this both coreboot and coreboot64 start up and work reasonably well > > on Brya (x86 Chromebook) and U-Boot can boot common Linux distros. > > > > - Make coreboot64 debug UART start reliably > > - Avoid the long USB-init delay on startup > > - Correct the timer speed on coreboo64 > > - Fix a bootstd cros bug (will likely be squashed into another patch) > > - Fix the terribly slow console scrolling > > > > With v2 I have also brought in some lost x86 patches so they are all in > > one series. > > > > Changes in v5: > > - Use 'lzma' instead of 'LZMA' > > - Drop unwanted space > > - Correct 'teechnique' typo in commit message > > - Make use of the uSE_PREBOOT mechanism > > > > Changes in v4: > > - Fix arm and riscv > > - Rewrite this to use events instead > > > > Changes in v3: > > - Allow SMBIOS if EFI_LOADER is enabled > > - Reword the help > > - Use log_debug() to show the message > > - Squash in the next patch > > > > Changes in v2: > > - Update the malloc size too > > - Add new patch > > - Add new patch > > - Add new patch > > - Add new patch > > - Add new patch > > - Add new patch > > - Add new patch > > - Add new patch > > - Add new patch > > > > Simon Glass (20): > > x86: coreboot: Add IDE and SATA > > x86: coreboot: Enable standard boot > > x86: coreboot: Rearrange arch_cpu_init() > > x86: Set the CPU vendor in SPL > > x86: Allow APCI in SPL > > x86: coreboot: Look for DBG2 UART in SPL too > > x86: coreboot: Enable CONFIG_SYS_NS16550_MEM32 > > x86: coreboot: Drop USB init on startup > > x86: coreboot: Align options between coreboot and coreboot64 > > x86: coreboot: Enable VIDEO_COPY > > efi: x86: Correct the condition for installing ACPI tables > > x86: smbios: Add a Kconfig indicating SMBIOS-table presence > > bootstd: Keep track of use of usb stop > > Record the position of the SMBIOS tables > > efi: Use the installed SMBIOS tables > > x86: coreboot: Record the position of the SMBIOS tables > > x86: doc: Move into its own directory > > x86: doc: Update summaries and add links > > x86: doc: Split out manual booting into its own file > > x86: doc: coreboot: Mention 64-bit Linux distros > > > > Patch #8 needs to respin to address PREBOOT comment > Path#18 does not apply. > > Patch#13, 15 v6 version are applied. > > Reset patches in this series are applied to u-boot-x86/next, thanks! The CI still fails on u-boot-x86/next which is already rebased on origin/next. https://source.denx.de/u-boot/custodians/u-boot-x86/-/pipelines/17784 Regards, Bin
Re: [PATCH v5 00/20] x86: efi: Fixes and improvements for coreboot
Hi Simon, On Wed, Sep 20, 2023 at 11:00 AM Simon Glass wrote: > > This little series fixes various bugs and annoyances in coreboot and > coreboot64. > > With this both coreboot and coreboot64 start up and work reasonably well > on Brya (x86 Chromebook) and U-Boot can boot common Linux distros. > > - Make coreboot64 debug UART start reliably > - Avoid the long USB-init delay on startup > - Correct the timer speed on coreboo64 > - Fix a bootstd cros bug (will likely be squashed into another patch) > - Fix the terribly slow console scrolling > > With v2 I have also brought in some lost x86 patches so they are all in > one series. > > Changes in v5: > - Use 'lzma' instead of 'LZMA' > - Drop unwanted space > - Correct 'teechnique' typo in commit message > - Make use of the uSE_PREBOOT mechanism > > Changes in v4: > - Fix arm and riscv > - Rewrite this to use events instead > > Changes in v3: > - Allow SMBIOS if EFI_LOADER is enabled > - Reword the help > - Use log_debug() to show the message > - Squash in the next patch > > Changes in v2: > - Update the malloc size too > - Add new patch > - Add new patch > - Add new patch > - Add new patch > - Add new patch > - Add new patch > - Add new patch > - Add new patch > - Add new patch > > Simon Glass (20): > x86: coreboot: Add IDE and SATA > x86: coreboot: Enable standard boot > x86: coreboot: Rearrange arch_cpu_init() > x86: Set the CPU vendor in SPL > x86: Allow APCI in SPL > x86: coreboot: Look for DBG2 UART in SPL too > x86: coreboot: Enable CONFIG_SYS_NS16550_MEM32 > x86: coreboot: Drop USB init on startup > x86: coreboot: Align options between coreboot and coreboot64 > x86: coreboot: Enable VIDEO_COPY > efi: x86: Correct the condition for installing ACPI tables > x86: smbios: Add a Kconfig indicating SMBIOS-table presence > bootstd: Keep track of use of usb stop > Record the position of the SMBIOS tables > efi: Use the installed SMBIOS tables > x86: coreboot: Record the position of the SMBIOS tables > x86: doc: Move into its own directory > x86: doc: Update summaries and add links > x86: doc: Split out manual booting into its own file > x86: doc: coreboot: Mention 64-bit Linux distros > Patch #8 needs to respin to address PREBOOT comment Path#18 does not apply. Patch#13, 15 v6 version are applied. Reset patches in this series are applied to u-boot-x86/next, thanks! The reset Regards, Bin
Re: [PATCH v3] clk: ti: Notify AVS driver upon setting clock rate
Thanks Nishanth On 9/20/2023 5:50 PM, Nishanth Menon wrote: On 17:32-20230920, Udit Kumar wrote: AVS is enabled at R5 SPL stage, on few platforms like J721E and J7200 clk-k3 is used instead if clk-sci driver. [...] I think it is better to put IS_ENABLED() as the first check. See other usage: $ git grep IS_ENABLED . |grep if|grep '&&' will address in next version [..] First look - it looks fine, but note: these are two different patches. the clk-sci.c is a fix for an existing implementation and clk-k3.c is a new feature addition. please don't mix the two. Sure, Let me send two patches then, One for new implementation clk-k3.c version v4. and another for clk-sci.c with Fixes tag.
Re: [PATCH v5 08/20] x86: coreboot: Drop USB init on startup
Hi Simon, On Wed, Sep 20, 2023 at 9:37 PM Heinrich Schuchardt wrote: > > On 20.09.23 13:50, Marek Vasut wrote: > > On 9/20/23 09:19, Heinrich Schuchardt wrote: > >> On 9/20/23 05:00, Simon Glass wrote: > >>> This is very annoying as it is quite slow on many machines. Also, U-Boot > >>> has an existing 'preboot' mechanism to enable this feature if desired. > >>> > >>> Drop this code so that it is possible to choose whether to init USB or > >>> not. > >>> > >>> Use the existing USE_PREBOOT mechanism instead. > >>> > >>> Signed-off-by: Simon Glass > >>> --- > >>> > >>> Changes in v5: > >>> - Make use of the uSE_PREBOOT mechanism > >>> > >>> arch/x86/cpu/coreboot/Kconfig| 1 + > >>> arch/x86/cpu/coreboot/coreboot.c | 4 > >>> 2 files changed, 1 insertion(+), 4 deletions(-) > >>> > >>> diff --git a/arch/x86/cpu/coreboot/Kconfig > >>> b/arch/x86/cpu/coreboot/Kconfig > >>> index b97c27790419..178f8ad18162 100644 > >>> --- a/arch/x86/cpu/coreboot/Kconfig > >>> +++ b/arch/x86/cpu/coreboot/Kconfig > >>> @@ -25,6 +25,7 @@ config SYS_COREBOOT > >>> imply FS_CBFS > >>> imply CBMEM_CONSOLE > >>> imply X86_TSC_READ_BASE > >>> +imply USE_PREBOOT > >> > >> For automatic initialization of the PCI bus we have CONFIG_PCI_INIT_R. > >> Wouldn't it be preferable to also have a CONFIG_USB_INIT_R instead of > >> relying on console commands in CONFIG_PREBOOT? > > > > I'd much prefer 'preboot=usb init' or whatever console command, since > > this is not hard-coded into the U-Boot binary and can be overridden by > > user if the 'usb init' is inconvenient/unnecessary/... without replacing > > and/or rebuilding the U-Boot binary. > > Just for the record this means using CONFIG_PREBOOT: > > include/env_default.h: > > #ifdef CONFIG_PREBOOT_DEFINED > "preboot="CONFIG_PREBOOT"\0" > #endif > > Thank you for the clarification. Will you update the coreboot documentation to mention the PREBOOT mechanism to initialize USB so that a USB keyboard can be used as the input for the U-Boot console? Regards, Bin
Re: [PATCH v5 07/20] x86: coreboot: Enable CONFIG_SYS_NS16550_MEM32
On Wed, Sep 20, 2023 at 11:00 AM Simon Glass wrote: > > The debug UART on modern machines uses a 32-bit wide transfer. Without > this, setting debug output causes a hang or no output. It is not obvious > (when enabling CONFIG_DEBUG_UART) that this is needed. > > Enable 32-bit access to avoid this trap. > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > configs/coreboot64_defconfig | 1 + > configs/coreboot_defconfig | 1 + > 2 files changed, 2 insertions(+) > Reviewed-by: Bin Meng
Re: [PATCH v4 2/2] x86: Update cbmem driver
Hi Simon, On Wed, Sep 20, 2023 at 10:59 AM Simon Glass wrote: > > Hi Bin, > > On Tue, 19 Sept 2023 at 02:47, Bin Meng wrote: > > > > Hi Simon, > > > > On Mon, Sep 11, 2023 at 3:13 AM Simon Glass wrote: > > > > > > This driver is not actually built since a Kconfig was never created for > > > it. > > > > > > Add a Kconfig (which is already implied by COREBOOT) and update the > > > implementation to avoid using unnecessary memory. Drop the #ifdef at the > > > top since we can rely on Kconfig to get that right. > > > > > > To enable it (in addition to serial and video), use: > > > > > >setenv stdout serial,vidconsole,cbmem > > > > > > Signed-off-by: Simon Glass > > > --- > > > > > > Changes in v4: > > > - Add some comments to help understand the overflow mechanism > > > > > > Changes in v2: > > > - Update to support the new overflow mechanism > > > > > > drivers/misc/Kconfig | 8 +++ > > > drivers/misc/cbmem_console.c | 43 ++-- > > > 2 files changed, 34 insertions(+), 17 deletions(-) > > > > > > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig > > > index a6e3f62ecb09..c930e4a361bf 100644 > > > --- a/drivers/misc/Kconfig > > > +++ b/drivers/misc/Kconfig > > > @@ -122,6 +122,14 @@ config VEXPRESS_CONFIG > > > configuration bus on the Arm Versatile Express boards via > > > a sysreg driver. > > > > > > +config CBMEM_CONSOLE > > > + bool "Write console output to coreboot cbmem" > > > + depends on X86 > > > + help > > > + Enables console output to the cbmem console, which is a memory > > > + region set up by coreboot to hold a record of all console > > > output. > > > + Enable this only if booting from coreboot. > > > + > > > config CMD_CROS_EC > > > bool "Enable crosec command" > > > depends on CROS_EC > > > diff --git a/drivers/misc/cbmem_console.c b/drivers/misc/cbmem_console.c > > > index 8bbe33d414da..3cbe9fb1a46a 100644 > > > --- a/drivers/misc/cbmem_console.c > > > +++ b/drivers/misc/cbmem_console.c > > > @@ -5,27 +5,37 @@ > > > > > > #include > > > #include > > > -#ifndef CONFIG_SYS_COREBOOT > > > -#error This driver requires coreboot > > > -#endif > > > - > > > #include > > > > > > -struct cbmem_console { > > > - u32 buffer_size; > > > - u32 buffer_cursor; > > > - u8 buffer_body[0]; > > > -} __attribute__ ((__packed__)); > > > - > > > -static struct cbmem_console *cbmem_console_p; > > > - > > > void cbmemc_putc(struct stdio_dev *dev, char data) > > > { > > > - int cursor; > > > + const struct sysinfo_t *sysinfo = cb_get_sysinfo(); > > > + struct cbmem_console *cons; > > > + uint pos, flags; > > > + > > > + if (!sysinfo) > > > + return; > > > + cons = sysinfo->cbmem_cons; > > > + if (!cons) > > > + return; > > > + > > > + pos = cons->cursor & CBMC_CURSOR_MASK; > > > + > > > + /* preserve the overflow flag if present */ > > > + flags = cons->cursor & ~CBMC_CURSOR_MASK; > > > + > > > + cons->body[pos++] = data; > > > + > > > + /* > > > +* Deal with overflow - the flag may be cleared by another > > > program which > > > +* reads the buffer out, e.g. Linux > > > +*/ > > > > U-Boot is not memory resident, so this does not sound like a correct > > overflow mechanism to me. > > I am not sure what you mean. This logic is used in coreboot and some > payloads, so I want to do the same in U-Boot. It basically let's > U-Boot handle an overflow properly by setting the overflow flag. A > later program (e.g. Linux) can then tell that that an overflow > occurred. > Okay, I modified the comment to /* * Deal with overflow - the flag may be cleared by another program which * reads the buffer out later, e.g. Linux */ which makes more sense. applied to u-boot-x86/next, thanks! Regards, Bin
[PATCH v2 32/32] pci: serial: Support reading PCI-register size with base
The PCI helpers read only the base address for a PCI region. In some cases the size is needed as well, e.g. to pass along to a driver which needs to know the size of its register area. Update the functions to allow the size to be returned. For serial, record the information and provided it with the serial_info() call. A limitation still exists in that the size is not available when OF_LIVE is enabled, so take account of that in the tests. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/dts/test.dts | 6 +++--- drivers/core/fdtaddr.c | 6 +++--- drivers/core/ofnode.c | 11 --- drivers/core/read.c | 6 -- drivers/core/util.c | 2 +- drivers/pci/pci-uclass.c| 2 +- drivers/pci/pci_mvebu.c | 3 ++- drivers/pci/pci_tegra.c | 2 +- drivers/pci/pcie_mediatek.c | 4 ++-- drivers/serial/ns16550.c| 15 ++- include/dm/fdtaddr.h| 3 ++- include/dm/ofnode.h | 4 +++- include/dm/read.h | 8 +--- include/ns16550.h | 4 +++- include/serial.h| 2 ++ test/dm/pci.c | 14 ++ 16 files changed, 60 insertions(+), 32 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index d4693e3c7a93..20024101d8ad 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -1098,8 +1098,8 @@ pci@1,0 { compatible = "pci-generic"; /* reg 0 is at 0x14, using FDT_PCI_SPACE_MEM32 */ - reg = <0x02000814 0 0 0 0 - 0x01000810 0 0 0 0>; + reg = <0x02000814 0 0 0x80 0 + 0x01000810 0 0 0xc0 0>; sandbox,emul = <&swap_case_emul0_1>; }; p2sb-pci@2,0 { @@ -1126,7 +1126,7 @@ pci@1f,0 { compatible = "pci-generic"; /* reg 0 is at 0x10, using FDT_PCI_SPACE_IO */ - reg = <0x0100f810 0 0 0 0>; + reg = <0x0100f810 0 0 0x100 0>; sandbox,emul = <&swap_case_emul0_1f>; }; }; diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c index 546db675aaf6..b79d138c4196 100644 --- a/drivers/core/fdtaddr.c +++ b/drivers/core/fdtaddr.c @@ -215,7 +215,7 @@ void *devfdt_map_physmem(const struct udevice *dev, unsigned long size) return map_physmem(addr, size, MAP_NOCACHE); } -fdt_addr_t devfdt_get_addr_pci(const struct udevice *dev) +fdt_addr_t devfdt_get_addr_pci(const struct udevice *dev, fdt_size_t *sizep) { ulong addr; @@ -226,12 +226,12 @@ fdt_addr_t devfdt_get_addr_pci(const struct udevice *dev) int ret; ret = ofnode_read_pci_addr(dev_ofnode(dev), FDT_PCI_SPACE_MEM32, - "reg", &pci_addr); + "reg", &pci_addr, sizep); if (ret) { /* try if there is any i/o-mapped register */ ret = ofnode_read_pci_addr(dev_ofnode(dev), FDT_PCI_SPACE_IO, "reg", - &pci_addr); + &pci_addr, sizep); if (ret) return FDT_ADDR_T_NONE; } diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 2ef4114cb6f8..c9cec456f430 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1270,7 +1270,8 @@ const uint8_t *ofnode_read_u8_array_ptr(ofnode node, const char *propname, } int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type, -const char *propname, struct fdt_pci_addr *addr) +const char *propname, struct fdt_pci_addr *addr, +fdt_size_t *size) { const fdt32_t *cell; int len; @@ -1298,14 +1299,18 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type, (ulong)fdt32_to_cpu(cell[1]), (ulong)fdt32_to_cpu(cell[2])); if ((fdt32_to_cpu(*cell) & type) == type) { + const unaligned_fdt64_t *ptr; + addr->phys_hi = fdt32_to_cpu(cell[0]); addr->phys_mid = fdt32_to_cpu(cell[1]); addr->phys_lo = fdt32_to_cpu(cell[2]); + ptr = (const unaligned_fdt64_t *)(cell + 3); + if (size) + *size = fdt64_to_cpu(*ptr); break; } - cell += (FDT_PCI_ADDR_CELLS + -FDT_PCI_SIZE_CELLS); +
[PATCH v2 31/32] command: Include a required header in command.h
This uses ARRAY_SIZE() but does not include the header file which declares it. Fix this, so that command.h can be included without common.h Signed-off-by: Simon Glass --- (no changes since v1) include/command.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/command.h b/include/command.h index ae7bb4a30b05..8aebf7a95bf8 100644 --- a/include/command.h +++ b/include/command.h @@ -15,6 +15,9 @@ #include +/* For ARRAY_SIZE() */ +#include + #ifndef NULL #define NULL 0 #endif -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 30/32] fdt: Allow the devicetree to come from a bloblist
Standard passage provides for a bloblist to be passed from one firmware phase to the next. That can be used to pass the devicetree along as well. Add an option to support this. Tests for this will be added as part of the Universal Payload work. Signed-off-by: Simon Glass --- Changes in v2: - No changes as it still seems unclear what should be done common/bloblist.c | 2 ++ doc/develop/devicetree/control.rst | 3 ++ dts/Kconfig| 8 ++ include/bloblist.h | 5 include/fdtdec.h | 3 +- lib/fdtdec.c | 44 ++ 6 files changed, 52 insertions(+), 13 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index 6f2a4577708d..b07ede11cfe2 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -48,9 +48,11 @@ static struct tag_name { { BLOBLISTT_ACPI_TABLES, "ACPI tables for x86" }, { BLOBLISTT_SMBIOS_TABLES, "SMBIOS tables for x86" }, { BLOBLISTT_VBOOT_CTX, "Chrome OS vboot context" }, + { BLOBLISTT_CONTROL_FDT, "Control FDT" }, /* BLOBLISTT_PROJECT_AREA */ { BLOBLISTT_U_BOOT_SPL_HANDOFF, "SPL hand-off" }, + { BLOBLISTT_VBE, "VBE" }, { BLOBLISTT_U_BOOT_VIDEO, "SPL video handoff" }, /* BLOBLISTT_VENDOR_AREA */ diff --git a/doc/develop/devicetree/control.rst b/doc/develop/devicetree/control.rst index cbb65c9b177f..56e00090166f 100644 --- a/doc/develop/devicetree/control.rst +++ b/doc/develop/devicetree/control.rst @@ -108,6 +108,9 @@ If CONFIG_OF_BOARD is defined, a board-specific routine will provide the devicetree at runtime, for example if an earlier bootloader stage creates it and passes it to U-Boot. +If CONFIG_OF_BLOBLIST is defined, the devicetree comes from a bloblist passed +from a previous stage. + If CONFIG_SANDBOX is defined, then it will be read from a file on startup. Use the -d flag to U-Boot to specify the file to read, -D for the default and -T for the test devicetree, used to run sandbox unit tests. diff --git a/dts/Kconfig b/dts/Kconfig index 9152f5885e9a..6c1edbddb57b 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -105,6 +105,14 @@ config OF_EMBED endchoice +config OF_BLOBLIST + bool "DTB is provided by a bloblist" + help + Select this to read the devicetree from the bloblist. This allows + using a bloblist to transfer the devicetree between U-Boot phases. + The devicetree is stored in the bloblist by an early phase so that + U-Boot can read it. + config OF_BOARD bool "Provided by the board (e.g a previous loader) at runtime" default y if SANDBOX || OF_HAS_PRIOR_STAGE diff --git a/include/bloblist.h b/include/bloblist.h index 080cc46a1266..e16d122f4fb1 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -103,6 +103,11 @@ enum bloblist_tag_t { BLOBLISTT_ACPI_TABLES = 0x104, /* ACPI tables for x86 */ BLOBLISTT_SMBIOS_TABLES = 0x105, /* SMBIOS tables for x86 */ BLOBLISTT_VBOOT_CTX = 0x106,/* Chromium OS verified boot context */ + /* +* Devicetree for use by firmware. On some platforms this is passed to +* the OS also +*/ + BLOBLISTT_CONTROL_FDT = 0x107, /* * Project-specific tags are permitted here. Projects can be open source diff --git a/include/fdtdec.h b/include/fdtdec.h index bd1149f46d08..1888c4645619 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -72,7 +72,7 @@ struct bd_info; * U-Boot is packaged as an ELF file, e.g. for debugging purposes * @FDTSRC_ENV: Provided by the fdtcontroladdr environment variable. This should * be used for debugging/development only - * @FDTSRC_NONE: No devicetree at all + * @FDTSRC_BLOBLIST: Provided by a bloblist from an earlier phase */ enum fdt_source_t { FDTSRC_SEPARATE, @@ -80,6 +80,7 @@ enum fdt_source_t { FDTSRC_BOARD, FDTSRC_EMBED, FDTSRC_ENV, + FDTSRC_BLOBLIST, }; /* diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 7a6916764835..bd88e6a418eb 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -7,7 +7,11 @@ */ #ifndef USE_HOSTCC + +#define LOG_CATEGORY LOGC_DT + #include +#include #include #include #include @@ -87,6 +91,7 @@ static const char *const fdt_src_name[] = { [FDTSRC_BOARD] = "board", [FDTSRC_EMBED] = "embed", [FDTSRC_ENV] = "env", + [FDTSRC_BLOBLIST] = "bloblist", }; const char *fdtdec_get_srcname(void) @@ -1666,20 +1671,35 @@ int fdtdec_setup(void) int ret; /* The devicetree is typically appended to U-Boot */ - if (IS_ENABLED(CONFIG_OF_SEPARATE)) { - gd->fdt_blob = fdt_find_separate(); - gd->fdt_src = FDTSRC_SEPARATE; - } else { /* embed dtb in ELF file for testing / development */ - gd->fdt_blob = dtb_dt_embedded(); - gd->fdt_src = FDTSRC_EMBED; - } - -
[PATCH v2 29/32] bloblist: Support initing from multiple places
Typically the bloblist is set up after the devicetree is present. This makes sense because bloblist may use malloc() to allocate the space it needs. However sometimes the devicetree itself may be present in the bloblist. In that case it is at a known location in memory so we can init the bloblist very early, before devicetree. Add a flag to indicate whether the bloblist has been inited. Add a function to init it only if needed. Use that in the init sequence. Signed-off-by: Simon Glass --- (no changes since v1) common/bloblist.c | 13 - common/board_f.c | 4 +--- include/asm-generic/global_data.h | 4 include/bloblist.h| 18 ++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index 2144b10e1d04..6f2a4577708d 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -476,6 +476,17 @@ int bloblist_init(void) log_debug("Found existing bloblist size %lx at %lx\n", size, addr); } + if (ret) + return log_msg_ret("ini", ret); + gd->flags |= GD_FLG_BLOBLIST_READY; + + return 0; +} - return ret; +int bloblist_maybe_init(void) +{ + if (CONFIG_IS_ENABLED(BLOBLIST) && !(gd->flags & GD_FLG_BLOBLIST_READY)) + return bloblist_init(); + + return 0; } diff --git a/common/board_f.c b/common/board_f.c index aef395b1354e..244b0c5685e7 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -841,9 +841,7 @@ static const init_fnc_t init_sequence_f[] = { log_init, initf_bootstage,/* uses its own timer, so does not need DM */ event_init, -#ifdef CONFIG_BLOBLIST - bloblist_init, -#endif + bloblist_maybe_init, setup_spl_handoff, #if defined(CONFIG_CONSOLE_RECORD_INIT_F) console_record_init, diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index edf9ff6823f2..b0485f3dd2a3 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -674,6 +674,10 @@ enum gd_flags { * @GD_FLG_OF_TAG_MIGRATE: Device tree has old u-boot,dm- tags */ GD_FLG_OF_TAG_MIGRATE = 0x20, + /** +* @GD_FLG_BLOBLIST_READY: bloblist is ready for use +*/ + GD_FLG_BLOBLIST_READY = 0x40, }; #endif /* __ASSEMBLY__ */ diff --git a/include/bloblist.h b/include/bloblist.h index 7ea72c6bd46d..080cc46a1266 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -413,8 +413,26 @@ void bloblist_reloc(void *to, uint to_size, void *from, uint from_size); * standard passage. The size is detected automatically so CONFIG_BLOBLIST_SIZE * can be 0. * + * Sets GD_FLG_BLOBLIST_READY in global_data flags on success + * * Return: 0 if OK, -ve on error */ int bloblist_init(void); +#if CONFIG_IS_ENABLED(BLOBLIST) +/** + * bloblist_maybe_init() - Init the bloblist system if not already done + * + * Calls bloblist_init() if the GD_FLG_BLOBLIST_READY flag is not et + * + * Return: 0 if OK, -ve on error + */ +int bloblist_maybe_init(void); +#else +static inline int bloblist_maybe_init(void) +{ + return 0; +} +#endif /* BLOBLIST */ + #endif /* __BLOBLIST_H */ -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 28/32] sandbox: Move the bloblist down a little in memory
Move this down by 4KB so that it is large enough to hold the devicetree. Also fix up the devicetree address in the documetation while we are here. Signed-off-by: Simon Glass --- (no changes since v1) common/Kconfig | 2 +- doc/arch/sandbox/sandbox.rst | 4 ++-- test/lib/kconfig.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/Kconfig b/common/Kconfig index 21eaa5e815f9..5e79b5422178 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -1012,7 +1012,7 @@ endchoice config BLOBLIST_ADDR hex "Address of bloblist" - default 0xc000 if SANDBOX + default 0xb000 if SANDBOX depends on BLOBLIST_FIXED help Sets the address of the bloblist, set up by the first part of U-Boot diff --git a/doc/arch/sandbox/sandbox.rst b/doc/arch/sandbox/sandbox.rst index a3631de74932..23902dee89e7 100644 --- a/doc/arch/sandbox/sandbox.rst +++ b/doc/arch/sandbox/sandbox.rst @@ -614,8 +614,8 @@ that are mapped into that memory: === === Addr Config Usage === === - 0 CONFIG_SYS_FDT_LOAD_ADDR Device tree - c000 CONFIG_BLOBLIST_ADDR Blob list +100 CONFIG_SYS_FDT_LOAD_ADDR Device tree + b000 CONFIG_BLOBLIST_ADDR Blob list 1 CFG_MALLOC_F_ADDR Early memory allocation f CONFIG_PRE_CON_BUF_ADDRPre-console buffer 10 CONFIG_TRACE_EARLY_ADDREarly trace buffer (if enabled). Also used diff --git a/test/lib/kconfig.c b/test/lib/kconfig.c index 76225ba8ffa9..3914f699659f 100644 --- a/test/lib/kconfig.c +++ b/test/lib/kconfig.c @@ -22,9 +22,9 @@ static int lib_test_is_enabled(struct unit_test_state *uts) ut_asserteq(0, CONFIG_IS_ENABLED(OF_PLATDATA)); ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED)); - ut_asserteq(0xc000, + ut_asserteq(0xb000, IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, CONFIG_BLOBLIST_ADDR)); - ut_asserteq(0xc000, + ut_asserteq(0xb000, CONFIG_IF_ENABLED_INT(BLOBLIST_FIXED, BLOBLIST_ADDR)); /* -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 27/32] sandbox: Only read the state if we have a state file
We should not read this unless requested. Make it conditional on the option being provided. Add some debugging to show the state being written. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/start.c | 8 +--- arch/sandbox/cpu/state.c | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 5dc4db8bf605..efbc60e66805 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -522,9 +522,11 @@ int sandbox_main(int argc, char *argv[]) state->ram_buf_fname = NULL; } - ret = sandbox_read_state(state, state->state_fname); - if (ret) - goto err; + if (state->read_state && state->state_fname) { + ret = sandbox_read_state(state, state->state_fname); + if (ret) + goto err; + } if (state->handle_signals) { ret = os_setup_signal_handlers(); diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index fcc0028ff4a2..e38bb248b7ff 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -521,6 +521,7 @@ int state_uninit(void) printf("Failed to write sandbox state\n"); return -1; } + log_debug("Wrote state to file '%s'\n", state->ram_buf_fname); } /* Delete this at the last moment so as not to upset gdb too much */ -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 26/32] sandbox: Init the EC properly even if no state file is available
This currently relies on sandbox attempting to read a state file. At present it always does, even when there is no state file, in which case it fails, but still inits the EC. That is a bug, so update this driver to set the current image always, even if no state is read. Signed-off-by: Simon Glass --- (no changes since v1) drivers/misc/cros_ec_sandbox.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c index 8dbe0b188a48..1201535f4af4 100644 --- a/drivers/misc/cros_ec_sandbox.c +++ b/drivers/misc/cros_ec_sandbox.c @@ -81,6 +81,7 @@ struct ec_pwm_channel { /** * struct ec_state - Information about the EC state * + * @valid: true if this struct contains valid state data * @vbnv_context: Vboot context data stored by EC * @ec_config: FDT config information about the EC (e.g. flashmap) * @flash_data: Contents of flash memory @@ -95,6 +96,7 @@ struct ec_pwm_channel { * @pwm: Information per PWM channel */ struct ec_state { + bool valid; u8 vbnv_context[EC_VBNV_BLOCK_SIZE_V2]; struct fdt_cros_ec ec_config; uint8_t *flash_data; @@ -145,6 +147,7 @@ static int cros_ec_read_state(const void *blob, int node) memcpy(ec->flash_data, prop, len); debug("%s: Loaded EC flash data size %#x\n", __func__, len); } + ec->valid = true; return 0; } @@ -589,6 +592,7 @@ static int process_cmd(struct ec_state *ec, printf(" ** Unknown EC command %#02x\n", req_hdr->command); return -1; } + debug(" - EC command %#0x, result %d\n", req_hdr->command, len); return len; } @@ -675,7 +679,10 @@ int cros_ec_probe(struct udevice *dev) ofnode node; int err; - memcpy(ec, &s_state, sizeof(*ec)); + if (s_state.valid) + memcpy(ec, &s_state, sizeof(*ec)); + else + ec->current_image = EC_IMAGE_RO; err = cros_ec_decode_ec_flash(dev, &ec->ec_config); if (err) { debug("%s: Cannot device EC flash\n", __func__); -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 25/32] sandbox: Move reading the RAM buffer into a better place
This should not happen in the argument-parsing function. Move it to the main program. Add some debugging for reading/writing. Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/start.c | 19 +++ arch/sandbox/cpu/state.c | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 1026898727f5..5dc4db8bf605 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -272,17 +272,9 @@ SANDBOX_CMDLINE_OPT_SHORT(program, 'p', 1, "U-Boot program name"); static int sandbox_cmdline_cb_memory(struct sandbox_state *state, const char *arg) { - int err; - /* For now assume we always want to write it */ state->write_ram_buf = true; state->ram_buf_fname = arg; - - err = os_read_ram_buf(arg); - if (err) { - printf("Failed to read RAM buffer '%s': %d\n", arg, err); - return err; - } state->ram_buf_read = true; return 0; @@ -512,6 +504,17 @@ int sandbox_main(int argc, char *argv[]) if (os_parse_args(state, argc, argv)) return 1; + if (state->ram_buf_fname) { + ret = os_read_ram_buf(state->ram_buf_fname); + if (ret) { + printf("Failed to read RAM buffer '%s': %d\n", + state->ram_buf_fname, ret); + } else { + state->ram_buf_read = true; + log_debug("Read RAM buffer from '%s'\n", state->ram_buf_fname); + } + } + /* Remove old memory file if required */ if (state->ram_buf_rm && state->ram_buf_fname) { os_unlink(state->ram_buf_fname); diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index d67834988fd4..fcc0028ff4a2 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -513,6 +513,7 @@ int state_uninit(void) printf("Failed to write RAM buffer\n"); return err; } + log_debug("Wrote RAM to file '%s'\n", state->ram_buf_fname); } if (state->write_state) { -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 24/32] dm: core: Add tests for oftree_path()
Add a few simple tests for getting the root node, since this is handled as a special case in the implementation. Signed-off-by: Simon Glass --- (no changes since v1) test/dm/ofnode.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 5e63efdfa891..af3aa1e2ec51 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -228,6 +228,9 @@ static int dm_test_ofnode_read(struct unit_test_state *uts) ofnode node; int size; + node = oftree_path(oftree_default(), "/"); + ut_assert(ofnode_valid(node)); + node = ofnode_path("/a-test"); ut_assert(ofnode_valid(node)); @@ -256,6 +259,9 @@ static int dm_test_ofnode_read_ot(struct unit_test_state *uts) ofnode node; int size; + node = oftree_path(otree, "/"); + ut_assert(ofnode_valid(node)); + node = oftree_path(otree, "/node/subnode"); ut_assert(ofnode_valid(node)); -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 19/32] dm: core: Add a way to copy a node
Add a function to copy a node to another place under a new name. This is useful at least for testing, since copying a test node with existing properties is easier than writing the code to generate it all afresh. Signed-off-by: Simon Glass --- (no changes since v1) drivers/core/ofnode.c | 20 ++ include/dm/ofnode.h | 15 +++ test/dm/ofnode.c | 63 +++ 3 files changed, 98 insertions(+) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 7100fc630352..ba8385af7b46 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1743,3 +1743,23 @@ int ofnode_copy_props(ofnode dst, ofnode src) return 0; } + +int ofnode_copy_node(ofnode dst_parent, const char *name, ofnode src, +ofnode *nodep) +{ + ofnode node; + int ret; + + ret = ofnode_add_subnode(dst_parent, name, &node); + if (ret) { + if (ret == -EEXIST) + *nodep = node; + return log_msg_ret("add", ret); + } + ret = ofnode_copy_props(node, src); + if (ret) + return log_msg_ret("cpy", ret); + *nodep = node; + + return 0; +} diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index fa6a83188995..80708a3644c4 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -1567,4 +1567,19 @@ int ofnode_add_subnode(ofnode parent, const char *name, ofnode *nodep); */ int ofnode_copy_props(ofnode dst, ofnode src); +/** + * ofnode_copy_node() - Copy a node to another place + * + * If a node with this name already exists in dst_parent, this returns an + * .error + * + * @dst_parent: Parent of the newly copied node + * @name: Name to give the new node + * @src: Source node to copy + * @nodep: Returns the new node, or the existing node if there is one + * Return: 0 if OK, -EEXIST if dst_parent already has a node with this parent + */ +int ofnode_copy_node(ofnode dst_parent, const char *name, ofnode src, +ofnode *nodep); + #endif diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 63b651df84eb..fe7916c27222 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -1343,3 +1343,66 @@ static int dm_test_oftree_new(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_oftree_new, UT_TESTF_SCAN_FDT); + +static int check_copy_node(struct unit_test_state *uts, ofnode dst, ofnode src, + ofnode *nodep) +{ + u32 reg[2], val; + ofnode node; + + ut_assertok(ofnode_copy_node(dst, "copy-test", src, &node)); + + ut_assertok(ofnode_read_u32(node, "ping-expect", &val)); + ut_asserteq(3, val); + + ut_asserteq_str("denx,u-boot-fdt-test", + ofnode_read_string(node, "compatible")); + + /* check that a property with the same name is overwritten */ + ut_assertok(ofnode_read_u32_array(node, "reg", reg, ARRAY_SIZE(reg))); + ut_asserteq(3, reg[0]); + ut_asserteq(1, reg[1]); + + /* reset the compatible so the live tree does not change */ + ut_assertok(ofnode_write_string(node, "compatible", "nothing")); + *nodep = node; + + return 0; +} + +static int dm_test_ofnode_copy_node(struct unit_test_state *uts) +{ + ofnode src, dst, node, try; + + /* +* These nodes are chosen so that the src node is before the destination +* node in the tree. This doesn't matter with livetree, but with +* flattree any attempt to insert a property earlier in the tree will +* mess up the offsets after it. +*/ + src = ofnode_path("/b-test"); + dst = ofnode_path("/some-bus"); + + ut_assertok(check_copy_node(uts, dst, src, &node)); + + /* check trying to copy over an existing node */ + ut_asserteq(-EEXIST, ofnode_copy_node(dst, "copy-test", src, &try)); + ut_asserteq(try.of_offset, node.of_offset); + + return 0; +} +DM_TEST(dm_test_ofnode_copy_node, UT_TESTF_SCAN_FDT); + +/* test ofnode_copy_node() with the 'other' tree */ +static int dm_test_ofnode_copy_node_ot(struct unit_test_state *uts) +{ + oftree otree = get_other_oftree(uts); + ofnode src, dst, node; + + src = ofnode_path("/b-test"); + dst = oftree_path(otree, "/node/subnode2"); + ut_assertok(check_copy_node(uts, dst, src, &node)); + + return 0; +} +DM_TEST(dm_test_ofnode_copy_node_ot, UT_TESTF_SCAN_FDT | UT_TESTF_OTHER_FDT); -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 23/32] dm: core: Support writing a 64-bit value
Add support for writing a single 64-bit value into a property. Repurpose the existing tests to handle this case too. Signed-off-by: Simon Glass --- (no changes since v1) drivers/core/ofnode.c | 17 - include/dm/ofnode.h | 10 ++ test/dm/ofnode.c | 15 +-- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 0229695dba1f..2ef4114cb6f8 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1621,7 +1621,22 @@ int ofnode_write_u32(ofnode node, const char *propname, u32 value) return -ENOMEM; *val = cpu_to_fdt32(value); - return ofnode_write_prop(node, propname, val, sizeof(value), false); + return ofnode_write_prop(node, propname, val, sizeof(value), true); +} + +int ofnode_write_u64(ofnode node, const char *propname, u64 value) +{ + fdt64_t *val; + + assert(ofnode_valid(node)); + + log_debug("%s = %llx", propname, (unsigned long long)value); + val = malloc(sizeof(*val)); + if (!val) + return -ENOMEM; + *val = cpu_to_fdt64(value); + + return ofnode_write_prop(node, propname, val, sizeof(value), true); } int ofnode_write_bool(ofnode node, const char *propname, bool value) diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 58c6849534ea..726d8f82ddf2 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -1460,6 +1460,16 @@ int ofnode_write_string(ofnode node, const char *propname, const char *value); */ int ofnode_write_u32(ofnode node, const char *propname, u32 value); +/** + * ofnode_write_u64() - Set an integer property of an ofnode + * + * @node: The node for whose string property should be set + * @propname: The name of the string property to set + * @value: The new value of the 64-bit integer property + * Return: 0 if successful, -ve on error + */ +int ofnode_write_u64(ofnode node, const char *propname, u64 value); + /** * ofnode_write_bool() - Set a boolean property of an ofnode * diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index af844a50308e..5e63efdfa891 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -990,7 +990,8 @@ static int dm_test_ofnode_u32_array(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_u32_array, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); -static int dm_test_ofnode_read_u64(struct unit_test_state *uts) +/* test ofnode_read_u64() and ofnode_write_u64() */ +static int dm_test_ofnode_u64(struct unit_test_state *uts) { ofnode node; u64 val; @@ -999,6 +1000,10 @@ static int dm_test_ofnode_read_u64(struct unit_test_state *uts) ut_assert(ofnode_valid(node)); ut_assertok(ofnode_read_u64(node, "int64-value", &val)); ut_asserteq_64(0x, val); + ut_assertok(ofnode_write_u64(node, "new-int64-value", 0x9876543210)); + ut_assertok(ofnode_read_u64(node, "new-int64-value", &val)); + ut_asserteq_64(0x9876543210, val); + ut_asserteq(-EINVAL, ofnode_read_u64(node, "missing", &val)); ut_assertok(ofnode_read_u64_index(node, "int64-array", 0, &val)); @@ -1009,9 +1014,15 @@ static int dm_test_ofnode_read_u64(struct unit_test_state *uts) ofnode_read_u64_index(node, "int64-array", 2, &val)); ut_asserteq(-EINVAL, ofnode_read_u64_index(node, "missing", 0, &val)); + ut_assertok(ofnode_write_u64(node, "int64-array", 0x9876543210)); + ut_assertok(ofnode_read_u64_index(node, "int64-array", 0, &val)); + ut_asserteq_64(0x9876543210, val); + ut_asserteq(-EOVERFLOW, + ofnode_read_u64_index(node, "int64-array", 1, &val)); + return 0; } -DM_TEST(dm_test_ofnode_read_u64, UT_TESTF_SCAN_FDT); +DM_TEST(dm_test_ofnode_u64, UT_TESTF_SCAN_FDT); static int dm_test_ofnode_add_subnode(struct unit_test_state *uts) { -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 15/32] dm: core: Reverse the argument order in ofnode_copy_props()
Follow the order used by memcpy() as it may be less confusing. Signed-off-by: Simon Glass --- (no changes since v1) boot/vbe_request.c| 2 +- boot/vbe_simple_os.c | 2 +- drivers/core/ofnode.c | 2 +- include/dm/ofnode.h | 6 +++--- test/dm/ofnode.c | 9 - 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/boot/vbe_request.c b/boot/vbe_request.c index 2f218d4bf97c..917251afa1ca 100644 --- a/boot/vbe_request.c +++ b/boot/vbe_request.c @@ -187,7 +187,7 @@ static int bootmeth_vbe_ft_fixup(void *ctx, struct event *event) ret = ofnode_add_subnode(dest_parent, name, &dest); if (ret && ret != -EEXIST) return log_msg_ret("add", ret); - ret = ofnode_copy_props(node, dest); + ret = ofnode_copy_props(dest, node); if (ret) return log_msg_ret("cp", ret); diff --git a/boot/vbe_simple_os.c b/boot/vbe_simple_os.c index 3285e438a568..84626cdeaf24 100644 --- a/boot/vbe_simple_os.c +++ b/boot/vbe_simple_os.c @@ -94,7 +94,7 @@ static int bootmeth_vbe_simple_ft_fixup(void *ctx, struct event *event) /* Copy over the vbe properties for fwupd */ log_debug("Fixing up: %s\n", dev->name); - ret = ofnode_copy_props(dev_ofnode(dev), subnode); + ret = ofnode_copy_props(subnode, dev_ofnode(dev)); if (ret) return log_msg_ret("cp", ret); diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 8311282abf69..8227eac1e4fe 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1672,7 +1672,7 @@ int ofnode_add_subnode(ofnode node, const char *name, ofnode *subnodep) return ret; /* 0 or -EEXIST */ } -int ofnode_copy_props(ofnode src, ofnode dst) +int ofnode_copy_props(ofnode dst, ofnode src) { struct ofprop prop; diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 0a85db31f360..abdfa58036d5 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -1545,7 +1545,7 @@ int ofnode_add_subnode(ofnode parent, const char *name, ofnode *nodep); /** * ofnode_copy_props() - copy all properties from one node to another * - * Makes a copy of all properties from the source note in the destination node. + * Makes a copy of all properties from the source node to the destination node. * Existing properties in the destination node remain unchanged, except that * any with the same name are overwritten, including changing the size of the * property. @@ -1553,9 +1553,9 @@ int ofnode_add_subnode(ofnode parent, const char *name, ofnode *nodep); * For livetree, properties are copied / allocated, so the source tree does not * need to be present afterwards. * + * @dst: Destination node to write properties to * @src: Source node to read properties from - * @dst: Destination node to write properties too */ -int ofnode_copy_props(ofnode src, ofnode dst); +int ofnode_copy_props(ofnode dst, ofnode src); #endif diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index b74f5c2ebcff..49fa5d27e6ec 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -1190,12 +1190,11 @@ static int dm_test_ofnode_too_many(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_too_many, UT_TESTF_SCAN_FDT); -static int check_copy_props(struct unit_test_state *uts, ofnode src, - ofnode dst) +static int check_copy_props(struct unit_test_state *uts, ofnode dst, ofnode src) { u32 reg[2], val; - ut_assertok(ofnode_copy_props(src, dst)); + ut_assertok(ofnode_copy_props(dst, src)); ut_assertok(ofnode_read_u32(dst, "ping-expect", &val)); ut_asserteq(3, val); @@ -1227,7 +1226,7 @@ static int dm_test_ofnode_copy_props(struct unit_test_state *uts) src = ofnode_path("/b-test"); dst = ofnode_path("/some-bus"); - ut_assertok(check_copy_props(uts, src, dst)); + ut_assertok(check_copy_props(uts, dst, src)); /* check a property that is in the destination already */ ut_asserteq_str("mux0", ofnode_read_string(dst, "mux-control-names")); @@ -1243,7 +1242,7 @@ static int dm_test_ofnode_copy_props_ot(struct unit_test_state *uts) src = ofnode_path("/b-test"); dst = oftree_path(otree, "/node/subnode2"); - ut_assertok(check_copy_props(uts, src, dst)); + ut_assertok(check_copy_props(uts, dst, src)); return 0; } -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 22/32] dm: core: Support writing a boolean
Add functions to write a boolean property. This involves deleting it if the value is false. Add a new ofnode_has_property() as well. Add a comment about the behaviour of of_read_property() when the property value is empty. Signed-off-by: Simon Glass --- (no changes since v1) drivers/core/ofnode.c | 36 ++-- include/dm/ofnode.h | 32 +++- test/dm/ofnode.c | 25 + 3 files changed, 90 insertions(+), 3 deletions(-) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 4dc7589c1d23..0229695dba1f 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -491,12 +491,12 @@ u64 ofnode_read_u64_default(ofnode node, const char *propname, u64 def) bool ofnode_read_bool(ofnode node, const char *propname) { - const void *prop; + bool prop; assert(ofnode_valid(node)); debug("%s: %s: ", __func__, propname); - prop = ofnode_get_property(node, propname, NULL); + prop = ofnode_has_property(node, propname); debug("%s\n", prop ? "true" : "false"); @@ -1168,6 +1168,14 @@ const void *ofnode_get_property(ofnode node, const char *propname, int *lenp) propname, lenp); } +bool ofnode_has_property(ofnode node, const char *propname) +{ + if (ofnode_is_np(node)) + return of_find_property(ofnode_to_np(node), propname, NULL); + else + return ofnode_get_property(node, propname, NULL); +} + int ofnode_first_property(ofnode node, struct ofprop *prop) { prop->node = node; @@ -1616,6 +1624,30 @@ int ofnode_write_u32(ofnode node, const char *propname, u32 value) return ofnode_write_prop(node, propname, val, sizeof(value), false); } +int ofnode_write_bool(ofnode node, const char *propname, bool value) +{ + if (value) + return ofnode_write_prop(node, propname, NULL, 0, false); + else + return ofnode_delete_prop(node, propname); +} + +int ofnode_delete_prop(ofnode node, const char *propname) +{ + if (ofnode_is_np(node)) { + struct property *prop; + int len; + + prop = of_find_property(ofnode_to_np(node), propname, &len); + if (prop) + return of_remove_property(ofnode_to_np(node), prop); + return 0; + } else { + return fdt_delprop(ofnode_to_fdt(node), ofnode_to_offset(node), + propname); + } +} + int ofnode_set_enabled(ofnode node, bool value) { assert(ofnode_valid(node)); diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index f3ef1bff6db6..58c6849534ea 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -1036,10 +1036,19 @@ int ofnode_decode_panel_timing(ofnode node, * @node: node to read * @propname: property to read * @lenp: place to put length on success - * Return: pointer to property, or NULL if not found + * Return: pointer to property value, or NULL if not found or empty */ const void *ofnode_get_property(ofnode node, const char *propname, int *lenp); +/** + * ofnode_has_property() - check if a node has a named property + * + * @node: node to read + * @propname: property to read + * Return: true if the property exists in the node, false if not + */ +bool ofnode_has_property(ofnode node, const char *propname); + /** * ofnode_first_property()- get the reference of the first property * @@ -1451,6 +1460,27 @@ int ofnode_write_string(ofnode node, const char *propname, const char *value); */ int ofnode_write_u32(ofnode node, const char *propname, u32 value); +/** + * ofnode_write_bool() - Set a boolean property of an ofnode + * + * This either adds or deleted a property with a zero-length value + * + * @node: The node for whose string property should be set + * @propname: The name of the string property to set + * @value: The new value of the boolean property + * Return: 0 if successful, -ve on error + */ +int ofnode_write_bool(ofnode node, const char *propname, bool value); + +/** + * ofnode_delete_prop() - Delete a property + * + * @node: Node containing the property to delete + * @propname: Name of property to delete + * Return: 0 if successful, -ve on error + */ +int ofnode_delete_prop(ofnode node, const char *propname); + /** * ofnode_set_enabled() - Enable or disable a device tree node given by its * ofnode diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index d2b393750ffc..af844a50308e 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -1461,3 +1461,28 @@ static int dm_test_oftree_to_fdt(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_oftree_to_fdt, UT_TESTF_SCAN_FDT); + +/* test ofnode_read_bool() and ofnode_write_bool() */ +static int dm_test_bool(struct unit_test_state *uts) +{ + const char *propname = "missing-bool-value"; + ofnode node; +
[PATCH v2 21/32] dm: core: Add a way to convert a devicetree to a dtb
Add a way to flatten a devicetree into binary form. For livetree this involves generating the devicetree using fdt_property() and other calls. For flattree it simply involves providing the buffer containing the tree. Signed-off-by: Simon Glass --- (no changes since v1) drivers/core/ofnode.c | 18 +++ include/dm/ofnode.h | 13 + include/of_live.h | 10 lib/of_live.c | 122 ++ test/dm/ofnode.c | 24 + 5 files changed, 187 insertions(+) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index fe143f990915..4dc7589c1d23 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -243,6 +243,24 @@ int oftree_new(oftree *treep) #endif /* OFNODE_MULTI_TREE */ +int oftree_to_fdt(oftree tree, struct abuf *buf) +{ + int ret; + + if (of_live_active()) { + ret = of_live_flatten(ofnode_to_np(oftree_root(tree)), buf); + if (ret) + return log_msg_ret("flt", ret); + } else { + void *fdt = oftree_lookup_fdt(tree); + + abuf_init(buf); + abuf_set(buf, fdt, fdt_totalsize(fdt)); + } + + return 0; +} + /** * ofnode_from_tree_offset() - get an ofnode from a tree offset (flat tree) * diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 8be617b21043..f3ef1bff6db6 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -17,6 +17,7 @@ /* Enable checks to protect against invalid calls */ #undef OF_CHECKS +struct abuf; struct resource; #include @@ -135,6 +136,18 @@ static inline ofnode noffset_to_ofnode(ofnode other_node, int of_offset) */ int oftree_new(oftree *treep); +/** + * oftree_to_fdt() - Convert an oftree to a flat FDT + * + * @tree: tree to flatten (if livetree) or copy (if not) + * @buf: Returns inited buffer containing the newly created flat tree. Note + * that for flat tree the buffer is not allocated. In either case the caller + * must call abut_uninit() to free any memory used by @buf + * Return: 0 on success, -ENOMEM if out of memory, other -ve value for any other + * error + */ +int oftree_to_fdt(oftree tree, struct abuf *buf); + /** * ofnode_to_np() - convert an ofnode to a live DT node pointer * diff --git a/include/of_live.h b/include/of_live.h index 81cb9bd13e2c..67bd5f02c744 100644 --- a/include/of_live.h +++ b/include/of_live.h @@ -9,6 +9,7 @@ #ifndef _OF_LIVE_H #define _OF_LIVE_H +struct abuf; struct device_node; /** @@ -54,4 +55,13 @@ void of_live_free(struct device_node *root); */ int of_live_create_empty(struct device_node **rootp); +/** + * of_live_flatten() - Create an FDT from a hierarchical tree + * + * @root: Root node of tree to convert + * @buf: Buffer to return the tree (inited by this function) + * Return: 0 if OK, -ENOMEM if out of memory + */ +int of_live_flatten(const struct device_node *root, struct abuf *buf); + #endif diff --git a/lib/of_live.c b/lib/of_live.c index e4eee3855476..812c488f6067 100644 --- a/lib/of_live.c +++ b/lib/of_live.c @@ -8,13 +8,21 @@ * Copyright (c) 2017 Google, Inc */ +#define LOG_CATEGORY LOGC_DT + #include +#include #include #include #include #include #include #include +#include + +enum { + BUF_STEP= SZ_64K, +}; static void *unflatten_dt_alloc(void **mem, unsigned long size, unsigned long align) @@ -355,3 +363,117 @@ int of_live_create_empty(struct device_node **rootp) return 0; } + +static int check_space(int ret, struct abuf *buf) +{ + if (ret == -FDT_ERR_NOSPACE) { + if (!abuf_realloc_inc(buf, BUF_STEP)) + return log_msg_ret("spc", -ENOMEM); + ret = fdt_resize(abuf_data(buf), abuf_data(buf), +abuf_size(buf)); + if (ret) + return log_msg_ret("res", -EFAULT); + + return -EAGAIN; + } + + return 0; +} + +/** + * flatten_node() - Write out the node and its properties into a flat tree + */ +static int flatten_node(struct abuf *buf, const struct device_node *node) +{ + const struct device_node *np; + const struct property *pp; + int ret; + + ret = fdt_begin_node(abuf_data(buf), node->name); + ret = check_space(ret, buf); + if (ret == -EAGAIN) { + ret = fdt_begin_node(abuf_data(buf), node->name); + if (ret) { + log_debug("Internal error a %d\n", ret); + return -EFAULT; + } + } + if (ret) + return log_msg_ret("beg", ret); + + /* First write out the properties */ + for (pp = node->properties; !ret && pp; pp = pp->next) { + ret = fdt_property(abuf_data(buf), pp->name, pp->value, + pp->length); + ret = check_space(ret, buf); + if (ret ==
[PATCH v2 20/32] dm: core: Add a way to delete a node
Add a function to delete a node in an existing tree. Signed-off-by: Simon Glass --- (no changes since v1) drivers/core/of_access.c | 65 drivers/core/ofnode.c| 23 ++ include/dm/of_access.h | 18 +++ include/dm/ofnode.h | 13 test/dm/ofnode.c | 31 +++ 5 files changed, 150 insertions(+) diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c index 1bb4d8eab709..0df5c867c8b3 100644 --- a/drivers/core/of_access.c +++ b/drivers/core/of_access.c @@ -1040,3 +1040,68 @@ int of_add_subnode(struct device_node *parent, const char *name, int len, return 0; } + +int __of_remove_property(struct device_node *np, struct property *prop) +{ + struct property **next; + + for (next = &np->properties; *next; next = &(*next)->next) { + if (*next == prop) + break; + } + if (*next == NULL) + return -ENODEV; + + /* found the node */ + *next = prop->next; + + return 0; +} + +int of_remove_property(struct device_node *np, struct property *prop) +{ + int rc; + + mutex_lock(&of_mutex); + + rc = __of_remove_property(np, prop); + + mutex_unlock(&of_mutex); + + return rc; +} + +int of_remove_node(struct device_node *to_remove) +{ + struct device_node *parent = to_remove->parent; + struct device_node *np, *prev; + + if (!parent) + return -EPERM; + prev = NULL; + __for_each_child_of_node(parent, np) { + if (np == to_remove) + break; + prev = np; + } + if (!np) + return -EFAULT; + + /* if there is a previous node, link it to this one's sibling */ + if (prev) + prev->sibling = np->sibling; + else + parent->child = np->sibling; + + /* +* don't free it, since if this is an unflattened tree, all the memory +* was alloced in one block; this pointer will be somewhere in the +* middle of that +* +* TODO(s...@chromium.org): Consider marking nodes as 'allocated'? +* +* free(np); +*/ + + return 0; +} diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index ba8385af7b46..fe143f990915 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1720,6 +1720,29 @@ int ofnode_add_subnode(ofnode node, const char *name, ofnode *subnodep) return ret; /* 0 or -EEXIST */ } +int ofnode_delete(ofnode *nodep) +{ + ofnode node = *nodep; + int ret; + + assert(ofnode_valid(node)); + if (ofnode_is_np(node)) { + ret = of_remove_node(ofnode_to_np(node)); + } else { + void *fdt = ofnode_to_fdt(node); + int offset = ofnode_to_offset(node); + + ret = fdt_del_node(fdt, offset); + if (ret) + ret = -EFAULT; + } + if (ret) + return ret; + *nodep = ofnode_null(); + + return 0; +} + int ofnode_copy_props(ofnode dst, ofnode src) { struct ofprop prop; diff --git a/include/dm/of_access.h b/include/dm/of_access.h index 9361d0a87bfb..de740d44674c 100644 --- a/include/dm/of_access.h +++ b/include/dm/of_access.h @@ -597,4 +597,22 @@ int of_write_prop(struct device_node *np, const char *propname, int len, int of_add_subnode(struct device_node *node, const char *name, int len, struct device_node **subnodep); +/** + * of_remove_property() - Remove a property from a node + * + * @np: Node to remove from + * @prop: Pointer to property to remove + * Return 0 if OK, -ENODEV if the property could not be found in the node + */ +int of_remove_property(struct device_node *np, struct property *prop); + +/** + * of_remove_node() - Remove a node from the tree + * + * @to_remove: Node to remove + * Return: 0 if OK, -EPERM if it is the root node (wWhich cannot be removed), + * -ENOENT if the tree is broken (to_remove is not a child of its parent) + */ +int of_remove_node(struct device_node *to_remove); + #endif diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 80708a3644c4..8be617b21043 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -1582,4 +1582,17 @@ int ofnode_copy_props(ofnode dst, ofnode src); int ofnode_copy_node(ofnode dst_parent, const char *name, ofnode src, ofnode *nodep); +/** + * ofnode_delete() - Delete a node + * + * Delete a node from the tree + * + * @nodep: Pointer to node to delete (set to ofnode_null() on success) + * Return: 0 if OK, -ENOENT if the node does not exist, -EPERM if it is the root + * node (wWhich cannot be removed), -EFAULT if the tree is broken (to_remove is + * not a child of its parent), + * + */ +int ofnode_delete(ofnode *nodep); + #endif diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index fe7916c272
[PATCH v2 18/32] dm: core: Add a function to create an empty tree
Provide a function to create a new, empty tree. Signed-off-by: Simon Glass --- (no changes since v1) drivers/core/ofnode.c | 56 +++ include/dm/ofnode.h | 9 +++ include/of_live.h | 8 +++ lib/of_live.c | 19 +++ test/dm/ofnode.c | 16 + 5 files changed, 104 insertions(+), 4 deletions(-) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 8227eac1e4fe..7100fc630352 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -47,6 +47,17 @@ static int oftree_find(const void *fdt) return -1; } +static int check_tree_count(void) +{ + if (oftree_count == CONFIG_OFNODE_MULTI_TREE_MAX) { + log_warning("Too many registered device trees (max %d)\n", + CONFIG_OFNODE_MULTI_TREE_MAX); + return -E2BIG; + } + + return 0; +} + static oftree oftree_ensure(void *fdt) { oftree tree; @@ -69,11 +80,8 @@ static oftree oftree_ensure(void *fdt) if (gd->flags & GD_FLG_RELOC) { i = oftree_find(fdt); if (i == -1) { - if (oftree_count == CONFIG_OFNODE_MULTI_TREE_MAX) { - log_warning("Too many registered device trees (max %d)\n", - CONFIG_OFNODE_MULTI_TREE_MAX); + if (check_tree_count()) return oftree_null(); - } /* register the new tree */ i = oftree_count++; @@ -92,6 +100,41 @@ static oftree oftree_ensure(void *fdt) return tree; } +int oftree_new(oftree *treep) +{ + oftree tree = oftree_null(); + int ret; + + if (of_live_active()) { + struct device_node *root; + + ret = of_live_create_empty(&root); + if (ret) + return log_msg_ret("liv", ret); + tree = oftree_from_np(root); + } else { + const int size = 1024; + void *fdt; + + ret = check_tree_count(); + if (ret) + return log_msg_ret("fla", ret); + + /* register the new tree with a small size */ + fdt = malloc(size); + if (!fdt) + return log_msg_ret("fla", -ENOMEM); + ret = fdt_create_empty_tree(fdt, size); + if (ret) + return log_msg_ret("fla", -EINVAL); + oftree_list[oftree_count++] = fdt; + tree.fdt = fdt; + } + *treep = tree; + + return 0; +} + void oftree_dispose(oftree tree) { if (of_live_active()) @@ -193,6 +236,11 @@ static inline int oftree_find(const void *fdt) return 0; } +int oftree_new(oftree *treep) +{ + return -ENOSYS; +} + #endif /* OFNODE_MULTI_TREE */ /** diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index abdfa58036d5..fa6a83188995 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -126,6 +126,15 @@ static inline ofnode noffset_to_ofnode(ofnode other_node, int of_offset) #endif /* OFNODE_MULTI_TREE */ +/** + * oftree_new() - Create a new, empty tree + * + * @treep: Returns a pointer to the tree, on success + * Returns: 0 on success, -ENOMEM if out of memory, -E2BIG if !OF_LIVE and + * there are too many (flattrees) already + */ +int oftree_new(oftree *treep); + /** * ofnode_to_np() - convert an ofnode to a live DT node pointer * diff --git a/include/of_live.h b/include/of_live.h index 05e86ac06b1a..81cb9bd13e2c 100644 --- a/include/of_live.h +++ b/include/of_live.h @@ -46,4 +46,12 @@ int unflatten_device_tree(const void *blob, struct device_node **mynodes); */ void of_live_free(struct device_node *root); +/** + * of_live_create_empty() - Create a new, empty tree + * + * @rootp: Returns the root node of the created tree + * Return: 0 if OK, -ENOMEM if out of memory + */ +int of_live_create_empty(struct device_node **rootp); + #endif diff --git a/lib/of_live.c b/lib/of_live.c index 25f7af61061e..e4eee3855476 100644 --- a/lib/of_live.c +++ b/lib/of_live.c @@ -336,3 +336,22 @@ void of_live_free(struct device_node *root) /* the tree is stored as a contiguous block of memory */ free(root); } + +int of_live_create_empty(struct device_node **rootp) +{ + struct device_node *root; + + root = calloc(1, sizeof(struct device_node)); + if (!root) + return -ENOMEM; + root->name = strdup(""); + if (!root->name) { + free(root); + return -ENOMEM; + } + root->type = ""; + root->full_name = ""; + *rootp = root; + + return 0; +} diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 84ed7f92b235..63b651df84eb 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -1327,3 +1327,19 @@ static in
[PATCH v2 17/32] dm: core: Tidy up comments in the ofnode tests
Add comments to the functions where the test name does not indicate what is being tested. Rename functions in a few cases, so that a search for the function will also file its test. Signed-off-by: Simon Glass --- (no changes since v1) test/dm/ofnode.c | 46 +++--- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index a29c9aae870b..84ed7f92b235 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -91,6 +91,7 @@ void free_oftree(oftree tree) free(tree.np); } +/* test ofnode_device_is_compatible() */ static int dm_test_ofnode_compatible(struct unit_test_state *uts) { ofnode root_node = ofnode_path("/"); @@ -134,6 +135,7 @@ static int dm_test_ofnode_get_by_phandle(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_get_by_phandle, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); +/* test oftree_get_by_phandle() with a the 'other' oftree */ static int dm_test_ofnode_get_by_phandle_ot(struct unit_test_state *uts) { oftree otree = get_other_oftree(uts); @@ -188,6 +190,7 @@ static int dm_test_ofnode_by_prop_value(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_by_prop_value, UT_TESTF_SCAN_FDT); +/* test ofnode_by_prop_value() with a the 'other' oftree */ static int dm_test_ofnode_by_prop_value_ot(struct unit_test_state *uts) { oftree otree = get_other_oftree(uts); @@ -200,6 +203,7 @@ static int dm_test_ofnode_by_prop_value_ot(struct unit_test_state *uts) DM_TEST(dm_test_ofnode_by_prop_value_ot, UT_TESTF_SCAN_FDT | UT_TESTF_OTHER_FDT); +/* test ofnode_read_fmap_entry() */ static int dm_test_ofnode_fmap(struct unit_test_state *uts) { struct fmap_entry entry; @@ -215,6 +219,7 @@ static int dm_test_ofnode_fmap(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_fmap, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); +/* test ofnode_read_prop() */ static int dm_test_ofnode_read(struct unit_test_state *uts) { const u32 *val; @@ -241,6 +246,7 @@ static int dm_test_ofnode_read(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_read, UT_TESTF_SCAN_FDT); +/* test ofnode_read_prop() with the 'other' tree */ static int dm_test_ofnode_read_ot(struct unit_test_state *uts) { oftree otree = get_other_oftree(uts); @@ -260,6 +266,7 @@ static int dm_test_ofnode_read_ot(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_read_ot, UT_TESTF_SCAN_FDT | UT_TESTF_OTHER_FDT); +/* test ofnode_count_/parse_phandle_with_args() */ static int dm_test_ofnode_phandle(struct unit_test_state *uts) { struct ofnode_phandle_args args; @@ -335,6 +342,7 @@ static int dm_test_ofnode_phandle(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_phandle, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); +/* test ofnode_count_/parse_phandle_with_args() with 'other' tree */ static int dm_test_ofnode_phandle_ot(struct unit_test_state *uts) { oftree otree = get_other_oftree(uts); @@ -363,6 +371,7 @@ static int dm_test_ofnode_phandle_ot(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_phandle_ot, UT_TESTF_OTHER_FDT); +/* test ofnode_read_chosen_string/node/prop() */ static int dm_test_ofnode_read_chosen(struct unit_test_state *uts) { const char *str; @@ -392,6 +401,7 @@ static int dm_test_ofnode_read_chosen(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_read_chosen, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); +/* test ofnode_get_aliases_node/prop() */ static int dm_test_ofnode_read_aliases(struct unit_test_state *uts) { const void *val; @@ -435,6 +445,7 @@ static int dm_test_ofnode_get_child_count(struct unit_test_state *uts) DM_TEST(dm_test_ofnode_get_child_count, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); +/* test ofnode_get_child_count() with 'other' tree */ static int dm_test_ofnode_get_child_count_ot(struct unit_test_state *uts) { oftree otree = get_other_oftree(uts); @@ -469,6 +480,7 @@ static int dm_test_ofnode_is_enabled(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_is_enabled, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); +/* test ofnode_is_enabled() with 'other' tree */ static int dm_test_ofnode_is_enabled_ot(struct unit_test_state *uts) { oftree otree = get_other_oftree(uts); @@ -482,6 +494,7 @@ static int dm_test_ofnode_is_enabled_ot(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_is_enabled_ot, UT_TESTF_OTHER_FDT); +/* test ofnode_get_addr/size() */ static int dm_test_ofnode_get_reg(struct unit_test_state *uts) { ofnode node; @@ -518,6 +531,7 @@ static int dm_test_ofnode_get_reg(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_get_reg, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); +/* test ofnode_get_addr() with 'other' tree */ static int dm_test_ofnode_get_reg_ot(struct unit_test_state *uts) { oftree otree = get_other_oftree(uts); @@ -552,6 +566,7 @@ static int dm_test_ofnode_get_path(struct unit_test_stat
[PATCH v2 14/32] spl: Move bloblist writing until the image is known
The bloblist should not be finalised until the image is fully set up. This allows any final handoff information to be included in the bloblist. Signed-off-by: Simon Glass --- (no changes since v1) common/spl/spl.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 1f0412b96b32..b554ea0b1944 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -728,18 +728,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } spl_perform_fixups(&spl_image); - if (CONFIG_IS_ENABLED(HANDOFF)) { - ret = write_spl_handoff(); - if (ret) - printf(SPL_TPL_PROMPT - "SPL hand-off write failed (err=%d)\n", ret); - } - if (CONFIG_IS_ENABLED(BLOBLIST)) { - ret = bloblist_finish(); - if (ret) - printf("Warning: Failed to finish bloblist (ret=%d)\n", - ret); - } os = spl_image.os; if (os == IH_OS_U_BOOT) { @@ -786,6 +774,18 @@ void board_init_r(gd_t *dummy1, ulong dummy2) dev->name, rc); } } + if (CONFIG_IS_ENABLED(HANDOFF)) { + ret = write_spl_handoff(); + if (ret) + printf(SPL_TPL_PROMPT + "SPL hand-off write failed (err=%d)\n", ret); + } + if (CONFIG_IS_ENABLED(BLOBLIST)) { + ret = bloblist_finish(); + if (ret) + printf("Warning: Failed to finish bloblist (ret=%d)\n", + ret); + } spl_board_prepare_for_boot(); jump_to_image_no_args(&spl_image); -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 16/32] dm: core: Ensure we run flattree tests on ofnode
We need the UT_TESTF_SCAN_FDT flag set for these tests to run with flat tree. In some cases it is missing, so add it. Signed-off-by: Simon Glass --- (no changes since v1) test/dm/ofnode.c | 33 ++--- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 49fa5d27e6ec..a29c9aae870b 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -114,7 +114,7 @@ static int dm_test_ofnode_compatible_ot(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_ofnode_compatible_ot, UT_TESTF_OTHER_FDT); +DM_TEST(dm_test_ofnode_compatible_ot, UT_TESTF_SCAN_FDT | UT_TESTF_OTHER_FDT); static int dm_test_ofnode_get_by_phandle(struct unit_test_state *uts) { @@ -146,7 +146,8 @@ static int dm_test_ofnode_get_by_phandle_ot(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_ofnode_get_by_phandle_ot, UT_TESTF_OTHER_FDT); +DM_TEST(dm_test_ofnode_get_by_phandle_ot, + UT_TESTF_SCAN_FDT | UT_TESTF_OTHER_FDT); static int check_prop_values(struct unit_test_state *uts, ofnode start, const char *propname, const char *propval, @@ -196,7 +197,8 @@ static int dm_test_ofnode_by_prop_value_ot(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_ofnode_by_prop_value_ot, UT_TESTF_OTHER_FDT); +DM_TEST(dm_test_ofnode_by_prop_value_ot, + UT_TESTF_SCAN_FDT | UT_TESTF_OTHER_FDT); static int dm_test_ofnode_fmap(struct unit_test_state *uts) { @@ -237,7 +239,7 @@ static int dm_test_ofnode_read(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_ofnode_read, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); +DM_TEST(dm_test_ofnode_read, UT_TESTF_SCAN_FDT); static int dm_test_ofnode_read_ot(struct unit_test_state *uts) { @@ -256,7 +258,7 @@ static int dm_test_ofnode_read_ot(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_ofnode_read_ot, UT_TESTF_OTHER_FDT); +DM_TEST(dm_test_ofnode_read_ot, UT_TESTF_SCAN_FDT | UT_TESTF_OTHER_FDT); static int dm_test_ofnode_phandle(struct unit_test_state *uts) { @@ -452,7 +454,8 @@ static int dm_test_ofnode_get_child_count_ot(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_ofnode_get_child_count_ot, UT_TESTF_OTHER_FDT); +DM_TEST(dm_test_ofnode_get_child_count_ot, + UT_TESTF_SCAN_FDT | UT_TESTF_OTHER_FDT); static int dm_test_ofnode_is_enabled(struct unit_test_state *uts) { @@ -526,7 +529,7 @@ static int dm_test_ofnode_get_reg_ot(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_ofnode_get_reg_ot, UT_TESTF_OTHER_FDT); +DM_TEST(dm_test_ofnode_get_reg_ot, UT_TESTF_SCAN_FDT | UT_TESTF_OTHER_FDT); static int dm_test_ofnode_get_path(struct unit_test_state *uts) { @@ -566,7 +569,7 @@ static int dm_test_ofnode_get_path_ot(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_ofnode_get_path_ot, UT_TESTF_OTHER_FDT); +DM_TEST(dm_test_ofnode_get_path_ot, UT_TESTF_SCAN_FDT | UT_TESTF_OTHER_FDT); static int dm_test_ofnode_conf(struct unit_test_state *uts) { @@ -581,7 +584,7 @@ static int dm_test_ofnode_conf(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_ofnode_conf, 0); +DM_TEST(dm_test_ofnode_conf, UT_TESTF_SCAN_FDT); static int dm_test_ofnode_for_each_compatible_node(struct unit_test_state *uts) { @@ -646,7 +649,7 @@ static int dm_test_ofnode_string(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_ofnode_string, 0); +DM_TEST(dm_test_ofnode_string, UT_TESTF_SCAN_FDT); static int dm_test_ofnode_string_err(struct unit_test_state *uts) { @@ -717,7 +720,7 @@ static int dm_test_ofnode_get_phy(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_ofnode_get_phy, 0); +DM_TEST(dm_test_ofnode_get_phy, UT_TESTF_SCAN_FDT); /** * make_ofnode_fdt() - Create an FDT for testing with ofnode @@ -901,7 +904,7 @@ static int dm_test_ofnode_write_copy_ot(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_ofnode_write_copy_ot, UT_TESTF_OTHER_FDT); +DM_TEST(dm_test_ofnode_write_copy_ot, UT_TESTF_SCAN_FDT | UT_TESTF_OTHER_FDT); static int dm_test_ofnode_u32(struct unit_test_state *uts) { @@ -1103,7 +1106,7 @@ static int dm_test_ofnode_by_compatible_ot(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_ofnode_by_compatible_ot, UT_TESTF_OTHER_FDT); +DM_TEST(dm_test_ofnode_by_compatible_ot, UT_TESTF_SCAN_FDT | UT_TESTF_OTHER_FDT); static int dm_test_ofnode_find_subnode(struct unit_test_state *uts) { @@ -1272,7 +1275,7 @@ static int dm_test_livetree_align(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_livetree_align, UT_TESTF_LIVE_TREE); +DM_TEST(dm_test_livetree_align, UT_TESTF_SCAN_FDT | UT_TESTF_LIVE_TREE); /* check that it is possible to load an arbitrary livetree */ static int dm_test_livetree_ensure(struct unit_test_state *uts) @@ -1291,4 +1294,4 @@ static int dm_test_livetree_ensure(struct unit_test_state *uts)
[PATCH v2 13/32] spl: Use the correct FIT_..._PROP constants
Rather than open-coding the property names, use the existing constants provided for this purpose. This better aligns the simple-FIT code with the full FIT implementation. Signed-off-by: Simon Glass --- (no changes since v1) common/spl/spl_fit.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 5b5f6c620457..03ff9a5db9a8 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -43,7 +43,7 @@ static int find_node_from_desc(const void *fit, int node, const char *str) for (child = fdt_first_subnode(fit, node); child >= 0; child = fdt_next_subnode(fit, child)) { int len; - const char *desc = fdt_getprop(fit, child, "description", &len); + const char *desc = fdt_getprop(fit, child, FIT_DESC_PROP, &len); if (!desc) continue; @@ -475,10 +475,11 @@ static int spl_fit_record_loadable(const struct spl_fit_info *ctx, int index, node = spl_fit_get_image_node(ctx, "loadables", index); ret = fdt_record_loadable(blob, index, name, image->load_addr, - image->size, image->entry_point, - fdt_getprop(ctx->fit, node, "type", NULL), - fdt_getprop(ctx->fit, node, "os", NULL), - fdt_getprop(ctx->fit, node, "arch", NULL)); + image->size, image->entry_point, + fdt_getprop(ctx->fit, node, FIT_TYPE_PROP, NULL), + fdt_getprop(ctx->fit, node, FIT_OS_PROP, NULL), + fdt_getprop(ctx->fit, node, FIT_ARCH_PROP, NULL)); + return ret; } -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 12/32] spl: Move the full FIT code to spl_fit.c
For some reason this code was put in the main spl.c file. Move it out to the FIT implementation where it belongs. Signed-off-by: Simon Glass --- (no changes since v1) common/spl/spl.c | 108 +++ common/spl/spl_fit.c | 93 + include/spl.h| 11 + 3 files changed, 111 insertions(+), 101 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 8541bef00466..1f0412b96b32 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -260,102 +260,6 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image) } #endif -#if CONFIG_IS_ENABLED(LOAD_FIT_FULL) -/* Parse and load full fitImage in SPL */ -static int spl_load_fit_image(struct spl_image_info *spl_image, - const struct legacy_img_hdr *header) -{ - struct bootm_headers images; - const char *fit_uname_config = NULL; - uintptr_t fdt_hack; - const char *uname; - ulong fw_data = 0, dt_data = 0, img_data = 0; - ulong fw_len = 0, dt_len = 0, img_len = 0; - int idx, conf_noffset; - int ret; - -#ifdef CONFIG_SPL_FIT_SIGNATURE - images.verify = 1; -#endif - ret = fit_image_load(&images, (ulong)header, -NULL, &fit_uname_config, -IH_ARCH_DEFAULT, IH_TYPE_STANDALONE, -1, -FIT_LOAD_OPTIONAL, &fw_data, &fw_len); - if (ret >= 0) { - printf("DEPRECATED: 'standalone = ' property."); - printf("Please use either 'firmware =' or 'kernel ='\n"); - } else { - ret = fit_image_load(&images, (ulong)header, NULL, -&fit_uname_config, IH_ARCH_DEFAULT, -IH_TYPE_FIRMWARE, -1, FIT_LOAD_OPTIONAL, -&fw_data, &fw_len); - } - - if (ret < 0) { - ret = fit_image_load(&images, (ulong)header, NULL, -&fit_uname_config, IH_ARCH_DEFAULT, -IH_TYPE_KERNEL, -1, FIT_LOAD_OPTIONAL, -&fw_data, &fw_len); - } - - if (ret < 0) - return ret; - - spl_image->size = fw_len; - spl_image->entry_point = fw_data; - spl_image->load_addr = fw_data; - if (fit_image_get_os(header, ret, &spl_image->os)) - spl_image->os = IH_OS_INVALID; - spl_image->name = genimg_get_os_name(spl_image->os); - - debug(SPL_TPL_PROMPT "payload image: %32s load addr: 0x%lx size: %d\n", - spl_image->name, spl_image->load_addr, spl_image->size); - -#ifdef CONFIG_SPL_FIT_SIGNATURE - images.verify = 1; -#endif - ret = fit_image_load(&images, (ulong)header, NULL, &fit_uname_config, - IH_ARCH_DEFAULT, IH_TYPE_FLATDT, -1, - FIT_LOAD_OPTIONAL, &dt_data, &dt_len); - if (ret >= 0) { - spl_image->fdt_addr = (void *)dt_data; - - if (spl_image->os == IH_OS_U_BOOT) { - /* HACK: U-Boot expects FDT at a specific address */ - fdt_hack = spl_image->load_addr + spl_image->size; - fdt_hack = (fdt_hack + 3) & ~3; - debug("Relocating FDT to %p\n", spl_image->fdt_addr); - memcpy((void *)fdt_hack, spl_image->fdt_addr, dt_len); - } - } - - conf_noffset = fit_conf_get_node((const void *)header, -fit_uname_config); - if (conf_noffset < 0) - return 0; - - for (idx = 0; -uname = fdt_stringlist_get((const void *)header, conf_noffset, - FIT_LOADABLE_PROP, idx, - NULL), uname; -idx++) - { -#ifdef CONFIG_SPL_FIT_SIGNATURE - images.verify = 1; -#endif - ret = fit_image_load(&images, (ulong)header, -&uname, &fit_uname_config, -IH_ARCH_DEFAULT, IH_TYPE_LOADABLE, -1, -FIT_LOAD_OPTIONAL_NON_ZERO, -&img_data, &img_len); - if (ret < 0) - return ret; - } - - return 0; -} -#endif - __weak int spl_parse_board_header(struct spl_image_info *spl_image, const struct spl_boot_device *bootdev, const void *image_header, size_t size) @@ -375,12 +279,14 @@ int spl_parse_image_header(struct spl_image_info *spl_image, const struct spl_boot_device *bootdev, const struct legacy_img_hdr *header) { -#if CONFIG_IS_ENABLED(LOAD_FIT_FULL) - int ret = spl_load_fit_image(spl_image, header); + int ret; - if
[PATCH v2 11/32] spl: Rename spl_load_fit_image() to load_simple_fit()
We have two functions called spl_load_fit_image(), one in spl.c and one in spl_fit.c Rename the second one, to indicate that it relates to simple FIT parsing, rather than the full version. Signed-off-by: Simon Glass --- (no changes since v1) common/spl/spl_fit.c | 21 ++--- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 1bfdc0af4969..8e7d033dd1a4 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -207,7 +207,7 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size, } /** - * spl_load_fit_image(): load the image described in a certain FIT node + * load_simple_fit(): load the image described in a certain FIT node * @info: points to information about the device to load data from * @sector:the start sector of the FIT image on the device * @ctx: points to the FIT context structure @@ -220,9 +220,9 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size, * * Return: 0 on success or a negative error number. */ -static int spl_load_fit_image(struct spl_load_info *info, ulong sector, - const struct spl_fit_info *ctx, int node, - struct spl_image_info *image_info) +static int load_simple_fit(struct spl_load_info *info, ulong sector, + const struct spl_fit_info *ctx, int node, + struct spl_image_info *image_info) { int offset; size_t length; @@ -385,8 +385,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, else return node; } else { - ret = spl_load_fit_image(info, sector, ctx, node, -&image_info); + ret = load_simple_fit(info, sector, ctx, node, &image_info); if (ret < 0) return ret; } @@ -425,8 +424,8 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, __func__); } image_info.load_addr = (ulong)tmpbuffer; - ret = spl_load_fit_image(info, sector, ctx, -node, &image_info); + ret = load_simple_fit(info, sector, ctx, node, + &image_info); if (ret < 0) break; @@ -616,7 +615,7 @@ static int spl_fit_load_fpga(struct spl_fit_info *ctx, warn_deprecated("'fpga' property in config node. Use 'loadables'"); /* Load the image and set up the fpga_image structure */ - ret = spl_load_fit_image(info, sector, ctx, node, &fpga_image); + ret = load_simple_fit(info, sector, ctx, node, &fpga_image); if (ret) { printf("%s: Cannot load the FPGA: %i\n", __func__, ret); return ret; @@ -741,7 +740,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, } /* Load the image and set up the spl_image structure */ - ret = spl_load_fit_image(info, sector, &ctx, node, spl_image); + ret = load_simple_fit(info, sector, &ctx, node, spl_image); if (ret) return ret; @@ -782,7 +781,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, continue; image_info.load_addr = 0; - ret = spl_load_fit_image(info, sector, &ctx, node, &image_info); + ret = load_simple_fit(info, sector, &ctx, node, &image_info); if (ret < 0) { printf("%s: can't load image loadables index %d (ret = %d)\n", __func__, index, ret); -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 10/32] spl: Remove #ifdefs with BOOTSTAGE
This feature has some helpers in its header file so that its functions resolve to nothing when the feature is disabled. Add a few more and use these to simplify the code. With this there are no more #ifdefs in board_init_r() Signed-off-by: Simon Glass --- (no changes since v1) common/spl/spl.c| 15 +++ include/bootstage.h | 26 ++ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 5f57b51ca2d1..8541bef00466 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -542,17 +542,11 @@ static int spl_common_init(bool setup_malloc) ret); return ret; } -#ifdef CONFIG_BOOTSTAGE_STASH if (!u_boot_first_phase()) { - const void *stash = map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR, - CONFIG_BOOTSTAGE_STASH_SIZE); - - ret = bootstage_unstash(stash, CONFIG_BOOTSTAGE_STASH_SIZE); + ret = bootstage_unstash_default(); if (ret) - debug("%s: Failed to unstash bootstage: ret=%d\n", - __func__, ret); + log_debug("Failed to unstash bootstage: ret=%d\n", ret); } -#endif /* CONFIG_BOOTSTAGE_STASH */ bootstage_mark_name(get_bootstage_id(true), spl_phase_name(spl_phase())); #if CONFIG_IS_ENABLED(LOG) @@ -870,12 +864,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2) gd_malloc_ptr(), gd_malloc_ptr() / 1024); bootstage_mark_name(get_bootstage_id(false), "end phase"); -#ifdef CONFIG_BOOTSTAGE_STASH - ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR, - CONFIG_BOOTSTAGE_STASH_SIZE); + ret = bootstage_stash_default(); if (ret) debug("Failed to stash bootstage: err=%d\n", ret); -#endif if (IS_ENABLED(CONFIG_SPL_VIDEO_REMOVE)) { struct udevice *dev; diff --git a/include/bootstage.h b/include/bootstage.h index 685939ccffc0..38388afc259b 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -244,6 +244,8 @@ void show_boot_progress(int val); #ifdef ENABLE_BOOTSTAGE +#include + /* This is the full bootstage implementation */ /** @@ -364,6 +366,20 @@ int bootstage_stash(void *base, int size); */ int bootstage_unstash(const void *base, int size); +static inline int bootstage_stash_default(void) +{ + return bootstage_stash(map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR, 0), + CONFIG_BOOTSTAGE_STASH_SIZE); +} + +static inline int bootstage_unstash_default(void) +{ + const void *stash = map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR, + CONFIG_BOOTSTAGE_STASH_SIZE); + + return bootstage_unstash(stash, CONFIG_BOOTSTAGE_STASH_SIZE); +} + /** * bootstage_get_size() - Get the size of the bootstage data * @@ -440,6 +456,16 @@ static inline int bootstage_unstash(const void *base, int size) return 0; /* Pretend to succeed */ } +static inline int bootstage_stash_default(void) +{ + return 0; /* Pretend to succeed */ +} + +static inline int bootstage_unstash_default(void) +{ + return 0; /* Pretend to succeed */ +} + static inline int bootstage_get_size(void) { return 0; -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 09/32] spl: Avoid an #ifdef when printing gd->malloc_ptr
Use an accessor in the header file to avoid this. Signed-off-by: Simon Glass --- Changes in v2: - Use the same condition for both pieces to avoid possible problems common/spl/spl.c | 9 + include/asm-generic/global_data.h | 7 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 8511c66d7394..5f57b51ca2d1 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -864,10 +864,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } else { debug("Unsupported OS image.. Jumping nevertheless..\n"); } -#if CONFIG_VAL(SYS_MALLOC_F_LEN) && !defined(CONFIG_SPL_SYS_MALLOC_SIZE) - debug("SPL malloc() used 0x%lx bytes (%ld KB)\n", gd->malloc_ptr, - gd->malloc_ptr / 1024); -#endif + if (IS_ENABLED(CONFIG_SYS_MALLOC_F) && + !IS_ENABLED(CONFIG_SPL_SYS_MALLOC_SIZE)) + debug("SPL malloc() used 0x%lx bytes (%ld KB)\n", + gd_malloc_ptr(), gd_malloc_ptr() / 1024); + bootstage_mark_name(get_bootstage_id(false), "end phase"); #ifdef CONFIG_BOOTSTAGE_STASH ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR, diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 8fc205ded1a3..edf9ff6823f2 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -573,6 +573,13 @@ static_assert(sizeof(struct global_data) == GD_SIZE); #define gd_malloc_start() 0 #define gd_set_malloc_start(val) #endif + +#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#define gd_malloc_ptr()gd->malloc_ptr +#else +#define gd_malloc_ptr()0L +#endif + /** * enum gd_flags - global data flags * -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 08/32] spl: Drop the switch() statement for OS selection
This code is pretty ugly, with many #ifdefs There are quite a lot of IH_OS_U_BOOT values so the compiler struggles to create a jump table here. Also, most of the options are normally disabled. Change it to an else...if construct instead. Add an accessor for the spl_image field behind an #ifdef to avoid needing #ifdef in the C code. Signed-off-by: Simon Glass --- (no changes since v1) common/spl/spl.c | 32 ++-- include/spl.h| 9 + 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 703f45cd8044..8511c66d7394 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -748,7 +748,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) BOOT_DEVICE_NONE, }; struct spl_image_info spl_image; - int ret; + int ret, os; debug(">>" SPL_TPL_PROMPT "board_init_r()\n"); @@ -841,39 +841,27 @@ void board_init_r(gd_t *dummy1, ulong dummy2) ret); } - switch (spl_image.os) { - case IH_OS_U_BOOT: + os = spl_image.os; + if (os == IH_OS_U_BOOT) { debug("Jumping to %s...\n", spl_phase_name(spl_next_phase())); - break; -#if CONFIG_IS_ENABLED(ATF) - case IH_OS_ARM_TRUSTED_FIRMWARE: + } else if (CONFIG_IS_ENABLED(ATF) && os == IH_OS_ARM_TRUSTED_FIRMWARE) { debug("Jumping to U-Boot via ARM Trusted Firmware\n"); - spl_fixup_fdt(spl_image.fdt_addr); + spl_fixup_fdt(spl_image_fdt_addr(&spl_image)); spl_invoke_atf(&spl_image); - break; -#endif -#if CONFIG_IS_ENABLED(OPTEE_IMAGE) - case IH_OS_TEE: + } else if (CONFIG_IS_ENABLED(OPTEE_IMAGE) && os == IH_OS_TEE) { debug("Jumping to U-Boot via OP-TEE\n"); - spl_board_prepare_for_optee(spl_image.fdt_addr); + spl_board_prepare_for_optee(spl_image_fdt_addr(&spl_image)); jump_to_image_optee(&spl_image); - break; -#endif -#if CONFIG_IS_ENABLED(OPENSBI) - case IH_OS_OPENSBI: + } else if (CONFIG_IS_ENABLED(OPENSBI) && os == IH_OS_OPENSBI) { debug("Jumping to U-Boot via RISC-V OpenSBI\n"); spl_invoke_opensbi(&spl_image); - break; -#endif -#if CONFIG_IS_ENABLED(OS_BOOT) - case IH_OS_LINUX: + } else if (CONFIG_IS_ENABLED(OS_BOOT) && os == IH_OS_LINUX) { debug("Jumping to Linux\n"); if (IS_ENABLED(CONFIG_SPL_OS_BOOT)) spl_fixup_fdt((void *)SPL_PAYLOAD_ARGS_ADDR); spl_board_prepare_for_linux(); jump_to_image_linux(&spl_image); -#endif - default: + } else { debug("Unsupported OS image.. Jumping nevertheless..\n"); } #if CONFIG_VAL(SYS_MALLOC_F_LEN) && !defined(CONFIG_SPL_SYS_MALLOC_SIZE) diff --git a/include/spl.h b/include/spl.h index d16cea3ea50b..60b55b75195b 100644 --- a/include/spl.h +++ b/include/spl.h @@ -263,6 +263,15 @@ struct spl_image_info { #endif }; +static inline void *spl_image_fdt_addr(struct spl_image_info *info) +{ +#if CONFIG_IS_ENABLED(LOAD_FIT) || CONFIG_IS_ENABLED(LOAD_FIT_FULL) + return info->fdt_addr; +#else + return 0; +#endif +} + /** * Information required to load data from a device * -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 07/32] spl: Avoid #ifdef with CONFIG_SPL_PAYLOAD_ARGS_ADDR
Move the condition to the header file to improve readability. Signed-off-by: Simon Glass --- Changes in v2: - Change the approach to use the header file common/spl/spl.c | 10 -- include/system-constants.h | 7 +++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 9870e9a65468..703f45cd8044 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -810,9 +810,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } memset(&spl_image, '\0', sizeof(spl_image)); -#ifdef CONFIG_SPL_PAYLOAD_ARGS_ADDR - spl_image.arg = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR; -#endif + if (IS_ENABLED(CONFIG_SPL_OS_BOOT)) + spl_image.arg = (void *)SPL_PAYLOAD_ARGS_ADDR; spl_image.boot_device = BOOT_DEVICE_NONE; board_boot_order(spl_boot_list); @@ -869,9 +868,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2) #if CONFIG_IS_ENABLED(OS_BOOT) case IH_OS_LINUX: debug("Jumping to Linux\n"); -#if defined(CONFIG_SPL_PAYLOAD_ARGS_ADDR) - spl_fixup_fdt((void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR); -#endif + if (IS_ENABLED(CONFIG_SPL_OS_BOOT)) + spl_fixup_fdt((void *)SPL_PAYLOAD_ARGS_ADDR); spl_board_prepare_for_linux(); jump_to_image_linux(&spl_image); #endif diff --git a/include/system-constants.h b/include/system-constants.h index dca6a86b01f5..59371568d1e7 100644 --- a/include/system-constants.h +++ b/include/system-constants.h @@ -34,4 +34,11 @@ #define SPL_SYS_MALLOC_SIZE\ IF_ENABLED_INT(CONFIG_SPL_SYS_MALLOC, CONFIG_SPL_SYS_MALLOC_SIZE) +/* deal with an optional value */ +#ifdef CONFIG_SPL_OS_BOOT +#define SPL_PAYLOAD_ARGS_ADDR CONFIG_SPL_PAYLOAD_ARGS_ADDR +#else +#define SPL_PAYLOAD_ARGS_ADDR 0 +#endif + #endif -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 06/32] spl: Drop #ifdefs for BOARD_INIT and watchdog
Avoid using the preprocessor for these checks. Signed-off-by: Simon Glass --- (no changes since v1) common/spl/spl.c | 10 -- include/spl.h| 8 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 80a3a3f1516e..9870e9a65468 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -782,13 +782,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } } -#if CONFIG_IS_ENABLED(BOARD_INIT) - spl_board_init(); -#endif + if (CONFIG_IS_ENABLED(BOARD_INIT)) + spl_board_init(); -#if defined(CONFIG_SPL_WATCHDOG) && CONFIG_IS_ENABLED(WDT) - initr_watchdog(); -#endif + if (IS_ENABLED(CONFIG_SPL_WATCHDOG) && CONFIG_IS_ENABLED(WDT)) + initr_watchdog(); if (IS_ENABLED(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF) || IS_ENABLED(CONFIG_SPL_ATF)) diff --git a/include/spl.h b/include/spl.h index 92bcaa90a4af..d16cea3ea50b 100644 --- a/include/spl.h +++ b/include/spl.h @@ -707,9 +707,13 @@ int spl_early_init(void); */ int spl_init(void); -#ifdef CONFIG_SPL_BOARD_INIT +/* + * spl_board_init() - Do board-specific init in SPL + * + * If xPL_BOARD_INIT is enabled, this is called from board_init_r() before + * jumping to the next phase. + */ void spl_board_init(void); -#endif /** * spl_was_boot_source() - check if U-Boot booted from SPL -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 05/32] spl: mx6: powerpc: Drop the condition on timer_init()
It doesn't make sense to have some boards do this differently. Drop the condition in the hope that the maintainers can figure out any run-time problems. Signed-off-by: Simon Glass --- Changes in v2: - Explicitly copy two maintainers as it seems only Mario was auto-cc'd common/spl/spl.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 90e6dc2b5c9b..80a3a3f1516e 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -762,13 +762,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) if (spl_init()) hang(); } -#if !defined(CONFIG_PPC) && !defined(CONFIG_ARCH_MX6) - /* -* timer_init() does not exist on PPC systems. The timer is initialized -* and enabled (decrementer) in interrupt_init() here. -*/ timer_init(); -#endif if (CONFIG_IS_ENABLED(BLOBLIST)) { ret = bloblist_init(); if (ret) { -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 04/32] spl: Avoid #ifdef with CONFIG_SPL_SYS_MALLOC
Use IF_ENABLED_INT() to avoid needing to use the preprocessor. Signed-off-by: Simon Glass --- Changes in v2: - Improve readability by moving the size part to the header file common/spl/spl.c | 8 include/system-constants.h | 7 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index acd154986e15..90e6dc2b5c9b 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -754,10 +754,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2) spl_set_bd(); -#if defined(CONFIG_SPL_SYS_MALLOC) - mem_malloc_init(SPL_SYS_MALLOC_START, CONFIG_SPL_SYS_MALLOC_SIZE); - gd->flags |= GD_FLG_FULL_MALLOC_INIT; -#endif + if (IS_ENABLED(CONFIG_SPL_SYS_MALLOC)) { + mem_malloc_init(SPL_SYS_MALLOC_START, SPL_SYS_MALLOC_SIZE); + gd->flags |= GD_FLG_FULL_MALLOC_INIT; + } if (!(gd->flags & GD_FLG_SPL_INIT)) { if (spl_init()) hang(); diff --git a/include/system-constants.h b/include/system-constants.h index f0a191be590e..dca6a86b01f5 100644 --- a/include/system-constants.h +++ b/include/system-constants.h @@ -24,9 +24,14 @@ */ #ifdef CONFIG_SPL_HAS_CUSTOM_MALLOC_START #define SPL_SYS_MALLOC_START CONFIG_SPL_CUSTOM_SYS_MALLOC_ADDR -#else +#elif defined(CONFIG_SPL_BSS_START_ADDR) #define SPL_SYS_MALLOC_START (CONFIG_SPL_BSS_START_ADDR + \ CONFIG_SPL_BSS_MAX_SIZE) +#else +/* feature not enabled: this value avoids compiler errors but is not used */ +#define SPL_SYS_MALLOC_START 0 #endif +#define SPL_SYS_MALLOC_SIZE\ + IF_ENABLED_INT(CONFIG_SPL_SYS_MALLOC, CONFIG_SPL_SYS_MALLOC_SIZE) #endif -- 2.42.0.515.g380fc7ccd1-goog
[PATCH v2 03/32] spl: Rename SYS_SPL_ARGS_ADDR to SPL_PAYLOAD_ARGS_ADDR
Rename this so that SPL is first, as per U-Boot convention. Also add PAYLOAD_ since this is where in memory the parameters for the payload have been stored. Signed-off-by: Simon Glass --- Changes in v2: - Rename based on Tom's feedback arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon | 2 +- common/spl/Kconfig | 2 +- common/spl/spl.c| 8 common/spl/spl_ext.c| 4 ++-- common/spl/spl_fat.c| 4 ++-- common/spl/spl_mmc.c| 2 +- common/spl/spl_nand.c | 10 +- common/spl/spl_nor.c| 8 common/spl/spl_spi.c| 2 +- common/spl/spl_ubi.c| 2 +- common/spl/spl_xip.c| 2 +- configs/am3517_evm_defconfig| 2 +- configs/devkit8000_defconfig| 2 +- configs/display5_defconfig | 2 +- configs/display5_factory_defconfig | 2 +- configs/gwventana_emmc_defconfig| 2 +- configs/gwventana_nand_defconfig| 2 +- configs/igep00x0_defconfig | 2 +- configs/imx28_xea_defconfig | 2 +- configs/imx6dl_mamoj_defconfig | 2 +- configs/imx6q_logic_defconfig | 2 +- configs/imx6qdl_icore_mipi_defconfig| 2 +- configs/imx6qdl_icore_mmc_defconfig | 2 +- configs/imx6qdl_icore_rqs_defconfig | 2 +- configs/ls1046ardb_qspi_spl_defconfig | 2 +- configs/mccmon6_nor_defconfig | 2 +- configs/omap35_logic_defconfig | 2 +- configs/omap35_logic_somlv_defconfig| 2 +- configs/omap3_logic_defconfig | 2 +- configs/omap3_logic_somlv_defconfig | 2 +- configs/riotboard_defconfig | 2 +- configs/stm32746g-eval_spl_defconfig| 2 +- configs/stm32f746-disco_spl_defconfig | 2 +- configs/stm32f769-disco_spl_defconfig | 2 +- configs/syzygy_hub_defconfig| 2 +- configs/vyasa-rk3288_defconfig | 2 +- configs/xilinx_zynq_virt_defconfig | 2 +- configs/xilinx_zynqmp_virt_defconfig| 2 +- doc/develop/falcon.rst | 2 +- 39 files changed, 51 insertions(+), 51 deletions(-) diff --git a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon index b3c6693a42c2..2bbe4e2d1235 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon +++ b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon @@ -30,7 +30,7 @@ to understand the device tree in FIT image should be the one actually used, or leave it absent to favor the stored sectors. It is easier to deploy the FIT image with embedded static device tree to multiple boards. -Macro CONFIG_SYS_SPL_ARGS_ADDR serves two purposes. One is the pointer to load +Macro CONFIG_SPL_PAYLOAD_ARGS_ADDR serves two purposes. One is the pointer to load the stored sectors to. Normally this is the static device tree. The second purpose is the memory location of signature header for secure boot. After the FIT image is loaded into memory, it is validated against the signature header diff --git a/common/spl/Kconfig b/common/spl/Kconfig index b9d96fbe1355..463235979427 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -1063,7 +1063,7 @@ config SPL_OS_BOOT Enable booting directly to an OS from SPL. for more info read doc/README.falcon -config SYS_SPL_ARGS_ADDR +config SPL_PAYLOAD_ARGS_ADDR hex "Address in memory to load 'args' file for Falcon Mode to" depends on SPL_OS_BOOT default 0x8800 if ARCH_OMAP2PLUS diff --git a/common/spl/spl.c b/common/spl/spl.c index 1e50043cf77b..acd154986e15 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -818,8 +818,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } memset(&spl_image, '\0', sizeof(spl_image)); -#ifdef CONFIG_SYS_SPL_ARGS_ADDR - spl_image.arg = (void *)CONFIG_SYS_SPL_ARGS_ADDR; +#ifdef CONFIG_SPL_PAYLOAD_ARGS_ADDR + spl_image.arg = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR; #endif spl_image.boot_device = BOOT_DEVICE_NONE; board_boot_order(spl_boot_list); @@ -877,8 +877,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2) #if CONFIG_IS_ENABLED(OS_BOOT) case IH_OS_LINUX: debug("Jumping to Linux\n"); -#if defined(CONFIG_SYS_SPL_ARGS_ADDR) - spl_fixup_fdt((void *)CONFIG_SYS_SPL_ARGS_ADDR); +#if defined(CONFIG_SPL_PAYLOAD_ARGS_ADDR) + spl_fixup_fdt(
[PATCH v2 01/32] dm: core: support reading a single indexed u64 value
From: Michal Simek Add helper function to allow reading a single indexed u64 value from a device-tree property containing multiple u64 values, that is an array of u64's. Co-developed-by: Ashok Reddy Soma Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek Reviewed-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/dts/test.dts | 1 + drivers/core/of_access.c | 16 drivers/core/ofnode.c | 30 ++ include/dm/of_access.h| 19 +++ include/dm/ofnode.h | 12 test/dm/ofnode.c | 8 6 files changed, 82 insertions(+), 4 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 63fda15da764..d4693e3c7a93 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -301,6 +301,7 @@ uint-value = <(-1234)>; int64-value = /bits/ 64 <0x>; int-array = <5678 9123 4567>; + int64-array = /bits/ 64 <0x 0x>; str-value = "test string"; interrupts-extended = <&irq 3 0>; acpi,name = "GHIJ"; diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c index 57f10445b122..1bb4d8eab709 100644 --- a/drivers/core/of_access.c +++ b/drivers/core/of_access.c @@ -570,26 +570,34 @@ int of_read_u32_index(const struct device_node *np, const char *propname, return 0; } -int of_read_u64(const struct device_node *np, const char *propname, u64 *outp) +int of_read_u64_index(const struct device_node *np, const char *propname, + int index, u64 *outp) { const __be64 *val; debug("%s: %s: ", __func__, propname); if (!np) return -EINVAL; - val = of_find_property_value_of_size(np, propname, sizeof(*outp)); + + val = of_find_property_value_of_size(np, propname, +sizeof(*outp) * (index + 1)); if (IS_ERR(val)) { debug("(not found)\n"); return PTR_ERR(val); } - *outp = be64_to_cpup(val); + *outp = be64_to_cpup(val + index); debug("%#llx (%lld)\n", (unsigned long long)*outp, - (unsigned long long)*outp); + (unsigned long long)*outp); return 0; } +int of_read_u64(const struct device_node *np, const char *propname, u64 *outp) +{ + return of_read_u64_index(np, propname, 0, outp); +} + int of_property_match_string(const struct device_node *np, const char *propname, const char *string) { diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index a4dc9bde085c..8311282abf69 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -344,6 +344,36 @@ int ofnode_read_u32_index(ofnode node, const char *propname, int index, return 0; } +int ofnode_read_u64_index(ofnode node, const char *propname, int index, + u64 *outp) +{ + const fdt64_t *cell; + int len; + + assert(ofnode_valid(node)); + + if (ofnode_is_np(node)) + return of_read_u64_index(ofnode_to_np(node), propname, index, +outp); + + cell = fdt_getprop(ofnode_to_fdt(node), ofnode_to_offset(node), + propname, &len); + if (!cell) { + debug("(not found)\n"); + return -EINVAL; + } + + if (len < (sizeof(u64) * (index + 1))) { + debug("(not large enough)\n"); + return -EOVERFLOW; + } + + *outp = fdt64_to_cpu(cell[index]); + debug("%#llx (%lld)\n", *outp, *outp); + + return 0; +} + u32 ofnode_read_u32_index_default(ofnode node, const char *propname, int index, u32 def) { diff --git a/include/dm/of_access.h b/include/dm/of_access.h index c556a18f7d9c..9361d0a87bfb 100644 --- a/include/dm/of_access.h +++ b/include/dm/of_access.h @@ -333,6 +333,25 @@ int of_read_u32(const struct device_node *np, const char *propname, u32 *outp); int of_read_u32_index(const struct device_node *np, const char *propname, int index, u32 *outp); +/** + * of_read_u64_index() - Find and read a 64-bit value from a multi-value + * property + * + * @np:device node from which the property value is to be read. + * @propname: name of the property to be searched. + * @index: index of the u32 in the list of values + * @outp: pointer to return value, modified only if return value is 0. + * + * Search for a property in a device node and read a 64-bit value from + * it. + * + * Return: + * 0 on success, -EINVAL if the property does not exist, or -EOVERFLOW if the + * property data isn't large enough. + */ +int of_read_u64_index(const struct device_node *np, const char
[PULL] u-boot-riscv/master
Hi Tom, The following changes since commit b9b83a86f0e84e837191db120c279a9cc0e3434b: Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sh (2023-09-17 09:25:42 -0400) are available in the Git repository at: https://source.denx.de/u-boot/custodians/u-boot-riscv.git for you to fetch changes up to 43177705ab29ed1ccca970096de1ef3c6095e7e6: board: visionfive2: Fixup memory size passed to kernel (2023-09-20 20:30:30 +0800) CI result shows no issue: https://source.denx.de/u-boot/custodians/u-boot-riscv/-/pipelines/1 + Fixup memory size passed to kernel Shengyu Qu (2): configs: visionfive2: Enable CONFIG_OF_BOARD_SETUP board: visionfive2: Fixup memory size passed to kernel board/starfive/visionfive2/starfive_visionfive2.c | 7 +++ configs/starfive_visionfive2_defconfig| 1 + 2 files changed, 8 insertions(+) Best regards, Leo
[PULL] u-boot-riscv/next
Hi Tom, The following changes since commit c58ee1c9946a1550b1f6fee2b25da9ecc89baf71: Merge branch '2023-09-19-tidy-up-some-kconfig-options' into next (2023-09-19 17:44:18 -0400) are available in the Git repository at: https://source.denx.de/u-boot/custodians/u-boot-riscv.git next for you to fetch changes up to 90602e779d3ae3bd02faae0eb40b4fcefec419f7: riscv: dts: starfive: generate u-boot-spl.bin.normal.out (2023-09-20 21:05:16 +0800) CI result shows no issue: https://source.denx.de/u-boot/custodians/u-boot-riscv/-/pipelines/17779 + Add NVMe & USB boot devices for VisionFive2 + Add StarFive SPL image support in mkimage tool Heinrich Schuchardt (4): riscv: set fdtfile on VisionFive 2 configs: NVMe/USB target boot devices on VisionFive 2 tools: mkimage: Add StarFive SPL image support riscv: dts: starfive: generate u-boot-spl.bin.normal.out Milan P. Stanić (1): starfive: visionfive2: add mmc0 and nvme boot targets arch/riscv/Kconfig | 1 + .../dts/jh7110-starfive-visionfive-2-u-boot.dtsi | 11 ++ board/starfive/visionfive2/starfive_visionfive2.c | 43 - boot/image.c | 1 + doc/board/starfive/visionfive2.rst | 14 +- include/configs/starfive-visionfive2.h | 3 + include/image.h| 1 + tools/Makefile | 1 + tools/sfspl.c | 174 + 9 files changed, 235 insertions(+), 14 deletions(-) create mode 100644 tools/sfspl.c Best regards, Leo
Re: [PATCH 3/4] spl: atf: Fix potential but not occurring bug
On Sat, 16 Sept 2023 at 02:25, Massimo Pegorer wrote: > > Bug: function spl_fit_images_get_entry returns uninitialized variable > val if both fit_image_get_entry() and fit_image_get_load() fail (note > that both of them do not set val on failure). Fix: use val only if > entry or load address has been retrieved successfully. > > Note: in real world a failure of fit_image_get_load() will make current > SPL flow to break on loading images, see spl_load_fit_image(), before > entering spl_invoke_atf(). > > Signed-off-by: Massimo Pegorer > --- > common/spl/spl_atf.c | 15 +++ > 1 file changed, 7 insertions(+), 8 deletions(-) > Reviewed-by: Simon Glass
Re: [PATCHv9 01/15] submodule: add lwIP as git submodule
Hi Maxim, On Thu, 14 Sept 2023 at 10:20, Maxim Uvarov wrote: > > add external lwIP library as a git submodule. Oh dear...what is the motivation for using a submodule? Our current stack is nicely integrated into U-Boot. This would make moving between development branches much more painful. I would much prefer that we bring in the necessary code, and that you send a patch every 3 months or so to deal with updates, making sure there are no code-size regressions. Regards, Simon
Re: [PATCH 30/32] fdt: Allow the devicetree to come from a bloblist
Hi, On Mon, 11 Sept 2023 at 05:48, Ilias Apalodimas wrote: > > Hi Michal, > > On Mon, 11 Sept 2023 at 13:58, Michal Simek wrote: > > > > Hi Ilias, > > > > On 9/11/23 09:56, Ilias Apalodimas wrote: > > > Hi Michal, > > > > > > On Mon, 11 Sept 2023 at 09:38, Michal Simek wrote: > > >> > > >> > > >> > > >> On 9/11/23 08:17, Ilias Apalodimas wrote: > > >>> Hi Simon, > > >>> > > >>> On Sun, 10 Sept 2023 at 22:14, Simon Glass wrote: > > > > Hi Ilias, > > > > On Mon, 4 Sept 2023 at 03:31, Ilias Apalodimas > > wrote: > > > > > > Hi Simon, > > > > > > On Fri, 1 Sept 2023 at 18:51, Simon Glass wrote: > > >> > > >> Hi Ilias, > > >> > > >> On Fri, 1 Sept 2023 at 01:50, Ilias Apalodimas > > >> wrote: > > >>> > > >>> [...] > > >>> > > > > > >> +config OF_BLOBLIST > > >> + bool "DTB is provided by a bloblist" > > >> + help > > >> + Select this to read the devicetree from the bloblist. > > >> This allows > > >> + using a bloblist to transfer the devicetree between > > >> U-Boot phases. > > >> + The devicetree is stored in the bloblist by an early > > >> phase so that > > >> + U-Boot can read it. > > >> + > > > > > > I dont think this is a good idea. We used to have 4-5 different > > > options > > > here, which we tried to clean up and ended up with two very > > > discrete > > > options. Why do we have to reintroduce a new one? Doesn't that > > > bloblist > > > have a header of some sort? The bloblist literally comes from a > > > previous > > > stage bootloader which is what OF_BOARD is here for. So why can't > > > we just > > > read the header and figure out if the magic of the bloblist > > > matches? > > > > No, OF_BOARD is a hack to allow boards to do what they like with > > the FDT. > > > > This patch is a standard mechanism to pass the DT from one firmware > > phase to the next. We have spent quite a bit of time creating a > > spec > > for it, and we should use it. > > >>> > > >>> Where exactly am I objecting using the spec? Can you please > > >>> re-read my email? > > >>> I am actually pointing out we should use the spec *properly*. So > > >>> instead of having a Kconfig option for the DT, which is pretty > > >>> pointless, we should parse the bloblist. If the header defined by > > >>> the *spec* is found, we should just search for the DT in there. > > >>> What you are doing here, is take the spec, pick a very specific item > > >>> that the list contains, and create a Kconfig option out of it. > > >>> Which > > >>> basically ignores the discoverable options of the bloblist. For > > >>> example, that bloblist can also contain an entry to a TPM eventlog. > > >>> Should we start creating Kconfig options for all the firmware > > >>> handoff > > >>> entries that are defined on that spec? > > >> > > >> OK so that is a different thing. What should it do if it expects to > > >> find a bloblist but cannot? I want it to throw an error, because I > > >> am trying to make the boot deterministic. What do you think? > > > > > > That's fine by me. You can even put that under IS_ENABLED for the > > > bloblist inside the existing OF_BOARD check. So I was thinking > > > - If no bloblist is required in Kconfig options we do the hacks we > > > used to > > > - if bloblist is selected and the config option is OF_BOARD, throw an > > > error and mention that the previous stage loader should hand over a DT > > > > > > Is that what you had in mind? > > > > Yes, that sounds good to me. > > > > But I still think we need an OF_BLOBLIST option to control whether the > > devicetree comes from there. > > Otherwise we will end up with people > > using OF_BOARD to work around it. We also have the SPL case which does > > not pass the DT in a bloblist...in fact SPL typically doesn't even > > have the full DT. > > >>> > > >>> Wouldn't IS_ENABLED(BLOBLIST) || IS_ENABLED(SPL_BLOBLIST) be enough? > > >>> Inside the OF_BOARD portion of the function, search for a bloblist if > > >>> the option is enabled. If you can't find a bloblist and the DT within > > >>> that bloblist, then error out > > >> > > >> Just my 2c here. > > >> I think all options should be possible to disable. It means I can > > >> imagine to > > >> disable u-boot not to take care about DT provided from previous stage. > > >> The same > > >> is for TPM event log. IMHO every stage should have an option to simply > > >> ignore > > >> data pass from previous stage. I don't really mind how it is done but > > >> there > > >> s
Re: [PATCH v3 5/5] fdt: Fix compile error for !OFNODE_MULTI_TREE
On Tue, 12 Sept 2023 at 15:35, wrote: > > From: Sean Edmond > > Required to fix the following compile error when building sandbox: > /tmp/cci9ibby.ltrans21.ltrans.o: In function `do_cedit_load': > :(.text+0x601d): undefined reference to `oftree_dispose' > > Signed-off-by: Sean Edmond > --- > drivers/core/ofnode.c | 12 ++-- > 1 file changed, 6 insertions(+), 6 deletions(-) Reviewed-by: Simon Glass
Re: [PATCH v2 1/8] drivers: introduce Secure Monitor uclass
Hi Alexey, On Mon, 11 Sept 2023 at 10:35, Alexey Romanov wrote: > > At the moment, we don't have a common API for working with > SM, only the smc_call() function. This approach is not generic > and difficult to configure and maintain. > > This patch adds UCLASS_SM with the generic API: > > - sm_call() > - sm_call_write() > - sm_call_read() > > These functions operate with struct pt_regs, which describes > Secure Monitor arguments. > > Signed-off-by: Alexey Romanov > --- > drivers/Kconfig| 2 ++ > drivers/Makefile | 1 + > drivers/sm/Kconfig | 2 ++ > drivers/sm/Makefile| 3 ++ > drivers/sm/sm-uclass.c | 55 > include/dm/uclass-id.h | 1 + > include/sm-uclass.h| 72 ++ > include/sm.h | 67 +++ > 8 files changed, 203 insertions(+) > create mode 100644 drivers/sm/Kconfig > create mode 100644 drivers/sm/Makefile > create mode 100644 drivers/sm/sm-uclass.c > create mode 100644 include/sm-uclass.h > create mode 100644 include/sm.h Reviewed-by: Simon Glass nit below > > diff --git a/drivers/Kconfig b/drivers/Kconfig > index 75ac149d31..72e6405322 100644 > --- a/drivers/Kconfig > +++ b/drivers/Kconfig > @@ -112,6 +112,8 @@ source "drivers/scsi/Kconfig" > > source "drivers/serial/Kconfig" > > +source "drivers/sm/Kconfig" > + > source "drivers/smem/Kconfig" > > source "drivers/sound/Kconfig" > diff --git a/drivers/Makefile b/drivers/Makefile > index 6f1de58e00..b7bd3633b1 100644 > --- a/drivers/Makefile > +++ b/drivers/Makefile > @@ -124,3 +124,4 @@ obj-$(CONFIG_DM_RNG) += rng/ > endif > > obj-y += soc/ > +obj-y += sm/ > diff --git a/drivers/sm/Kconfig b/drivers/sm/Kconfig > new file mode 100644 > index 00..6cc6d55578 > --- /dev/null > +++ b/drivers/sm/Kconfig > @@ -0,0 +1,2 @@ > +config SM > + bool "Enable Secure Monitor driver support" > diff --git a/drivers/sm/Makefile b/drivers/sm/Makefile > new file mode 100644 > index 00..9f4683ba06 > --- /dev/null > +++ b/drivers/sm/Makefile > @@ -0,0 +1,3 @@ > +# SPDX-License-Identifier: GPL-2.0-only > + > +obj-y += sm-uclass.o > diff --git a/drivers/sm/sm-uclass.c b/drivers/sm/sm-uclass.c > new file mode 100644 > index 00..78af857026 > --- /dev/null > +++ b/drivers/sm/sm-uclass.c > @@ -0,0 +1,55 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Copyright (c) 2023 SberDevices, Inc. > + * > + * Author: Alexey Romanov > + */ > + > +#include > +#include > +#include > +#include > + > +static const struct sm_ops *get_sm_ops(struct udevice *dev) > +{ > + return (const struct sm_ops *)dev->driver->ops; > +} > + > +int sm_call(struct udevice *dev, u32 cmd, s32 *ret, struct pt_regs *args) > +{ > + const struct sm_ops *ops = get_sm_ops(dev); > + > + if (ops->sm_call) > + return ops->sm_call(dev, cmd, ret, args); > + > + return -EPROTONOSUPPORT; We normally use -ENOSYS in U-Boot Regards, Simon
Re: [PATCH v2 4/8] sandbox: add tests for UCLASS_SM
On Mon, 11 Sept 2023 at 10:35, Alexey Romanov wrote: > > This patchs adds simple tests for Secure Monitor uclass. > > Signed-off-by: Alexey Romanov > --- > test/dm/Makefile | 1 + > test/dm/sm.c | 65 > 2 files changed, 66 insertions(+) > create mode 100644 test/dm/sm.c Reviewed-by: Simon Glass
Re: [PATCH v2 7/8] arch: meson: sm: set correct order of the includes
On Mon, 11 Sept 2023 at 10:35, Alexey Romanov wrote: > > The common.h header should always be first, followed > by other headers in order, then headers with directories, > then local files. > > Signed-off-by: Alexey Romanov > --- > arch/arm/mach-meson/sm.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) Reviewed-by: Simon Glass > > diff --git a/arch/arm/mach-meson/sm.c b/arch/arm/mach-meson/sm.c > index d600c64d0b..b5dd6c6d39 100644 > --- a/arch/arm/mach-meson/sm.c > +++ b/arch/arm/mach-meson/sm.c > @@ -6,7 +6,10 @@ > */ > > #include > +#include > #include > +#include > +#include > #include > #include > #include > @@ -14,10 +17,7 @@ > #include > #include > #include > -#include > #include > -#include > -#include > > #define FN_GET_SHARE_MEM_INPUT_BASE0x8220 > #define FN_GET_SHARE_MEM_OUTPUT_BASE 0x8221 > -- > 2.25.1 >
Re: [PATCH 4/4] spl: atf: Reduce SPL code size
On Sat, 16 Sept 2023 at 02:25, Massimo Pegorer wrote: > > Previous fix commit increases code size of a few bytes. This minor > rework finally reduces SPL size of about 64-72 bytes (tested with > buildman on several aarch64 boards). > > Signed-off-by: Massimo Pegorer > --- > common/spl/spl_atf.c | 42 +++--- > 1 file changed, 19 insertions(+), 23 deletions(-) Reviewed-by: Simon Glass It would be nice to have test coverage of this code, in a sandbox_spl test
Re: [PATCH v2 8/8] arch: meson: use secure monitor driver
Hi Alexey, On Mon, 11 Sept 2023 at 10:35, Alexey Romanov wrote: > > Now we have to use UCLASS_SM driver instead of > raw smc_call() function call. > > Signed-off-by: Alexey Romanov > --- > arch/arm/mach-meson/Kconfig | 1 + > arch/arm/mach-meson/sm.c| 110 +++- > 2 files changed, 58 insertions(+), 53 deletions(-) Reviewed-by: Simon Glass with fix below > > diff --git a/arch/arm/mach-meson/Kconfig b/arch/arm/mach-meson/Kconfig > index 669ca09a00..d6c8905806 100644 > --- a/arch/arm/mach-meson/Kconfig > +++ b/arch/arm/mach-meson/Kconfig > @@ -11,6 +11,7 @@ config MESON64_COMMON > select PWRSEQ > select MMC_PWRSEQ > select BOARD_LATE_INIT > + select MESON_SM > imply CMD_DM > > config MESON_GX > diff --git a/arch/arm/mach-meson/sm.c b/arch/arm/mach-meson/sm.c > index b5dd6c6d39..0c60aa8695 100644 > --- a/arch/arm/mach-meson/sm.c > +++ b/arch/arm/mach-meson/sm.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -18,70 +19,62 @@ > #include > #include > #include > +#include > > -#define FN_GET_SHARE_MEM_INPUT_BASE0x8220 > -#define FN_GET_SHARE_MEM_OUTPUT_BASE 0x8221 > -#define FN_EFUSE_READ 0x8230 > -#define FN_EFUSE_WRITE 0x8231 > -#define FN_CHIP_ID 0x8244 > -#define FN_PWRDM_SET 0x8293 > - > -static void *shmem_input; > -static void *shmem_output; > - > -static void meson_init_shmem(void) > +static inline struct udevice *meson_get_sm_device(void) > { > - struct pt_regs regs; > - > - if (shmem_input && shmem_output) > - return; > + struct udevice *dev; > + int err; > > - regs.regs[0] = FN_GET_SHARE_MEM_INPUT_BASE; > - smc_call(®s); > - shmem_input = (void *)regs.regs[0]; > - > - regs.regs[0] = FN_GET_SHARE_MEM_OUTPUT_BASE; > - smc_call(®s); > - shmem_output = (void *)regs.regs[0]; > + err = uclass_get_device_by_name(UCLASS_SM, "secure-monitor", &dev); Can you use uclass_first_device_err(UCLASS_SM, ... instead? We should not be looking up devices by name. > + if (err) { > + pr_err("Mesom SM device not found\n"); > + return ERR_PTR(err); > + } > > - debug("Secure Monitor shmem: 0x%p 0x%p\n", shmem_input, shmem_output); > + return dev; > } > > ssize_t meson_sm_read_efuse(uintptr_t offset, void *buffer, size_t size) > { > - struct pt_regs regs; > + struct udevice *dev; > + struct pt_regs regs = { 0 }; > + int err; > > - meson_init_shmem(); > + dev = meson_get_sm_device(); > + if (IS_ERR(dev)) > + return PTR_ERR(dev); > > - regs.regs[0] = FN_EFUSE_READ; > regs.regs[1] = offset; > regs.regs[2] = size; > > - smc_call(®s); > + err = sm_call_read(dev, buffer, size, > + MESON_SMC_CMD_EFUSE_READ, ®s); > + if (err < 0) > + pr_err("Failed to read efuse memory (%d)\n", err); > > - if (regs.regs[0] == 0) > - return -1; > - > - memcpy(buffer, shmem_output, min(size, regs.regs[0])); > - > - return regs.regs[0]; > + return err; > } > > ssize_t meson_sm_write_efuse(uintptr_t offset, void *buffer, size_t size) > { > - struct pt_regs regs; > - > - meson_init_shmem(); > + struct udevice *dev; > + struct pt_regs regs = { 0 }; > + int err; > > -memcpy(shmem_input, buffer, size); > + dev = meson_get_sm_device(); > + if (IS_ERR(dev)) > + return PTR_ERR(dev); > > - regs.regs[0] = FN_EFUSE_WRITE; > regs.regs[1] = offset; > regs.regs[2] = size; > > - smc_call(®s); > + err = sm_call_write(dev, buffer, size, > + MESON_SMC_CMD_EFUSE_WRITE, ®s); > + if (err < 0) > + pr_err("Failed to write efuse memory (%d)\n", err); > > - return regs.regs[0]; > + return err; > } > > #define SM_CHIP_ID_LENGTH 119 > @@ -90,18 +83,21 @@ ssize_t meson_sm_write_efuse(uintptr_t offset, void > *buffer, size_t size) > > int meson_sm_get_serial(void *buffer, size_t size) > { > - struct pt_regs regs; > + struct udevice *dev; > + struct pt_regs regs = { 0 }; > + u8 id_buffer[SM_CHIP_ID_LENGTH]; > + int err; > > - meson_init_shmem(); > + dev = meson_get_sm_device(); > + if (IS_ERR(dev)) > + return PTR_ERR(dev); > > - regs.regs[0] = FN_CHIP_ID; > - regs.regs[1] = 0; > - regs.regs[2] = 0; > + err = sm_call_read(dev, id_buffer, SM_CHIP_ID_LENGTH, > + MESON_SMC_CMD_CHIP_ID_GET, ®s); > + if (err < 0) > + pr_err("Failed to read serial number (%d)\n", err); > > - smc_call(®s); > - > - memcpy(buffer, shmem_output +
Re: [PATCH v2 3/8] sandbox: dts: add meson secure monitor node
On Mon, 11 Sept 2023 at 10:35, Alexey Romanov wrote: > > We need this to test UCLASS_SM. > > Signed-off-by: Alexey Romanov > --- > arch/sandbox/dts/test.dts | 4 > 1 file changed, 4 insertions(+) Reviewed-by: Simon Glass
Re: [PATCH 2/2] malloc_simple: add mem_malloc_init_simple()
Hi Rasmus, On Fri, 15 Sept 2023 at 11:51, Rasmus Villemoes wrote: > > I was running out of malloc() in SPL, and the message told me to look > at CONFIG_SYS_SPL_MALLOC_SIZE. So I did, and bumped it quite a bit, > but that had no effect whatsoever. > > The reason for that was that I also have > CONFIG_SPL_SYS_MALLOC_SIMPLE=y. So while board_init_r() in spl.c duly > calls > > mem_malloc_init(SYS_SPL_MALLOC_START, CONFIG_SYS_SPL_MALLOC_SIZE); > > that doesn't actually do anything, because that function just sets > some variables in dlmalloc.c, and (as the linker map shows), the rest > of dlmalloc.o has been garbage-collected. > > I don't want to have the full dlmalloc implementation in SPL - code > size is still precious. However, once SDRAM is initialized, the heap > is practically infinite, if only CONFIG_SYS_SPL_MALLOC_SIZE actually > had an effect. > > So just as CONFIG_SPL_SYS_MALLOC_SIMPLE redirects malloc() and friends > at build-time to the _simple variants, add a _simple variant of > mem_malloc_init() which will actually update the bookkeeping variables > relevant to the actual and active malloc() implementation. > > Signed-off-by: Rasmus Villemoes > --- > common/dlmalloc.c | 2 +- > common/malloc_simple.c | 7 +++ > include/malloc.h | 7 +-- > 3 files changed, 13 insertions(+), 3 deletions(-) Reviewed-by: Simon Glass width change below > > diff --git a/common/dlmalloc.c b/common/dlmalloc.c > index dcecdb8623..d42b26410f 100644 > --- a/common/dlmalloc.c > +++ b/common/dlmalloc.c > @@ -619,7 +619,7 @@ void *sbrk(ptrdiff_t increment) > return (void *)old; > } > > -void mem_malloc_init(ulong start, ulong size) > +void mem_dlmalloc_init(ulong start, ulong size) > { > mem_malloc_start = start; > mem_malloc_end = start + size; > diff --git a/common/malloc_simple.c b/common/malloc_simple.c > index 0a004d40e1..9ecf05cf2e 100644 > --- a/common/malloc_simple.c > +++ b/common/malloc_simple.c > @@ -17,6 +17,13 @@ > > DECLARE_GLOBAL_DATA_PTR; > > +void mem_malloc_init_simple(ulong start, ulong size) > +{ > + gd->malloc_base = start; > + gd->malloc_ptr = 0; > + gd->malloc_limit = size; > +} > + > static void *alloc_simple(size_t bytes, int align) > { > ulong addr, new_ptr; > diff --git a/include/malloc.h b/include/malloc.h > index 161ccbd129..f59942115b 100644 > --- a/include/malloc.h > +++ b/include/malloc.h > @@ -899,6 +899,7 @@ void malloc_disable_testing(void); > #define malloc malloc_simple > #define realloc realloc_simple > #define memalign memalign_simple > +#define mem_malloc_init mem_malloc_init_simple > #if IS_ENABLED(CONFIG_VALGRIND) > #define free free_simple > #else > @@ -908,6 +909,9 @@ void *calloc(size_t nmemb, size_t size); > void *realloc_simple(void *ptr, size_t size); > #else > > +#define mem_malloc_init mem_dlmalloc_init > +void mem_dlmalloc_init(ulong start, ulong size); Please add a full comment here > + > # ifdef USE_DL_PREFIX > # define cALLOcdlcalloc > # define fREe dlfree > @@ -955,6 +959,7 @@ int initf_malloc(void); > /* Simple versions which can be used when space is tight */ > void *malloc_simple(size_t size); > void *memalign_simple(size_t alignment, size_t bytes); > +void mem_malloc_init_simple(ulong start, ulong size); Please add a full comment here > > #pragma GCC visibility push(hidden) > # if __STD_C > @@ -997,8 +1002,6 @@ extern ulong mem_malloc_start; > extern ulong mem_malloc_end; > extern ulong mem_malloc_brk; > > -void mem_malloc_init(ulong start, ulong size); > - > #ifdef __cplusplus > }; /* end of extern "C" */ > #endif > -- > 2.37.2 > Regards, Simon
Re: [PATCH v2 2/8] sandbox: add sandobx sm uclass driver
Hi Alexey, On Mon, 11 Sept 2023 at 10:35, Alexey Romanov wrote: > > This patch adds sandbox secure monitor driver. Please fix typo in subject > > Signed-off-by: Alexey Romanov > --- > drivers/sm/Makefile | 1 + > drivers/sm/sandbox-sm.c | 76 + > include/sandbox-sm.h| 18 ++ > 3 files changed, 95 insertions(+) > create mode 100644 drivers/sm/sandbox-sm.c > create mode 100644 include/sandbox-sm.h > Reviewed-by: Simon Glass
Re: [PATCH 1/4] mkimage: also honour -B even without external data
Hi Rasmus, On Tue, 19 Sept 2023 at 05:37, Rasmus Villemoes wrote: > > In some cases, using the "external data" feature is impossible or > undesirable, but one may still want (or need) the FIT image to have a > certain alignment. Also, given the current 'mkimage -h' output, > > -B => align size in hex for FIT structure and header > > it is quite unexpected for -B to be effectively ignored without -E. > > Signed-off-by: Rasmus Villemoes > --- > tools/fit_image.c | 40 > 1 file changed, 40 insertions(+) Reviewed-by: Simon Glass Q below > > diff --git a/tools/fit_image.c b/tools/fit_image.c > index 9fe69ea0d9..2f5b25098a 100644 > --- a/tools/fit_image.c > +++ b/tools/fit_image.c > @@ -712,6 +712,42 @@ err: > return ret; > } > > +/** > + * fit_align() - Ensure FIT image has certain alignment > + * > + * This takes a normal FIT file (with embedded data) and increases its > + * size so that it is a multiple of params->bl_len. > + */ > +static int fit_align(struct image_tool_params *params, const char *fname) > +{ > + int fit_size, new_size; > + int fd; > + struct stat sbuf; > + void *fdt; > + int ret = 0; > + int align_size; > + > + align_size = params->bl_len; > + fd = mmap_fdt(params->cmdname, fname, 0, &fdt, &sbuf, false, false); > + if (fd < 0) > + return -EIO; > + > + fit_size = fdt_totalsize(fdt); > + new_size = ALIGN(fit_size, align_size); > + fdt_set_totalsize(fdt, new_size); Shouldn't this be fdt_open_into()? > + debug("Size extended from from %x to %x\n", fit_size, new_size); > + munmap(fdt, sbuf.st_size); > + > + if (ftruncate(fd, new_size)) { > + debug("%s: Failed to truncate file: %s\n", __func__, > + strerror(errno)); > + ret = -EIO; > + } > + > + close(fd); > + return ret; > +} > + > /** > * fit_handle_file - main FIT file processing function > * > @@ -817,6 +853,10 @@ static int fit_handle_file(struct image_tool_params > *params) > ret = fit_extract_data(params, tmpfile); > if (ret) > goto err_system; > + } else if (params->bl_len) { > + ret = fit_align(params, tmpfile); > + if (ret) > + goto err_system; > } > > if (rename (tmpfile, params->imagefile) == -1) { > -- > 2.37.2 > Regards, Simon
Re: [PATCH 09/32] spl: Avoid an #ifdef when printing gd->malloc_ptr
Hi Tom, On Wed, 30 Aug 2023 at 15:39, Tom Rini wrote: > > On Wed, Aug 30, 2023 at 12:04:40PM -0600, Simon Glass wrote: > > Use an accessor in the header file to avoid this. > > > > Signed-off-by: Simon Glass > > --- > > > > common/spl/spl.c | 9 + > > include/asm-generic/global_data.h | 7 +++ > > 2 files changed, 12 insertions(+), 4 deletions(-) > > > > diff --git a/common/spl/spl.c b/common/spl/spl.c > > index f0a90c280da..f5cef81000c 100644 > > --- a/common/spl/spl.c > > +++ b/common/spl/spl.c > > @@ -876,10 +876,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2) > > } else { > > debug("Unsupported OS image.. Jumping nevertheless..\n"); > > } > > -#if CONFIG_VAL(SYS_MALLOC_F_LEN) && !defined(CONFIG_SPL_SYS_MALLOC_SIZE) > > - debug("SPL malloc() used 0x%lx bytes (%ld KB)\n", gd->malloc_ptr, > > - gd->malloc_ptr / 1024); > > -#endif > > + if (IS_ENABLED(CONFIG_SYS_MALLOC_F) && > > + !IS_ENABLED(CONFIG_SPL_SYS_MALLOC_SIZE)) > > + debug("SPL malloc() used 0x%lx bytes (%ld KB)\n", > > + gd_malloc_ptr(), gd_malloc_ptr() / 1024); > > + > > bootstage_mark_name(get_bootstage_id(false), "end phase"); > > #ifdef CONFIG_BOOTSTAGE_STASH > > ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR, > > diff --git a/include/asm-generic/global_data.h > > b/include/asm-generic/global_data.h > > index 8fc205ded1a..edf9ff6823f 100644 > > --- a/include/asm-generic/global_data.h > > +++ b/include/asm-generic/global_data.h > > @@ -573,6 +573,13 @@ static_assert(sizeof(struct global_data) == GD_SIZE); > > #define gd_malloc_start()0 > > #define gd_set_malloc_start(val) > > #endif > > + > > +#if CONFIG_VAL(SYS_MALLOC_F_LEN) > > +#define gd_malloc_ptr() gd->malloc_ptr > > +#else > > +#define gd_malloc_ptr() 0L > > +#endif > > + > > /** > > * enum gd_flags - global data flags > > * > > This is another case where readability is not improved. I also have a > bad feeling that changing that exact area had some unintended > consequences from the compiler, that totally should not have happened. > But maybe that was something in a similar code section instead. The improvement is in the C file...here we have an accessor in the header file as has been done elsewhere. Do you have any more details on the problem you mention? I will align the accessor to the struct member which should resolve it. Regards, Simon
Re: [PATCH 1/2] spl: make SYS_SPL_MALLOC depend on !(SPL_STACK_R && SPL_SYS_MALLOC_SIMPLE)
On Fri, 15 Sept 2023 at 11:51, Rasmus Villemoes wrote: > > Currently, one can have both SYS_SPL_MALLOC=y and > SPL_SYS_MALLOC_SIMPLE=y. > > However, while the former does make board_init_r() in spl.c call > mem_malloc_init(), that has no effect at all, because that just > updates a few bookkeeping variables, but as the linker map shows, the > latter setting has (as expected) caused most of dlmalloc.o to be > garbage-collected. That is, those bookkeeping variables are not used > for anything. > > IOWs, with SYS_SPL_MALLOC=y and SPL_SYS_MALLOC_SIMPLE=y, the value of > CONFIG_SYS_SPL_MALLOC_SIZE is irrelevant, and one still only has the > small, SRAM-backed, malloc arena available. > > Now I want to change that so that the mem_malloc_init() instead > updates the gd->malloc* variables to point at the SDRAM area. > > However, there's a small complication, namely when SPL_STACK_R=y is > also in the mix. In that case, the "simple" malloc arena is indeed > updated to point at the SDRAM area carved out of the new stack (see > spl_relocate_stack_gd()). So that case works in the sense that one > does get a "large" "simple" malloc arena (of size > SPL_STACK_R_MALLOC_SIMPLE_LEN) - but CONFIG_SYS_SPL_MALLOC_SIZE is > still irrelevant. Once I change the mem_malloc_init() logic, this > would then break, because the gd->malloc* variables would be updated > again. Also, it doesn't really make sense to allow the .config to > essentially specify two different SDRAM-backed malloc arenas. > > So since CONFIG_SYS_SPL_MALLOC and its dependent options are no-ops > currently when SPL_STACK_R && SPL_SYS_MALLOC_SIMPLE, simply forbid > that combination. > > Simple grepping suggests that these boards/configs are affected, in > that they become a tiny bit smaller, and the defconfig will need > refreshing: > > am62ax_evm_r5_defconfig > am62x_evm_r5_defconfig > am64x_evm_a53_defconfig > am64x_evm_r5_defconfig > am65x_evm_a53_defconfig > am65x_hs_evm_a53_defconfig > iot2050_defconfig > j7200_evm_a72_defconfig > j721e_evm_a72_defconfig > j721s2_evm_a72_defconfig > j721s2_evm_r5_defconfig > verdin-am62_r5_defconfig > > Signed-off-by: Rasmus Villemoes > --- > common/spl/Kconfig | 1 + > 1 file changed, 1 insertion(+) > Reviewed-by: Simon Glass
Re: [PATCH 05/32] spl: mx6: powerpc: Drop the condition on timer_init()
Hi Tom, On Thu, 31 Aug 2023 at 11:51, Tom Rini wrote: > > On Wed, Aug 30, 2023 at 12:04:36PM -0600, Simon Glass wrote: > > > It doesn't make sense to have some boards do this differently. Drop the > > condition in the hope that the maintainers can figure out any run-time > > problems. > > > > Signed-off-by: Simon Glass > > --- > > > > common/spl/spl.c | 6 -- > > 1 file changed, 6 deletions(-) > > > > diff --git a/common/spl/spl.c b/common/spl/spl.c > > index 78db9ef5318..3f513b0563a 100644 > > --- a/common/spl/spl.c > > +++ b/common/spl/spl.c > > @@ -766,13 +766,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) > > if (spl_init()) > > hang(); > > } > > -#if !defined(CONFIG_PPC) && !defined(CONFIG_ARCH_MX6) > > - /* > > - * timer_init() does not exist on PPC systems. The timer is > > initialized > > - * and enabled (decrementer) in interrupt_init() here. > > - */ > > timer_init(); > > -#endif > > PowerPC might be a little tricky, did qemu-ppce500 run? And please > reach out to some of the iMX folks instead of just dropping this and > hoping it works. Yes, CI passes. +Christophe Leroy +Marek Behún PowerPC people, does this look OK? Regards, Simon
Re: [PATCH v2 5/8] sandbox: defconfig: enable CONFIG_SM option
On Mon, 11 Sept 2023 at 10:35, Alexey Romanov wrote: > > We use this option for test UCLASS_SM. s/for/to/ > > Signed-off-by: Alexey Romanov > --- > configs/sandbox_defconfig | 1 + > 1 file changed, 1 insertion(+) Reviewed-by: Simon Glass > > diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig > index be46cae7aa..0745a4ecca 100644 > --- a/configs/sandbox_defconfig > +++ b/configs/sandbox_defconfig > @@ -270,6 +270,7 @@ CONFIG_RTC_RV8803=y > CONFIG_SCSI=y > CONFIG_DM_SCSI=y > CONFIG_SANDBOX_SERIAL=y > +CONFIG_SM=y > CONFIG_SMEM=y > CONFIG_SANDBOX_SMEM=y > CONFIG_SOUND=y > -- > 2.25.1 >
Re: [PATCH v2 6/8] drivers: introduce Meson Secure Monitor driver
On Mon, 11 Sept 2023 at 10:35, Alexey Romanov wrote: > > This patch adds an implementation of the Meson Secure Monitor > driver based on UCLASS_SM. > > Signed-off-by: Alexey Romanov > --- > MAINTAINERS | 1 + > drivers/sm/Kconfig| 7 ++ > drivers/sm/Makefile | 1 + > drivers/sm/meson-sm.c | 198 ++ > include/meson/sm.h| 19 > 5 files changed, 226 insertions(+) > create mode 100644 drivers/sm/meson-sm.c > create mode 100644 include/meson/sm.h > Reviewed-by: Simon Glass
Re: [PATCH 2/4] binman: test: rename 275_fit_align.dts -> 275_fit_align_external.dts
On Tue, 19 Sept 2023 at 05:37, Rasmus Villemoes wrote: > > In preparation for adding a test case for fit,align without > fit,external-offset present, rename the existing test case and > corresponding file. > > Signed-off-by: Rasmus Villemoes > --- > tools/binman/ftest.py | 4 ++-- > .../test/{275_fit_align.dts => 275_fit_align_external.dts}| 0 > 2 files changed, 2 insertions(+), 2 deletions(-) > rename tools/binman/test/{275_fit_align.dts => 275_fit_align_external.dts} > (100%) > Reviewed-by: Simon Glass
Re: [PATCH v3 4/5] dm: core: Modify default for OFNODE_MULTI_TREE
On Tue, 12 Sept 2023 at 15:35, wrote: > > From: Sean Edmond > > There is a preference to use the "ofnode" API for FDT fixups > moving forward. The FDT fixup will usually be for the kernel FDT. To > fixup the kernel FDT with the ofnode API, it's required to set the > OFNODE_MULTI_TREE option. > > To ensure existing users of kaslr fdt fixup are not impacted, Let's modify > the default value for OFNODE_MULTI_TREE to ensure it's always set if > !OF_LIVE. This will cause a 1007 byte increase in the code size. > > Signed-off-by: Sean Edmond > --- > drivers/core/Kconfig | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Simon Glass
Re: [PATCH v2] Makefile: Force regeneration of env.txt
On Fri, 15 Sept 2023 at 08:43, Andrew Davis wrote: > > If the source .env file changes to one that is also older than the > generated env.txt file then the .env file is not regenerated. This > means when switching board configs we do not regenerate the env. > > This can be tested with: > > $ make j721e_evm_a72_defconfig > $ make # this may fail to complete but that is okay for this test > $ make am64x_evm_a53_defconfig > $ make > $ vim include/generated/env.txt > > Note this is still the J721e env not the AM64 config as expected. > > As ENV_FILE is set based on configuration, regenerate anytime > autoconf.h changes. > > Signed-off-by: Andrew Davis > --- > > Changes for v2: > - Depend on autoconf.h as suggested by Simon > > Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Simon Glass
Re: [PATCH] common: Drop linux/printk.h from common header
Hi Tom, On Fri, 15 Sept 2023 at 15:54, Tom Rini wrote: > > On Fri, Sep 15, 2023 at 02:01:33PM -0600, Simon Glass wrote: > > Hi Tom, > > > > On Fri, 15 Sept 2023 at 13:48, Tom Rini wrote: > > > > > > On Thu, Sep 14, 2023 at 06:21:46PM -0600, Simon Glass wrote: > > > > > > > This old patch was marked as deferred. Bring it back to life, to > > > > continue > > > > towards the removal of common.h > > > > > > > > Move this out of the common header and include it only where needed. > > > > > > > > Signed-off-by: Simon Glass > > > [snip] > > > > 317 files changed, 322 insertions(+), 3 deletions(-) > > > > > > So, going back to the original series here, how did you determine that > > > the files changed here need ? I can see how to get > > > there with some grep'ing but I think my original complaint was that we > > > added the new header too widely. > > > > Basically I used ctags to get the symbols from the header file, then > > grepped files for them. For that one, it is: > > > > KERN_ALERT,KERN_CONT,KERN_CRIT,KERN_DEBUG,KERN_EMERG,KERN_ERR,KERN_INFO,KERN_NOTICE,KERN_WARNING,__KERNEL_PRINTK__,__printk,no_printk,pr_alert,pr_cont,pr_crit,pr_debug,pr_debug,pr_devel,pr_devel,pr_emerg,pr_err,pr_fmt,pr_info,pr_notice,pr_warn,pr_warning,printk,printk_once > > OK, good. > > > I was a little miffed that a comment along these lines from Heinrich, > > with no actual evidence, and no response to my follow-up questions, > > caused the series to be dropped. It isn't easy to do these sorts of > > clean-ups. > > Well, I know earlier on I had concerns and spotted specific cases where > it was off. > > > A lot of files include things like net.h and image.h which bring in > > many headers...but we should clean up those header files up too > > (particularly image.h). So I think the standard should be: "include > > what you use". > > Yes, we should first get rid of common.h and then see what we can > remove next. Are you OK with this patch? If so I could send another, but should perhaps wait until this is in -next ? Regards, Simon
Re: [PATCH 3/4] tools: binman: add test case for fit, align without fit, external-offset
On Tue, 19 Sept 2023 at 05:37, Rasmus Villemoes wrote: > > Signed-off-by: Rasmus Villemoes > --- > tools/binman/ftest.py | 10 + > tools/binman/test/311_fit_align.dts | 58 + > 2 files changed, 68 insertions(+) > create mode 100644 tools/binman/test/311_fit_align.dts > Reviewed-by: Simon Glass
Re: [PATCH 4/4] binman: update documentation for fit,align property
On Tue, 19 Sept 2023 at 05:37, Rasmus Villemoes wrote: > > Eliminate the repetition "what alignment to use ... and provides the > alignment to use", and indicate that fit,align can both be used by > itself and together with fit,external-offset. > > Signed-off-by: Rasmus Villemoes > --- > tools/binman/entries.rst | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) Reviewed-by: Simon Glass
Re: [PATCH v6 1/2] configs: Add support in Kconfig and convert for armada boards
Hi Venkatesh, On Tue, 19 Sept 2023 at 21:28, Venkatesh Yadav Abbarapu wrote: > > From: Algapally Santosh Sagar > > The DEFAULT_ENV_IS_RW is moved to the Kconfig for easier configuration. Please use imperative mood [1] Move the DEFAULT_ENV_IS_RW to Kconfig for ... > Hence, the CONFIG_DEFAULT_ENV_IS_RW config is added to the defconfig files > to allow enabling them for armada boards. Hence, add the ... > > Signed-off-by: Algapally Santosh Sagar > Signed-off-by: Venkatesh Yadav Abbarapu > --- > configs/eDPU_defconfig | 1 + > configs/mvebu_db-88f3720_defconfig | 1 + > configs/mvebu_espressobin-88f3720_defconfig | 1 + > configs/uDPU_defconfig | 1 + > drivers/serial/Kconfig | 6 ++ > include/configs/mvebu_armada-37xx.h | 1 - > include/env_default.h | 2 +- > include/env_internal.h | 2 +- > 8 files changed, 12 insertions(+), 3 deletions(-) Reviewed-by: Simon Glass [1] https://www.kernel.org/doc/html/latest/process/submitting-patches.html
Re: [PATCH v2] cmd: sf: Fix the flash_is_unlocked api size parameter
On Tue, 19 Sept 2023 at 21:42, Venkatesh Yadav Abbarapu wrote: > > When flash erase is called with size parameter, code is checking > if sectors are locked or not. But for checking, the whole device > length minus offset is used instead of actual size which should > be erased. That's why when only some sectors are locked it is > not possible to erase unlocked sectors. > > The length is calculated as "length = max_chipsize - offset", > flash_is_unlocked() api is getting updated with length which is > incorrect. Fix this flash_is_unlocked() api by passing the size > parameter. > > ZynqMP> sf erase 0 10 > len=0x800 which is flash size > size=0x10 > > We need to update the size in the flash_is_unlocked() api and not > the length. > > Signed-off-by: Venkatesh Yadav Abbarapu > --- > Changes in v2: > - Updated the commit description. > --- > cmd/sf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Simon Glass
Re: [PATCH 2/4] image: fit: Improve functions description comments
On Sat, 16 Sept 2023 at 02:23, Massimo Pegorer wrote: > > Load and entry addresses are returned in ulong variables, which are > 32 or 64 bit depending on architecture. Specify that on failure these > functions do not set memory pointed by load / entry argument: this > detail is relavant for correct functions usage. > > Signed-off-by: Massimo Pegorer > --- > boot/image-fit.c | 12 +--- > 1 file changed, 5 insertions(+), 7 deletions(-) > Reviewed-by: Simon Glass
Re: [PATCH] bootstd: use ARCH_DMA_MINALIGN in memalign() when allocating memory
On Tue, 19 Sept 2023 at 15:27, Tony Dinh wrote: > > Use ARCH_DMA_MINALIGN in memalign() when allocating memory to read the script > from the media. > > Ref: > https://lore.kernel.org/u-boot/cajalify05f3cr4x4g2mvkppxnbefzrhq+5cngyn8ejpg8en...@mail.gmail.com/T/#m26daadc2463fe653b814a94e6309e5e6bb6be1d1 > > Note: this patch depends on the previous patch > https://patchwork.ozlabs.org/project/uboot/patch/20230917230649.30357-1-mibo...@gmail.com/ > > Signed-off-by: Tony Dinh > --- > > boot/bootmeth_script.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Simon Glass > > diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c > index 96e0ec5efa..de2e510da1 100644 > --- a/boot/bootmeth_script.c > +++ b/boot/bootmeth_script.c > @@ -99,7 +99,7 @@ static int script_read_bootflow_file(struct udevice > *bootstd, > if (!bflow->subdir) > return log_msg_ret("prefix", -ENOMEM); > > - ret = bootmeth_alloc_file(bflow, 0x1, 1); > + ret = bootmeth_alloc_file(bflow, 0x1, ARCH_DMA_MINALIGN); > if (ret) > return log_msg_ret("read", ret); > > -- > 2.39.2 >
Re: [PATCH v3 3/5] cmd: kaslrseed: Use common API to fixup FDT
On Tue, 12 Sept 2023 at 15:35, wrote: > > From: Sean Edmond > > Use the newly introduced common API fdt_fixup_kaslr_seed() in the > kaslrseed command. > > Signed-off-by: Sean Edmond > --- > cmd/kaslrseed.c | 22 -- > 1 file changed, 8 insertions(+), 14 deletions(-) > Reviewed-by: Simon Glass
Re: [PATCH 1/4] spl: atf: Improve comments and code readability
On Sat, 16 Sept 2023 at 02:23, Massimo Pegorer wrote: > > Rename bl31_entry static function to avoid name clash with its first > argument. Fix spaces misuse. Describe code accurately: load address > is used if getting entry point address fails, and not if addresses > differ. Remove not up-to-date comment about BL3-2 usage. > > Signed-off-by: Massimo Pegorer > --- > common/spl/spl_atf.c | 34 +++--- > 1 file changed, 15 insertions(+), 19 deletions(-) > Reviewed-by: Simon Glass
Re: [PATCH v3 2/7] net: wget: add wget with dns utility function
Hi Masahisa, On Fri, 15 Sept 2023 at 04:17, Masahisa Kojima wrote: > > Current wget takes the target uri in this format: > ":" e.g.) 192.168.1.1:/bar > The http server ip address must be resolved before > calling wget. > > This commit adds the utility function runs wget with dhs. > User can call wget with the uri like "http://foo/bar";. > > Signed-off-by: Masahisa Kojima > --- > include/net.h | 2 ++ > net/wget.c| 54 +++ > 2 files changed, 56 insertions(+) > > diff --git a/include/net.h b/include/net.h > index e254df7d7f..b9cba5244a 100644 > --- a/include/net.h > +++ b/include/net.h > @@ -926,4 +926,6 @@ void eth_set_enable_bootdevs(bool enable); > static inline void eth_set_enable_bootdevs(bool enable) {} > #endif > > +int wget_with_dns(ulong dst_addr, char *uri); Please add a comment about what this does, including args and return value. We comment all global functions and non-trvial static ones. > + > #endif /* __NET_H__ */ > diff --git a/net/wget.c b/net/wget.c > index 9690e4539c..bdf940a315 100644 > --- a/net/wget.c > +++ b/net/wget.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > > DECLARE_GLOBAL_DATA_PTR; > > @@ -504,3 +505,56 @@ void wget_start(void) > > wget_send(TCP_SYN, 0, 0, 0); > } > + > +#if (IS_ENABLED(CONFIG_CMD_DNS)) > +int wget_with_dns(ulong dst_addr, char *uri) > +{ > + int ret; > + char *s, *host_name, *file_name, *str_copy; > + > + /* > +* Download file using wget. > +* > +* U-Boot wget takes the target uri in this format. > +* ":" e.g.) 192.168.1.1:/sample/test.iso > +* Need to resolve the http server ip address before starting wget. > +*/ > + str_copy = strdup(uri); > + if (!str_copy) > + return -ENOMEM; > + > + s = str_copy + strlen("http://";); > + host_name = strsep(&s, "/"); > + if (!s) { > + log_err("Error: invalied uri, no file path\n"); > + ret = -EINVAL; > + goto out; > + } > + file_name = s; > + > + /* TODO: If the given uri has ip address for the http server, skip > dns */ > + net_dns_resolve = host_name; > + net_dns_env_var = "httpserverip"; > + if (net_loop(DNS) < 0) { > + log_err("Error: dns lookup of %s failed, check setup\n", > net_dns_resolve); > + ret = -EINVAL; > + goto out; > + } > + s = env_get("httpserverip"); > + if (!s) { > + ret = -EINVAL; > + goto out; > + } > + > + strlcpy(net_boot_file_name, s, sizeof(net_boot_file_name)); > + strlcat(net_boot_file_name, ":/", sizeof(net_boot_file_name)); /* > append '/' which is removed by strsep() */ > + strlcat(net_boot_file_name, file_name, sizeof(net_boot_file_name)); > + image_load_addr = dst_addr; > + ret = net_loop(WGET); > + > +out: > + free(str_copy); > + > + return ret; > +} > +#endif > -- > 2.34.1 > Regards, Simon
Re: [PATCH v3 2/5] fdt: kaslr seed from RNG device
On Tue, 12 Sept 2023 at 15:35, wrote: > > From: Dhananjay Phadke > > Add support for KASLR seed from the RNG device. Invokes dm_rng_read() > API to read 8-bytes of random bytes. Performs the FDT fixup using event > spy. To enable use CONFIG_KASLR_RNG_SEED > > Signed-off-by: Dhananjay Phadke > Signed-off-by: Drew Kluemke > Signed-off-by: Sean Edmond > --- > common/fdt_support.c | 36 > lib/Kconfig | 7 +++ > 2 files changed, 43 insertions(+) Reviewed-by: Simon Glass Note that with VBE this is deterministic, in that the kernel declares what it wants. See bootmeth_vbe_ft_fixup()
Re: [PATCH v3 1/5] fdt: common API to populate kaslr seed
On Tue, 12 Sept 2023 at 15:35, wrote: > > From: Dhananjay Phadke > > fdt_fixup_kaslr_seed() will update given ofnode with random seed value. > Source for random seed can be TPM or RNG driver in u-boot or sec > firmware (ARM). > > Signed-off-by: Dhananjay Phadke > Signed-off-by: Sean Edmond > --- > arch/arm/cpu/armv8/sec_firmware.c | 39 +++ > common/fdt_support.c | 19 +++ > drivers/core/ofnode.c | 17 ++ > include/dm/ofnode.h | 12 ++ > include/fdt_support.h | 9 +++ > 5 files changed, 71 insertions(+), 25 deletions(-) > Reviewed-by: Simon Glass
Re: [PATCH v3 1/7] net: wget: prevent overwriting reserved memory
Hi Masahisa, On Fri, 15 Sept 2023 at 04:17, Masahisa Kojima wrote: > > This introduces the valid range check to store the received > blocks using lmb. The same logic is implemented in tftp. > > Signed-off-by: Masahisa Kojima > --- > net/wget.c | 80 +- > 1 file changed, 73 insertions(+), 7 deletions(-) > Reviewed-by: Simon Glass > diff --git a/net/wget.c b/net/wget.c > index 2dbfeb1a1d..9690e4539c 100644 > --- a/net/wget.c > +++ b/net/wget.c > @@ -4,16 +4,20 @@ > * Copyright Duncan Hare 2017 > */ > > +#include > #include > #include > #include > #include > #include > +#include > #include > #include > #include > #include > > +DECLARE_GLOBAL_DATA_PTR; > + > static const char bootfile1[] = "GET "; > static const char bootfile3[] = " HTTP/1.0\r\n\r\n"; > static const char http_eom[] = "\r\n\r\n"; > @@ -55,6 +59,29 @@ static unsigned int retry_tcp_ack_num; /* TCP retry > acknowledge number*/ > static unsigned int retry_tcp_seq_num; /* TCP retry sequence number */ > static int retry_len; /* TCP retry length */ > > +static ulong wget_load_size; > + > +/** > + * wget_init_max_size() - initialize maximum load size > + * > + * Return: 0 if success, -1 if fails > + */ > +static int wget_init_load_size(void) > +{ > + struct lmb lmb; > + phys_size_t max_size; > + > + lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob); That function should be changed to const void * but we plan to move to ofnode anyway, so let's not worry about it. [..] Regards, Simon
Re: [PATCH 0/2] make CONFIG_SPL_SYS_MALLOC_SIMPLE && CONFIG_SYS_SPL_MALLOC actually work
Hi Rasmus, On Fri, 15 Sept 2023 at 11:51, Rasmus Villemoes wrote: > > Currently, setting both CONFIG_SPL_SYS_MALLOC_SIMPLE and > CONFIG_SYS_SPL_MALLOC (but not CONFIG_SPL_STACK_R) doesn't work as > expected: The SIMPLE option means that all malloc etc. calls are > directed at build-time to the implementation in malloc_simple.c, but Sort-of. It is control by both a CONFIG and GD_FLG_FULL_MALLOC_INIT. > the mem_alloc_init() call which is done in board_init_f() currently > calls into dlmalloc.c, and updates the variables describing the > dlmalloc arena - which is of course completely unused. And the > malloc() implementation continues to hand out allocations from the > initial SPL_SYS_MALLOC_F_LEN bytes. > > These two patches are an attempt at making the combination in $subject > actually work as one would expect: define an area of sdram to be used > as a malloc arena, but still manage that using the malloc_simple() > implementation. > > Since this now changes the mem_alloc_init() from being a harmless > no-op call to actually doing something, there's a risk of some boards > breaking. The solution for those boards will probably be to just drop > CONFIG_SYS_SPL_MALLOC, since that hasn't actually done anything. > > Rasmus Villemoes (2): > spl: make SYS_SPL_MALLOC depend on !(SPL_STACK_R && > SPL_SYS_MALLOC_SIMPLE) > malloc_simple: add mem_malloc_init_simple() > > common/dlmalloc.c | 2 +- > common/malloc_simple.c | 7 +++ > common/spl/Kconfig | 1 + > include/malloc.h | 7 +-- > 4 files changed, 14 insertions(+), 3 deletions(-) > > -- > 2.37.2 > Regards, Simon
[PATCH 9/9] test: bdinfo: Test bdinfo -e
The bdinfo -e should print only the board ethernet settings. Test the expected output. Signed-off-by: Marek Vasut --- Cc: Bin Meng Cc: Mario Six Cc: Nikhil M Jain Cc: Simon Glass --- test/cmd/bdinfo.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index f090667fb42..6caee4b0b50 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -263,6 +263,20 @@ static int bdinfo_test_memory(struct unit_test_state *uts) BDINFO_TEST(bdinfo_test_memory, UT_TESTF_CONSOLE_REC); +static int bdinfo_test_eth(struct unit_test_state *uts) +{ + /* Test BDINFO ethernet settings only print */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("bdinfo -e")); + if (IS_ENABLED(CONFIG_CMD_NET)) + ut_assertok(test_eth(uts)); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} + +BDINFO_TEST(bdinfo_test_eth, UT_TESTF_CONSOLE_REC); + int do_ut_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(bdinfo_test); -- 2.40.1
[PATCH 8/9] test: bdinfo: Test bdinfo -m
The bdinfo -m should print only the board memory layout. Test the expected output. Signed-off-by: Marek Vasut --- Cc: Bin Meng Cc: Mario Six Cc: Nikhil M Jain Cc: Simon Glass --- test/cmd/bdinfo.c | 26 +++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index 2f34d877e5c..f090667fb42 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -130,13 +130,11 @@ static int lmb_test_dump_all(struct unit_test_state *uts, struct lmb *lmb) return 0; } -static int bdinfo_test_all(struct unit_test_state *uts) +static int bdinfo_test_mem(struct unit_test_state *uts) { struct bd_info *bd = gd->bd; int i; - ut_assertok(test_num_l(uts, "boot_params", 0)); - for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) { if (bd->bi_dram[i].size) { ut_assertok(test_num_l(uts, "DRAM bank", i)); @@ -147,6 +145,15 @@ static int bdinfo_test_all(struct unit_test_state *uts) } } + return 0; +} + +static int bdinfo_test_all(struct unit_test_state *uts) +{ + ut_assertok(test_num_l(uts, "boot_params", 0)); + + ut_assertok(bdinfo_test_mem(uts)); + /* CONFIG_SYS_HAS_SRAM testing not supported */ ut_assertok(test_num_l(uts, "flashstart", 0)); ut_assertok(test_num_l(uts, "flashsize", 0)); @@ -243,6 +250,19 @@ static int bdinfo_test_help(struct unit_test_state *uts) BDINFO_TEST(bdinfo_test_help, UT_TESTF_CONSOLE_REC); +static int bdinfo_test_memory(struct unit_test_state *uts) +{ + /* Test BDINFO memory layout only print */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("bdinfo -m")); + ut_assertok(bdinfo_test_mem(uts)); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} + +BDINFO_TEST(bdinfo_test_memory, UT_TESTF_CONSOLE_REC); + int do_ut_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(bdinfo_test); -- 2.40.1
[PATCH 7/9] test: bdinfo: Test bdinfo -h
The bdinfo -h should print error message that -h is an unknown parameter and then command help text. Test the expected output. Signed-off-by: Marek Vasut --- Cc: Bin Meng Cc: Mario Six Cc: Nikhil M Jain Cc: Simon Glass --- test/cmd/bdinfo.c | 17 + 1 file changed, 17 insertions(+) diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index 509a8b5c586..2f34d877e5c 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -226,6 +226,23 @@ static int bdinfo_test_full(struct unit_test_state *uts) BDINFO_TEST(bdinfo_test_full, UT_TESTF_CONSOLE_REC); +static int bdinfo_test_help(struct unit_test_state *uts) +{ + /* Test BDINFO unknown option help text print */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("bdinfo -h")); + ut_assert_nextlinen("bdinfo: invalid option -- h"); + ut_assert_nextlinen("bdinfo - print Board Info structure"); + ut_assert_nextline_empty(); + ut_assert_nextlinen("Usage:"); + ut_assert_nextlinen("bdinfo"); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} + +BDINFO_TEST(bdinfo_test_help, UT_TESTF_CONSOLE_REC); + int do_ut_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(bdinfo_test); -- 2.40.1
[PATCH 6/9] test: bdinfo: Test both bdinfo and bdinfo -a
Factor out the core of test for all bdinfo output into bdinfo_test_all() and then reuse it to verify that both 'bdinfo' and 'bdinfo -a' print all the bdinfo output. Signed-off-by: Marek Vasut --- Cc: Bin Meng Cc: Mario Six Cc: Nikhil M Jain Cc: Simon Glass --- test/cmd/bdinfo.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index b2896e8eb41..509a8b5c586 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -130,15 +130,11 @@ static int lmb_test_dump_all(struct unit_test_state *uts, struct lmb *lmb) return 0; } -static int bdinfo_test_full(struct unit_test_state *uts) +static int bdinfo_test_all(struct unit_test_state *uts) { struct bd_info *bd = gd->bd; int i; - /* Test moving the working BDINFO to a new location */ - ut_assertok(console_record_reset_enable()); - ut_assertok(run_commandf("bdinfo")); - ut_assertok(test_num_l(uts, "boot_params", 0)); for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) { @@ -212,6 +208,17 @@ static int bdinfo_test_full(struct unit_test_state *uts) ut_assertok(test_num_l(uts, "malloc base", gd_malloc_start())); } + return 0; +} + +static int bdinfo_test_full(struct unit_test_state *uts) +{ + /* Test BDINFO full print */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("bdinfo")); + ut_assertok(bdinfo_test_all(uts)); + ut_assertok(run_commandf("bdinfo -a")); + ut_assertok(bdinfo_test_all(uts)); ut_assertok(ut_check_console_end(uts)); return 0; -- 2.40.1
[PATCH 5/9] test: bdinfo: Rename bdinfo_test_move() to bdinfo_test_full()
Rename bdinfo_test_move() to bdinfo_test_full(). The former is a remnant of deriving this test from another test. No functional change. Signed-off-by: Marek Vasut --- Cc: Bin Meng Cc: Mario Six Cc: Nikhil M Jain Cc: Simon Glass --- test/cmd/bdinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index 8c09281cac0..b2896e8eb41 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -130,7 +130,7 @@ static int lmb_test_dump_all(struct unit_test_state *uts, struct lmb *lmb) return 0; } -static int bdinfo_test_move(struct unit_test_state *uts) +static int bdinfo_test_full(struct unit_test_state *uts) { struct bd_info *bd = gd->bd; int i; @@ -217,7 +217,7 @@ static int bdinfo_test_move(struct unit_test_state *uts) return 0; } -BDINFO_TEST(bdinfo_test_move, UT_TESTF_CONSOLE_REC); +BDINFO_TEST(bdinfo_test_full, UT_TESTF_CONSOLE_REC); int do_ut_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { -- 2.40.1
[PATCH 4/9] configs: sandbox: Enable GETOPT for sandbox and sandbox64 target
Enable GETOPT so that 'bdinfo' command with getopt() support can be tested in CI. Signed-off-by: Marek Vasut --- Cc: Bin Meng Cc: Mario Six Cc: Nikhil M Jain Cc: Simon Glass --- configs/sandbox64_defconfig | 1 + configs/sandbox_defconfig | 1 + 2 files changed, 2 insertions(+) diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index fd110d99a3a..8aef76a5c00 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -262,6 +262,7 @@ CONFIG_CMD_DHRYSTONE=y CONFIG_TPM=y CONFIG_LZ4=y CONFIG_ERRNO_STR=y +CONFIG_GETOPT=y CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index d667cb9ae47..ca54e445426 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -338,6 +338,7 @@ CONFIG_ECDSA_VERIFY=y CONFIG_TPM=y CONFIG_SHA384=y CONFIG_ERRNO_STR=y +CONFIG_GETOPT=y CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y -- 2.40.1
[PATCH 3/9] cmd: bdinfo: Implement support for printing ethernet settings via bdinfo -e
Add support for printing ethernet settings only via 'bdinfo -e' . Signed-off-by: Marek Vasut --- Cc: Bin Meng Cc: Mario Six Cc: Nikhil M Jain Cc: Simon Glass --- cmd/bdinfo.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index c720ee6f9b6..79106caeec2 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -193,10 +193,15 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return bdinfo_print_all(bd); getopt_init_state(&gs); - while ((opt = getopt(&gs, argc, argv, "am")) > 0) { + while ((opt = getopt(&gs, argc, argv, "aem")) > 0) { switch (opt) { case 'a': return bdinfo_print_all(bd); + case 'e': + if (!IS_ENABLED(CONFIG_CMD_NET)) + return CMD_RET_USAGE; + print_eth(); + return CMD_RET_SUCCESS; case 'm': print_bi_dram(bd); return CMD_RET_SUCCESS; -- 2.40.1
[PATCH 2/9] cmd: bdinfo: Implement support for printing memory layout via bdinfo -m
Add support for printing memory layout only via 'bdinfo -m' . Signed-off-by: Marek Vasut --- Cc: Bin Meng Cc: Mario Six Cc: Nikhil M Jain Cc: Simon Glass --- cmd/bdinfo.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index 2c0d5e9c01b..c720ee6f9b6 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -193,10 +193,13 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return bdinfo_print_all(bd); getopt_init_state(&gs); - while ((opt = getopt(&gs, argc, argv, "a")) > 0) { + while ((opt = getopt(&gs, argc, argv, "am")) > 0) { switch (opt) { case 'a': return bdinfo_print_all(bd); + case 'm': + print_bi_dram(bd); + return CMD_RET_SUCCESS; default: return CMD_RET_USAGE; } -- 2.40.1
[PATCH 1/9] cmd: bdinfo: Optionally use getopt and implement bdinfo -a
Add optional support for getopt() and in case this is enabled via GETOPT configuration option, implement support for 'bdinfo -a'. The 'bdinfo -a' behaves exactly like bdinfo and prints 'all' the bdinfo information. This is implemented in preparation for other more fine-grained options. Signed-off-by: Marek Vasut --- Cc: Bin Meng Cc: Mario Six Cc: Nikhil M Jain Cc: Simon Glass --- cmd/bdinfo.c | 29 + 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index 1fe13ca13a0..2c0d5e9c01b 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -133,10 +134,8 @@ static void print_serial(struct udevice *dev) bdinfo_print_num_l(" clock", info.clock); } -int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +static int bdinfo_print_all(struct bd_info *bd) { - struct bd_info *bd = gd->bd; - #ifdef DEBUG bdinfo_print_num_l("bd address", (ulong)bd); #endif @@ -184,8 +183,30 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return 0; } +int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + struct bd_info *bd = gd->bd; + struct getopt_state gs; + int opt; + + if (!CONFIG_IS_ENABLED(GETOPT) || argc == 1) + return bdinfo_print_all(bd); + + getopt_init_state(&gs); + while ((opt = getopt(&gs, argc, argv, "a")) > 0) { + switch (opt) { + case 'a': + return bdinfo_print_all(bd); + default: + return CMD_RET_USAGE; + } + } + + return CMD_RET_USAGE; +} + U_BOOT_CMD( - bdinfo, 1, 1, do_bdinfo, + bdinfo, 2, 1, do_bdinfo, "print Board Info structure", "" ); -- 2.40.1
Re: [BUG] sandbox_defconfig u-boot -T crashes
Hi Heinrich, On Wed, 20 Sept 2023 at 10:01, Heinrich Schuchardt wrote: > > Hello Simon, > > I have built sandbox_defconfig using origin/master > (b9b83a86f0e8 ("Merge branch 'master' of > https://source.denx.de/u-boot/custodians/u-boot-sh";)) > on Ubuntu 23.10. > > Running ./u-boot -T leads to a crash: > > #9 0x77a28189 in __libc_start_main_impl (main=0x55591540 > , argc=2, argv=0x7fffd918, init=, > fini=, rtld_fini=, > stack_end=0x7fffd908) at ../csu/libc-start.c:360 > 360 in ../csu/libc-start.c > (gdb) > #8 0x77a280d0 in __libc_start_call_main > (main=main@entry=0x55591540 , argc=argc@entry=2, > argv=argv@entry=0x7fffd918) > at ../sysdeps/nptl/libc_start_call_main.h:58 > 58 ../sysdeps/nptl/libc_start_call_main.h: No such file or directory. > (gdb) > #7 0x55591e19 in sandbox_main (argc=2, argv=0x7fffd918) at > arch/sandbox/cpu/start.c:557 > 557 board_init_r(gd->new_gd, 0); > (gdb) > #6 board_init_r (new_gd=, dest_addr=dest_addr@entry=0) > at common/board_r.c:818 > 818 if (initcall_run_list(init_sequence_r)) > (gdb) > #5 0x555d961e in initcall_run_list > (init_sequence=0x558e1860 ) at include/initcall.h:46 > 46 ret = (*init_fnc_ptr)(); > (gdb) > #4 0x555e695d in stdio_add_devices () at common/stdio.c:332 > 332 for (ret = > uclass_first_device_check(UCLASS_KEYBOARD, &dev); > (gdb) > #3 0x555f9e4f in uclass_first_device_check (devp= out>, id=UCLASS_KEYBOARD) at drivers/core/uclass.c:644 > 644 return device_probe(*devp); > (gdb) > #2 0x555f7235 in device_probe (dev=0x1ac9c800) at > drivers/core/device.c:583 > > 583 ret = drv->probe(dev); > (gdb) > #1 0x5560ae09 in input_stdio_register (dev=0x1aead870) at > drivers/input/input.c:674 > 674 if (!error && strcmp(env_get("stdin"), dev->name) == 0) { > (gdb) > #0 strcmp (cs=0x1 , > ct=0x1aead879 "ros-ec-keyb", ct@entry=0x1aead878 "cros-ec-keyb") at > lib/string.c:217 > 217 ret = a - b; > > > env_get("stdin") returns NULL here and should not be used without checking. Something else is wrong though, since env_get() should return the correct value here, not NULL. Regards, Simon
Re: [PATCH] bmips: Add Inteno XG6846 board
On Wed, Sep 20, 2023 at 08:51:07PM +0200, Linus Walleij wrote: > On Wed, Sep 20, 2023 at 4:22 PM Tom Rini wrote: > > > > + * This is a diet version of the device tree from Linux, > > > + * suitable for U-Boot. > > > + */ > > > > We shouldn't need a diet version of the tree. If it's reasonably done > > and stable in the kernel, we can even move towards just passing the > > U-Boot tree along to Linux. > > The device tree is not stable in the kernel. > It exists in OpenWrt and the creators of the bmips target are > kind of absent for the moment. The reason it is not in Linux > is that the "switch ethernet" driver and bindings need to be > upstreamed before the device trees can be upstreamed. > > But I can try to bring in more of it for sure :) Just like ARM the goal is just to drop in the kernel dts here. > > > +++ b/board/inteno/xg6846/xg6846.c > > > @@ -0,0 +1,6 @@ > > > +// SPDX-License-Identifier: GPL-2.0+ > > > +/* > > > + * Copyright (C) 2023 Linus Walleij > > > + */ > > > + > > > +#include > > > > So basically just an empty object file. Can we just _not_ have > > something here, if we perhaps don't set SYS_BOARD? I assume if there's > > just nothing here the link rules fail. > > Admittedly my knowledge of U-Boot internals are not the > best and this is a bit of a copy and paste job from > board/comtrend/ar5387un/ar-5387un.c which looks like > this and sets a bad example I suppose. Yeah, I didn't know we had someone doing that already here, whoops. > I guess you are asking me to modify U-Boots build system to > make the whole .c and Makefile inside a board subdir optional > so we can delete all such empty boardfiles? Well, it'd sure be nice if we could avoid having a dummy C file. If it looks like a nightmare once you take a peek, we can just live with it. -- Tom signature.asc Description: PGP signature
Re: [PATCH] bmips: Add Inteno XG6846 board
On Wed, Sep 20, 2023 at 4:22 PM Tom Rini wrote: > > + * This is a diet version of the device tree from Linux, > > + * suitable for U-Boot. > > + */ > > We shouldn't need a diet version of the tree. If it's reasonably done > and stable in the kernel, we can even move towards just passing the > U-Boot tree along to Linux. The device tree is not stable in the kernel. It exists in OpenWrt and the creators of the bmips target are kind of absent for the moment. The reason it is not in Linux is that the "switch ethernet" driver and bindings need to be upstreamed before the device trees can be upstreamed. But I can try to bring in more of it for sure :) > > +++ b/board/inteno/xg6846/xg6846.c > > @@ -0,0 +1,6 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > +/* > > + * Copyright (C) 2023 Linus Walleij > > + */ > > + > > +#include > > So basically just an empty object file. Can we just _not_ have > something here, if we perhaps don't set SYS_BOARD? I assume if there's > just nothing here the link rules fail. Admittedly my knowledge of U-Boot internals are not the best and this is a bit of a copy and paste job from board/comtrend/ar5387un/ar-5387un.c which looks like this and sets a bad example I suppose. I guess you are asking me to modify U-Boots build system to make the whole .c and Makefile inside a board subdir optional so we can delete all such empty boardfiles? Yours, Linus Walleij
Re: [PATCH] verdin-imx8mp: drop unused tdx easy installer ifdef
On Mon, Sep 4, 2023 at 11:09 AM Hiago De Franco wrote: > > From: Hiago De Franco > > Drop unused code related to CONFIG_TDX_EASY_INSTALLER, that existed only on > toradex downstream branch. > > Signed-off-by: Hiago De Franco Reviewed-by: Fabio Estevam
Re: [PATCH] imx8mp: binman: rename spl and u-boot nodes
On Tue, Sep 19, 2023 at 6:29 AM Rasmus Villemoes wrote: > > The hab signing script doc/imx/habv4/csf_examples/mx8m/csf.sh does > > fdtget -t x u-boot.dtb /binman/imx-boot/uboot offset > > to figure out the offset of u-boot.itb inside flash.bin. That works > fine for imx8mm, imx8mn, imx8mq, but fails for imx8mp because in that > case 'uboot' is merely a label and not actually the node name. > > Homogenize these cases and make imx8mp the same as the other imx8m* > variants. The binman type is explicitly given and no longer derived > from the node name, and the csf.sh script will work for all four SOCs. > > Signed-off-by: Rasmus Villemoes Reviewed-by: Fabio Estevam
[PATCH v5] board: rockchip: Add Bananapi R2Pro Board
From: Frank Wunderlich Add Bananapi R2 Pro board. tested: - sdcard - both front usb-ports - sata - wan-port lan-ports are connected to mt7531 switch where driver needs to be separated from mtk ethernet-driver. Signed-off-by: Frank Wunderlich --- because iodomain is different to evb and now iodomain driver is sent as patch we need to separate between EVB and R2Pro else board can be bricked. ethernet support depends on these series from jonas: rockchip: Port IO-domain driver for RK3568 from linux https://patchwork.ozlabs.org/project/uboot/cover/20230821223020.3918620-1-jo...@kwiboo.se/ and rockchip: Add GMAC support for RK3568 and RK3588 https://patchwork.ozlabs.org/project/uboot/cover/20230807000817.1701012-1-jo...@kwiboo.se/ --- v5: - add line break in description - reorder in makefile - drop special dts-handling (deletion of switchnode, disable of usb and gmac0) - add MAINTAINERS entry - changes to defconfig suggested by jonas - remove "pinctrl-0 pinctrl-names" from CONFIG_OF_SPL_REMOVE_PROPS - add CONFIG_SPL_DM_SEQ_ALIAS=y - add CONFIG_SPL_PINCTRL=y - remove CONFIG_USB_UHCI_HCD - enable EFI_LOADER (defaults to y) - drop CONFIG_SYSRESET_PSCI (reset works without) v4: - add r2pro board to readme - update r2pro dts to linux version - remove switch node from linux dts - disable gmac0 because switch driver does not work yet to solve timeout error: ethernet@fe2a Waiting for PHY auto negotiation to complete. TIMEOUT! phy_startup() failed: -110FAILED: -110ethernet@fe01 Waiting for PHY auto nee - cleanup r2pro u-boot.dtsi like jonas suggests - update and reorder defconfig based on jonas suggestions - dts: disable usb_host0_ohci because of error on usb-start scanning bus usb@fd84 for devices... ERROR: USB-error: DEVICENOTRESPONDING: Device did not respond to token (IN) or did not provide a handshake (OUT) (5) unable to get device descriptor (error=-1) - pcie is not yet working, so not adding these options rockchip_pcie3phy phy@fe8c: lock failed 0x689 rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110. pcie_dw_rockchip pcie@fe27: failed to init phy (ret=-110) rockchip_pcie3phy phy@fe8c: lock failed 0x689 rockchip_pcie3phy phy@fe8c: PHY: Failed to init phy@fe8c: -110. pcie_dw_rockchip pcie@fe28: failed to init phy (ret=-110) - emmc not tested as it is empty on my board because it breaks sdcard boot - rename dts and defconfig (add minus sign) - enable efi_loader in defconfig v3: - disable gmac0 as switch-driver is not yet ready to attach to the mac v2: - drop switch-node for now as u-boot driver works differently to linux --- arch/arm/dts/Makefile | 1 + arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi | 19 + arch/arm/dts/rk3568-bpi-r2-pro.dts | 852 + board/rockchip/evb_rk3568/MAINTAINERS | 7 + configs/bpi-r2-pro-rk3568_defconfig| 94 +++ doc/board/rockchip/rockchip.rst| 1 + 6 files changed, 974 insertions(+) create mode 100644 arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi create mode 100644 arch/arm/dts/rk3568-bpi-r2-pro.dts create mode 100644 configs/bpi-r2-pro-rk3568_defconfig diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 85fd5b1157b1..016eb5556513 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -177,6 +177,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3568) += \ rk3566-soquartz-blade.dtb \ rk3566-soquartz-cm4.dtb \ rk3566-soquartz-model-a.dtb \ + rk3568-bpi-r2-pro.dtb \ rk3568-evb.dtb \ rk3568-lubancat-2.dtb \ rk3568-nanopi-r5c.dtb \ diff --git a/arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi b/arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi new file mode 100644 index ..60a3b21f2d45 --- /dev/null +++ b/arch/arm/dts/rk3568-bpi-r2-pro-u-boot.dtsi @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2021 Rockchip Electronics Co., Ltd + */ + +#include "rk356x-u-boot.dtsi" + +/ { + chosen { + stdout-path = &uart2; + }; +}; + +&uart2 { + clock-frequency = <2400>; + bootph-pre-ram; + status = "okay"; +}; + diff --git a/arch/arm/dts/rk3568-bpi-r2-pro.dts b/arch/arm/dts/rk3568-bpi-r2-pro.dts new file mode 100644 index ..f9127ddfbb7d --- /dev/null +++ b/arch/arm/dts/rk3568-bpi-r2-pro.dts @@ -0,0 +1,852 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Author: Frank Wunderlich + * + */ + +/dts-v1/; +#include +#include +#include +#include +#include "rk3568.dtsi" + +/ { + model = "Bananapi-R2 Pro (RK3568) DDR4 Board"; + compatible = "rockchip,rk3568-bpi-r2pro", "rockchip,rk3568"; + + aliases { + ethernet0 = &gmac0; + ethernet1 = &gmac1; + mmc0 = &sdmmc0; + mmc1 = &sdhci; + }; + + chosen: chosen { + stdout-path = "serial2:150n8"; + }; + +
[BUG] sandbox_defconfig u-boot -T crashes
Hello Simon, I have built sandbox_defconfig using origin/master (b9b83a86f0e8 ("Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sh";)) on Ubuntu 23.10. Running ./u-boot -T leads to a crash: #9 0x77a28189 in __libc_start_main_impl (main=0x55591540 , argc=2, argv=0x7fffd918, init=, fini=, rtld_fini=, stack_end=0x7fffd908) at ../csu/libc-start.c:360 360 in ../csu/libc-start.c (gdb) #8 0x77a280d0 in __libc_start_call_main (main=main@entry=0x55591540 , argc=argc@entry=2, argv=argv@entry=0x7fffd918) at ../sysdeps/nptl/libc_start_call_main.h:58 58 ../sysdeps/nptl/libc_start_call_main.h: No such file or directory. (gdb) #7 0x55591e19 in sandbox_main (argc=2, argv=0x7fffd918) at arch/sandbox/cpu/start.c:557 557 board_init_r(gd->new_gd, 0); (gdb) #6 board_init_r (new_gd=, dest_addr=dest_addr@entry=0) at common/board_r.c:818 818 if (initcall_run_list(init_sequence_r)) (gdb) #5 0x555d961e in initcall_run_list (init_sequence=0x558e1860 ) at include/initcall.h:46 46 ret = (*init_fnc_ptr)(); (gdb) #4 0x555e695d in stdio_add_devices () at common/stdio.c:332 332 for (ret = uclass_first_device_check(UCLASS_KEYBOARD, &dev); (gdb) #3 0x555f9e4f in uclass_first_device_check (devp=, id=UCLASS_KEYBOARD) at drivers/core/uclass.c:644 644 return device_probe(*devp); (gdb) #2 0x555f7235 in device_probe (dev=0x1ac9c800) at drivers/core/device.c:583 583 ret = drv->probe(dev); (gdb) #1 0x5560ae09 in input_stdio_register (dev=0x1aead870) at drivers/input/input.c:674 674 if (!error && strcmp(env_get("stdin"), dev->name) == 0) { (gdb) #0 strcmp (cs=0x1 , ct=0x1aead879 "ros-ec-keyb", ct@entry=0x1aead878 "cros-ec-keyb") at lib/string.c:217 217 ret = a - b; env_get("stdin") returns NULL here and should not be used without checking. Best regards Heinrich
Re: [PATCH v11] Boot var automatic management for removable medias
Hi Masahisa, Thanks for spending time on this test failure! I am not sure why this cannot be reproduced in my end, but I totally agree with the rationale you analyzed - my previous patch will just add boot options whenever a media is probed. Thanks for adding the changes into the pytest. Regards, Raymond
[PATCH] ARM: vexpress_ca9x4: Add missing flash width config option
Allow for a proper configuration of CFI flash banks avaialble on the vexpress_ca9x4 board. Without this option, the CFI flash incorrectly detects that the board has two banks of 32MB flash devices, while in reality, the board provides two flash banks, each with 64MB size. As a result, it becomes impossible to e.g. to save u-boot env in flash. According to device tree for this board and its implementation in QEMU, the CFI width should be set to 32 bits. After applying this fix, CFI flash will correctly detect both flash banks each with a size of 64MB. As as result the functionality of e.g. saving u-boot env will work correctly. Tested on QEMU 6.2.0. Cc: Kristian Amlie Signed-off-by: Patryk Biel --- configs/vexpress_ca9x4_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/vexpress_ca9x4_defconfig b/configs/vexpress_ca9x4_defconfig index 5cacecc7cb..ac9c0e1d71 100644 --- a/configs/vexpress_ca9x4_defconfig +++ b/configs/vexpress_ca9x4_defconfig @@ -55,3 +55,4 @@ CONFIG_SMC911X_32_BIT=y CONFIG_BAUDRATE=38400 CONFIG_CONS_INDEX=0 CONFIG_SYS_TIMER_COUNTS_DOWN=y +CONFIG_SYS_FLASH_CFI_WIDTH_32BIT=y -- 2.34.1
Re: [PATCH V2 3/3] dts: andes: add SPL config option for itb layout
Hi Tom, Tom Rini 於 2023年9月18日 週一 下午11:04寫道: > > On Mon, Sep 18, 2023 at 08:11:36PM +0800, Randolph wrote: > > > Add SPL_LOAD_FIT_CONFIG for binman itb layout selection > > > > Signed-off-by: Randolph > > --- > > arch/riscv/dts/ae350-u-boot.dtsi | 1 + > > arch/riscv/dts/ae350_32.dts | 1 - > > arch/riscv/dts/ae350_64.dts | 1 - > > board/AndesTech/ae350/Kconfig| 6 ++ > > configs/ae350_rv32_defconfig | 1 + > > configs/ae350_rv32_spl_defconfig | 1 + > > configs/ae350_rv32_spl_xip_defconfig | 1 + > > configs/ae350_rv32_xip_defconfig | 1 + > > configs/ae350_rv64_defconfig | 1 + > > configs/ae350_rv64_spl_defconfig | 1 + > > configs/ae350_rv64_spl_xip_defconfig | 1 + > > configs/ae350_rv64_xip_defconfig | 1 + > > 12 files changed, 15 insertions(+), 2 deletions(-) > > So this is where I have a problem. It's not clear why you need to > change anything here, as there's no example given for doing something > other than what you do today, and there's no documentation about it > either. From other contexts, it seems like you're trying to re-implement > CONFIG_SPL_OS_BOOT but not explaining why you can't use the existing > framework. > > -- > Tom We want to add our binman.dtsi (very similar to SPL_OS_BOOT) in the future, but this may affect other vendors' code under arch/riscv. To take a step back and reduce the gap, we just want to rearrange our code now (in this patch). We are not re-implementing SPL_OS_BOOT, the goal (skip loading u-boot proper) is the same, the method is different. For example, in ARM architecture, the Falcon mode (by enabling SPL_OS_BOOT), the boot flow is u-boot SPL jump to Linux kernel. In RISC-V architecture, most SOCs require OpenSBI, the boot flow should be u-boot SPL -> OpenSBI -> Linux kernel. Apart from the boot flow, the code flow is also different, "jump_to_image_linux" is not necessary and the names are not quite right in the RISC-V architecture. The CONFIG_SPL_ARGS_ADDR macro is also not required when building RISC-V u-boot. That's why we need to create another way for OpenSBI to do the actions like CONFIG_SPL_OS_BOOT. Randolph Sincerely
Re: [PATCH] bmips: Add Inteno XG6846 board
On Wed, Sep 20, 2023 at 09:42:25AM +0200, Linus Walleij wrote: > This adds support for the Inteno XG6846 board based on the > Broadcom MIPS 6328 SoC. > > The default boot will read a uImage from flash and boot it. > > Cc: Daniel Schwierzeck > Signed-off-by: Linus Walleij [snip] > diff --git a/arch/mips/dts/inteno,xg6846.dts b/arch/mips/dts/inteno,xg6846.dts > new file mode 100644 > index ..180cfdcac9d4 > --- /dev/null > +++ b/arch/mips/dts/inteno,xg6846.dts > @@ -0,0 +1,57 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Copyright (C) 2023 Linus Walleij > + * > + * This is a diet version of the device tree from Linux, > + * suitable for U-Boot. > + */ We shouldn't need a diet version of the tree. If it's reasonably done and stable in the kernel, we can even move towards just passing the U-Boot tree along to Linux. > diff --git a/board/inteno/xg6846/Kconfig b/board/inteno/xg6846/Kconfig > new file mode 100644 > index ..4dd78b3b1960 > --- /dev/null > +++ b/board/inteno/xg6846/Kconfig > @@ -0,0 +1,12 @@ > +if BOARD_INTENO_XG6846 > + > +config SYS_BOARD > + default "xg6846" > + > +config SYS_VENDOR > + default "inteno" > + > +config SYS_CONFIG_NAME > + default "inteno_xg6846" > + > +endif [snip] > diff --git a/board/inteno/xg6846/Makefile b/board/inteno/xg6846/Makefile > new file mode 100644 > index ..311e1db7a775 > --- /dev/null > +++ b/board/inteno/xg6846/Makefile > @@ -0,0 +1,3 @@ > +# SPDX-License-Identifier: GPL-2.0+ > + > +obj-y += xg6846.o > diff --git a/board/inteno/xg6846/xg6846.c b/board/inteno/xg6846/xg6846.c > new file mode 100644 > index ..b3b6751a6256 > --- /dev/null > +++ b/board/inteno/xg6846/xg6846.c > @@ -0,0 +1,6 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Copyright (C) 2023 Linus Walleij > + */ > + > +#include So basically just an empty object file. Can we just _not_ have something here, if we perhaps don't set SYS_BOARD? I assume if there's just nothing here the link rules fail. -- Tom signature.asc Description: PGP signature
Re: [PATCH v5 08/20] x86: coreboot: Drop USB init on startup
On 20.09.23 13:50, Marek Vasut wrote: On 9/20/23 09:19, Heinrich Schuchardt wrote: On 9/20/23 05:00, Simon Glass wrote: This is very annoying as it is quite slow on many machines. Also, U-Boot has an existing 'preboot' mechanism to enable this feature if desired. Drop this code so that it is possible to choose whether to init USB or not. Use the existing USE_PREBOOT mechanism instead. Signed-off-by: Simon Glass --- Changes in v5: - Make use of the uSE_PREBOOT mechanism arch/x86/cpu/coreboot/Kconfig | 1 + arch/x86/cpu/coreboot/coreboot.c | 4 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/x86/cpu/coreboot/Kconfig b/arch/x86/cpu/coreboot/Kconfig index b97c27790419..178f8ad18162 100644 --- a/arch/x86/cpu/coreboot/Kconfig +++ b/arch/x86/cpu/coreboot/Kconfig @@ -25,6 +25,7 @@ config SYS_COREBOOT imply FS_CBFS imply CBMEM_CONSOLE imply X86_TSC_READ_BASE + imply USE_PREBOOT For automatic initialization of the PCI bus we have CONFIG_PCI_INIT_R. Wouldn't it be preferable to also have a CONFIG_USB_INIT_R instead of relying on console commands in CONFIG_PREBOOT? I'd much prefer 'preboot=usb init' or whatever console command, since this is not hard-coded into the U-Boot binary and can be overridden by user if the 'usb init' is inconvenient/unnecessary/... without replacing and/or rebuilding the U-Boot binary. Just for the record this means using CONFIG_PREBOOT: include/env_default.h: #ifdef CONFIG_PREBOOT_DEFINED "preboot="CONFIG_PREBOOT "\0" #endif Thank you for the clarification. Best regards Heinrich
[PATCH v6 15/20] efi: Use the installed SMBIOS tables
U-Boot should set up the SMBIOS tables during startup, as it does on x86. Ensure that it does this correctly on non-x86 machines too, by creating an event spy for last-stage init. Tidy up the installation-condition code while we are here. Signed-off-by: Simon Glass --- Changes in v6: - Add a condition for mvebu_db-88f3720 last-stage init Changes in v4: - Rewrite this to use events instead Changes in v3: - Use log_debug() to show the message - Squash in the next patch Changes in v2: - Add new patch board/Marvell/mvebu_armada-37xx/board.c | 3 +- lib/Kconfig | 1 + lib/efi_loader/Makefile | 2 +- lib/efi_loader/efi_setup.c | 10 ++-- lib/efi_loader/efi_smbios.c | 72 - test/py/tests/test_event_dump.py| 1 + 6 files changed, 56 insertions(+), 33 deletions(-) diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c index 3fe5319437ea..04124d8014dd 100644 --- a/board/Marvell/mvebu_armada-37xx/board.c +++ b/board/Marvell/mvebu_armada-37xx/board.c @@ -307,7 +307,8 @@ static int last_stage_init(void) struct udevice *bus; ofnode node; - if (!of_machine_is_compatible("globalscale,espressobin")) + if (!CONFIG_IS_ENABLED(DM_MDIO) || + !of_machine_is_compatible("globalscale,espressobin")) return 0; node = ofnode_by_compatible(ofnode_null(), "marvell,orion-mdio"); diff --git a/lib/Kconfig b/lib/Kconfig index 6b5389f3a87d..79cf9ef0fa31 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1049,6 +1049,7 @@ config SMBIOS bool "SMBIOS support" depends on X86 || EFI_LOADER default y + select LAST_STAGE_INIT help Indicates that this platform can support System Management BIOS (SMBIOS) tables. These provide various pieces of information about diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 0eb748ff1a59..8d31fc61c601 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -79,7 +79,7 @@ obj-$(CONFIG_VIDEO) += efi_gop.o obj-$(CONFIG_BLK) += efi_disk.o obj-$(CONFIG_NETDEVICES) += efi_net.o obj-$(CONFIG_ACPI) += efi_acpi.o -obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o +obj-$(CONFIG_SMBIOS) += efi_smbios.o obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o obj-$(CONFIG_EFI_RISCV_BOOT_PROTOCOL) += efi_riscv.o diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index ad719afd6328..e6de685e8795 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -326,11 +326,11 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; } -#ifdef CONFIG_GENERATE_SMBIOS_TABLE - ret = efi_smbios_register(); - if (ret != EFI_SUCCESS) - goto out; -#endif + if (IS_ENABLED(CONFIG_SMBIOS)) { + ret = efi_smbios_register(); + if (ret != EFI_SUCCESS) + goto out; + } ret = efi_watchdog_register(); if (ret != EFI_SUCCESS) goto out; diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c index 306c0bc54f90..48446f654d9b 100644 --- a/lib/efi_loader/efi_smbios.c +++ b/lib/efi_loader/efi_smbios.c @@ -10,8 +10,14 @@ #include #include #include +#include #include #include +#include + +enum { + TABLE_SIZE = SZ_4K, +}; /* * Install the SMBIOS table as a configuration table. @@ -20,36 +26,50 @@ */ efi_status_t efi_smbios_register(void) { - /* Map within the low 32 bits, to allow for 32bit SMBIOS tables */ - u64 dmi_addr = U32_MAX; + ulong addr; efi_status_t ret; - void *dmi; - /* Reserve 4kiB page for SMBIOS */ - ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, -EFI_RUNTIME_SERVICES_DATA, 1, &dmi_addr); + addr = gd->arch.smbios_start; + if (!addr) { + log_err("No SMBIOS tables to install\n"); + return EFI_NOT_FOUND; + } + + /* Mark space used for tables */ + ret = efi_add_memory_map(addr, TABLE_SIZE, EFI_RUNTIME_SERVICES_DATA); + if (ret) + return ret; + + log_debug("EFI using SMBIOS tables at %lx\n", addr); + + /* Install SMBIOS information as configuration table */ + return efi_install_configuration_table(&smbios_guid, + map_sysmem(addr, 0)); +} + +static int install_smbios_table(void) +{ + ulong addr; + void *buf; - if (ret != EFI_SUCCESS) { - /* Could not find space in lowmem, use highmem instead */ - ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, -EFI_RUNTIME_SERVICES_DATA, 1, -&dmi_addr); + if (!IS_E
[PATCH v6 13/20] bootstd: Keep track of use of usb stop
When 'usb stop' is run, doing 'bootflow scan' does not run the USB hunter again so does not see any devices. Fix this by telling bootstd about the state of USB. Signed-off-by: Simon Glass --- Changes in v6: - Ensure that bootstd functions are not called in SPL boot/bootdev-uclass.c | 27 +++ drivers/usb/host/usb-uclass.c | 8 include/bootdev.h | 9 + 3 files changed, 44 insertions(+) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 69506e3865fc..974ddee5d2fa 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -830,6 +830,33 @@ int bootdev_hunt(const char *spec, bool show) return result; } +int bootdev_unhunt(enum uclass_id id) +{ + struct bootdev_hunter *start; + int n_ent, i; + + start = ll_entry_start(struct bootdev_hunter, bootdev_hunter); + n_ent = ll_entry_count(struct bootdev_hunter, bootdev_hunter); + for (i = 0; i < n_ent; i++) { + struct bootdev_hunter *info = start + i; + + if (info->uclass == id) { + struct bootstd_priv *std; + int ret; + + ret = bootstd_get_priv(&std); + if (ret) + return log_msg_ret("std", ret); + if (!(std->hunters_used & BIT(i))) + return -EALREADY; + std->hunters_used &= ~BIT(i); + return 0; + } + } + + return -ENOENT; +} + int bootdev_hunt_prio(enum bootdev_prio_t prio, bool show) { struct bootdev_hunter *start; diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index e5fe949f254c..a1cd0ad2d669 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -9,6 +9,7 @@ #define LOG_CATEGORY UCLASS_USB #include +#include #include #include #include @@ -208,6 +209,13 @@ int usb_stop(void) #ifdef CONFIG_USB_STORAGE usb_stor_reset(); #endif + if (CONFIG_IS_ENABLED(BOOTSTD)) { + int ret; + + ret = bootdev_unhunt(UCLASS_USB); + if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && ret && ret != -EALREADY) + printf("failed to unhunt USB (err=%dE)\n", ret); + } uc_priv->companion_device_count = 0; usb_started = 0; diff --git a/include/bootdev.h b/include/bootdev.h index 848233187f87..b079a91b5b7f 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -320,6 +320,15 @@ int bootdev_hunt(const char *spec, bool show); */ int bootdev_hunt_prio(enum bootdev_prio_t prio, bool show); +/** + * bootdev_unhunt() - Mark a device as needing to be hunted again + * + * @id: uclass ID to update + * Return: 0 if done, -EALREADY if already in this state, -ENOENT if no hunter + * found for that uclass + */ +int bootdev_unhunt(enum uclass_id id); + /** * bootdev_hunt_and_find_by_label() - Hunt for bootdevs by label * -- 2.42.0.459.ge4e396fd5e-goog
Re: [PATCH] env: Improve ENV_OFFSET help message
On 02/09/2023 01:09, Simon Glass wrote: > On Fri, 1 Sept 2023 at 08:29, Paul Barker > wrote: >> >> When reading Kconfig help messages to understand ENV_OFFSET and >> ENV_OFFSET_REDUND, developers may not realise that they need to also >> look at the chosen ENV_IS_IN_* options to see how the offsets will be >> interpreted. >> >> Signed-off-by: Paul Barker >> --- >> env/Kconfig | 12 +++- >> 1 file changed, 11 insertions(+), 1 deletion(-) >> > > Reviewed-by: Simon Glass Gentle ping to the list for this patch, it's reviewed but it hasn't been picked up for master or next yet. Thanks, Paul OpenPGP_0x27F4B3459F002257.asc Description: OpenPGP public key OpenPGP_signature Description: OpenPGP digital signature
Re: [PATCH 1/1] starfive: visionfive2: add mmc0 and nvme boot targets
On Mon, Sep 18, 2023 at 10:32:29AM +0200, Milan P. Stanić wrote: > boot from SDIO3.0 (mmc sdcard) first if it is plugged. > If mmc is not plugged try to boot from emmc if it is plugged. > If emmc is not plugged then try to boot from nvme. > > Signed-off-by: Milan P. Stanić > --- > include/configs/starfive-visionfive2.h | 2 ++ > 1 file changed, 2 insertions(+) Reviewed-by: Leo Yu-Chi Liang