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 RockPro64 support, fix Rock64 build, misc related changes #53170

Merged
merged 8 commits into from Jan 21, 2019

Conversation

lopsided98
Copy link
Contributor

Motivation for this change

This PR started as an attempt to add RockPro64 support to U-Boot in Nix, but a bunch of other related changes accumulated along the way.

Things done
  • Add rkdeveloptool package. This is a tool for communicating with Rockchip devices over their USB OTG port, allowing flashing the eMMC/SD and SPI flash.
  • Upgrade ARM trusted firmware from 1.5 to 2.0. This works correctly in the Rock64 U-Boot.
  • Add RK3399 support to ATF. This was supposed to be for the RockPro64, but it caused U-Boot to hang in the SPL.
  • Add libfdt Python package. This is just toPythonModule dtc.
  • Add RockPro64 U-Boot support. This uses a downstream version of 2017.09 (maintained by ayufan), which is the best supported U-Boot tree for this board. This uses a binary blob for ATF as well as the TPL.
  • Fix Rock64 U-Boot build. This switches from ayufan's mainline-master branch to rockchip-master, which is better maintained (even though it is older). This is the same branch I use for the RockPro64. I attempted to get rid of the TPL blob, but using U-Boot's TPL causes the board to hang after a few minutes (previously it would not even finish booting before hanging).

I got rid of the pythonpath patch in U-Boot, because I could not see why it was necessary and it was annoying to have to maintain a separate backport for 2017.09. Most builds don't use any Python libraries, so the PYTHONPATH doesn't matter. The Rock64 build requires libfdt, but the patch didn't seem to fix the build, I had to use withPackages.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nox --run "nox-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)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@lopsided98 lopsided98 force-pushed the uboot-rockpro64 branch 2 times, most recently from c71557c to a6e52a2 Compare January 5, 2019 04:02
@lopsided98
Copy link
Contributor Author

cc @dezgeg

pkgs/misc/arm-trusted-firmware/default.nix Show resolved Hide resolved
Copy link
Member

@FRidh FRidh left a comment

Choose a reason for hiding this comment

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

Python part (and generally overall) looks good to me.

pkgs/misc/uboot/rockpro64.nix Outdated Show resolved Hide resolved
@Mic92
Copy link
Member

Mic92 commented Jan 5, 2019

cc @thefloweringash

@Mic92 Mic92 requested a review from dezgeg January 5, 2019 11:34
@Mic92
Copy link
Member

Mic92 commented Jan 17, 2019

I also would have the hardware for testing. Did you use the mainline kernel or the rock64 one?

@lopsided98
Copy link
Contributor Author

lopsided98 commented Jan 18, 2019

I wasn't able to get mainline 4.20 to boot on the RockPro64, but I didn't try that hard. I was able to get mainline to boot on the Rock64 a while ago but had lots of problems with ethernet and USB. Currently, I use a custom version of ayufan's linux-mainline-kernel rebased against the latest mainline stable branch. ayufan's linux-mainline-kernel or linux-kernel should both work fine, except I wasn't able to get the latter to compile last time I tried.

@lopsided98 lopsided98 changed the title uboot: add RockPro64 support, fix Rock64 build, misc related changes [WIP] uboot: add RockPro64 support, fix Rock64 build, misc related changes Jan 18, 2019
@lopsided98
Copy link
Contributor Author

It turns out that the dtc update from 1.4.5 to 1.4.7 broke the build of U-Boot 2017.09, and I can't see an easy fix for it. I will probably end up adding an override to pin dtc to 1.4.5 for the Rock{Pro,}64 U-Boot builds, but for now I just added a revert for that commit in case anyone wants to test this PR.

Here is the error in case anyone has an idea of how to fix it:

In file included from ./tools/../lib/libfdt/libfdt.h:10:0,
                 from tools/../include/libfdt.h:1,
                 from tools/fdt_host.h:11,
                 from tools/imagetool.h:24,
                 from tools/aisimage.c:8:
/nix/store/yyfzjvpk0ij1ixb5hlaznin54sw2awpz-dtc-1.4.7/include/libfdt_env.h:71:30: error: conflicting types for 'fdt64_t'
 typedef uint64_t FDT_BITWISE fdt64_t;
                              ^~~~~~~
In file included from <command-line>:0:0:
././include/libfdt_env.h:19:16: note: previous declaration of 'fdt64_t' was here
 typedef __be64 fdt64_t;
                ^~~~~~~
In file included from ././include/libfdt_env.h:12:0,
                 from <command-line>:0:
/nix/store/yyfzjvpk0ij1ixb5hlaznin54sw2awpz-dtc-1.4.7/include/libfdt_env.h:91:24: error: expected ')' before 'x'
 static inline uint32_t fdt32_to_cpu(fdt32_t x)
                        ^
././include/compiler.h:71:9: error: expected ')' before '&' token
  ((((x) & 0xff000000) >> 24) | \
         ^
././include/compiler.h:71:23: error: expected ')' before '>>' token
  ((((x) & 0xff000000) >> 24) | \
                       ^
././include/compiler.h:71:30: error: expected ')' before '|' token
  ((((x) & 0xff000000) >> 24) | \
                              ^
/nix/store/yyfzjvpk0ij1ixb5hlaznin54sw2awpz-dtc-1.4.7/include/libfdt_env.h:95:23: error: expected ')' before 'x'
 static inline fdt32_t cpu_to_fdt32(uint32_t x)
                       ^
././include/compiler.h:71:9: error: expected ')' before '&' token
  ((((x) & 0xff000000) >> 24) | \
         ^
././include/compiler.h:71:23: error: expected ')' before '>>' token
  ((((x) & 0xff000000) >> 24) | \
                       ^
././include/compiler.h:71:30: error: expected ')' before '|' token
  ((((x) & 0xff000000) >> 24) | \
                              ^
/nix/store/yyfzjvpk0ij1ixb5hlaznin54sw2awpz-dtc-1.4.7/include/libfdt_env.h:100:24: error: expected ')' before 'x'
 static inline uint64_t fdt64_to_cpu(fdt64_t x)
                        ^
././include/compiler.h:76:9: error: expected ')' before '&' token
  ((((x) & 0xff00000000000000##sfx) >> 56) | \
         ^
././include/compiler.h:76:36: error: expected ')' before '>>' token
  ((((x) & 0xff00000000000000##sfx) >> 56) | \
                                    ^
././include/compiler.h:76:43: error: expected ')' before '|' token
  ((((x) & 0xff00000000000000##sfx) >> 56) | \
                                           ^
/nix/store/yyfzjvpk0ij1ixb5hlaznin54sw2awpz-dtc-1.4.7/include/libfdt_env.h:104:23: error: expected ')' before 'x'
 static inline fdt64_t cpu_to_fdt64(uint64_t x)
                       ^
././include/compiler.h:76:9: error: expected ')' before '&' token
  ((((x) & 0xff00000000000000##sfx) >> 56) | \
         ^
././include/compiler.h:76:36: error: expected ')' before '>>' token
  ((((x) & 0xff00000000000000##sfx) >> 56) | \
                                    ^
././include/compiler.h:76:43: error: expected ')' before '|' token
  ((((x) & 0xff00000000000000##sfx) >> 56) | \
                                           ^
make[1]: *** [scripts/Makefile.host:116: tools/aisimage.o] Error 1
make: *** [Makefile:1278: tools] Error 2

@Mic92
Copy link
Member

Mic92 commented Jan 18, 2019

@lopsided98 do you have some nixos configuration, I could use to deploy this?

@lopsided98
Copy link
Contributor Author

@Mic92 I just dd it to the card manually. idbloader.img needs to be placed at sector 64. I usually add a partition that starts at sector 64 to make updating less error prone, but this is not necessary.

My disk layout looks like this:

Disk /dev/mmcblk1: 29.1 GiB, 31268536320 bytes, 61071360 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 8BCF5A28-7359-4B24-922B-4593E27C33FE

Device         Start      End  Sectors  Size Type
/dev/mmcblk1p1    64     8063     8000  3.9M Linux filesystem
/dev/mmcblk1p2 16384 61071326 61054943 29.1G Linux filesystem

This allows me to run dd if=/path/to/idbloader.img of=/dev/mmcblk1p1 to update the bootloader.

@lopsided98
Copy link
Contributor Author

I made ubootRock64 and ubootRockPro64 use dtc 1.4.5. This requires some kind of ugly code but I don't see a better way of doing it.

@lopsided98 lopsided98 changed the title [WIP] uboot: add RockPro64 support, fix Rock64 build, misc related changes uboot: add RockPro64 support, fix Rock64 build, misc related changes Jan 19, 2019
@ck3d
Copy link
Contributor

ck3d commented Jan 20, 2019

I could get the u-boot on my RockPro64 running. Thanks a lot for the PR!

@Mic92 Mic92 merged commit 615ed6d into NixOS:master Jan 21, 2019
@lopsided98 lopsided98 deleted the uboot-rockpro64 branch January 21, 2019 22:56
@JasonSwindle
Copy link

@lopsided98 Where did you get idbloader.img from? Or did you compile it?

@lopsided98
Copy link
Contributor Author

@JasonSwindle It is one of the files in the ubootRock64 and ubootRockPro64 derivations.

@JasonSwindle
Copy link

Any plans to get it added to http://nixos-arm.dezgeg.me/installer ?

I was just reading over this ( https://nixos.wiki/wiki/NixOS_on_ARM#Contributing_new_boards_to_nixpkgs ), so I figured I would ask. :)

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

8 participants