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

u-boot: ROCK64 RAM init improvements #191538

Merged
merged 1 commit into from
Nov 25, 2023

Conversation

lorenz
Copy link
Contributor

@lorenz lorenz commented Sep 16, 2022

Description of changes

This switches the ROCK64 over to the open-source RAM init as it now works flawlessly. It also removes the HDCP flag from the ATF for the RK3328 as it cannot use it, it is only used in the RK3399. This makes the ROCK64 u-boot now fully open.

There is also an issue with the ROCK64 v2 revision where the DRAM routing is marginal, making some of them unstable. So also package a variant which uses a lower-speed DDR3 timing configuration which is stable on these boards.

Things done
  • Built on platform(s)
    • x86_64-linux (cross-built to aarch64)
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@lorenz lorenz force-pushed the rock64-uboot-improvements branch from c9deb72 to 687d795 Compare September 16, 2022 18:30
@ofborg ofborg bot added the 8.has: package (new) This PR adds a new package label Sep 16, 2022
@ofborg ofborg bot requested review from lopsided98, dezgeg and samueldr September 16, 2022 18:40
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Sep 16, 2022
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.

This looks good and I'm glad to finally see the removal of the binary blob.

I tested ubootRock64v2 on my ROCK64 v2 and it boots, although not completely reliably. I don't have physical or UART access to the board right now (just a remote power switch), so I don't have any idea where it is getting stuck (it might not be U-Boot).

# frequency. If your ROCK64 is unstable you can try this u-boot variant to
# see if it works better for you. The only disadvantage is lowered memory
# bandwidth.
ubootRock64v2 = buildUBoot {
Copy link
Member

Choose a reason for hiding this comment

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

minor: how about converting this to a function that accepts either { memFreq = "666"; } or { memFreq = "1600"; } as argument and calling it from all-packages with { memFreq = "666"; }?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, the memory frequency is not just a tunable (it is also half, i.e. 333MHz / 800MHz), there is a whole host of timing parameters that need to be configured to make it work. There are only two specification in the u-boot tree, the "regular" 1600MT/s and the 666MT/s. I've actually reverse-engineered most of the memory controller, but I don't have the time currently to write a driver which would allow us to do something like that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think @wamserma meant just templating the memFreq value into the .dtsi name to select the correct one without duplicating the whole buildUBoot invocation.

Copy link
Member

Choose a reason for hiding this comment

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

If you want to further improve eval-time robustness, it could be checked with either an attrset of valid values, or couple of ifs. Otherwise it would fail during a needless attempt at building, which is still probably fine.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it was just about templating it into the name because it is more readable (and thus clearer) than the replacement expression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had a try at implementing this, but I struggled with where to put the function. There is a single callPackage in all-packages for these, which then get inherited up. So the only place I can see to put this is to put the function at the top together with buildUBoot and then call it twice. But that IMO makes the file relatively hard to read.

@lorenz
Copy link
Contributor Author

lorenz commented Sep 16, 2022

I tested ubootRock64v2 on my ROCK64 v2 and it boots, although not completely reliably. I don't have physical or UART access to the board right now (just a remote power switch), so I don't have any idea where it is getting stuck (it might not be U-Boot).

I've actually never had it fail at the u-boot stage already (with the full 1600MT/s), always after a few minutes to hours of operation. The special v2 version has been running on my V2s for ~3 months without any incident. Would be interesting to know if yours actually fails to start u-boot.

@samueldr
Copy link
Member

See also #145506 and #146725

@lorenz lorenz force-pushed the rock64-uboot-improvements branch from 687d795 to 1aec824 Compare October 6, 2022 20:26
@ofborg ofborg bot requested a review from lopsided98 October 6, 2022 20:36
@lorenz
Copy link
Contributor Author

lorenz commented Oct 6, 2022

@lopsided98 Please retest this, I figured out that the patch hook for the reduced-clock version applied too late. Before I PRed this, I used a patch which applied earlier and it worked.

@lopsided98
Copy link
Contributor

That explains why my Rock64 locked up after a few days as well. I just tested the new version and it seems to boot reliably.

@lorenz
Copy link
Contributor Author

lorenz commented Oct 19, 2022

Anything I can do to get this merged? @wamserma @samueldr

@lorenz
Copy link
Contributor Author

lorenz commented Nov 2, 2022

Pinging @lopsided98 @dezgeg @samueldr

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.

My Rock64v2 currently has 19 days of uptime running this.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/1392

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/1945

# see if it works better for you. The only disadvantage is lowered memory
# bandwidth.
ubootRock64v2 = buildUBoot {
prePatch = ''
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
prePatch = ''
postPatch = ''

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would require a change to buildUBoot to avoid overwriting the postPatch defined there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, this can be done, but would require adding a new argument to buildUBoot.

@lorenz lorenz requested a review from SuperSandro2000 March 27, 2023 19:25
@lopsided98 lopsided98 mentioned this pull request Oct 5, 2023
12 tasks
This switches the ROCK64 over to the open-source RAM init as it now
works flawlessly. It also removes the HDCP flag from the ATF for the
RK3328 as it cannot use it, it is only used in the RK3399. This makes
the ROCK64 u-boot now fully open.

There is also an issue with the ROCK64 v2 revision where the DRAM
routing is marginal, making some of them unstable. So also package a
variant which uses a lower-speed DDR3 timing configuration which is
stable on these boards.
@lorenz lorenz force-pushed the rock64-uboot-improvements branch from 1aec824 to 6568016 Compare November 25, 2023 10:21
@ofborg ofborg bot requested a review from lopsided98 November 25, 2023 12:26
Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

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

Reviewed together at #ZurichZHF, looking good!

@infinisil infinisil merged commit 1fb1239 into NixOS:master Nov 25, 2023
18 checks passed
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/installing-nixos-on-rock64-2024-experience/40954/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: package (new) This PR adds a new package 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants