summaryrefslogtreecommitdiff
path: root/common/spl
AgeCommit message (Collapse)Author
2025-05-03spl: imx: use trampoline buffer to load images to secure regionYe Li
When SPL loading image to secure region, for example, ATF and tee to DDR secure region. Because the USDHC controller is non-secure master, it can't access this region and will cause loading issue. So use a trampoline buffer in non-secure region, then use CPU to copy the image from trampoline buffer to destination secure region. Signed-off-by: Ye Li <ye.li@nxp.com> Signed-off-by: Alice Guo <alice.guo@nxp.com> Reviewed-by: Peng Fan <peng.fan@nxp.com>
2025-04-24configs: set SPL_TEXT_BASE by default for k3 platformsAnshul Dalal
SPL_TEXT_BASE is used as the load address for the main domain SPL on k3 platforms. Since the config value is the same for every board, this patch sets the value 0x80080000 as default for all 64-bit ARCH_K3, 0x43c00000 as default for the R5 cores and deletes the instances of SPL_TEXT_BASE in individual defconfigs. Signed-off-by: Anshul Dalal <anshuld@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2025-04-16ARM: mvebu: Correct SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR usageTom Rini
As the code is today, we get a warning about "select" statements on "choice" options not doing anything. However, it also works as intended because SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR is the default option within that choice statement. To guard against future regressions, make the choice statement in common/spl/Kconfig have an explicit default if MVEBU_SPL_BOOT_DEVICE_MMC. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Stefan Roese <sr@denx.de>
2025-04-08Merge patch series "Annotate switch/case fallthrough cases"Tom Rini
Andre Przywara <andre.przywara@arm.com> says: C's implicit fallthrough behaviour in switch/case statements can lead to subtle bugs. Quite some while ago many compilers introduced warnings in those cases, requiring intentional fallthrough's to be annotated. So far we were not enabling that compiler option, so many ambiguities and some bugs in the code went unnoticed. This series adds the required annotations in code paths that the first stage of the U-Boot CI covers. There is a large number of cases left in the libbz2 code. The usage of switch/case is borderline insane there, labels are hidden in macros, and there are no breaks, but just goto's. Upstream still uses very similar code, without any annotations. I still am not 100% sure those are meant to fall through or not, and plan to do further investigations, but didn't want to hold the rest of the patches back. You can see for yourself by applying patch 18/18 and building for sandbox64, for instance. Because of this we cannot quite enable the warning in the Makefile yet, but those fixes are worth regardless, and be it to increase readability. Please note that those patches do not fix anything, really, they just add those fallthrough annotations, so the series is not really critical. Link: https://lore.kernel.org/r/20250327153313.2105227-1-andre.przywara@arm.com
2025-04-08spl: mmc: properly annotate fallthroughAndre Przywara
Depending on the various MMC boot configurations, we might end up with trying filesystem mode when a raw image boot failed. This fall-through in the switch/case statement is explained in a comment, but this is not visible to the compiler, which still will complain. Add the proper compiler-visible annotation, to allow enabling the compiler check in the future. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2025-04-02Merge patch series "Various toolchain compatibility fixes/improvements"Tom Rini
Sam Edwards <cfsworks@gmail.com> says: This is v2 of my "misc. fixes" series, sent to prepare the codebase for more direct LLVM support in the near future. This series contains several fixes that I found in the process of preparing that support and which address issues independent of any future feature or enhancement. I am sending these now, both so that their inclusion is not delayed by discussion on my upcoming series and to make the latter more manageable. Link: https://lore.kernel.org/r/20250315221813.1265193-1-CFSworks@gmail.com
2025-04-02spl: Align FDT load addressSam Edwards
While the image size is generally a multiple of 8 bytes, this is not actually guaranteed; some linkers (like LLD) will shave a few bytes off of the end of output sections if there are no content bytes there. Since libfdt imposes a hard rule of 8-byte alignment, make the SPL also be explicit about the alignment when loading the FDT. Signed-off-by: Sam Edwards <CFSworks@gmail.com>
2025-04-02spl: riscv: opensbi: Error on misaligned FDTSam Edwards
libfdt 1.6.1+ requires the FDT to be 8-byte aligned and returns an error if not. OpenSBI 1.0+ includes this version of libfdt and will also reject misaligned FDTs. However, OpenSBI cannot indicate the error to the user: since it cannot access the serial console, it can only silently hang. This proved very difficult to diagnose without proper debugging facilities. Therefore, give the U-Boot SPL, which *can* print error messages, an additional check for proper FDT alignment. Hopefully this saves a lot of development cycles if another developer encounters alignment problems. Signed-off-by: Sam Edwards <CFSworks@gmail.com>
2025-03-30spl: return header size to spl_load in os bootAnshul Dalal
During linux build process the header size is computed including the BSS whereas it's removed when creating the uncompressed image. Therefore the size of the uncompressed image on filesystem will be smaller than the size specified in the header. This causes issues when loading the kernel image from the SPL (as in falcon boot) with spl_load since it compares the read file size from the FS to the header size form the image. Which leads to the following check in `include/spl_load.h` failing to -EIO when loading kernel image: return read < spl_image->size ? -EIO : 0; Therefore we should return the header size back to spl_load instead of the file size in falcon boot when not loading a FIT image. Bug report: https://lore.kernel.org/u-boot/20250214111656.2358748-1-anshuld@ti.com/ Fixes: 775074165d97 ("spl: Add generic spl_load function") Reported-by: Anshul Dalal <anshuld@ti.com> Reviewed-by: Sean Anderson <seanga2@gmail.com> Signed-off-by: Anshul Dalal <anshuld@ti.com>
2025-03-30config: falcon: move CFG_SYS_SPI_* to KconfigAnshul Dalal
CFG_SYS_SPI_* are used in falcon boot to specify the offsets and size of the respective payloads. This patch moves them to Kconfig keeping the values consistent for each of the affected boards. Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Fabio Estevam <festevam@gmail.com> Signed-off-by: Anshul Dalal <anshuld@ti.com>
2025-03-27spl: reorder SPL_MAX_SIZE defaults for sunxiAndre Przywara
Reorder the Kconfig defaults for the maximum SPL size, to make the Allwinner specific values more readable and extensible: many older SoCs need to be limited to 32KB, so make this the last ARCH_SUNXI entry, used as a fallback unless explicitly overridden before. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
2025-03-13arm: Support a separate stack for VPLSimon Glass
VPL has the same needs as TPL in situations where the stack is at the top of SRAM. Add an option for this and implement it for arm Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-13spl: Use CONFIG_VAL() to obtain the SPL stackSimon Glass
Now that we have the same option for SPL and TPL, simplify the logic for determining the initial stack. Note that this changes behaviour as current SPL_STACK is a fallback for TPL. However, that was likely unintended and can be handled with Kconfig defaults if needed. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com> Suggested-by: Tom Rini <trini@konsulko.com>
2025-03-13spl: Add an SPL_HAVE_INIT_STACK optionSimon Glass
At present there is a hex value SPL_STACK which both determines whether SPL has its own initial stack and the hex value of that stack. Split off the former into SPL_HAVE_INIT_STACK with SPL_STACK depending on that and only providing the latter. Signed-off-by: Simon Glass <sjg@chromium.org> [trini: Resync defconfig files]
2025-03-13tpl: Rename TPL_NEEDS_SEPARATE_STACK to TPL_HAVE_INIT_STACKSimon Glass
The most common word for features that make a platform work is to use 'HAVE_xxx'. Rename this option to match. Update the help to use the word 'phase' rather than 'stage', since that is the current terminology. Also clarify that, absent this setting, the stack pointer generally comes from the value used by U-Boot proper, rather than SPL. Move the option just above TPL_STACK which depends on it. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-14Merge patch series "Introduce K3 remoteproc driver for M4 subsystem"Tom Rini
Judith Mendez <jm@ti.com> says: Some K3 devices like am62x and am64x have a M4 processor in the MCU voltage domain. This patch series introduces remoteproc M4 driver which will be used to load firmware into and start the M4 remote core. This series also adds support for R5F cores on am64x SoCs in patch 2 and sets up environment to load FW in remote cores in patch 3,4,5. This patch series also enables remoteproc drivers by default as per what remoteproc sybsystem is supported per SoC, thus all remoteproc options are now deleted in configs/* since they are no longer required. This patch series was tested on am64x EVM, am62x SK, am62ax SK, am62px SK boards. Any additional tested by's are welcome since I was not able to test any additional boards. Tested by running the following commands in u-boot prompt: => setenv dorprocboot 1 => run boot_rprocs Link: https://lore.kernel.org/r/20250210202944.1071931-1-jm@ti.com
2025-02-14spl: Enable SPL remoteproc by default for K3 ARCHJudith Mendez
If building for v7R and K3 architecture, enable SPL remoteproc so that it does not have to be defined in each board defconfig file. Signed-off-by: Judith Mendez <jm@ti.com>
2025-02-03vbe: Allow VBE to disable adding loadables to the FDTSimon Glass
When VBE operates within VPL it does not want the FDT to be changed. Provide a way to disable this feature. Move the FIT_IMAGE_TINY condition out of spl_fit_record_loadable() so that both conditions are together. This makes the code easier to understand. Replace the existing fit_loaded member, which is no-longer used. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-03vbe: Provide VPL binman-symbols for the next phaseSimon Glass
Add support for moving from TPL->VPL->SPL so that the VPL build can fit properly into the boot flow. Use #ifdefs to avoid creating unwanted symbols which Binman would then try (and perhaps fail) to provide. Add debugging to indicate the next phase. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-03vbe: Support providing a linker scriptSimon Glass
Allow a linker script to be provided for VPL as it is for other U-Boot phases. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-03spl: Support selecting images based on phase in simple FITSimon Glass
At present the simple FIT-loader always loads images, ignoring whether they are intended for the next phase or not. VBE packages up several images in the same FIT, some destined for VPL and some for SPL. Add logic to check the phase before loading the image. Return -EPERM in that case and handle it gracefully. Fix a unnecessary re-computation of read_offset while here. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-03spl: Adjust debugging and xPL symbolsSimon Glass
The size of some malloc() fields has reduced on 64-bit machines, but the spl_reloc code was not updated. Fix this to avoid a compiler warning. Also update for the new xPL naming. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2025-01-22Merge patch series "upl: Prerequite patches for updated spec"Tom Rini
Simon Glass <sjg@chromium.org> says: The current UPL spec[1] has been tidied up and improved over the last year, since U-Boot's original UPL support was written. This series includes some prerequisite patches needed for the real UPL patches. It is split from [2] [1] https://github.com/UniversalPayload/spec/tree/3f1450d [2] https://patchwork.ozlabs.org/project/uboot/list/?series=438574&state=* Link: https://lore.kernel.org/r/20250111000029.245022-1-sjg@chromium.org
2025-01-22boot: Rename fit_image_get_data()Simon Glass
This function can only be used with FITs that use embedded data. Rename it so this is clear. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-01-22Merge patch series "vbe: Series part F"Tom Rini
Simon Glass <sjg@chromium.org> says: This includes various patches towards implementing the VBE abrec bootmeth in U-Boot. It mostly focuses on introducing a relocating SPL-loader so that VBE can run in the limited amount of SRAM available on many devices. Another minor new feature is support in VBE for specifying the image phase when loading from a FIT. This allows a single FIT to include images for several boot phases, thus simplifying image-creation. One lingering niggle in this series is that it has a different code path for sandbox, since it does not support the relocating jump. It should be possible to resolve this with additional work, but I have not attempted this so far. For v2, I have split the first patch into 5 pieces, to make it easier to see the code-size impact, plus added a few tweaks to reduce code size. Again, only MMC is supported so far. Looking ahead, series G will have some more plumbing and H some rk3399 pieces. That should be enough to complete these feature. Here is a run in my lab, with the VBE ABrec bootmeth. You can see that VPL runs before memory is set up. SPL sets up memory and can be upgraded in the field reliably. $ ub-int vbe Building U-Boot in sourcedir for rk3399-generic Bootstrapping U-Boot from dir /tmp/b/rk3399-generic Writing U-Boot using method rockchip U-Boot TPL 2025.01-rc3-00345-gdfbdbf1eb56c-dirty (Jan 08 2025 - 10:47:58) Trying to boot from vbe_abrec load: Firefly-RK3399 Board Using 'config-3' configuration Trying 'image-vpl' firmware subimage Using 'config-3' configuration Trying 'fdt-3' fdt subimage U-Boot VPL 2025.01-rc3-00345-gdfbdbf1eb56c-dirty (Jan 08 2025 - 10:47:58) Trying to boot from vbe_abrec load: Firefly-RK3399 Board Starting with empty state VBE: Firmware pick A at 800000 Using 'config-3' configuration Trying 'spl' firmware subimage Using 'config-3' configuration Trying 'fdt-3' fdt subimage Channel 0: DDR3, 800MHz BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB Channel 1: DDR3, 800MHz BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB 256B stride U-Boot SPL 2025.01-rc3-00345-gdfbdbf1eb56c-dirty (Jan 08 2025 - 10:47:58 -0700) Trying to boot from vbe_abrec load: Firefly-RK3399 Board VBE: Firmware pick A at 900000 load_simple_fit: Skip load 'atf-5': image size is 0! Relocating bloblist ff8eff00 to 100000: done ns16550_serial serial@ff1a0000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19 U-Boot 2025.01-rc3-00345-gdfbdbf1eb56c-dirty (Jan 08 2025 - 10:47:58 -0700) SoC: Rockchip rk3399 Reset cause: POR Model: Firefly-RK3399 Board DRAM: 4 GiB (effective 3.9 GiB) Core: 314 devices, 33 uclasses, devicetree: separate MMC: mmc@fe310000: 3, mmc@fe320000: 1, mmc@fe330000: 0 Loading Environment from SPIFlash... Invalid bus 0 (err=-19) *** Warning - spi_flash_probe_bus_cs() failed, using default environment In: serial,usbkbd Out: serial,vidconsole Err: serial,vidconsole Model: Firefly-RK3399 Board Net: PMIC: RK808 eth0: ethernet@fe300000 starting USB... Bus usb@fe380000: USB EHCI 1.00 Bus usb@fe3a0000: USB OHCI 1.0 Bus usb@fe3c0000: USB EHCI 1.00 Bus usb@fe3e0000: USB OHCI 1.0 Bus usb@fe900000: Register 2000140 NbrPorts 2 Starting the controller USB XHCI 1.10 scanning bus usb@fe380000 for devices... 1 USB Device(s) found scanning bus usb@fe3a0000 for devices... 1 USB Device(s) found scanning bus usb@fe3c0000 for devices... 2 USB Device(s) found scanning bus usb@fe3e0000 for devices... 1 USB Device(s) found scanning bus usb@fe900000 for devices... 1 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Hit any key to stop autoboot: 0 Link: https://lore.kernel.org/r/20250116012723.2820301-1-sjg@chromium.org
2025-01-22spl: Plumb in the relocating loaderSimon Glass
This is fairly easy to use. The SPL loader sets up some fields in the spl_image_info struct and calls spl_reloc_prepare(). When SPL is ready to do the jump it must call spl_reloc_jump() instead of jump_to_image(). Add this logic. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-22spl: Add support for a relocating jump to the next phaseSimon Glass
When one xPL phase wants to jump to the next, the next phase must be loaded into its required address. This means that the TEXT_BASE for the two phases must be different and there cannot be any memory overlap between the code used by the two phases. It also can mean that phases need to be moved around to accommodate any size growth. Having two xPL phases in SRAM at the same time can be tricky if SRAM is limited, which it often is. It would be better if the second phase could be loaded somewhere else, then decompressed into place over the top of the first phase. Introduce a relocating jump for xPL to support this. This selects a suitable place to load the (typically compressed) next phase, copies some decompression code out of the first phase, then jumps to this code to decompress and start the next phase. This feature makes it much easier to support Verified Boot for Embedded (VBE) on RK3399 boards, which have 192KB of SRAM. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-22spl: Add a type for the jumper functionSimon Glass
This function will be used by the relocating jumper too, so add a typedef to the header file to avoid mismatches. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-14common: Move autoprobe out to board initSimon Glass
Rather than doing autoprobe within the driver model code, move it out to the board-init code. This makes it clear that it is a separate step from binding devices. For now this is always done twice, before and after relocation, but we should discuss whether it might be possible to drop the post-relocation probe. For boards with SPL, the autoprobe is still done there as well. Note that with this change, autoprobe happens after the EVT_DM_POST_INIT_R/F events are sent, rather than before. Link: https://lore.kernel.org/u-boot/20240626235717.272219-1-marex@denx.de/ Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-27spl: Add some more debugging to load_simple_fit()Simon Glass
Add debugging of image-loading progress. Fix a stale comment in the function comment while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-27spl: Drop a duplicate variable in boot_from_devices()Simon Glass
The variable 'ret' is defined twice, which is not intended. This may have been a local merge error. Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: 2eefeb6d893 ("spl: Report a loader failure")
2024-12-27spl: Drop use of uintptr_tSimon Glass
U-Boot uses ulong for addresses. It is confusing to use uintptr_t in a few places, since it makes people wonder if the types are compatible. Change the few occurences in SPL to use ulong Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-27spl: Support a relocated stack in any XPL phaseSimon Glass
The current check looks only at SPL, but TPL or VPL might have a different setting. Update the condition. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-27spl: Allow serial to be disabled in any XPL phaseSimon Glass
The current check looks only at SPL, but TPL or VPL might have a different setting. Update the condition. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-27spl: Report a loader failureSimon Glass
If a loader returns an error code it is silently ignored. Show a message to at least provide some feedback to the user. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-27Support setting a maximum size for the VPL imageSimon Glass
Add a size limit for VPL, to match those for SPL and TPL Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-27malloc: Provide a simple malloc for VPLSimon Glass
The VPL phase may want to use the smaller malloc() implementation, so add an option for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-27spl: mmc: Avoid size growth in spl_mmc_find_device() debugSimon Glass
The for() loop ends up being in the code even if the log_debug() does nothing. Add a condition to fix this. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
2024-12-18riscv: spl: add FIT name for RISC-V Falcon modeRandolph
The FIT name in RISC-V Falcon mode should be different from that in normal boot mode; it is called linux.itb. If the setting is missing in common/spl, the normal boot file name will be used. Signed-off-by: Randolph <randolph@andestech.com>
2024-12-12Revert "Merge patch series "vbe: Series part E""Tom Rini
This reverts commit 1fdf53ace13f745fe8ad4d2d4e79eed98088d555, reversing changes made to e5aef1bbf11412eebd4c242b46adff5301353c30. I had missed that this caused too much size growth on rcar3_salvator-x. Signed-off-by: Tom Rini <trini@konsulko.com>
2024-12-12Merge patch series "vbe: Series part E"Tom Rini
Simon Glass <sjg@chromium.org> says: This includes various patches towards implementing the VBE abrec bootmeth in U-Boot. It mostly focuses on SPL tweaks and adjusting what fatures are available in VPL. Link: https://lore.kernel.org/r/20241207172412.1124558-1-sjg@chromium.org
2024-12-12spl: Add some more debugging to load_simple_fit()Simon Glass
Add debugging of image-loading progress. Fix a stale comment in the function comment while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-12spl: Drop a duplicate variable in boot_from_devices()Simon Glass
The variable 'ret' is defined twice, which is not intended. This may have been a local merge error. Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: 2eefeb6d893 ("spl: Report a loader failure")
2024-12-12spl: Drop use of uintptr_tSimon Glass
U-Boot uses ulong for addresses. It is confusing to use uintptr_t in a few places, since it makes people wonder if the types are compatible. Change the few occurences in SPL to use ulong Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-12spl: Support a relocated stack in any XPL phaseSimon Glass
The current check looks only at SPL, but TPL or VPL might have a different setting. Update the condition. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-12spl: Allow serial to be disabled in any XPL phaseSimon Glass
The current check looks only at SPL, but TPL or VPL might have a different setting. Update the condition. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-12spl: Report a loader failureSimon Glass
If a loader returns an error code it is silently ignored. Show a message to at least provide some feedback to the user. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-12Support setting a maximum size for the VPL imageSimon Glass
Add a size limit for VPL, to match those for SPL and TPL Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-12malloc: Provide a simple malloc for VPLSimon Glass
The VPL phase may want to use the smaller malloc() implementation, so add an option for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-12spl: mmc: Avoid size growth in spl_mmc_find_device() debugSimon Glass
The for() loop ends up being in the code even if the log_debug() does nothing. Add a condition to fix this. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>