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

Add pine h64 board #65

Open
wants to merge 6 commits into
base: development
Choose a base branch
from

Conversation

dwagenk
Copy link

@dwagenk dwagenk commented Dec 8, 2021

This adds support for the pine H64 board, both the A and the B variant (which are almost identical). An adapted builder for the Arm-Trusted-Firmware for the Allwinner H6 SOC was also necessary.

https://wiki.pine64.org/index.php/PINE_H64

I tested the shared.disk-image.img with the B variant of the board.

--- List updated ---

  • Tow-Boot is starting and I get the boot selection menu via serial connection when pressing CTRL-C or ESC.
  • Switching out the SD Card and selecting "Boot from SD" works
  • USB: lower of the two USB2 port works
  • USB: The upper USB2 port one and the USB3 Port do not work (even after update to v2021.10)
  • HDMI: not working (apparently no support in u-boot, see arch/arm/mach-sunxi/Kconfig dependecy chain VIDEO_HDMI->VIDEO_SUNXI->!SUN50I_GEN_H6)
  • netbooting (DHCP or PXE): at least the IP gets assigned, did not set up a TFTP server for testing
  • eMMC: I do not have an eMMC module and thus didn't test booting form it
  • SPI flash: works, though BOOTROM attempts to boot from SD and eMMC first

Comment on lines 82 to 85
allwinnerH6 = aarch64.callPackage ../builders/allwinner-a64 {
TF-A = aarch64.armTrustedFirmwareAllwinnerH6;
};

Copy link
Contributor

Choose a reason for hiding this comment

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

(You don't need to do anything about this...)

I'm rewriting the build setup for Tow-Boot using the modules system. So importing the A64 builder for H6 won't be a thing anymore in the future. So it's fine to add this right now even though I don't exactly like this :).

Using the modules system, it will be easier to configure complex build instructions.

+# CONFIG_CMD_FLASH is not set
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_DEFAULT_DEVICE_TREE="sun50i-h6-pine-h64-model-b"
Copy link
Contributor

Choose a reason for hiding this comment

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

(You don't need to do anything about this, this is a not for future readers wanting to know more about porting)

It is important that CONFIG_DEFAULT_DEVICE_TREE matches the file names in the mainline kernel.

This is because this config is used to seed the environment with the name of the dtb file that should be loaded automatically with the different boot schemes.

boards/pine64/default.nix Outdated Show resolved Hide resolved
@samueldr
Copy link
Contributor

samueldr commented Dec 9, 2021

Hi! 👋 A new face! And welcome.

Looks good generally speaking.

Are you going to look at SPI Flash for this PR?

Other non-working features (e.g. HDMI) are more for upstream problems, assuming it's not just not configured. We need to upgrade the backing U-Boot version anyway, so it's not too much of a concern for now. It will need to be re-evaluated once udpated.

@dwagenk
Copy link
Author

dwagenk commented Dec 9, 2021

I'm not sure what else needs to be done for enabling SPI. I'm planning to dive in a little deeper to see if I can fix this. The trivial approach of enabling the option in the Tow-Boot board description and patching the defconfig to include
CONFIG_SPL_SPI_SUNXI=y CONFIG_SPI_FLASH_WINBOND=y
didn't work. I think there's some intermediary Kconfig option missing and thus the config options from the defconfig are not properly applied. First found problem is

Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|NAND|NVRAM|ONENAND|SATA|SPI_FLASH|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE

while that is explicitely set through the Tow-Boot builder.

The .dts file mentions eMMC and SPI sharing a pin, so eMMC would probably have to be disabled in there.

Are you going to look at SPI Flash for this PR?
I'd prefer to have this merged without SPI and then do a follow-up PR if I get SPI to work.

@samueldr
Copy link
Contributor

samueldr commented Dec 9, 2021

Ooooof... In other words, how to make the SPI basically unusable :|

AFAIUI Tow-Boot could be made to load from SPI, but that build wouldn't be able to interact with SPI once loaded. E.g. it wouldn't be able to save env, or update itself. I'm not sure this use case is already "supported" in U-Boot. E.g. SPL has &mmc2 disabled, and &spi0 enabled, but the "proper" U-Boot itself has &mmc2 enabled and &spi0 disabled.

I believe your issues here with enabling SPI were that it wasn't configured in the device tree. But that's a guess.

Though it might be possible to add some sort of special casing to "unprobe" the MMC2 while reading/writing to SPI. This would require out of scope work, especially for this PR.

@dwagenk
Copy link
Author

dwagenk commented Dec 9, 2021

AFAIUI Tow-Boot could be made to load from SPI, but that build wouldn't be able to interact with SPI once loaded. E.g. it wouldn't be able to save env, or update itself. I'm not sure this use case is already "supported" in U-Boot. E.g. SPL has &mmc2 disabled, and &spi0 enabled, but the "proper" U-Boot itself has &mmc2 enabled and &spi0 disabled.

Is it possible to reload the dts from inside u-boot? I'm thinking about something like

  1. Boot with &mmc2 disabled and &spi0 enabled
  2. Only when "Boot from eMMC" is selected from the menu switch to &mmc2 enabled and &spi0 disabled, probe mmc2

I believe your issues here with enabling SPI were that it wasn't configured in the device tree. But that's a guess.

I don't think so. I'm running into build problems with SPI, but to my understanding u-boot sees device-tree as run-time config (like linux, unlike zephyr) and doesn't pull any data from it during build.

@dwagenk
Copy link
Author

dwagenk commented Dec 12, 2021

Patches 0001 - 0003 will be sent to the u-boot mailing list and thus might be obsolete soon.

I updated the PR description to give an overview. I'm currently not planning on doing anything about the missing HDMI support and the non working USB ports.

Regarding the eMMC I can't test without a module. Since u-boot doesn't do mutlithreading I guess enabling both eMMC and SPI might actually work. If the drivers ensure the pinmuxing is configured before operating on the busses they should both work.

Subject: [PATCH 2/4] sunxi: configs: add defconfig for pine H64 model B

It almost identical to the defconfig for pine H64 model A with only
the CONFIG_DEFUALT_DEVICE_TREE adapted.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
the CONFIG_DEFUALT_DEVICE_TREE adapted.
the CONFIG_DEFAULT_DEVICE_TREE adapted.

(Since you want to upstream, let's correct nits :))

Comment on lines 9 to 11
The differences between the boards model A and model B are irrelevant
inside u-boot, but the device-tree name is relevant as default for
selecting the correct device-tree when booting linux.
Copy link
Contributor

Choose a reason for hiding this comment

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

(Nothing to do really)

I believe the "more correct" way to handle this would be like for the Pinephone, figure out a detectable difference between boards during early boot and setup accordingly.

I don't really know the H64. There may be nothing that can be detected for this. At least from the Linux dts, I don't really see anything.

@samueldr samueldr added this to the [blocked or WIP] milestone Jun 2, 2022
samueldr and others added 6 commits June 29, 2022 19:37
This is useful for targets where there's no display support, rather than
dig in the implementation details (e.g. withLogo).
Signed-off-by: Daniel Wagenknecht <dwagenk@mailbox.org>
Signed-off-by: Daniel Wagenknecht <dwagenk@mailbox.org>
@auchter
Copy link

auchter commented Jun 29, 2022

Hey y'all,

As this branch no longer cleanly applied to the HEAD of the development branch (and I was wanting Tow-Boot on my Pine H64), I took a stab at updating this. I have a branch at https://github.com/auchter/Tow-Boot/commits/auchter/pineh64 that should apply cleanly.

The branch incorporates @dwagenk's patches against u-boot, but I rewrote the Nix stuff to deal with the changes in Tow-Boot since this PR was opened. I also cherry-picked two of @samueldr's commits into that branch from #155 to cleanly handle the lack of display support for the H64 in upstream u-boot.

I chose to add a new board for each variant (H64A/H64B) with the H64B importing and overriding the configuration as appropriate.

Like @dwagenk, I don't have an eMMC module to test with (nor do I have an H64A), but I was able to successfully boot both shared.disk-image.img and spi.installer.img via SD on my H64B, and also verified that flashing and then booting from SPI works.

Let me know if you'd like me to open up a separate PR for this

@samueldr
Copy link
Contributor

I personally wouldn't mind another PR, but let's also see if @dwagenk has anything to say, just in case, maybe you can cooperate for bringing the changes in.

@dwagenk
Copy link
Author

dwagenk commented Jul 1, 2022

Hey. Don't have time to continue this for now. @auchter I added you as collaborator to my fork, so you should be able to modify the base-branch for this PR.

@auchter
Copy link

auchter commented Jul 1, 2022

Thanks, @dwagenk! I've pushed my changes to the base branch, and also pushed a branch (dwagenk/add-pineH64-board-orig) to backup your original branch state for posterity.

Looks like your pinmux fix landed in u-boot already, and someone else has added a Model B device tree, so we should be able to drop patches 1 and 3 once Tow-Boot updates the u-boot version used. I'll ping the mailing list this week to see if we can get the defconfig for model B merged as well.

@clee
Copy link

clee commented Apr 15, 2023

Just wanted to comment here, I tried @auchter's branch and was able to successfully build and install tow-boot to the SPI flash on my H64B here. And now my H64B can PXE boot without any SD card installed 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants