Page MenuHomeFreeBSD

Improve U-Boot API detection
ClosedPublic

Authored by sgalabov on Feb 29 2016, 3:11 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 13 2024, 12:55 AM
Unknown Object (File)
Nov 13 2024, 12:55 AM
Unknown Object (File)
Nov 13 2024, 12:55 AM
Unknown Object (File)
Nov 13 2024, 12:29 AM
Unknown Object (File)
Oct 24 2024, 2:07 PM
Unknown Object (File)
Oct 2 2024, 9:42 PM
Unknown Object (File)
Sep 23 2024, 3:49 AM
Unknown Object (File)
Sep 18 2024, 6:02 AM
Subscribers
None

Details

Summary

Until now, ubldr has been trying to locate the U-Boot API using a hint address (U-Boot's current stack pointer), aligning it to 1MiB and going over a 3MiB (or 1MiB in case of MIPS) memory region searching for a valid API signature.

This change proposes an alternative way of doing this, namely the following:

  • both U-Boot's bootelf and go commands actually pass argc and argv to the entry point (e.g., ubldr's start function, but they should also be passed over to main() transparently)
  • so, instead of trying to go and look for a valid API signature, we look at the parameters passed to main()
  • if there's an option '-a' with argument, which is a valid hexadecimal unsigned long number (x), we try to verify whether we have a valid API signature at address x. If so - we use it. If not - we fallback to the original way of locating the API signature.

This requires the following one-line change to U-Boot's master branch as of today:
diff --git a/api/api.c b/api/api.c
index ae1160c..92dff3e 100644
--- a/api/api.c
+++ b/api/api.c
@@ -661,6 +661,7 @@ void api_init(void)
return;
}

+ setenv_hex("api_address", (unsigned long)sig);
debugf("API sig @ 0x%lX\n", (unsigned long)sig);
memcpy(sig->magic, API_SIG_MAGIC, 8);
sig->version = API_SIG_VERSION;

This makes U-Boot export an environment variable called api_address upon API initialization, which is later (see below) used as a command line parameter when starting ubldr.

For older U-Boot versions, which do not have setenv_hex() the change is similarly trivial.

Then, in order to boot, the following line:
# go ffffffff80800000
needs to be replaced with:
# go ffffffff80800000 -a ${api_address}
(the above is from a mips64el under qemu).

If we decide to go forward with this change, I will try to send it to upstream U-Boot.

Test Plan

Tested with MIPS on qemu.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sgalabov retitled this revision from to Improve U-Boot API detection.
sgalabov updated this object.
sgalabov edited the test plan for this revision. (Show Details)
sgalabov added reviewers: imp, adrian, andrew.
sgalabov set the repository for this revision to rS FreeBSD src repository - subversion.
sgalabov updated this object.
adrian edited edge metadata.

I think this is fine!

This revision is now accepted and ready to land.Feb 29 2016, 7:10 PM

Have you submitted the patch to U-Boot?

Have you submitted the patch to U-Boot?

Not yet, I am waiting to see if we would agree on it first. Moreover, U-Boot are currently in a release freeze and don't accept patches it seems. I can submit it, however.

The relevant change is now available in U-Boot's git tree as of commit 22aa61f707574dd569296f521fcfc46a05f51c48:
http://git.denx.de/?p=u-boot.git;a=commit;h=22aa61f707574dd569296f521fcfc46a05f51c48

andrew edited edge metadata.
This revision was automatically updated to reflect the committed changes.