Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uboot: add support for the ODROID-C2 #75069

Merged
merged 5 commits into from Jan 8, 2020
Merged

Conversation

@lopsided98
Copy link
Contributor

@lopsided98 lopsided98 commented Dec 5, 2019

Motivation for this change

This adds support for the ODROID-C2 to U-Boot in nixpkgs. It minimizes the use of binary blobs and vendor tools. It has been tested in combination with mainline Linux 5.4.1.

The Amlogic S905 uses 5 bootloader stages. The first (bl1.bin.hardkernel) is partially placed in the MBR bootstrap code area and partially in the sector after the MBR. The rest of the stages are stored in a FIP image placed at sector 97. bl30.bin and bl301.bin are binary blobs (sources are technically available for bl301.bin, but building them is more trouble than it's worth). The other two images are ATF and U-Boot, both of which have upstream support for the SoC/board.

Hardkernel's U-Boot tree has a custom version of the fip_create tool taken from ATF. It was modified to add padding to the BL301 image (to make room for a signature) and place the BL301 image between BL30 and BL31 (ATF) with a custom UUID. BL301 needs to be signed by the aml_encrypt_gxb tool which is only provided as a binary for x86_64-linux.

Upstream ATF has replaced fip_create with fiptool. It is possible to add images with custom UUIDs using fiptool, but they are always added to the end of the file. This is a problem because the bootloader blob responsible for loading the FIP only looks at the order of the images, not their UUIDs. fiptool can be patched to place the BL301 image at the right position, but it turns out that this is not really necessary. Since the bootloader doesn't care about UUIDs, we can simply put the images in the right order with the wrong UUIDs using an unmodified fiptool. See afaerber/meson-tools#3 for more information.

The meson-tools project contains a reverse engineered version of aml_encrypt_gxb, which can be used instead.

There is an opportunity for bikeshedding here: what should the ATF package be called?

  • armTrustedFirmwareS905
  • armTrustedFirmwareAmlogicS905
  • armTrustedFirmwareMesonGxbb
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @samueldr @dezgeg @grahamc

Copy link
Member

@samueldr samueldr left a comment

I don't have the HW to verify. Otherwise looks good to me, except for the small change.

👍 It cross-compiles!

I think it's also appropriate to add yourself to the u-boot maintainers :).

pkgs/misc/uboot/default.nix Show resolved Hide resolved
lopsided98 added 4 commits Dec 5, 2019
This package currently contains fiptool, cert_create and sptool.
This supports the Amlogic S905, otherwise known as Meson GXBB.
@lopsided98 lopsided98 force-pushed the lopsided98:uboot-odroid-c2 branch from e86e3f8 to 8845809 Dec 6, 2019
@lopsided98
Copy link
Contributor Author

@lopsided98 lopsided98 commented Dec 6, 2019

I added the license and fixed the conflicts with my Rock64 changes.

@ofborg ofborg bot requested a review from samueldr Dec 6, 2019
Copy link
Member

@markuskowa markuskowa left a comment

This is great!

@samueldr samueldr merged commit 4f67905 into NixOS:master Jan 8, 2020
15 checks passed
15 checks passed
Evaluation Performance Report Evaluator Performance Report
Details
armTrustedFirmwareS905, armTrustedFirmwareTools, meson-tools, ubootOdroidC2 on aarch64-linux Success
Details
armTrustedFirmwareS905, armTrustedFirmwareTools, meson-tools, ubootOdroidC2 on x86_64-linux Success
Details
grahamcofborg-eval ^.^!
Details
grahamcofborg-eval-check-maintainers matching changed paths to changed attrs...
Details
grahamcofborg-eval-check-meta config.nix: checkMeta = true
Details
grahamcofborg-eval-darwin nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A darwin-tested
Details
grahamcofborg-eval-nixos nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release-combined.nix -A tested
Details
grahamcofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A manual
Details
grahamcofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A options
Details
grahamcofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A manual
Details
grahamcofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A tarball
Details
grahamcofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A unstable
Details
grahamcofborg-eval-package-list nix-env -qa --json --file .
Details
grahamcofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
@lopsided98 lopsided98 deleted the lopsided98:uboot-odroid-c2 branch Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.