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: init (firmwareOdroidC2/C4, ubootOdroidC4) Hardkernel's Odroid C4 and Odroid C2 board support, drop Armbian dependency #101454

Closed
wants to merge 11 commits into from

Conversation

arapov
Copy link
Contributor

@arapov arapov commented Oct 23, 2020

Motivation for this change

This enables Odroid C4 board in NixOS with Linux kernel version 5.8+.
Also retires dependency on 3rd-party repository from Armbian.

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 nixpkgs-review --run "nixpkgs-review wip"
  • Tested Odroid C2/C4 actually boots from produced u-boot.
  • Odroid C4 boot from SD tested.
  • Odroid C4 boot from eMMC tested.
  • Odroid C2 boot from SD tested.
  • Odroid C2 boot from eMMC tested.
  • Fits CONTRIBUTING.md.

@arapov
Copy link
Contributor Author

arapov commented Oct 23, 2020

fyi, booting from eMMC on OdroidC2 is failing for me in u-boot v2020.07 and v2020.10. Though works flawlessly in v2020.04. I am triaging it and working on a fix right now.

@arapov
Copy link
Contributor Author

arapov commented Oct 23, 2020

fyi, booting from eMMC on OdroidC2 is failing for me in u-boot v2020.07 and v2020.10. Though works flawlessly in v2020.04. I am triaging it and working on a fix right now.

this is the commit which breaks eMMC for OdroidC2:
https://gitlab.denx.de/u-boot/u-boot/-/commit/dd5f2351e99aad8fcbedbc1305b8b51b09952336

looking into...

@arapov
Copy link
Contributor Author

arapov commented Oct 23, 2020

fyi, booting from eMMC on OdroidC2 is failing for me in u-boot v2020.07 and v2020.10. Though works flawlessly in v2020.04. I am triaging it and working on a fix right now.

this is the commit which breaks eMMC for OdroidC2:
https://gitlab.denx.de/u-boot/u-boot/-/commit/dd5f2351e99aad8fcbedbc1305b8b51b09952336

looking into...

This is the line from the patch that breaks eMMC:
https://gitlab.denx.de/u-boot/u-boot/-/blob/master/arch/arm/dts/meson-gxbb.dtsi#L411

I will send out patch to respective upstreams.

pkgs/misc/uboot/default.nix Outdated Show resolved Hide resolved
pkgs/misc/uboot/default.nix Outdated Show resolved Hide resolved
pkgs/misc/uboot/hardkernel-firmware.nix Show resolved Hide resolved
pkgs/misc/uboot/hardkernel-firmware.nix Show resolved Hide resolved
pkgs/misc/uboot/hardkernel-firmware.nix Show resolved Hide resolved
pkgs/misc/uboot/default.nix Outdated Show resolved Hide resolved
@arapov
Copy link
Contributor Author

arapov commented Oct 27, 2020

FYI, discussion for the possible eMMC fix: https://groups.io/g/u-boot-amlogic/topic/meson_gxbb_regression_since/77816805
@lopsided98, thanks for comments, I should have a time next week to address all the notes.

@ofborg ofborg bot requested a review from samueldr November 14, 2020 11:05
@arapov
Copy link
Contributor Author

arapov commented Nov 14, 2020

I decided to keep the odroid-c4 hack in git history, so that it is more clear what has actually happened in mmc driver for gx/sm1 boards.

pkgs/misc/uboot/default.nix Outdated Show resolved Hide resolved
@arapov arapov changed the title RFC: uboot: init Hardkernel Odroid C4 board and drop Armbian deps for Odroid C2 board uboot: init (firmwareOdroidC2/C4, ubootOdroidC4) Hardkernel's Odroid C4 board support, drop Armbian dependency Dec 15, 2020
@arapov
Copy link
Contributor Author

arapov commented Dec 16, 2020

All the initial hacks were fixed and fixes are cherry-picked. Fixes are in staging for 2021.01 release.

Copy link
Contributor

@sbruder sbruder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After changing the u-boot source hash (see inline comment) and erasing petitboot from the SPI flash as described here, this successfully booted on my Odroid HC4 (compatible with Odroid C4).

Thank you!

pkgs/misc/uboot/hardkernel-firmware.nix Outdated Show resolved Hide resolved
@arapov
Copy link
Contributor Author

arapov commented Feb 5, 2021

@lopsided98, could you check this patchset please. I will be happy to see this merged eventually. :-)

Copy link
Contributor

@lopsided98 lopsided98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I successfully tested this with my ODROID-C2. This looks good except for the two suggestions.

pkgs/misc/uboot/hardkernel-firmware.nix Outdated Show resolved Hide resolved
pkgs/misc/uboot/default.nix Outdated Show resolved Hide resolved
@arapov
Copy link
Contributor Author

arapov commented Feb 9, 2021

@lopsided98, thanks for the ACK. Could you point me to a document that describes the process of getting this code merged? Or explain it here briefly. I am new to nixos development model, need to close some gaps.

ssia

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
Odroid C4: Cortex-A55 CPU, Mali-G31 GPU.
More data: https://wiki.odroid.com/odroid-c4/

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
Retire dependency on Armbian provided board blobs.
Use official hardkernel's ones instead.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
u-boot 2021.01 was released, required patches to run hardkernel's boards
are no longer needed as they made the release.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This solves repo pinpointing to particular commit number, thus prevents
failing builds when the repos are updated.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
an open alternative to aml_encrypt_g12a and aml_encrypt_g12b.
Proprietary tool is not available for aarch64 architecture, which is a
show stopper for building u-boot images for the boards like Odroid C4.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This makes aarch64 builds possible.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
as per review request

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
postPatch should be used because prePatch breaks patches put in patches.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
@arapov
Copy link
Contributor Author

arapov commented Apr 13, 2021

@samueldr , yeah I will give your branch a test and soaking time. thanks!

@samueldr
Copy link
Member

samueldr commented Apr 13, 2021

I force-pushed the minor fixes to the branch. For transparency, one of the builder functions didn't install the README.md file, and I ended up not deleting the python and sh helpers from the firmware files, as they do things not done with the other tools.

I also opened #119371 which will build on top of those changes.


I am inclined to think the changes are correct and desirable in Nixpkgs. I would simply append those commits on this PR, without squashing anything currently observable. The whole trail is AFAIK buildable. At least for my changes. It clearly shows how it went from the original builds to the final builds.

Any other U-Boot maintainers (e.g. @lopsided98) have opinions here?

Note that it is my understanding that we probably won't really be able to replace those early init blob ever. Though BL31 may, at some point, we'll see.

@arapov
Copy link
Contributor Author

arapov commented Apr 14, 2021

@samueldr, ssd in my laptop has died. waiting for a replacement, till then I'm not able to build/test the u-boot images.
I tried to build it on my Mac and it fails, and I'm not sure I want to look into it. :-)

@erdnaxe
Copy link
Contributor

erdnaxe commented Aug 10, 2021

I am able to boot my Odroid HC4 with this PR, it works perfectly!

My Odroid HC4 is now running NixOS 21.05 using https://github.com/NixOS/nixpkgs/blob/nixos-21.05/nixos/modules/installer/sd-card/sd-image-aarch64-new-kernel-installer.nix and I removed Petitboot (instructions on https://www.armbian.com/odroid-hc4/).

@Patagonicus
Copy link
Contributor

Can confirm that this works on the HC4. For anyone trying to reproduce this:

  1. Flash https://hydra.nixos.org/build/151751284 to an sdcard.
  2. Check out this pull request, currently at 7cf5a0e, nix-build . -A pkgsCross.aarch64-multiplatform.ubootOdroidC4, then ./result/sd_fusing.sh $SDCARDDEV.
  3. Hold down the button on the underside of the HC4 while you plug in the power, which will bypass the petitboot boot loader in the SPI flash and instead load the u-boot from the Micro-SD card.

Once you've confirmed that NixOS boots successfully and you won't need Ubuntu anymore, you can also erase petitboot, which remove the need for pressing the button, see https://nixos.wiki/wiki/NixOS_on_ARM/ODROID-HC4#Petitboot_removal.

Unfortunately with that image I don't get any output on HDMI or UART, but I was able to use the Hardkernel Ubuntu image to rebuild the image with a password for nixos set, which allowed SSH login: check out 8a2ec31, modify nixos/modules/installer/sd-card/sd-image-aarch64-new-kernel-installer.nix to set the password, then build via nix-build nixos -I nixos-config=nixos/modules/installer/sd-card/sd-image-aarch64-new-kernel-installer.nix -A config.system.build.sdImage.

Currently trying to see if the Hardkernel kernel will make HDMI and/or UART work. Basing my kernel package off of https://github.com/considerate/nixos-odroidhc4/tree/983c146bc7d1d05594e04f99e808b0a661ed80bd/overlays/kernel for that. That should also hopefully make SATA work (didn't test it with a drive, but at least dmesg and lspci do not show anything with mainline kernel; https://nixos.wiki/wiki/NixOS_on_ARM/ODROID-HC4 also notes that SATA is not working).

@erdnaxe
Copy link
Contributor

erdnaxe commented Sep 4, 2021

Unfortunately with that image I don't get any output on HDMI

In my case I was able to get HDMI working with a standard 1080p screen, following your method.

SATA is not working on my side (lspci output is empty).

@considerate
Copy link
Member

SATA is not working on my side (lspci output is empty).

SATA works for me if I update to a more recent version of uboot and use the odroid-hc4_defconfig file which includes SCSI=y and SATA=y.

https://github.com/u-boot/u-boot/blob/v2022.04/configs/odroid-hc4_defconfig

@dnr
Copy link
Contributor

dnr commented Jul 3, 2022

Another report: this works great on my HC4. Thanks to everyone who worked on this.

I built u-boot with the instructions here, which refer to samueldr's repo, but it looks like it's the same code rebased.

Using nixos 22.05 with stock kernel, currently 5.15.49. SATA works. I have not verified HDMI or UART.

@considerate
Copy link
Member

I have not verified HDMI or UART.

I have verified that both HDMI and UART works. I'm using the configuration here https://github.com/considerate/nixos-odroidhc4/tree/0c1716bf1d8c7f99ba6ad0334e81240afdc27cbf which is based on this PR.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 7, 2023
@sorki
Copy link
Member

sorki commented Oct 20, 2023

There's some overlap with #245100 that has no merge conflicts currently. So maybe we can get that in and update this one.

@arapov
Copy link
Contributor Author

arapov commented Oct 20, 2023

There's some overlap with #245100 that has no merge conflicts currently. So maybe we can get that in and update this one.

I was under impression that this patch is "no-go" because of the https://github.com/Tow-Boot/Tow-Boot project. @samueldr ?

In case it is not true - I can update this PR.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 20, 2023
@lopsided98
Copy link
Contributor

I don't think Tow-Boot should have any impact on U-Boot packaging in nixpkgs. Was this discussed somewhere?

Binary blobs are never nice, but we already support the ODROID-C2, and the C4 is basically the same. This PR also gets rid of some of the existing C2 blobs.

My only suggestion after reading through this PR again is that perhaps the package attributes should be firmware-odroid-c2/c4. Our U-Boot packages use camel case, and I'm guilty of copying it with armTrustedFirmware, but this is not the standard convention in nixpkgs.

@arapov arapov closed this by deleting the head repository Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet