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)
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)
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>
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>
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>
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>
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>
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>
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.
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>
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>
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.
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>
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>
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")
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>