Commit graph

98975 commits

Author SHA1 Message Date
Simon Glass
b4a3ebe304 x86: Rename the _D dirty flag
This value happens to be used by ctype.h so chose a different name.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:55 -06:00
Simon Glass
ffd92a25be x86: Use a simple jump into long mode
With the 64-bit descriptor we can use a jump instruction, rather than
pushing things on the stack.

Since the processor is in 64-bit mode by this point, pop a 64-bit value
from the stack, containing the target address.

This simplifies the code slightly, in particular its use of the stack.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:55 -06:00
Simon Glass
f5b1c643b4 x86: Use the same GDT when jumping to long mode
Make use the existing GDT which now includes entries for 64-bit code.
Leave the interrupt descriptors alone. They can be tidied up once U-Boot
starts up.

With this, kvm mode works with QEMU.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/31
2025-04-03 11:41:55 -06:00
Simon Glass
f5f1ed8ae7 x86: Disable paging before changing to long mode
This is required as part of the procedure. The existing code works
because it changes the GDT at the same time, but this makes kvm
unhappy.

Update the algorithm to disable and then re-enable paging.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:55 -06:00
Simon Glass
3c7ab12249 x86: Tidy up the GDT size in start/16.S
Use a symbol to select the size of the GDT, rather than hard-coding a
value. This matches how it is done in start64

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:55 -06:00
Simon Glass
aae07e3df8 x86: Include stdbool.h in interrupt header
This makes use of a 'bool' type, so include the required header.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:55 -06:00
Simon Glass
1111d92360 x86: Drop the message about features missing in 64-bit
This functions normally and has done for a while, so drop this scary
message.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:55 -06:00
Simon Glass
e93da0399c x86: spl: Drop duplicate CPU init
x86_cpu_init_f() is called by arch_cpu_init() a few lines below this
code. Drop the duplicate call.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:55 -06:00
Simon Glass
912e32d34f x86: Use defines for the cache flags
Use some named flags when setting up the cache, so it is easier to see
what is going on.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:55 -06:00
Simon Glass
66f0dcb07f x86: Add 64-bit entries to the GDT
At present it is not possible to execution 64-bit code without
installing an entire new Global Descriptor Table. This is inconvenient
since kvm does not seem to like switching into long mode with a new
table.

It isn't actually necessary, since we can just extend the existing
table. Add some new entries to this effect.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:55 -06:00
Simon Glass
899ab6cd52 x86: Avoid clearing the VESA display
U-Boot clears the display when it starts up, so there is no need to ask
the VESA driver to do this. Fix this and add a comment explaining the
flags.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:55 -06:00
Simon Glass
a9ba0080db x86: Drop use of CONFIG_REALMODE_DEBUG
This option is not actually defined in Kconfig anymore. Use a normal
debug print instead, which has a similar effect.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2025-04-03 11:41:55 -06:00
Simon Glass
22c434b0fb x86: Add some log categories
Add categories for i8259 and bios files, so that log statements have the
right category.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:55 -06:00
Simon Glass
05b8f8a95d x86: Drop mpspec from the SPL build
This is not needed in SPL, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:55 -06:00
Simon Glass
6f18c59315 x86: qemu: Avoid accessing BSS too early
BSS is placed in DRAM which is actually available early with QEMU. But
it is cleared by the init sequence, so values stored there are lost.

Move the system-type flag into a function, instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:55 -06:00
Simon Glass
6f30ae6cd6 x86: qemu: Enable dhrystone
Provide the 'dhry' command, which helps to check that kvm is being used
properly with QEMU.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:55 -06:00
Simon Glass
515d4ee339 x86: qemu: Switch to bochs display
The vesa display is widely used on hardware, but it is a bit of a pain
with QEMU. It requires executing option ROMs, which either doesn't work
with kvm, or is difficult to do in a kvm/QEMU-friendly way.

THe bochs display is probably better anyway, so switch to that. It works
fine with kvm as it doesn't need an option ROM.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/31
2025-04-03 11:41:55 -06:00
Simon Glass
e95bc5e929 x86: Expand x86_64 early memory
The SPL and pre-reloc malloc()-space is not large enough to start up
with a display. Expand it.

Switch the order of SPL_SYS_MALLOC_F_LEN and SPL_TEXT_BASE since this
matches what 'savedefconfig' gives us.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:54 -06:00
Simon Glass
96aa0719b7 sandbox: Correct a typo in mapmem
This should say 'cast', not 'case', so fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03 11:41:54 -06:00
Tom Rini
39ff722b3e Merge patch series "acpi_table: Fix IORT RC node"
This series from Patrick Rudolph <patrick.rudolph@9elements.com> brings
in an assortment of ACPI related fixes.

Link: https://lore.kernel.org/r/20250316083300.2692377-1-patrick.rudolph@9elements.com
2025-04-03 11:38:22 -06:00
Patrick Rudolph
636b62c265 test: acpi: Add IORT tests
Add tests for IORT table generation:
- SMMU_V3 node
- RC node

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2025-04-03 11:38:14 -06:00
Patrick Rudolph
9c74857640 acpi: Conditionally set mapping_offset in IORT
The spec recommends to set the mapping_offset only when there are
ID mappings as indicated by the mapping_count field.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2025-04-03 11:38:14 -06:00
Patrick Rudolph
fe8844f4ad acpi: Clear reserved bits in IORT
The IORT spec says that reserved bits must be set to zero, thus clear
all fields of the struct before starting to fill out non-reserved
fields.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2025-04-03 11:38:14 -06:00
Patrick Rudolph
0ae343239b acpi_table: Add asserts in IORT
Check that the provided offsets are really pointing to a node
that have been previously written and are of the correct type.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2025-04-03 11:38:14 -06:00
Patrick Rudolph
92d448f4f1 acpi_table: Fix IORT RC node
Even though the RC node has the correct size and the ID mappings
are written to the end of the node, the ID 'mapping offset' and
'mapping count' are not written in the IORT RC node header, thus it
looks like that the RC node has no ID mappings.
The Linux kernel doesn't complain about the invalid IORT RC node,
even though the spec says that each RC node must have an ID mapping.
The kernel will fail to use MSI IRQs and fall back to a legacy IRQ
mechanism that's not working either.
Finally it will show strange behaviour around PCI interrupts, making it
hard to trace back to an invalid IORT RC nodes.

Add the missing ID mapping count and mapping offset.

TEST: Fixes IRQ usage of PCI devices on qemu/sbsa-ref.
Fixes: bf5d37662d "acpi: acpi_table: Add IORT support"

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2025-04-03 11:38:14 -06:00
Tom Rini
ccb3826054 Merge patch series "Introduce J742S2 SoC and EVM"
Manorit Chawdhry <m-chawdhry@ti.com> says:

The series adds support for J742S2 family of SoCs. Also adds J742S2 EVM
Support and re-uses most of the stuff from the superset device J784s4.

This device is a subset of J784S4 and shares the same memory map and
thus the code is being reused from J784S4 to avoid duplication.

It initially cleans up the J784s4 and AM69 files so that they can be
re-usable for j742s2 and then it introduces J742S2.

The DT for the following SoC will be coming to U-boot during 6.13 Sync
so the series is kept as RFC till then.

Here are some of the salient features of the J742S2 automotive grade
application processor:

The J742S2 SoC belongs to the K3 Multicore SoC architecture platform,
providing advanced system integration in automotive, ADAS and industrial
applications requiring AI at the network edge. This SoC extends the K3
Jacinto 7 family of SoCs with focus on raising performance and
integration while providing interfaces, memory architecture and compute
performance for multi-sensor, high concurrency applications.

Some changes that this devices has from J784S4 are:
* 4x Cortex-A72 vs 8x Cortex-A72
* 3x C7x DSP vs 4x C7x DSP
* 4 port ethernet switch vs 8 port ethernet switch
* 2 DDR controller vs 4 DDR controller

Test logs:
https://gist.github.com/manorit2001/f7df0e8cca1e9973b4361f0559c6f53d

Link: https://lore.kernel.org/r/20250317-b4-upstream-j742s2-v4-0-4ba88bfd357a@ti.com
2025-04-03 11:37:57 -06:00
Manorit Chawdhry
fe36b22c32 configs: Introduce configs for J742S2
Based off j784s4 configs with delta changes for J742S2

[ Add AVS support for J742S2 ]

Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2025-04-03 11:37:46 -06:00
Manorit Chawdhry
45d056e275 arm: dts: Introduce J742S2 U-boot DTS files
Include the U-boot device tree files needed to boot the board.

[ DDR config ]

Signed-off-by: Neha Malcom Francis <n-francis@ti.com>
Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2025-04-03 11:37:46 -06:00
Manorit Chawdhry
4c31c0a4dd board: ti: Introduce basic board files for the J742S2 family
Introduce the basic files needed to support the TI J742S2 family of SoCs.

Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2025-04-03 11:37:46 -06:00
Manorit Chawdhry
dd837d6c88 arm: mach-k3: j742s2: Introduce clock and device files for J742S2 SoC
Re-use j784s4 clocks and power domains for j742s2 family of device.

Reviewed-by: Udit Kumar <u-kumar1@ti.com>
Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2025-04-03 11:37:46 -06:00
Manorit Chawdhry
201b08702e soc: Add information to identify the J742S2 SoC family
J742S2 has the same part number as J784S4 but JTAG_DEVICE_ID has a
PKG bit that tells about J742S2.

Add support for reading JTAG_DEVICE_ID and set family as J742S2 based
on that.

Link: https://www.ti.com/lit/pdf/spruje3 (TRM)
Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2025-04-03 11:37:46 -06:00
Manorit Chawdhry
61b6b2fcc9 arm: dts: k3-j784s4-ddr: Refactor J784s4 ddr file to a common file
Refactor J784s4 ddr file to a common file which uses the
superset device to allow reuse in j742s2-evm which uses the subset part.

Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2025-04-03 11:37:45 -06:00
Neha Malcom Francis
9e1295917e arm: dts: k3-j784s4-binman.dtsi: Clean up and templatize boot binaries
Clean up templatized boot binaries for j784s4 soc. This includes
modifying the k3-j784s4-binman.dtsi to use SPL_BOARD_DTB,
BOARD_DESCRIPTION and UBOOT_BOARD_DESCRIPTION from the files that
include it to further reuse code.

k3-j784s4-binman.dtsi will contain only templates. Only required boot
binaries can be built from the templates in the boards' respective
-u-boot.dtsi file (or k3-<board>-binman.dtsi if it exists). This allows
clear distinction between the SoC common stuff vs. what is additionally
needed to boot up a specific board.

Signed-off-by: Neha Malcom Francis <n-francis@ti.com>
[ Do it only for j784s4 ]
Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2025-04-03 11:37:45 -06:00
Neha Malcom Francis
42ce9ed7ff tools: binman: control.py: Delete template nodes after parsing
Dynamically going through the subnode array and deleting leads to
templates being skipped from deletion when templates are consecutive in
the subnode list. Prevent this from happening by first parsing the DT
and then deleting the nodes. Add a testcase as well for this cornercase.

Signed-off-by: Neha Malcom Francis <n-francis@ti.com>
2025-04-03 11:37:45 -06:00
Tom Rini
82b69fc422 Pull request efi-2025-04-rc6
Documentation:
 
 * correct references to overlay-fdt-boot.txt
 * build: docker: Fix code highlighting syntax
 * build: docker: Use code-block for syntax highlighting
 * Fix typo bootfloe to bootflow
 
 UEFI:
 
 * Correct the size of the AcpiReclaimMemory region for ACPI tables
   when using QFW
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEK7wKXt3/btL6/yA+hO4vgnE3U0sFAmfuRW4ACgkQhO4vgnE3
 U0uw0RAApYLbEkSIoosE1riOoq+VR0HF8jH59hpCLxgGEaNxP4nISyoQeNlnp9Np
 2uO/gyBVv5ZObKlaEG38vfbAhySbLQECB2efz1WnJ0axPFxtPhyTi66VdAP2EB/b
 JS3ygyGRJqGr9pk8XViXMiNjp9q0D/2JwU3aHGKKaX95BTg+7uZSYcmSdzZdLKQN
 auB5dFuADE7ZBXQe0MEaOndgjLrDn74SWejYstJcHYWI5xAm8DlOmfoLRT2pNITr
 uWPtmt/+PZ8x+HDKtuKYzDD0XXwH77PVS4mDUztXhYFEZWoY0q+vdtL2chti9LPg
 H2u3fH3K4grAMCLFbLseAbYjCQ4CUhbZmy8x7Qu++D5Jjfa3Oc63QzM2ueYOg3Vv
 PveaD4nfToy4kAWGIRyG2aZYJrVy7MNpHtfyVfqWIgooBkSxV6RjOmJrB15fYN0G
 V4tUox8zYQHA7Dz2VpIM2ErplTAMNiaS4dPFFXpfqD42vj126aqVjlXh7TrO7g8+
 eSdlv003FYyTjY/i6cMxhsCjZ83lldnNqtRww6g4r+P7KF+VAGKg8ViFEQY2HR6L
 gSqi3mQKYhKTaU7z74cdoTdD6C+1iyOnNfjb74fYZMiCG9i7AeH4CV9mnohfrnCo
 aD6kBu2A7vT3IRsuVCmClQTkvyYz1cjkIUFSqY/k1E7cm9kgIGE=
 =vXm2
 -----END PGP SIGNATURE-----

Merge tag 'efi-2025-04-rc6' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request efi-2025-04-rc6

CI:

* https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/25491

Documentation:

* correct references to overlay-fdt-boot.txt
* build: docker: Fix code highlighting syntax
* build: docker: Use code-block for syntax highlighting
* Fix typo bootfloe to bootflow

UEFI:

* Correct the size of the AcpiReclaimMemory region for ACPI tables
  when using QFW
2025-04-03 07:31:28 -06:00
Tom Rini
ce09def8ab First set of u-boot-at91 fixes for the 2025.04 cycle
-----BEGIN PGP SIGNATURE-----
 
 iQFNBAABCgA3FiEEqxhEmNJ6d7ZdeFLIHrMeAg6sL8gFAmfuKp8ZHGV1Z2VuLmhy
 aXN0ZXZAbGluYXJvLm9yZwAKCRAesx4CDqwvyD60B/wMYR1UooMXWyuJw6a2us+O
 ECzYJGyDHe1GixYTLADPPrju/O0Mj/Xh1dy8FPEZNgU0WWVPTWO9Of7lx4mgLvm4
 zgm1VvNxmRUFtMVPPz4CvYCimcF07FGMwEc/2zIidzLa0SA3uQuBlXQrtG/BjV3w
 CTkeOaBrEkslAPYRPWTQEo0DaRFP1zB0Xgxz4xrxq0OuWyiM+Hid0q8rKwXJ/VP1
 XpJBftNbj6OhteAC4h9YJuaxR2D3oIEuX6BncAHgcFJMrRs7Zn46SyG72dGO506y
 Am1RDZ7A+PWAM7Xzt7WzHpZwhoQbrI2xISfBEFGOGzqpfAkjtIy1HsjI0Gh8oFOp
 =IQHC
 -----END PGP SIGNATURE-----

Merge tag 'u-boot-at91-fixes-2025.04-a' of https://source.denx.de/u-boot/custodians/u-boot-at91

First set of u-boot-at91 fixes for the 2025.04 cycle:

- A single fix for the reset command on sama5d27 boards.
2025-04-03 07:27:33 -06:00
Andrew Davis
7871285a0a doc: Fix typo bootfloe to bootflow
Signed-off-by: Andrew Davis <afd@ti.com>
2025-04-03 09:06:51 +02:00
Heinrich Schuchardt
e66148060f doc: correct references to overlay-fdt-boot.txt
doc/uImage.FIT/overlay-fdt-boot.txt does not exist anymore.
Reference the correct section of doc/usage/fit/overlay-fdt-boot.rst.

Fixes: 6f6e8bb695 ("doc: Bring in the FIT overlay information")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-04-03 09:05:29 +02:00
Leonard Anderweit
4738e306fd doc: build: docker: Use code-block for syntax highlighting
Use ..code-block:: syntax highlighting instead of :: so all bash
commands use the same syntax highlighting.

Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
2025-04-03 09:04:35 +02:00
Leonard Anderweit
e763c19507 doc: build: docker: Fix code highlighting syntax
Remove double :: before .. code-block:: bash to correctly highlight the
following commands.

Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
2025-04-03 09:04:35 +02:00
Ilias Apalodimas
37a33d326e acpi: Fix table length for QEMU
The end of the ACPI table is set to 'addr' instead of 'end'. The ACPI
code for QEMU relies on those values to mark memory as 'ACPI Reclaim'
and as a result the ACPI RSDP ends up in Boot services Data.

Reported-by: Björn Töpel <bjorn@kernel.org>
Fixes: commit 638cc36348 ("acpi: enable writing ACPI tables on QEMU")
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-04-03 08:58:27 +02:00
Peter Robinson
f59fb9846c arm64: Add MIDR entries for Cortex-A55, A73 and A75
Add MIDR entries for Cortex-A55, Cortex-A73 and
Cortex-A75 cores and update the is_coretex_a entries.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
2025-04-02 20:02:27 -06:00
Tom Rini
0a174922c6 Merge patch series "fs: exfat: Add exfat port based on exfat-fuse"
Marek Vasut <marex@denx.de> says:

Import exfat-fuse libexfat, add U-Boot filesystem layer porting glue
code and wire exfat support into generic filesystem support code. This
adds exfat support to U-Boot.

Fill in generic filesystem interface for mkdir and rm commands.
Make filesystem tests test the generic interface as well as exfat,
to make sure this code does not fall apart.

Link: https://github.com/relan/exfat/commits/0b41c6d3560d ("CI: bump FreeBSD to 13.1.")
Link: https://lore.kernel.org/r/20250317031418.223019-1-marex@denx.de
2025-04-02 20:01:14 -06:00
Marek Vasut
8d0cc62a60 test_fs: Add exfat tests
Add tests for the exfat filesystem. These tests are largely an
extension of the FS_GENERIC tests with the following notable
exceptions.

The filesystem image for exfat tests is generated using combination
of exfatprogs mkfs.exfat and python fattools. The fattols are capable
of generating exfat filesystem images too, but this is not used, the
fattools are only used as a replacement for dosfstools 'mcopy' and
'mdir', which are used to insert files and directories into existing
fatfs images and list existing fatfs images respectively, without the
need for superuser access to mount such images.

The exfat filesystem has no filesystem specific command, there is only
the generic filesystem command interface, therefore check_ubconfig()
has to special case exfat and skip check for CONFIG_CMD_EXFAT and
instead check for CONFIG_FS_EXFAT.

Signed-off-by: Marek Vasut <marex@denx.de>
2025-04-02 20:00:59 -06:00
Marek Vasut
99b976712b configs: sandbox: Enable exfat support
Enable exfat support in sandbox and sandbox64 to assure build and
test coverage of this filesystem on both 32bit and 64bit builds.

Signed-off-by: Marek Vasut <marex@denx.de>
2025-04-02 20:00:59 -06:00
Marek Vasut
2375f713a2 fs: exfat: Demote filesystem detection failure message to debug()
Demote "exFAT file system is not found" message to debug(). This is
printed when U-Boot attempts to auto-detect the filesystem via generic
filesystem API by attempting to mount the device, and fails to do so
because there is another filesystem in place. The libexfat-fuse code
prints this an error, which interferes with 'test_gpt' test. Demote
the message to debug().

Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Marek Vasut <marex@denx.de>
2025-04-02 20:00:59 -06:00
Marek Vasut
74eb84686f fs: exfat: Fix conversion overflow errors
Fix the following conversion overflow errors. The UTF8-to-UTF16
conversion is done through 32bit wchar_t, but U-Boot codebase is
built with -fshort-wchar which limits wchar_t to 16bit. Replace
the built-in wchar_t with u32 to assure the intermediate type is
32bit.

"
fs/exfat/utf.c: In function ‘utf8_to_wchar’:
fs/exfat/utf.c:165:23: warning: overflow in conversion from ‘int’ to ‘wchar_t’ {aka ‘short unsigned int’} changes value from ‘(int)(short unsigned int)*input << 18 & 1835008’ to ‘0’ [-Woverflow]
  165 |                 *wc = ((wchar_t) input[0] & 0x07) << 18;
      |                       ^
fs/exfat/utf.c:170:23: warning: overflow in conversion from ‘int’ to ‘wchar_t’ {aka ‘short unsigned int’} changes value from ‘(int)(short unsigned int)*input << 24 & 50331648’ to ‘0’ [-Woverflow]
  170 |                 *wc = ((wchar_t) input[0] & 0x03) << 24;
      |                       ^
fs/exfat/utf.c:175:23: warning: overflow in conversion from ‘int’ to ‘wchar_t’ {aka ‘short unsigned int’} changes value from ‘(int)(short unsigned int)*input << 30 & 1073741824’ to ‘0’ [-Woverflow]
  175 |                 *wc = ((wchar_t) input[0] & 0x01) << 30;
      |                       ^
"

Signed-off-by: Marek Vasut <marex@denx.de>
2025-04-02 20:00:59 -06:00
Marek Vasut
b86a651b64 fs: exfat: Add U-Boot porting layer
Add U-Boot adjustments to the libexfat code and integrate
the result into U-Boot filesystem layer. This provides full
read-write exfat support for U-Boot available via generic
filesystem interface.

FS_DIRENT_NAME_LEN is increased to 1024 in case exfat is
enabled, because EXFAT can use UTF16 names, which do not
fit into current FS_DIRENT_NAME_LEN. To avoid affecting
every configuration, increase FS_DIRENT_NAME_LEN only in
case EXFAT is enabled.

Example usage via sandbox, assuming disk.img with one exfat partition:

Drive info:
$ ./u-boot -Tc 'host bind 0 ../disk.img ; host info 0'
dev       blocks  blksz label           path
  0       262144    512 0               ../disk.img

List files:
$ ./u-boot -Tc 'host bind 0 ../disk.img ; ls host 0:1 /api'
      475   Kconfig
      230   Makefile
     1873   README
     ...
10 file(s), 0 dir(s)

Load and checksum a file:
$ ./u-boot -Tc 'host bind 0 ../disk.img ; load host 0:1 $loadaddr .config ; \
                crc32 $loadaddr $filesize'
56724 bytes read in 1 ms (54.1 MiB/s)
crc32 for 00000000 ... 0000dd93 ==> b2e847c9

$ crc32 .config
b2e847c9

Load .config file to RAM, store the file into FS as /newconfig,
load the /newconfig into RAM and checksum the file:
$ ./u-boot -Tc 'host bind 0 ../disk.img ; load host 0:1 $loadaddr .config ; \
		save host 0:1 $loadaddr /newconfig $filesize ; \
		load host 0:1 0x10000 /newconfig ; \
		crc32 0x10000 $filesize'
56724 bytes read in 1 ms (54.1 MiB/s)
56724 bytes written in 0 ms
56724 bytes read in 0 ms
crc32 for 00010000 ... 0001dd93 ==> b2e847c9

Remove file 3.txt and create new directory /newdir:
$ ./u-boot -Tc 'host bind 0 ../disk.img ; ls host 0:1 / ; \
                rm host 0:1 3.txt ; mkdir host 0:1 /newdir ; \
		ls host 0:1 /'
...
        0   1.txt
        0   2.txt
        0   3.txt
        0   4.txt
        0   5.txt

7 file(s), 4 dir(s)
...
        0   1.txt
        0   2.txt
            newdir/
        0   4.txt
        0   5.txt

6 file(s), 5 dir(s)

Acked-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Marek Vasut <marex@denx.de>
2025-04-02 20:00:59 -06:00
Marek Vasut
88c1acd357 fs: exfat: Import libexfat from fuse-exfat
Import most of libexfat from [1] except for log.c verbatim. The code
does not even compile and further adjustments and integration into
U-Boot filesystem code is in the next patch.

[1] https://github.com/relan/exfat
    0b41c6d3560d ("CI: bump FreeBSD to 13.1.")

Acked-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Marek Vasut <marex@denx.de>
2025-04-02 20:00:59 -06:00
Marek Vasut
9e0e0ff260 fs: Add generic fs_devread() implementation
Add generic implementation of write into a block device to be used
by filesystem implementations. This is a pair function for already
existing fs_devread().

Signed-off-by: Marek Vasut <marex@denx.de>
2025-04-02 20:00:59 -06:00