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

Visionfive2: Build bootable SD card image #397

Merged
merged 7 commits into from
Apr 12, 2023
Merged

Conversation

a-firago
Copy link
Contributor

@a-firago a-firago commented Mar 7, 2023

This PR provides changes to create a bootable Visionfive2 SD card image, similar to the one created in the original Starfive SDK.
Changes include:

  • Add wks file with the partition layout taken from here
  • Add jh7710-spl-tool which is used to generate u-boot-spl.bin.normal.out expected on the SD card by the BootROM
  • Deploy visionfive2_fw_payload.img, which is a FIT image containing fw_payload.bin expected by SPL started from SD card
  • Update uEnv.txt, so that u-boot-starfive boots fitImage from the partition 3 and rootfs is expected on partition 4 of the SD card

Current state - SD card flashed with the core-image-minimal-visionfive2.wic using 'dd' or 'bmaptool' boots fine with few issues:

  • SPL built with bitbake, reports wrong DRAM size here. Simply putting a debug message printing in the dram_init() function resolves this issue. Seems like this has something to do with compiler/flags. Investigating.
  • During the boot, Linux kernel resets around 4 seconds timestamp. The same behavior is observed with the Starfive SDK sdcard.img. Investigating.

@a-firago
Copy link
Contributor Author

a-firago commented Mar 7, 2023

@cordlandwehr which boot source did you use with your PR #382? Have you seen issues with SPL and/or kernel resets as described here?

@@ -1,2 +1,8 @@
# Support fdt drivers for AE350
SRCREV:ae350-ax45mp = "22f38ee6c658a660083aa45c4ec6c72f66a17260"

BRANCH:visionfive2 = "JH7110_VisionFive2_devel"
SRC_URI:visionfive2 = "git://github.com/starfive-tech/opensbi.git;protocol=https;branch=${BRANCH}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

how different is this fork from upstream? is there a plan to upstream the changes can you comment on that ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I was looking at the upstream version, some VF2 reset related things were missing, but those were merged last week (riscv-software-src/opensbi@908be1b). I will try with the upstream version.

install -m 644 ${WORKDIR}/uEnv-visionfive2.txt ${DEPLOYDIR}/uEnv.txt
}

COMPATIBLE_MACHINE = "(visionfive2)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

does it support visionfive1 as well? if so can we add that here as well, so we can have both machines share same u-boot.

Copy link
Contributor Author

@a-firago a-firago Mar 8, 2023

Choose a reason for hiding this comment

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

JH7110_VisionFive2_devel branch of github.com/starfive-tech/u-boot moved to U-Boot v2021.10. Seems like this particular branch/tag is missing visionfive1 support. I decided to create a new recipe because all branches supporting visionfive1 are based on v2021.04.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmmm, this is not good, Can you check with upstream if there is a plan to maintain single branch for all visionfive variants ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Asked here starfive-tech/u-boot#43.

JH7110/Visionfive2 support in mainline U-Boot is currently under review (see https://rvspace.org/en/project/JH7110_Upstream_Plan and https://patchwork.ozlabs.org/project/uboot/list/?series=346514), so hopefully we can use upstream recipe soon.

Meanwhile, current u-boot-starfive_v2021.04 in meta-riscv is kind of broken:

  • BRANCH for Visionfive is "JH7100_VisionFive_OH_dev" which is based on v2022.04
  • BRANCH for Visionfive2 is "JH7110_VisionFive2_devel" which is based on v2021.10
  • BRANCH for beaglev-starlight-jh7100 is "Fedora_JH7100_2021.04" which is based on v2021.04

@kraj I guess the optimal solution now would be to rename "u-boot-starfive_v2021.04" to "u-boot-starfive" and set branches/SRCREV for each board.

@@ -0,0 +1,25 @@
DESCRIPTION = "spl_tool is a jh7110 signature tool used to generate spl header information and generate u-boot-spl.bin.normal.out."
LICENSE = "GPLv2"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mark it GPL-2.0-or-later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

do_install () {
cd ${S}
install -d ${D}${bindir}
install -m 0755 spl_tool ${D}${bindir}/spl_tool
Copy link
Collaborator

Choose a reason for hiding this comment

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

whole function could be a single line

install -Dm 0755 ${S}/spl_tool ${D}${bindir}/spl_tool

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

DESCRIPTION = "spl_tool is a jh7110 signature tool used to generate spl header information and generate u-boot-spl.bin.normal.out."
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://LICENSE;md5=e6dc25dc2418b8831c906d43809d8336"
SECTION = "BSP"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make this to match u-boot
SECTION = "bootloaders"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@cordlandwehr
Copy link
Contributor

@cordlandwehr which boot source did you use with your PR #382? Have you seen issues with SPL and/or kernel resets as described here?

I did all my tests by booting via the onboard SPL and than loading Kernel/rootfs from sd card. Right now I cannot recall any Kernel reset problems, but I am currently too many timezones away from my board to double check...

@a-firago
Copy link
Contributor Author

a-firago commented Mar 8, 2023

Updated PR:

  • Implemented requested changes for spl_tool
  • Used upstream opensbi - works the same.

Still in progress:

  • proper fix for "Unsupport size" message in SPL
  • Linux kernel resets around 4s after boot

@a-firago
Copy link
Contributor Author

  • Added fix for SPL DRAM size reading from EEPROM;
  • Kernel reset was an issue with a faulty USB TypeC cable on my setup. After cable replacement and SPL fix, SD card flashed with core-image-minimal.wic boots fine

@kraj please review.

@a-firago a-firago changed the title [RFC] Visionfive2: Build bootable SD card image Visionfive2: Build bootable SD card image Mar 17, 2023
Copy link
Collaborator

@kraj kraj left a comment

Choose a reason for hiding this comment

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

please rebase the pr on top of latest master and push again after you have addressed the feedback. Thanks

@@ -0,0 +1,20 @@
diff --git a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a patch header with some description of this patch and upstream status. For reference you can use this template

https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines

install -m 644 ${WORKDIR}/uEnv-visionfive2.txt ${DEPLOYDIR}/uEnv.txt
}

COMPATIBLE_MACHINE = "(visionfive2)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmmm, this is not good, Can you check with upstream if there is a plan to maintain single branch for all visionfive variants ?

Add u-boot-starfive_v2021.10.bb recipe to build U-Boot v2021.10
from https://github.com/starfive-tech/u-boot

Signed-off-by: Alexey Firago <alexey.firago@gmail.com>
Add recipe for a jh7110 signature tool, which is used to generate
SPL header information and generate u-boot-spl.bin.normal.out.

Signed-off-by: Alexey Firago <alexey.firago@gmail.com>
Build and deploy u-boot-spl.bin.normal.out. It is used to boot from
SD Card.

Signed-off-by: Alexey Firago <alexey.firago@gmail.com>
Add wks with the layout similar to the Starfive SDK from here:
https://github.com/starfive-tech/VisionFive2/blob/JH7110_VisionFive2_devel/conf/genimage-vf2.cfg

Signed-off-by: Alexey Firago <alexey.firago@gmail.com>
Deploy uEnv.txt as vf2_uEnv.txt. This file is expected by the
Starfive U-Boot.

Signed-off-by: Alexey Firago <alexey.firago@gmail.com>
Align uEnv.txt with the Starfive SDK to boot from SD card.
uEnv sets required variables to read the fitImage from the
partition 3 on the SD card and rootfs is expected on the
partition 4.

Signed-off-by: Alexey Firago <alexey.firago@gmail.com>
* Use visionfive2.wks
* Install required files on the boot partition

Signed-off-by: Alexey Firago <alexey.firago@gmail.com>
@a-firago a-firago force-pushed the vf2-wks branch 2 times, most recently from c26a77c to ceda92a Compare April 12, 2023 12:15
@a-firago
Copy link
Contributor Author

Add v3:

  • Updated U-Boot to tag v2.11.5
  • Do not use 0001-riscv-fix-build-with-binutils-2.38.patch, it was merged upstream in v2021.10
  • Remove fix EEPROM issue, it doesn't happen on v2.11.5

@kraj please review

Copy link
Collaborator

@kraj kraj left a comment

Choose a reason for hiding this comment

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

lgtm

@kraj kraj merged commit 7dc4ca0 into riscv:master Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants