367 Commits

Author SHA1 Message Date
Simon Glass
b64009e9a6 common: Move autoprobe out to board init
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>
(cherry picked from commit 6995f2c8be)
2025-12-21 06:01:44 -07:00
Simon Glass
e010443b06 common: Drop check for DM in initf_dm()
This is enabled by all boards, so drop the condition.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
(cherry picked from commit 70c79dc88f)
2025-12-21 05:46:50 -07:00
Simon Glass
331063acd0 malloc: Add a Kconfig option for heap protection
Add CONFIG_MCHECK_HEAP_PROTECTION option to enable mcheck heap
protection. Convert all uses of MCHECK_HEAP_PROTECTION to use the
CONFIG_ -prefixed version to work with Kconfig.

Disable this option when tracing is enabled, since the mcheck hooks (mcheck_pedantic_prehook(), etc.) interfere with function tracing.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:03 -07:00
Simon Glass
f22cc09203 malloc: Use mcheck.h header instead of local declaration
Include <mcheck.h> and remove the local declaration of
mcheck_on_ramrelocation() to use the proper header file.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:03 -07:00
Simon Glass
3df466ada2 board: Add a category for debugging
Provide a category in board_f and board_r so that log_debug() calls can
use the correct one.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-12 08:40:05 -07:00
Simon Glass
f81821c7f5 Add EVT_RESERVE_BOARD event for custom memory reservation
Add a new EVT_RESERVE_BOARD event that is triggered immediately after
the reserve_board() initcall completes during pre-relocation init. This
allows board or application code to reserve additional memory before
other reservations (global_data, fdt, etc).

The event is placed after EVT_FSP_INIT_F in the event enumeration and
is triggered in board_f.c right after the reserve_board initcall.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-12 08:40:05 -07:00
Simon Glass
01a1fa3a77 ulib: Add a flag to force use of the library
Provide a way to set the GD_FLG_ULIB flag early in boot. This is needed
where the main program cannot run first, such as where there is a
complex boot process still written in C.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-12 08:40:05 -07:00
Simon Glass
7850063907 ulib: board_f: Skip showing CPU info with ulib
When running as a library, don't show the CPU information, to avoid
printing output before the main program starts.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-12 08:40:05 -07:00
Simon Glass
03896c170e sandbox: Use a mon_len of 0 with the library
In the case of the shared/static libraries, the _end and _init symbols
are not necessarily provided since the linker script is provided by the
program which links against the U-Boot library.

In some cases the memory size can show up as less than available memory,
but enough that there is insufficient memory for U-Boot to start.

It seems better to just set the mon_len to 0 for the library.

Series-to: concept
Series-cc: heinrich

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-10 13:07:35 -06:00
Simon Glass
46e75d6234 Revert "sandbox: Avoid mon_len being larger than available RAM"
This fix turns out to be insufficient in the corner case where mon_len
is smaller than available, emulated RAM but large enough that there
isn't enough left.

This reverts commit 88b810e241.
2025-09-10 12:59:21 -06:00
Simon Glass
85674036ea ulib: Drop DRAM announcements for the library
We don't want any initial console output from the library, so check the
ULIB flag and skip any output related to DRAM.

Note that debug output is unaffected, but this is only visible if debug
is enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-04 14:23:55 -06:00
Simon Glass
88b810e241 sandbox: Avoid mon_len being larger than available RAM
With the shared library the size can be quite large. Normally sandbox
pretends that its code is mapped into emulated RAM, even though it
actually isn't.

This is fine in most cases, but when mon_len exceeds the RAM size the
reservation top starts off at a negative address (i.e. very near the top
of the address space), which immediately segfaults.

Add a special case for this, for sandbox only.

We might consider dropping this mapping altogether, as is down with
RISC-V, but that is left for further discussion.

With this, the test app boots to a prompt.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-04 14:23:55 -06:00
Simon Glass
8a698cf850 fs: Rename fs.h to fs_legacy.h
A new filesystem interface is coming, so rename the current header to
indicate that it is the old one.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 07:53:25 -06:00
Simon Glass
160269a21c global: Convert boards to use EVT_FT_FIXUP_F
Rather than using a weak function for pre-relocation devicetree-fixups,
use the new EVT_FT_FIXUP_F event.

Mark the functions as static and make a few other minor tweaks to tidy
up the code.
2025-06-08 04:58:49 -06:00
Simon Glass
13e4de7704 board_f: Move board_fix_fdt() call to renamed reloc_fdt()
We don't really need a separate initcall for this function. Move the
call to board_fix_fdt() into reloc_fdt() and rename it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-08 04:58:49 -06:00
Simon Glass
fec6fa7ead board_f: Simplify use of fdt_fixup
There are three options for the ordering of calls to fix_fdt() and
reloc_fdt() which is quite confusing:

1. OF_BOARD_FIXUP && !OF_INITIAL_DTB_READONLY
   - call fix_fdt() as soon as setup_dest_addr() is finished;
   - call reloc_fdt() after all reserve_...() calls

2. OF_BOARD_FIXUP && OF_INITIAL_DTB_READONLY
   - call reloc_fdt() and fix_fdt() immediately after reserve_fdt()

3. !OF_BOARD_FIXUP || !INITIAL_DTB_READONLY
   - call reloc_fdt() after all reserve_...() calls

It doesn't seem necessary to do things this way. Instead, we can wait
until the FDT is relocated, then do fixups if needed.

Note that OF_INITIAL_DTB_READONLY is enabled by only one board
(turris_1x_nor)

Move

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-08 04:58:49 -06:00
Simon Glass
7057f08282 x86: Correct condition for init_cache_f_r()
The condition here is reversed, which makes link and coral very slow,
leading to lab failures.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes 6182d2bdb6 ("common: board: make initcalls static")
2025-06-02 12:54:35 -06:00
Jerome Forissier
6182d2bdb6 common: board: make initcalls static
Change board_init_f(), board_init_f_r() and board_init_r() to make
static calls instead of iterating over the init_sequence_f,
init_sequence_f_r and init_sequence_r arrays, respectively. This makes
the code a simpler (and even more so when initcall_run_list() is
later removed) and it reduces the binary size as well. Tested with
xilinx_zynqmp_kria_defconfig; bloat-o-meter results:

- With LTO
add/remove: 106/196 grow/shrink: 10/28 up/down: 31548/-33829 (-2281)
Total: Before=1070471, After=1068190, chg -0.21%
- Without LTO
add/remove: 0/54 grow/shrink: 3/0 up/down: 2322/-2832 (-510)
Total: Before=1121723, After=1121213, chg -0.05%

Execution time does not change in a noticeable way.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-06-02 10:42:48 -06:00
Neha Malcom Francis
3406b9bb1c board_f: Modify DRAM message
The message "DRAM:  2 GiB (effective 32 GiB)" can be a little confusing,
modify the message s/effective/total to make it more evident.

Signed-off-by: Neha Malcom Francis <n-francis@ti.com>
2025-06-02 10:42:45 -06:00
Simon Glass
e9ff986fd0 x86: efi: Avoid calling arch_setup_gd() from jump_to_copy()
The EFI app has its own way of handling the global_data pointer,
regardless of which arch is in use. Skip the jump_to_copy() function
since it calls the arch-specific arch_setup_gd().

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-02 08:25:41 -06:00
Simon Glass
f4d8d9fff5 bloblist: Drop bloblist_maybe_init()
The bloblist is not inited any earlier in the board_f sequence now, so
drop this function. Just use bloblist_init() instead.

Series-changes: 5
- Add new patch to drop bloblist_maybe_init()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-29 17:21:36 +01:00
Simon Glass
e60873c8f3 passage: Support an incoming passage
Plumb in the ability for U-Boot proper to accept an incoming standard
passage from a previous phase, such as SPL or TF-A. This allows data to
be passed from binary to binary when firmware is booting.

Series-changes: 2
- Rebase to master
- Rework global_data for new stdpass convention

Series-changes: 3
- Move passage.h into this patch
- Add passage_valid() to decide if stdpass was provided
- Move arch_passage_entry() into this patch
- Make the global_data fields present only when needed

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-29 17:21:36 +01:00
Simon Glass
0a306683b5 efi: arm: Adjust how the monitor length is calculated
Adjust the conditions to support the EFI app when running on ARM.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2025-03-27 05:31:43 -06:00
Simon Glass
a873fec25b Revert "global_data: Drop spl_handoff"
This breaks chromebook_coral which says:

   Video: No video mode configured in FSP!

This reverts commit 2e9313179a.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-05 14:40:31 -07:00
Simon Glass
8fc28b7078 common: doc: Drop old LED support
This has been replaced with a new LED framework, so drop this old code
and documentation.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-03 06:42:29 -07:00
Tom Rini
e2032a0e4e global: Remove bi_sramstart/bi_sramsize
These fields are currently set on exactly two platforms today, and used
by only one of them. Update pic32mzdask to use CFG_SYS_SRAM* in the one
location it needs it and otherwise drop this field from the bd_info
struct.

Signed-off-by: Tom Rini <trini@konsulko.com>
2024-11-16 19:49:13 -06:00
Simon Glass
48008ec711 bootstage: Allow counting memory without strings
The bootstage array includes pointers to strings but not the strings
themselves. The strings are added when stashing, but including them in
the size calculation gives an inflated view of the amount of space used
by the array.

Update this function so it can return the amount of memory used by the
bootstage structures themselves, without the strings which they point
to.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-10-25 14:22:24 -06:00
Simon Glass
09f5be613a common: Fix up malloc() comment in reserve_noncached()
The function name has changed, so update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-25 14:22:24 -06:00
Simon Glass
456bdb70de xpl: Rename spl_phase() to xpl_phase()
Rename this function to indicate that it refers to any xPL phase.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-10-11 11:44:47 -06:00
Jonas Karlman
e83ced1a24 bootstage: Fix unstash of records from SPL
The commit b81e31a1e6 ("bootstash: Do not provide a default address
for all") changed a bootstage unstash call to bootstage stash, this
has resulted in bootstage records stashed in SPL no longer get unstaged
in U-Boot proper. Fix this by changing back to a unstage call.

Fixes: b81e31a1e6 ("bootstash: Do not provide a default address for all")
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2024-08-28 10:07:59 -06:00
Simon Glass
5aa828e3c6 global_data: Reduce the size of mon_len
This is the length of the U-Boot binary, which is typically 200-800KB
and certainly not larger than 4GB. Use a 32-bit value to save space in
global_data and move it up to be with fields of the same alignment.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-08-26 14:05:38 -06:00
Simon Glass
2e9313179a global_data: Drop spl_handoff
Provide a function to locate this information, rather than doing it
automatically on startup, to save space in global_data.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-08-26 14:05:38 -06:00
Simon Glass
e821897622 board_f: Move new_bloblist to boardf
This value is only used before relocation. Move it to the new boardf
struct.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-08-26 14:05:38 -06:00
Simon Glass
8941972854 board_f: Move new_bootstage to boardf
This value is only used before relocation. Move it to the new boardf
struct.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-08-26 14:05:38 -06:00
Simon Glass
5019d3282c board_f: Move fdt_size to board
This value is only really used before relocation. There is not much use
to showing its value in bdinfo, so drop it. Move it to the new boardf
struct.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-08-26 14:05:38 -06:00
Simon Glass
6abd992ada board_f: Add a new struct to hold pre-relocation info
Quite a few of the members of struct global_data are only used before
reloction, or have little meaning afterwards, yet they hang around in
struct global_data for the lifetime of U-Boot. This uses up precious
pre-relocation SRAM on many boards.

To help with this, start a new struct which exists only before
relocation. Move new_fdt into this new struct. Drop the display of it
in the 'bdinfo' command as it is probably not very useful.

Note that the field does not exist in SPL builds.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-08-26 14:05:38 -06:00
Simon Glass
f44fded236 global_data: Convert have_console into a flag
We don't need a full word for this boolean value. Convert it into a flag
to save space in global_data.

Reviewed-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2024-08-26 14:05:38 -06:00
Richard Weinberger
1779a58c66 bootstage: Fix out-of-bounds read in reloc_bootstage()
bootstage_get_size() returns the total size of the data structure
including associated records.
When copying from gd->bootstage, only the allocation size of gd->bootstage
must be used. Otherwise too much memory is copied.

This bug caused no harm so far because gd->new_bootstage is always
large enough and reading beyond the allocation length of gd->bootstage
caused no problem due to the U-Boot memory layout.

Fix by using the correct size and perform the initial copy directly
in bootstage_relocate() to have the whole relocation process in the
same function.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-08-15 14:35:31 -06:00
Simon Glass
0fc406ab20 upl: Plumb in universal payload to the init process
Read the UPL early in boot so that it is available. For now none of the
information is used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-08-09 16:03:20 -06:00
Tom Rini
b81e31a1e6 bootstash: Do not provide a default address for all
A valid memory location to stash bootstage information at will be
architecture dependent. Move the existing defaults to the main Kconfig
file for this option and set 0x0 as the default only for sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
2024-07-19 16:48:07 -06:00
Pali Rohár
0858e03b3d board_f: Add support for CONFIG_OF_BOARD_FIXUP for XIP images
When U-Boot is running from flash memory (execute in place) then
gd->fdt_blob before relocation points to read-only flash memory.

So U-Boot calls board_fix_fdt() with read-only gd->fdt_blob pointer which
cause immediate CPU crash when callback is trying to modify gd->fdt_blob.

Fix this issue by introducing a new config option OF_INITIAL_DTB_READONLY
which moves fix_fdt callback after the reloc_fdt callback. This makes
CONFIG_OF_BOARD_FIXUP working also if U-Boot before relocation is not
running from read/write (S)RAM memory.

This is required for mpc85xx boards when booting from flash NOR.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Mojík <marek.mojik@nic.cz>
Reviewed-by: Marek Behún <kabel@kernel.org>
2024-07-12 13:07:43 -06:00
Tom Rini
03de305ec4 Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"
As part of bringing the master branch back in to next, we need to allow
for all of these changes to exist here.

Reported-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-20 13:35:03 -06:00
Tom Rini
d678a59d2d Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay
Ethernet"' I failed to notice that b4 noticed it was based on next and
so took that as the base commit and merged that part of next to master.

This reverts commit c8ffd1356d, reversing
changes made to 2ee6f3a5f7.

Reported-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-19 08:16:36 -06:00
Tom Rini
a79fc7a79c common: Remove <common.h> and add needed includes
Remove <common.h> from all "commmon/" files and when needed add
missing include files directly.

Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-06 15:05:04 -06:00
Eugene Uriev
7bceb16106 mcheck: introduce mcheck_on_ramrelocation(.)
The using of pre-reloc/malloc_simple heap is
too hard to follow after the relocation.

So lets drop it from the pedantic registry
and switch to dlmalloc, when moved.

The offset is ignored, but kept in the API
for the probable case, when that early
heap is relocated too.

Signed-off-by: Eugene Uriev <eugeneuriev@gmail.com>
2024-04-12 16:23:06 -06:00
Stefan Bosch
d819250c2a common: board_f: change calculation of gd->mon_len to fix s5p4418 reloc
ARCH_NEXELL: Change calculation of monitor length (gd->mon_len) to fix
relocation at boards with s5p4418-SoC (ARCH_NEXELL). At s5p4418, _start
is after the header (NSIH). Therefore the monitor length has to be
calculated using __image_copy_start instead of _start in order the
whole monitor code is relocated.

Signed-off-by: Stefan Bosch <stefan_b@posteo.net>
2024-03-01 18:34:08 -05:00
Raymond Mao
1ef43f3bf2 bloblist: refactor of bloblist_reloc()
The current bloblist pointer and size can be retrieved from global
data, so we don't need to pass them from the function arguments.
This change also help to remove all external access of gd->bloblist
outside of bloblist module.

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-02-29 09:24:22 -05:00
Devarsh Thakkar
eefe23c127 video: Skip framebuffer reservation if already reserved
Skip framebufer reservation if it was already reserved from previous
stage and whose information was passed using a bloblist.

Return error in case framebuffer information received from bloblist is
invalid i.e NULL or empty.

While at it, improve the debug message to make it more clear that
address in discussion is of framebuffer and not bloblist and also match
it with printing scheme followed in video_reserve function.

Signed-off-by: Devarsh Thakkar <devarsht@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-01-29 14:49:17 -05:00
Devarsh Thakkar
4ef9c77248 common/board_f: Catch bloblist before starting reservations
Start reservations needed for init sequence only after catching
bloblists from previous stage.

This is to avoid catching bloblists in the middle causing gaps while
u-boot is reserving.

Adjust the relocaddr as per video hand-off information received from
previous stage so that further reservations start only after regions
reserved for previous stages

Skip reservation for video memory if it was already filled by a
bloblist.

Signed-off-by: Devarsh Thakkar <devarsht@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-01-29 14:49:17 -05:00
Simon Glass
3d6531803e bloblist: Support initing from multiple places
Typically the bloblist is set up after the devicetree is present. This
makes sense because bloblist may use malloc() to allocate the space it
needs.

However sometimes the devicetree itself may be present in the bloblist.
In that case it is at a known location in memory so we can init the
bloblist very early, before devicetree.

Add a flag to indicate whether the bloblist has been inited. Add a
function to init it only if needed. Use that in the init sequence.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-06 14:38:13 -04:00