]> git.dujemihanovic.xyz Git - u-boot.git/log
u-boot.git
13 months agocmd: efidebug: add uri device path
Masahisa Kojima [Fri, 10 Nov 2023 04:25:41 +0000 (13:25 +0900)]
cmd: efidebug: add uri device path

This adds the URI device path option for 'boot add' subcommand.
User can add the URI load option for downloading ISO image file
or EFI application through network. Currently HTTP is only supported.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
13 months agoefi_loader: support boot from URI device path
Masahisa Kojima [Fri, 10 Nov 2023 04:25:40 +0000 (13:25 +0900)]
efi_loader: support boot from URI device path

This supports to boot from the URI device path.
When user selects the URI device path, bootmgr downloads
the file using wget into the address specified by loadaddr
env variable.
If the file is .iso or .img file, mount the image with blkmap
then try to boot with the default file(e.g. EFI/BOOT/BOOTAA64.EFI).
Since boot option indicating the default file is automatically
created when new disk is detected, system can boot by selecting
the automatically created blkmap boot option.
If the file is PE-COFF file, load and start the downloaded file.

The buffer used to download the ISO image file must be
reserved to avoid the unintended access to the image and
expose the ramdisk to the OS.
For PE-COFF file case, this memory reservation is done
in LoadImage Boot Service.

[Ilias fix a few memory leaks by replacing returns with gotos]
Lore: https://lore.kernel.org/u-boot/20231110042542.3797301-1-masahisa.kojima@linaro.org/T/#mbac31da301ff465b60894b38f3a587b2868cf817
Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
13 months agoefi_loader: add return to efibootmgr event group
Masahisa Kojima [Fri, 10 Nov 2023 04:25:39 +0000 (13:25 +0900)]
efi_loader: add return to efibootmgr event group

When the image loaded by efibootmgr returns, efibootmgr
needs to clean the resources. Adding the event of returning
to efibootmgr is useful to simplify the implementation.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
13 months agoefi_loader: add missing const classifier for event service
Masahisa Kojima [Fri, 10 Nov 2023 04:25:38 +0000 (13:25 +0900)]
efi_loader: add missing const classifier for event service

const classifier is missing in EventGroup parameter of
CreateEventEx(). Fix it to remove the compiler warning.

NotifyContext parameter of CreateEventEx() is also defined
with const in UEFI specification, but NotifyContext parameter
of CreateEvent() is defined without const.
Since current implementation calls the common efi_create_event()
function from both CreateEventEx() and CreateEvent() services,
NotifyContext parameter leaves as is.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
13 months agoefi_loader: Boot var automatic management
Raymond Mao [Fri, 10 Nov 2023 04:25:37 +0000 (13:25 +0900)]
efi_loader: Boot var automatic management

Changes for complying to EFI spec §3.5.1.1
'Removable Media Boot Behavior'.
Boot variables can be automatically generated during a removable
media is probed. At the same time, unused boot variables will be
detected and removed.

Please note that currently the function 'efi_disk_remove' has no
ability to distinguish below two scenarios
a) Unplugging of a removable media under U-Boot
b) U-Boot exiting and booting an OS
Thus currently the boot variables management is not added into
'efi_disk_remove' to avoid boot options being added/erased
repeatedly under scenario b) during power cycles
See TODO comments under function 'efi_disk_remove' for more details

The original efi_secboot tests expect that BootOrder EFI variable
is not defined. With this commit, the BootOrder EFI variable is
automatically added when the disk is detected. The original
efi_secboot tests end up with unexpected failure.
The efi_secboot tests need to be modified to explicitly set
the BootOrder EFI variable.

squashfs and erofs ls tests are also affected by this modification,
need to clear the previous state before squashfs ls test starts.

Co-developed-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
13 months agoblk: blkmap: add ramdisk creation utility function
Masahisa Kojima [Fri, 10 Nov 2023 04:25:36 +0000 (13:25 +0900)]
blk: blkmap: add ramdisk creation utility function

User needs to call several functions to create the ramdisk
with blkmap.
This adds the utility function to create blkmap device and
mount the ramdisk.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
13 months agonet: wget: add wget with dns utility function
Masahisa Kojima [Fri, 10 Nov 2023 04:25:35 +0000 (13:25 +0900)]
net: wget: add wget with dns utility function

Current wget takes the target uri in this format:
 "<http server ip>:<file path>"  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 <masahisa.kojima@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
13 months agonet: wget: prevent overwriting reserved memory
Masahisa Kojima [Fri, 10 Nov 2023 04:25:34 +0000 (13:25 +0900)]
net: wget: prevent overwriting reserved memory

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 <masahisa.kojima@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
13 months agoMerge branch '2023-11-16-assorted-updates' into next
Tom Rini [Fri, 17 Nov 2023 13:38:05 +0000 (08:38 -0500)]
Merge branch '2023-11-16-assorted-updates' into next

- squashfs improvements, remove common.h in some places, assorted code
  fixes, fix a few CONFIG symbol names in Kconfig files, bring in
  linux's <linux/time.h> conversion functions, poplar updates, bcb
  improvements.

13 months agoblk: Drop reference to DM_SPL
Simon Glass [Sun, 12 Nov 2023 20:03:47 +0000 (13:03 -0700)]
blk: Drop reference to DM_SPL

The intent here is to only allow SPL_LEGACY_BLK if !SPL_DM - i.e. that
when driver model is enabled in SPL, legacy block cannot be used.

However this combination is used by about 240 boards, so we cannot
disallow it, at least not yet.

So just drop the condition.

Signed-off-by: Simon Glass <sjg@chromium.org>
13 months agodm: core: Correct reference to DM_SPL in SPL_DM_STATS
Simon Glass [Sun, 12 Nov 2023 20:03:46 +0000 (13:03 -0700)]
dm: core: Correct reference to DM_SPL in SPL_DM_STATS

This does not existing anymore. Update SPL_DM_STATS to use the correct
Kconfig option, which is SPL_DM

Signed-off-by: Simon Glass <sjg@chromium.org>
13 months agofs: btrfs: fix reading when length specified
Sam Edwards [Sat, 11 Nov 2023 15:19:04 +0000 (08:19 -0700)]
fs: btrfs: fix reading when length specified

The btrfs read function limits the read length to ensure that it
and the read offset do not together exceed the size of the file.
However, this size was only being queried if the read length was
passed a value of zero (meaning "whole file"), and the size is
defaulted to 0 otherwise. This means the clamp will just zero out
the length if one is specified, preventing reading of the file.

Fix this by checking the file size unconditionally, and unifying
the default length and clamping logic as a single range check instead.

This bug was discovered when trying to boot Linux with initrd= via
'bootefi' from a btrfs partition. The EFI stub entered an infinite
loop of zero-length reads while trying to read the initrd, and the
boot process stalled indefinitely.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
13 months agocmd: bcb: extend BCB C API to allow read/write the fields
Dmitrii Merkurev [Fri, 10 Nov 2023 05:59:55 +0000 (05:59 +0000)]
cmd: bcb: extend BCB C API to allow read/write the fields

Currently BCB C API only allows to modify 'command' BCB field.
Extend it so that we can also read and modify all the available
BCB fields (command, status, recovery, stage).

Co-developed-by: Cody Schuffelen <schuffelen@google.com>
Signed-off-by: Cody Schuffelen <schuffelen@google.com>
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eugeniu Rosca <erosca@de.adit-jv.com>
Cc: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Sean Anderson <sean.anderson@seco.com>
Cc: Cody Schuffelen <schuffelen@google.com>
Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # on vim3
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
13 months agocmd: bcb: support various block device interfaces for BCB command
Dmitrii Merkurev [Fri, 10 Nov 2023 05:59:54 +0000 (05:59 +0000)]
cmd: bcb: support various block device interfaces for BCB command

Currently BCB command-line, C APIs and implementation only
support MMC interface. Extend it to allow various block
device interfaces.

Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eugeniu Rosca <erosca@de.adit-jv.com>
Cc: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Sean Anderson <sean.anderson@seco.com>
Cc: Cody Schuffelen <schuffelen@google.com>
Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # on vim3
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
13 months agopoplar: provide more space for kernel image
Igor Opaniuk [Thu, 9 Nov 2023 22:34:35 +0000 (23:34 +0100)]
poplar: provide more space for kernel image

Adjust mem layout, providing more space for linux kernel image.

This fixes the problem:
ERROR: FDT image overlaps OS image (OS=0x30000000..0x32580000)

Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
13 months agopoplar: use random mac address
Igor Opaniuk [Thu, 9 Nov 2023 22:34:34 +0000 (23:34 +0100)]
poplar: use random mac address

Set CONFIG_NET_RANDOM_ETHADDR=y, which sets random eth address in
case there is no configuration provided neither in CONFIG_ETHADDR
nor in "ethaddr" env variable.

This fixes the problem:
poplar# dhcp
Error: ethernet@9841000 address not set.

Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
13 months agotreewide: use linux/time.h for time conversion defines
Igor Prusov [Thu, 9 Nov 2023 17:10:04 +0000 (20:10 +0300)]
treewide: use linux/time.h for time conversion defines

Now that we have time conversion defines from in time.h there is no need
for each driver to define their own version.

Signed-off-by: Igor Prusov <ivprusov@salutedevices.com>
Reviewed-by: Svyatoslav Ryhel <clamor95@gmail.com> # tegra
Reviewed-by: Eugen Hristev <eugen.hristev@collabora.com> #at91
Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org> #qcom geni
Reviewed-by: Stefan Bosch <stefan_b@posteo.net> #nanopi2
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
13 months agospi: meson_spifc_a1: Use define for time interval
Igor Prusov [Thu, 9 Nov 2023 17:10:03 +0000 (20:10 +0300)]
spi: meson_spifc_a1: Use define for time interval

Use USEC_PER_MSEC define for timeout to sync code with Linux version.

Signed-off-by: Igor Prusov <ivprusov@salutedevices.com>
13 months agolinux/time.h: Add Linux time conversion defines
Igor Prusov [Thu, 9 Nov 2023 17:10:02 +0000 (20:10 +0300)]
linux/time.h: Add Linux time conversion defines

Currently there are no defines for time conversion in time.h, which
leads to drivers declaring those locally or not using defines at all, so
add them from Linux.

Signed-off-by: Igor Prusov <ivprusov@salutedevices.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agofs: ext4: Remove unused parameter from ext4_mount
Sean Anderson [Wed, 8 Nov 2023 17:51:09 +0000 (12:51 -0500)]
fs: ext4: Remove unused parameter from ext4_mount

The part_length parameter is not used. Remove it.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
13 months agosysreset: Fix unsupported request return values
Paul Barker [Wed, 8 Nov 2023 08:51:10 +0000 (08:51 +0000)]
sysreset: Fix unsupported request return values

The description of the sysreset request method in <sysreset.h> says that
the return value should be -EPROTONOSUPPORT if the requested reset type
is not supported by this device.

Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agoboard: cssi: Remove usage of common.h
Christophe Leroy [Mon, 6 Nov 2023 18:12:05 +0000 (19:12 +0100)]
board: cssi: Remove usage of common.h

Remove inclusion of common.h and add relevant
includes when necessary.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
13 months agopowerpc: mpc8xx: Remove usage of common.h
Christophe Leroy [Mon, 6 Nov 2023 18:12:04 +0000 (19:12 +0100)]
powerpc: mpc8xx: Remove usage of common.h

Remove inclusion of common.h and add relevant
includes when necessary.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
13 months agofs/squashfs: enable LZ4 compression support
David Oberhollenzer [Mon, 6 Nov 2023 10:14:03 +0000 (11:14 +0100)]
fs/squashfs: enable LZ4 compression support

The structure is identical to the existing compressor implementations,
trivially adding lz4 decompression to sqfs_decompress.

The changes were tested using a sandbox build. An LZ4 compressed
squashfs image was bound as a host block device.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com>
13 months agofs/squashfs: remove unused declarations
David Oberhollenzer [Mon, 6 Nov 2023 10:03:20 +0000 (11:03 +0100)]
fs/squashfs: remove unused declarations

This patch removes a number of struct and macro declaration that
were found through `git-grep` to be unused. Most of those are
related to compressor options and super block flags.

For reading a SquashFS image, we do not need the compressor options
or the flags. Those only encode settings used for packing the image,
mksquashfs uses them when appending data to an existing image. The
kernel implementation does not touch those, and we don't need them
either.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
13 months agotest: eth: Don't crash if env_get returns NULL
Sean Anderson [Sat, 28 Oct 2023 22:57:27 +0000 (18:57 -0400)]
test: eth: Don't crash if env_get returns NULL

env_get can return NULL if it fails to find the variable. Check its result
before using it.

Fixes: 6d9764c2a87 ("dm: test: Add a new test case against dm eth codes for NULL pointer access")
Fixes: df33fd28897 ("test: eth: Add test for ethernet addresses")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
13 months agobootm: Enable legacy VxWorks booting from FITs
Sean Anderson [Fri, 27 Oct 2023 20:07:40 +0000 (16:07 -0400)]
bootm: Enable legacy VxWorks booting from FITs

This works without issue, so don't fail.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
13 months agoMerge patch series "spl: Use common function for loading/parsing images"
Tom Rini [Thu, 16 Nov 2023 17:55:48 +0000 (12:55 -0500)]
Merge patch series "spl: Use common function for loading/parsing images"

To quote the author:

This series adds support for loading all image types (Legacy (with and without
LZMA), FIT (with and without LOAD_FIT_FULL), and i.MX) to the MMC, SPI, NOR,
NET, FAT, EXT, NVMe, and semihosting load methods. It does this by introducing a
helper function which handles the minutiae of invoking the proper parsing
function, and reading the rest of the image.

Hopefully, this will make it easier for load methods to support all image types
that U-Boot supports, without having undocumented unsupported image types. I
applied this to several loaders which were invoking spl_load_simple_fit and/or
spl_parse_image_header, but I did not use it with others (e.g. DFU/RAM) which
had complications in the mix.

This series is organized roughly into two parts. Patches up to "spl: Add generic
spl_load function" are all setup or size-reduction oriented. Later patches
generally convert various load functions to spl_load.

bloat-o-meter results (for CONFIG_SPL only) at [1]. Size growth has been the
bigegst challenge to preparing this series. I have used every trick I can think
of to reduce bloat. Some SAMA boards no longer fit, but I have a plan to fix
them [2].

This is bar far the largest and most-difficult revision of this series to-date.
There are probably still things which can reduce the size, but I have been
working on this series for the better part of two months and I think it is a
good idea to get some feedback. Because of the SAMA bloat, this series will not
pass CI, so I expect to do a v7 before this is ready to apply. Feel free,
however, to apply patches in the first half (especially the fixes).

This version of the series is better-tested than ever before, thanks to some new
unit tests. However, things like the i.MX ROMAPI are untested. NAND should also
be tested more-widely, for reasons listed in the commit message. I encourage you
try this series out on your favorite board.

[1] https://gist.github.com/Forty-Bot/5bfe88676dd3c2aec6ebc23abb08e06f
    This includes some changes to am335x_evm_spiboot and am65x_evm_r5_usbdfu
    which have since been undone. This was ran for v6.
[2] https://lore.kernel.org/u-boot/20231105022742.632175-1-seanga2@gmail.com/

13 months agospl: fat: Add option to disable DMA alignment
Sean Anderson [Wed, 8 Nov 2023 16:48:58 +0000 (11:48 -0500)]
spl: fat: Add option to disable DMA alignment

If we don't DMA-align buffers we pass to FAT, it will align them itself.
This behaviour likely should be deprecated in favor of
CONFIG_BOUNCE_BUFFER, but that's a task for another series. For the
meantime, don't bother aligning the buffer unless we had been doing so in
the past.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: spi: Consolidate spi_load_image_os into spl_spi_load_image
Sean Anderson [Wed, 8 Nov 2023 16:48:57 +0000 (11:48 -0500)]
spl: spi: Consolidate spi_load_image_os into spl_spi_load_image

spi_load_image_os performs almost the same steps as the non-falcon-boot
path of spl_spi_load_image. The load address is different, and it also
loads a device tree, but that's it. Refactor the boot process so that
they can both use the same load function.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Convert spi to spl_load
Sean Anderson [Wed, 8 Nov 2023 16:48:56 +0000 (11:48 -0500)]
spl: Convert spi to spl_load

This converts the spi load method to use spl_load. The address used for
LOAD_FIT_FULL may be different, but there are no in-tree users of that
config. Since payload_offs is only used without OS_BOOT, we defer its
initialization.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Convert semihosting to spl_load
Sean Anderson [Wed, 8 Nov 2023 16:48:55 +0000 (11:48 -0500)]
spl: Convert semihosting to spl_load

This converts the semihosting load method to use spl_load. As a result, it
also adds support for LOAD_FIT_FULL and IMX images.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
13 months agospl: Convert NVMe to spl_load
Sean Anderson [Wed, 8 Nov 2023 16:48:54 +0000 (11:48 -0500)]
spl: Convert NVMe to spl_load

This converts the blk load method (used exclusively by NVMe) to use
spl_load. As a consequence, it also adds support for LOAD_FIT_FULL and
IMX images.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Convert nor to spl_load
Sean Anderson [Wed, 8 Nov 2023 16:48:53 +0000 (11:48 -0500)]
spl: Convert nor to spl_load

This converts the nor load method to use spl_load. As a result it also
adds support for LOAD_FIT_FULL. Since this is the last caller of
spl_load_legacy_img, it has been removed.

We can't load FITs with external data with SPL_LOAD_FIT_FULL, so disable the
test in that case. No boards enable SPL_NOR_SUPPORT and SPL_LOAD_FIT_FULL, so
this is not a regression.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Convert net to spl_load
Sean Anderson [Wed, 8 Nov 2023 16:48:52 +0000 (11:48 -0500)]
spl: Convert net to spl_load

This converts the net load method to use spl_load. As a result, it also
adds support for LOAD_FIT_FULL and IMX images.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Convert nand to spl_load
Sean Anderson [Wed, 8 Nov 2023 16:48:51 +0000 (11:48 -0500)]
spl: Convert nand to spl_load

This converts the nand load method to use spl_load. nand_page_size may not
be valid until after nand_spl_load_image is called (see e.g. fsl_ifc_spl),
so we set bl_len in spl_nand_read. Since spl_load reads the header for us,
we can remove that argument from spl_nand_load_element.

There are two possible regressions which could result from this commit.
First, we ask for a negative address from spl_get_load_buffer. That is,
instead of

header = spl_get_load_buffer(0, sizeof(*header));

we do

header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));

this could cause a problem if spl_get_load_buffer does not return valid
memory for negative offsets. Second, we now set bl_len for legacy images.
This can cause memory up to a bl_len - 1 before the image load address to
be written, which might not have been the case before. If this turns out to
be a problem, we can add an option for a bounce buffer.

We can't load FITs with external data with SPL_LOAD_FIT_FULL, so disable the
test in that case. No boards enable SPL_NAND_SUPPORT and SPL_LOAD_FIT_FULL, so
this is not a regression.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Convert mmc to spl_load
Sean Anderson [Wed, 8 Nov 2023 16:48:50 +0000 (11:48 -0500)]
spl: Convert mmc to spl_load

This converts the mmc loader to spl_load. Legacy images are handled by
spl_load (via spl_parse_image_header), so mmc_load_legacy can be
omitted. To accurately determine whether mmc_load_image_raw_sector is used
(which might not be the case if SYS_MMCSD_FS_BOOT is enabled), we introduce
a helper config SYS_MMCSD_RAW_MODE. This ensures we can inline spl_load
correctly when a board only boots from filesystems. We still need to check
for SPL_MMC, since some boards enable configure raw mode even without MMC
support.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Convert fat to spl_load
Sean Anderson [Wed, 8 Nov 2023 16:48:49 +0000 (11:48 -0500)]
spl: Convert fat to spl_load

This converts the fat loader to use spl_load. Some platforms are very
tight on space, so we take care to only include the code we really need.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Convert ext to use spl_load
Sean Anderson [Wed, 8 Nov 2023 16:48:48 +0000 (11:48 -0500)]
spl: Convert ext to use spl_load

This converts the ext load method to use spl_load. As a consequence, it
also adds support for FIT and IMX images.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Add generic spl_load function
Sean Anderson [Wed, 8 Nov 2023 16:48:47 +0000 (11:48 -0500)]
spl: Add generic spl_load function

Implementers of SPL_LOAD_IMAGE_METHOD have to correctly determine what
type of image is being loaded and then call the appropriate image load
function correctly. This is tricky, because some image load functions
expect the whole image to already be loaded (CONFIG_SPL_LOAD_FIT_FULL),
some will load the image automatically using spl_load_info.read()
(CONFIG_SPL_LOAD_FIT/CONFIG_SPL_LOAD_IMX_CONTAINER), and some just parse
the header and expect the caller to do the actual loading afterwards
(legacy/raw images). Load methods often only support a subset of the
above methods, meaning that not all image types can be used with all
load methods. Further, the code to invoke these functions is
duplicated between different load functions.

To address this problem, this commit introduces a "spl_load" function.
It aims to handle image detection and correct invocation of each of the
parse/load functions.

Although this function generally results in a size reduction with
several users, it tends to bloat boards with only a single user.
This is generally because programmers open-coding the contents of this
function can make optimizations based on the specific loader. For
example, NOR flash is memory-mapped, so it never bothers calling
load->read. The compiler can't really make these optimizations across
translation units. LTO solves this, but it is only available on some
arches. To address this, perform "pseudo-LTO" by inlining spl_load when
there are one or fewer users. At the moment, there are no users, so
define SPL_LOAD_USERS to be 0.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agotest: spl: Support testing LEGACY_LZMA filesystem images
Sean Anderson [Wed, 8 Nov 2023 16:48:46 +0000 (11:48 -0500)]
test: spl: Support testing LEGACY_LZMA filesystem images

These will soon be supported, so we need to be able to test it. Export the
lzma data and generally use the same process in spl_test_mmc_fs as
do_spl_test_load.  If we end up needing this in third place in the future,
it would probably be good to refactor things out.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: legacy: Split off LZMA decompression into its own function
Sean Anderson [Wed, 8 Nov 2023 16:48:45 +0000 (11:48 -0500)]
spl: legacy: Split off LZMA decompression into its own function

To allow for easier reuse of this functionality, split it off into its
own function.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: nand: Remove spl_nand_legacy_read
Sean Anderson [Wed, 8 Nov 2023 16:48:44 +0000 (11:48 -0500)]
spl: nand: Remove spl_nand_legacy_read

Now that spl_nand_fit_read works in units of bytes, it can be combined with
spl_nand_legacy_read. Rename the resulting function spl_nand_read, since it
is no longer FIT-specific.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Only support bl_len when we have to
Sean Anderson [Wed, 8 Nov 2023 16:48:43 +0000 (11:48 -0500)]
spl: Only support bl_len when we have to

Aligning addresses and sizes causes overhead which is unnecessary when we
are not loading from block devices. Remove bl_len when it is not needed.

For example, on iot2050 we save 144 bytes with this patch (once the rest of
this series is applied):

add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-144 (-144)
Function                                     old     new   delta
spl_load_simple_fit                          920     904     -16
load_simple_fit                              496     444     -52
spl_spi_load_image                           384     308     -76
Total: Before=87431, After=87287, chg -0.16%

We use panic() instead of BUILD_BUG_ON in spl_set_bl_len because we still
need to be able to compile it for things like mmc_load_image_raw_sector,
even if that function will not be used.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Remove filename from spl_load_info
Sean Anderson [Wed, 8 Nov 2023 16:48:42 +0000 (11:48 -0500)]
spl: Remove filename from spl_load_info

For filesystems, filename serves the same purpose as priv. However,
spl_load_fit_image also uses it to determine whether to use a DMA-aligned
buffer. This is beneficial for FAT, which uses a bounce-buffer if the
destination is not DMA-aligned. However, this is unnecessary now that
filesystems set bl_len to ARCH_DMA_MINALIGN instead. With this done, we can
remove filename entirely.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Set FAT bl_len to ARCH_DMA_MINALIGN
Sean Anderson [Wed, 8 Nov 2023 16:48:41 +0000 (11:48 -0500)]
spl: Set FAT bl_len to ARCH_DMA_MINALIGN

Instead of relying on the presence of filename to determine whether we are
dealing with a FAT filesystem (and should DMA-align the buffer), have FAT set
bl_len to ARCH_DMA_MINALIGN instead. With this done, we can remove the
special-case logic checking for the presence of filename.

Because filesystems are not block-based, we may read less than the size passed
to spl_load_info.read. This can happen if the file size is not DMA-aligned. This
is fine as long as we read the amount we originally wanted to. Modify the
conditions for callers of spl_load_info.read to check against the original,
unaligned size to avoid failing spuriously.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Refactor spl_load_info->read to use units of bytes
Sean Anderson [Wed, 8 Nov 2023 16:48:40 +0000 (11:48 -0500)]
spl: Refactor spl_load_info->read to use units of bytes

Simplify things a bit for callers of spl_load_info->read by refactoring it
to use units of bytes instead of bl_len. This generally simplifies the
logic, as MMC is the only loader which actually works in sectors. It will
also allow further refactoring to remove the special-case handling of
filename.  spl_load_legacy_img already works in units of bytes (oops) so it
doesn't need to be changed.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Take advantage of bl_len's power-of-twoness
Sean Anderson [Wed, 8 Nov 2023 16:48:39 +0000 (11:48 -0500)]
spl: Take advantage of bl_len's power-of-twoness

bl_len must be a power of two, so we can use ALIGN instead of roundup and
similar tricks to avoid divisions.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agoMerge patch series "nand: Add sandbox tests"
Tom Rini [Thu, 16 Nov 2023 17:46:09 +0000 (12:46 -0500)]
Merge patch series "nand: Add sandbox tests"

To quote the author:

This series tests raw nand flash in sandbox and fixes various bugs discovered in
the process. I've tried to do things in a contemporary manner, avoiding the
(numerous) variations present on only a few boards. The test is pretty minimal.
Future work could test the rest of the nand API as well as the MTD API.

Bloat (for v1) at [1] (for boards with SPL_NAND_SUPPORT enabled). Almost
everything grows by a few bytes due to nand_page_size. A few boards grow more,
mostly those using nand_spl_loaders.c. CI at [2].

[1] https://gist.github.com/Forty-Bot/9694f3401893c9e706ccc374922de6c2
[2] https://source.denx.de/u-boot/custodians/u-boot-clk/-/pipelines/18443

13 months agospl: Remove dev from spl_load_info
Sean Anderson [Wed, 8 Nov 2023 16:48:38 +0000 (11:48 -0500)]
spl: Remove dev from spl_load_info

dev and priv serve the same purpose, and are never set at the same time.
Remove dev and convert all users to priv. While we're at it, reorder bl_len
to be last for better alignment.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Remove NULL assignments in spl_load_info
Sean Anderson [Wed, 8 Nov 2023 16:48:37 +0000 (11:48 -0500)]
spl: Remove NULL assignments in spl_load_info

Remove NULL assignments to fields in spl_load_info when .load doesn't
reference these fields. This can result in more efficient code. filename
must stay even if it is unused, since load_simple_fit uses it.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: semihosting: Don't close fd before spl_load_simple_fit
Sean Anderson [Wed, 8 Nov 2023 16:48:36 +0000 (11:48 -0500)]
spl: semihosting: Don't close fd before spl_load_simple_fit

On real hardware, semihosting calls tend to have a large constant
overhead (on the order of tens of milliseconds). Reduce the number of
calls by one by reusing the existing fd in smh_fit_read, and closing it
at the end of spl_smh_load_image.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agospl: Make SHOW_ERRORS depend on LIBCOMMON
Sean Anderson [Wed, 8 Nov 2023 16:48:35 +0000 (11:48 -0500)]
spl: Make SHOW_ERRORS depend on LIBCOMMON

The purpose of SHOW_ERRORS is to print extra information. Make it depend
on LIBCOMMON to avoid having to check for two configs.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agoarm: Disable SPL_FS_FAT when it isn't used
Sean Anderson [Wed, 8 Nov 2023 16:48:34 +0000 (11:48 -0500)]
arm: Disable SPL_FS_FAT when it isn't used

Several boards enable SPL_FS_FAT and SPL_LIBDISK_SUPPORT when they can't be
used (as there is no block device support enabled). Disable these configs.
The list of boards was generated with the following command:

    $ tools/qconfig.py -f SPL SPL_FS_FAT ~SPL_MMC ~SPL_BLK_FS ~SPL_SATA \
                          ~SPL_USB_STORAGE ~ENV_IS_IN_FAT ~EFI

LIBDISK was left enabled for the am* boards, since it seems to result in
actual size reduction, indicating that partitions are being used for
something.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Michal Simek <michal.simek@amd.com>
13 months agospl: blk_fs: Fix uninitialized return value when we can't get a blk_desc
Sean Anderson [Wed, 8 Nov 2023 16:48:33 +0000 (11:48 -0500)]
spl: blk_fs: Fix uninitialized return value when we can't get a blk_desc

Initialize ret to avoid returning garbage if blk_get_devnum_by_uclass_id
fails.

Fixes: 8ce6a2e1757 ("spl: blk: Support loading images from fs")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 months agoarm: Enable SYS_THUMB_BUILD on AT91
Sean Anderson [Sun, 5 Nov 2023 02:27:42 +0000 (22:27 -0400)]
arm: Enable SYS_THUMB_BUILD on AT91

Several AT91 boards are quite close to their SPL size limit. For example,
sama5d27_wlsom1_ek_mmc is just 173 bytes short of its limit and doesn't
even fit with older GCCs.

All AT91 processors should have thumb support. Enable SYS_THUMB_BUILD. This
shrinks SPL by around 30%.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
13 months agotest: spl: Add a test for NAND
Sean Anderson [Sat, 4 Nov 2023 20:37:53 +0000 (16:37 -0400)]
test: spl: Add a test for NAND

Add a SPL test for the NAND load method. We use some different functions to
do the writing from the main test since things like nand_write_skip_bad
aren't available in SPL.

We disable BBT scanning, since scan_bbt is only populated when not in SPL.
We use nand_spl_loaders.c as it seems to be common to at least a few boards
already. However, we do not use nand_spl_simple.c because it would require
us to implement cmd_ctrl.  The various nand load functions are adapted from
omap_gpmc. However, they have been modified for simplicity/correctness.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
13 months agonand: Add sandbox driver
Sean Anderson [Sat, 4 Nov 2023 20:37:52 +0000 (16:37 -0400)]
nand: Add sandbox driver

Add a sandbox NAND flash driver to facilitate testing. This driver supports
any number of devices, each using a single chip-select. The OOB data is
stored in-band, with the separation enforced through the API.

For now, create two devices to test with. The first is a very small device
with basic ECC. The second is an 8G device (chosen to be larger than 32
bits). It uses ONFI, with the values copied from the datasheet. It also
doesn't need too strong ECC, which speeds things up.

Although the nand subsystem determines the parameters of a chip based on
the ID, the driver itself requires devicetree properties for each
parameter. We do not derive parameters from the ID because parsing the ID
is non-trivial. We do not just use the parameters that the nand subsystem
has calculated since that is something we should be testing. An exception
is made for the ECC layout, since that is difficult to encode in the device
tree and is not a property of the device itself.

Despite using file I/O to access the backing data, we do not support using
external files. In my experience, these are unnecessary for testing since
tests can generally be written to write their expected data beforehand.
Additionally, we would need to store the "programmed" information somewhere
(complicating the format and the programming process) or try to detect
whether block are erased at runtime (degrading probe speeds).

Information about whether each page has been programmed is stored in an
in-memory buffer. To simplify the implementation, we only support a single
program per erase. While this is accurate for many larger flashes, some
smaller flashes (512 byte) support multiple programs and/or subpage
programs. Support for this could be added later as I believe some
filesystems expect this.

To test ECC, we support error-injection. Surprisingly, only ECC bytes in
the OOB area are protected, even though all bytes are equally susceptible
to error. Because of this, we take care to only corrupt ECC bytes.
Similarly, because ECC covers "steps" and not the whole page, we must take
care to corrupt data in the same way.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
13 months agoarch: sandbox: Add function to create temporary files
Sean Anderson [Sat, 4 Nov 2023 20:37:51 +0000 (16:37 -0400)]
arch: sandbox: Add function to create temporary files

When working with sparse data buffers that may be larger than the address
space, it is convenient to work with files instead. Add a function to create
temporary files of a certain size.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
13 months agonand: Allow reinitialization
Sean Anderson [Sat, 4 Nov 2023 20:37:50 +0000 (16:37 -0400)]
nand: Allow reinitialization

NAND devices are destroyed in between unit tests. Provide a function to
reinitialize the subsystem at the beginning of each test.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
13 months agonand: Add function to unregister NAND devices
Sean Anderson [Sat, 4 Nov 2023 20:37:49 +0000 (16:37 -0400)]
nand: Add function to unregister NAND devices

This performs the opposite of nand_register, allowing drivers to unregister
nand devices. This is probably unnecessary for most regular drivers, but we
expect sandbox drivers to get repeatedly bound/unbound, so this will help
avoid dangling pointers.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
13 months agomtd: Add some fallbacks for add/del_mtd_device
Sean Anderson [Sat, 4 Nov 2023 20:37:48 +0000 (16:37 -0400)]
mtd: Add some fallbacks for add/del_mtd_device

This allows using these functions without ifdefs. OneNAND depends on MTD,
so this ifdef was redundant in the first place.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
13 months agomtd: Rename SPL_MTD_SUPPORT to SPL_MTD
Sean Anderson [Sat, 4 Nov 2023 20:37:47 +0000 (16:37 -0400)]
mtd: Rename SPL_MTD_SUPPORT to SPL_MTD

Rename SPL_MTD_SUPPORT to SPL_MTD in order to match MTD. This allows using
CONFIG_IS_ENABLED to test for MTD support.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
13 months agospl: nand: Map memory before accessing it
Sean Anderson [Sat, 4 Nov 2023 20:37:46 +0000 (16:37 -0400)]
spl: nand: Map memory before accessing it

In sandbox we must map memory before accessing it. Do so for the NAND load
method.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
13 months agocmd: nand: Map memory before accessing it
Sean Anderson [Sat, 4 Nov 2023 20:37:45 +0000 (16:37 -0400)]
cmd: nand: Map memory before accessing it

In sandbox, all memory must be mapped before accessing it. Do so for the
nand command.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
13 months agospl: nand: Set bl_len to page size
Sean Anderson [Sat, 4 Nov 2023 20:37:44 +0000 (16:37 -0400)]
spl: nand: Set bl_len to page size

Since commit 34793598c83 ("mtd: nand: mxs_nand_spl: Remove the page aligned
access") there are no longer any users of nand_get_mtd. However, it is
still important to know what the page size is so we can allocate a
large-enough buffer. If the image size is not page-aligned, we will go off
the end of the buffer and clobber some memory.

Introduce a new function nand_page_size which returns the page size. For
most drivers it is easy to determine the page size. However, a few need to
be modified since they only keep the page size around temporarily.

It's possible that this patch could cause a regression on some platforms if
the offset is non-aligned and there is invalid address space immediately
before the load address. spl_load_legacy_img does not (except when
compressing) respect bl_len, so only boards with SPL_LOAD_FIT (8 boards) or
SPL_LOAD_IMX_CONTAINER (none in tree) would be affected.

defconfig               CONFIG_TEXT_BASE
======================= ================
am335x_evm              0x80800000
am43xx_evm              0x80800000
am43xx_evm_rtconly      0x80800000
am43xx_evm_usbhost_boot 0x80800000
am43xx_hs_evm           0x80800000
dra7xx_evm              0x80800000
gwventana_nand          0x17800000
imx8mn_bsh_smm_s2       0x40200000

All the sitara boards have DDR mapped at 0x80000000. gwventana is an i.MX6Q
which has DDR at 0x10000000. I don't have the IMX8MNRM handy, but on the
i.MX8M DDR starts at 0x40000000. Therefore all of these boards can handle a
little underflow.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
13 months agospl: legacy: Honor bl_len when decompressing
Sean Anderson [Sat, 4 Nov 2023 20:37:43 +0000 (16:37 -0400)]
spl: legacy: Honor bl_len when decompressing

When allocating a buffer to load compressed data into, we need to ensure we
have enough space for over- and under-flow due to alignment. Otherwise we
will clobber the malloc bookkeeping data. Calculate the correct amount of
overhead and use it when determining the size.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
13 months agonand: spl_loaders: Only read enough pages to load the image
Sean Anderson [Sat, 4 Nov 2023 20:37:42 +0000 (16:37 -0400)]
nand: spl_loaders: Only read enough pages to load the image

All other implementations of nand_spl_load_image only read as many pages as
are necessary to load the image. However, nand_spl_loaders.c loads the full
block. Align it with other load functions so that it is easier to
determine how large of a load buffer we need.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
13 months agonand: Calculate SYS_NAND_BLOCK_PAGES (neé SYS_NAND_PAGE_COUNT) automatically
Sean Anderson [Sat, 4 Nov 2023 20:37:41 +0000 (16:37 -0400)]
nand: Calculate SYS_NAND_BLOCK_PAGES (neé SYS_NAND_PAGE_COUNT) automatically

Contrary to what the help message says, this is the number of pages per
block. Calculate it automatically based on SYS_NAND_BLOCK_SIZE and
SYS_NAND_PAGE_SIZE. To better reflect its semantics, rename it to
SYS_NAND_BLOCK_PAGES.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
13 months agonand: Don't dereference NULL manufacturer_desc
Sean Anderson [Sat, 4 Nov 2023 20:37:40 +0000 (16:37 -0400)]
nand: Don't dereference NULL manufacturer_desc

When no manufacturer is matched, manufacturer_desc is NULL. Avoid
dereferencing it in that case.

Fixes: 4e67c571252 ("mtd,ubi,ubifs: sync with linux v3.15")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
13 months agospl: nand: Fix NULL-pointer dereference
Sean Anderson [Sat, 4 Nov 2023 20:37:39 +0000 (16:37 -0400)]
spl: nand: Fix NULL-pointer dereference

spl_nand_fit_read unconditionally accesses load->priv. Ensure it is set.

Fixes: 00e180cc513 ("spl: nand: support loading i.MX container format file")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
13 months agoMerge tag 'u-boot-stm32-20231113' of https://source.denx.de/u-boot/custodians/u-boot...
Tom Rini [Mon, 13 Nov 2023 14:07:23 +0000 (09:07 -0500)]
Merge tag 'u-boot-stm32-20231113' of https://source.denx.de/u-boot/custodians/u-boot-stm into next

Introduce STM32MP2 SoCs family support
Add STM32MP257F-EV1 board

[trini: Adjust some includes]
Signed-off-by: Tom Rini <trini@konsulko.com>
13 months agostm32mp2: initial support
Patrice Chotard [Fri, 27 Oct 2023 14:43:04 +0000 (16:43 +0200)]
stm32mp2: initial support

Add initial support for STM32MP2 SoCs family.

SoCs information are available here :
https://www.st.com/content/st_com/en/campaigns/microprocessor-stm32mp2.html

Migrate all MP1 related code into stm32mp1/ directory
Create stm32mp2 directory dedicated for STM32MP2 SoCs.

Common code to MP1, MP13 and MP25 is kept into
arch/arm/mach-stm32/mach-stm32mp directory :
  - boot_params.c
  - bsec
  - cmd_stm32key
  - cmd_stm32prog
  - dram_init.c
  - syscon.c
  - ecdsa_romapi.c

For STM32MP2, it also :
  - adds memory region description needed for ARMv8 MMU.
  - enables early data cache before relocation.
    During the transition before/after relocation, the MMU, initially setup
    at the beginning of DDR, must be setup again at a correct address after
    relocation. This is done in enables_caches() by disabling cache, force
    arch.tlb_fillptr to NULL which will force the MMU to be setup again but
    with a new value for gd->arch.tlb_addr. gd->arch.tlb_addr has been
    updated after relocation in arm_reserve_mmu().

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
13 months agoARM: dts: stm32: Add STM32MP257F Evaluation board support
Patrice Chotard [Fri, 27 Oct 2023 14:43:03 +0000 (16:43 +0200)]
ARM: dts: stm32: Add STM32MP257F Evaluation board support

Add STM32MP257F Evaluation board support. It embeds a STM32MP257FAI SoC,
with 4GB of DDR4, TSN switch (2+1 ports), 2*USB typeA, 1*USB2 typeC,
SNOR OctoSPI, mini PCIe, STPMIC2 for power distribution ...

Sync device tree with kernel v6.6-rc1.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
13 months agopinctrl: pinctrl_stm32: Add stm32mp2 support
Patrice Chotard [Fri, 27 Oct 2023 14:43:02 +0000 (16:43 +0200)]
pinctrl: pinctrl_stm32: Add stm32mp2 support

Add stm32mp2 compatible.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
13 months agoserial: stm32: Fix AARCH64 compilation warnings
Patrice Chotard [Fri, 27 Oct 2023 14:43:01 +0000 (16:43 +0200)]
serial: stm32: Fix AARCH64 compilation warnings

When building with AARCH64 defconfig, we got warnings, fix them
by using registers base address defined as void __iomem * instead of
fdt_addr_t.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
13 months agostm32mp: bsec: Fix AARCH64 compilation warnings
Patrice Chotard [Fri, 27 Oct 2023 14:43:00 +0000 (16:43 +0200)]
stm32mp: bsec: Fix AARCH64 compilation warnings

When building with AARCH64 defconfig, we got warnings, fix them.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
13 months agostm32mp: dram_init: Limit DDR usage under 4GB boundary for STM32MP
Patrice Chotard [Fri, 27 Oct 2023 14:42:59 +0000 (16:42 +0200)]
stm32mp: dram_init: Limit DDR usage under 4GB boundary for STM32MP

Limit DDR usage under 4GB boundary on STM32MP regardless of
memory size declared in device tree.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
13 months agostm32mp: dram_init: Fix AARCH64 compilation warnings
Patrick Delaunay [Fri, 27 Oct 2023 14:42:58 +0000 (16:42 +0200)]
stm32mp: dram_init: Fix AARCH64 compilation warnings

When building with AARCH64 defconfig, we got warnings for debug
message
- format '%x' expects argument of type 'unsigned int',
   but argument 3 has type 'size_t' {aka 'long unsigned int'}).
- format '%lx' expects argument of type 'long unsigned int',
  but argument 2 has type 'phys_addr_t' {aka 'long long unsigned
  int'}

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
13 months agostm32mp: dram_init: Get RAM size from DT if no RAM driver found
Patrice Chotard [Fri, 27 Oct 2023 14:42:57 +0000 (16:42 +0200)]
stm32mp: dram_init: Get RAM size from DT if no RAM driver found

In case there is no RAM driver retrieve RAM size from DT as fallback.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
13 months agoarm: caches: Make DCACHE_DEFAULT_OPTION accessible for ARM64 arch
Patrice Chotard [Fri, 27 Oct 2023 14:42:56 +0000 (16:42 +0200)]
arm: caches: Make DCACHE_DEFAULT_OPTION accessible for ARM64 arch

This fixes the following compilation error in ARM64:
arch/arm/mach-stm32mp/dram_init.c: In function ‘board_get_usable_ram_top’:
arch/arm/mach-stm32mp/dram_init.c:59:45: error: ‘DCACHE_DEFAULT_OPTION’ undeclared (first use in this function)
   59 |  mmu_set_region_dcache_behaviour(reg, size, DCACHE_DEFAULT_OPTION);
      |                                             ^~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
13 months agoMerge branch '2023-11-10-improve-semihosting-armv6' into next
Tom Rini [Fri, 10 Nov 2023 16:55:28 +0000 (11:55 -0500)]
Merge branch '2023-11-10-improve-semihosting-armv6' into next

To quote the author:
This series has a few fixes for semihosting on ARMv6 and older CPUs. The
first two patches address problems regarding the stack pointer and link
register. U-Boot runs in supervisor mode, so taking a software interrupt
will clobber sp/lr. I think we really should run in system mode, since
it has separate sp/lr registers. To quote ARM DDI 0100I:

> The remaining mode is System mode, which is not entered by any
> exception and has exactly the same registers available as User mode.
> However, it is a privileged mode and is therefore not subject to the
> User mode restrictions. It is intended for use by operating system
> tasks that need access to system resources, but wish to avoid using
> the additional registers associated with the exception modes. Avoiding
> such use ensures that the task state is not corrupted by the
> occurrence of any exception.

However, the processor mode has been supervisor for such a long time
(since relocation got introduced) that I would rather not touch it.

13 months agoarm: semihosting: Support semihosting fallback on 32-bit ARM
Sean Anderson [Fri, 27 Oct 2023 20:40:15 +0000 (16:40 -0400)]
arm: semihosting: Support semihosting fallback on 32-bit ARM

Add support for a semihosting fallback on 32-bit ARM. The assembly is
lightly adapted from the irq return code, except there is no offset
since lr already points to the correct instruction. The C side is mostly
like ARM64, except we have fewer cases to deal with.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
13 months agoarm: semihosting: Fix returning from traps on ARMv6 and lower
Sean Anderson [Fri, 27 Oct 2023 20:40:14 +0000 (16:40 -0400)]
arm: semihosting: Fix returning from traps on ARMv6 and lower

U-Boot runs in supervisor mode. On ARMv6 and lower, software interrupts
are taken in supervisor mode. When entering an interrupt, the link
register is set to the address of the next instruction. However, if we
are already in supervisor mode, this clobbers the link register. The
debugger can't help us, since by the time it notices we've taken a
software interrupt, the link register is already gone. Work around this
by moving the return address to another register.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
13 months agoarm: Fix software interrupt handler
Sean Anderson [Fri, 27 Oct 2023 20:40:13 +0000 (16:40 -0400)]
arm: Fix software interrupt handler

When we take a software interrupt, we are already in supervisor mode.
get_bad_stack assumes we are not in supervisor mode so it can clobber
the stack pointer. This causes us to have an invalid stack once that
macro finishes. Revert back to the get_bad_stack_swi macro which was
previously removed.

Fixes: 41623c91b09 ("arm: move exception handling out of start.S files")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
13 months agoscsi: Forceably finish migration to DM_SCSI
Tom Rini [Sat, 28 Oct 2023 00:59:51 +0000 (20:59 -0400)]
scsi: Forceably finish migration to DM_SCSI

The migration deadline for moving to DM_SCSI was v2023.04. A further
reminder was sent out in August 2023 to the remaining platforms that had
not migrated already, and that a few more over the line (or configs
deleted).

With this commit we:
- Rename CONFIG_DM_SCSI to CONFIG_SCSI.
- Remove all of the non-DM SCSI code. This includes removing other
  legacy symbols and code and removes some legacy non-DM AHCI code.
- Some platforms that had previously been DM_SCSI=y && SCSI=n are now
  fully migrated to DM_SCSI as a few corner cases in the code assumed
  DM_SCSI=y meant SCSI=y.

Signed-off-by: Tom Rini <trini@konsulko.com>
13 months agoMerge branch '2023-11-07-assorted-big-cleanups' into next
Tom Rini [Tue, 7 Nov 2023 23:33:09 +0000 (18:33 -0500)]
Merge branch '2023-11-07-assorted-big-cleanups' into next

- Merge in changes such that CONFIG_CMDLINE can be disabled and merge
  in a series that starts to remove <common.h> usage.

13 months agox86: Drop <common.h> from remaining header files
Tom Rini [Wed, 1 Nov 2023 16:28:24 +0000 (12:28 -0400)]
x86: Drop <common.h> from remaining header files

None of these header files need to include <common.h> so we can just
drop that entirely.

Signed-off-by: Tom Rini <trini@konsulko.com>
13 months agoarm: Drop <common.h> from remaining header files
Tom Rini [Wed, 1 Nov 2023 16:28:23 +0000 (12:28 -0400)]
arm: Drop <common.h> from remaining header files

None of these header files need to include <common.h> so we can just
drop that entirely.

Signed-off-by: Tom Rini <trini@konsulko.com>
13 months agosandbox: Drop <common.h>
Tom Rini [Wed, 1 Nov 2023 16:28:22 +0000 (12:28 -0400)]
sandbox: Drop <common.h>

None of these headers need <common.h> to be included, drop it.

Signed-off-by: Tom Rini <trini@konsulko.com>
13 months agoti: k3: Drop <common.h> usage
Tom Rini [Wed, 1 Nov 2023 16:28:21 +0000 (12:28 -0400)]
ti: k3: Drop <common.h> usage

None of these files need <common.h> to be included, drop it.

Signed-off-by: Tom Rini <trini@konsulko.com>
13 months agoinclude: Drop <common.h> from include lists
Tom Rini [Wed, 1 Nov 2023 16:28:20 +0000 (12:28 -0400)]
include: Drop <common.h> from include lists

At this point, we don't need to have <common.h> be included because of
properties in the header itself, it only includes other common header
files. We've also audited the code enough at this point that we can drop
<common.h> from being included in headers and rely on code to have the
correct inclusions themselves, or at least <common.h>.

Signed-off-by: Tom Rini <trini@konsulko.com>
13 months agoinclude/linux/mii.h: Add <linux/types.h>
Tom Rini [Wed, 1 Nov 2023 16:28:19 +0000 (12:28 -0400)]
include/linux/mii.h: Add <linux/types.h>

As this file uses u8/u16 we need to bring in <linux/types.h> here.

Signed-off-by: Tom Rini <trini@konsulko.com>
13 months agofsl-mc: Add prototype for bd_info
Tom Rini [Wed, 1 Nov 2023 16:28:18 +0000 (12:28 -0400)]
fsl-mc: Add prototype for bd_info

As the functions fsl_mc_ldpaa_init/fsl_mc_ldpaa_exit take a bd_info as
an argument, add a struct bd_info to this header file rather than add
<asm/u-boot.h> to the overall chain.

Signed-off-by: Tom Rini <trini@konsulko.com>
13 months agols2080aqds: Add missing headers to eth_ls1088aqds.c
Tom Rini [Wed, 1 Nov 2023 16:28:17 +0000 (12:28 -0400)]
ls2080aqds: Add missing headers to eth_ls1088aqds.c

As we call sprintf in this file we need to include vsprintf.h in order
to get the function prototype and we need linux/string.h for strcmp.

Signed-off-by: Tom Rini <trini@konsulko.com>
13 months agols1088a: Add missing headers to eth_ls1088aqds.c
Tom Rini [Wed, 1 Nov 2023 16:28:16 +0000 (12:28 -0400)]
ls1088a: Add missing headers to eth_ls1088aqds.c

As we call sprintf in this file we need to include vsprintf.h in order
to get the function prototype and we need linux/string.h for strcmp.

Signed-off-by: Tom Rini <trini@konsulko.com>
13 months agopg-wcom-ls102xa: Include <config.h> in the board file
Tom Rini [Wed, 1 Nov 2023 16:28:15 +0000 (12:28 -0400)]
pg-wcom-ls102xa: Include <config.h> in the board file

Given that this file references CFG_* defines, we need to be explicit in
our inclusion of config.h, so that these will be defined.

Reviewed-by: Aleksandar Gerasimovski <aleksandar.gerasimovski@hitacienergy.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
13 months agopowerpc: Rework <asm/fsl_lbc.h> includes
Tom Rini [Wed, 1 Nov 2023 16:28:14 +0000 (12:28 -0400)]
powerpc: Rework <asm/fsl_lbc.h> includes

This file should not include <config.h> nor should it include <common.h>
so remove both.

Signed-off-by: Tom Rini <trini@konsulko.com>
13 months agoqe: Add <asm/ppc.h> on PowerPC
Tom Rini [Wed, 1 Nov 2023 16:28:13 +0000 (12:28 -0400)]
qe: Add <asm/ppc.h> on PowerPC

This driver needs <asm/ppc.h> when building on PowerPC, add it.

Signed-off-by: Tom Rini <trini@konsulko.com>
13 months agompc85xx: Add missing include in mpc85xx_sleep.c
Tom Rini [Wed, 1 Nov 2023 16:28:12 +0000 (12:28 -0400)]
mpc85xx: Add missing include in mpc85xx_sleep.c

This file needs the include file that provides the prototypes for
flush_dcache() and others.

Signed-off-by: Tom Rini <trini@konsulko.com>