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

Fix the uboot for rock-3a #3271

Merged
merged 3 commits into from
Dec 25, 2021
Merged

Fix the uboot for rock-3a #3271

merged 3 commits into from
Dec 25, 2021

Conversation

catalinii
Copy link
Contributor

@catalinii catalinii commented Nov 20, 2021

Description

This PR improves the kernel configuration for radxa rock pi 3A by adding more modules.
Additionally, it consolidates the packaging patch into 1 locations to ensure it accounts for the custom patches added to the radxa 4.19 kernel.

I am currently experiencing what seems to be u-boot issues
Found U-Boot script /boot/boot.scr
fs_devread read outside partition 2640856

Executing script at 00c00000

Wrong image format for "source" command
SCRIPT FAILED: continuing...
MMC error: The cmd index is 0, ret is -110
mmc_init: -110, time 4
starting USB...

**** This issue has been fixed by preventing EFI partitions from being read in U-boot ******

How Has This Been Tested?

Focal and Hirsute images

  • Test A
  • Test B

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@piter75
Copy link
Member

piter75 commented Nov 20, 2021

This was fixed with the patch for source command but now the patch is removed from Armbian because Radxa incorporated it in their sources.

Seeing this error now is odd as it seems your local u-boot sources were not updated.
Please verify that your cmd/source.c file is indeed updated in your local cache according to the patch changes.

@catalinii
Copy link
Contributor Author

Thanks for the tip, let me look into it

@catalinii
Copy link
Contributor Author

@piter75 I confirmed and the correct line is there. I even tried this: catalinii@dd7e6ad#diff-b5be43512e74a30c65e79d6af8395b6febb45bf93f593637372c7d4de03afa87

but without much luck. What I can see is:
Starting the controller
USB XHCI 1.10
scanning bus dwc3@fcc00000 for devices... 1 USB Device(s) found
scanning bus dwc3@fd000000 for devices... 1 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found

Device 0: unknown device
No ethernet found.
missing environment variable: pxeuuid
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm-rockchip
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default
No ethernet found.
Config file not found
No ethernet found.
No ethernet found.

Booting FIT Image FIT: No fit blob

FIT: No FIT image
MMC error: The cmd index is 0, ret is -110
mmc_init: -110, time 5
Could not get mmc 0

Is this expected?
scanning usb for storage devices... 0 Storage Device(s) found

@catalinii
Copy link
Contributor Author

Trying to see what is going on, so it seems that the actual image in the memory is not the right format.
With this patch
catalinii@83d036b#diff-b5be43512e74a30c65e79d6af8395b6febb45bf93f593637372c7d4de03afa87R41

I get the following:
Scanning mmc 1:1...
Found U-Boot script /boot/boot.scr
fs_devread read outside partition 2645944

Executing script at 00c00000

--> start
x = 0
--> fe ff ef ff
Wrong image format for "source" command

xxd boot/boot.scr | head -1

00000000: 2705 1956 ecf4 5dd6 61b5 6741 0000 0c31 '..V..].a.gA...1

So I am assuming at that location is not the correct content.

@catalinii
Copy link
Contributor Author

@piter75 @igorpecovnik it seems that the issue is that the partition (mmc 1:1) has for some reason the size set as 1048576 blocks as here:
https://github.com/radxa/u-boot/blob/stable-4.19-rock3/fs/fs_internal.c#L29

By disabling that check the boot works as expected, but still not sure where that size comes from. The partition name is set to "boot" if that helps.

@catalinii catalinii changed the title [DRAFT] Fix the uboot for rock-3a Fix the uboot for rock-3a Dec 17, 2021
@catalinii
Copy link
Contributor Author

@piter75 @igorpecovnik I have fixed the issue by preventing the EFI partition from being read before the DOS ones.
For some reason the EFI layout is different and has 2 partitions (boot - 512M and rootfs - remaining).

The PR has been tested and works good on both focal and hirsute.

@lanefu
Copy link
Member

lanefu commented Dec 17, 2021

Nice work @catalinii

I have received a confirmation that this image works from your PR

https://armbian.lane-fu.com/Armbian_21.11.0-trunk_Rock-3a_bullseye_legacy_4.19.193.img.xz

@catalinii
Copy link
Contributor Author

@piter75 @igorpecovnik gentle ping for review

@lanefu
Copy link
Member

lanefu commented Dec 25, 2021

Fine to merge

@lanefu lanefu merged commit f6143ef into armbian:master Dec 25, 2021
lanefu pushed a commit that referenced this pull request Dec 31, 2021
Revert a change in bddce2c now that rock-3a building succeeds and provides a usable image (#3271)
rpardini pushed a commit to rpardini/armbian-build that referenced this pull request Jan 7, 2022
add ssv6051 driver for kernel 5.10 and 5.15

(cherry picked from commit f3388b9)

Add upstream patches (armbian#3380)

(cherry picked from commit d7794cc)

Fixes for Github Actions (armbian#3379)

* Update build-beta-images.yml

* Update build-kernel-on-merge-request.yml

* Update build-train.yml

(cherry picked from commit 6bfc83b)

Refactor armbian-bsp-cli package creation (armbian#3378)

* Refactor armbian-bsp-cli package creation

- added general distro status for all in separate file inside BSP
- remove branch and distro specifics

* Looking for prebuild pack

* Small fixes

(cherry picked from commit 310495d)

Cleanup. Remove deprecated build targets (armbian#3148)

* Update targets.conf

* Update targets-desktop-beta.conf

* Update targets-cli-beta.conf

* Update targets.conf

Update targets according ot current status of maintainer list
reduce userspaces to Focal
reduce to xfce default desktop
keep one minimal and one edge to check if they build at least.

* adjust support status according current maintainer sheet

* Readd pbp

* Readd pbp

* Readd C2

Co-authored-by: Igor Pecovnik <igor.pecovnik@gmail.com>
(cherry picked from commit 9d8a424)

prepare_host: Installing packages with the install_pkg_deb function (armbian#3374)

* separate joint and own lists for architecture

Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>

* Remove duplicate selection

* Final add Installing build dependencies

* libncurses: Do not use transitional package

Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>

* add arch i386: Remove duplicate selection

* lib32ncurses-dev: Dependency only for amd64

* install_pkg_deb: parameter verbose to log

(cherry picked from commit 0282567)

Improve fist login UX (armbian#3375)

* Improve 1st login script

* Update packages/bsp/common/usr/lib/armbian/armbian-firstlogin

Co-authored-by: Manuel Rüger <manuel@rueg.eu>

* Address accessibility issue

Co-authored-by: Manuel Rüger <manuel@rueg.eu>
(cherry picked from commit e76a5b0)

fixes the manual launch of the installation script from USB media (armbian#3377)

(cherry picked from commit 3f8da05)

Bugfix - legacy kernels doesn't want to play nice with kernel options

When NFSD is enabled as module, kernel does not compile. But it works as build in. Since its pretty pointless to fix in the code, lets use this workaround.

FYI @patrickbkr

(cherry picked from commit 2b4e9e6)

Unify NFS configuration (armbian#3376)

* Unify NFS configuration
* Fix rk35xx kernel

Co-authored-by: Igor Pecovnik <igor.pecovnik@gmail.com>
(cherry picked from commit 7698848)

Limit sunxi-tools install to Allwinner family only

Close armbian#2941

(cherry picked from commit 181d0e2)

Re-enable rock-3a building now that it works (armbian#3373)

Revert a change in bddce2c now that rock-3a building succeeds and provides a usable image (armbian#3271)

(cherry picked from commit 32dc244)

sun50iw9 - bugfix - change phy driver to build-in since it breaks compilation when added as module

(cherry picked from commit 5a6b9b2)

Install debian packages using a special function (armbian#3368)

* Add new function install_pkg_deb

Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>

* Use the install_pkg_deb function

Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>

* sunxi-tools: Calculate build dependencies

Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>

* hostapd, hostapd-realtek: Calculate build dependencies

Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>

* Clean Environment for building as default

* upgrading: Repack a clean Environment archive

Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>
(cherry picked from commit fedc9c1)

fix kernel legacy for firefly-rk3399 (armbian#3369)

(cherry picked from commit e453e4d)

add station m2\p2 (armbian#3352)

(cherry picked from commit 08568a6)

Bump version to proceed on 22.02 Armbian Ratel

(cherry picked from commit 483c055)

Assemble needed runs into a GH Actions build train (armbian#3366)

(cherry picked from commit 7f556dc)

helios64: fix udev rules to let fancontrol work again (armbian#3367)

(cherry picked from commit 37662d8)

Fix the uboot for rock-3a (armbian#3271)

* Sync kernel config with radxa and remove packaging patch

* Merge the rockchip64 legacy config as well

* Lower priority of EFI partitioning against DOS partitioning which is used by Armbian

Co-authored-by: Catalin Toda <catalinii@yahoo.com>
(cherry picked from commit f6143ef)
useful64 pushed a commit to useful64/build that referenced this pull request Feb 4, 2022
* Sync kernel config with radxa and remove packaging patch

* Merge the rockchip64 legacy config as well

* Lower priority of EFI partitioning against DOS partitioning which is used by Armbian

Co-authored-by: Catalin Toda <catalinii@yahoo.com>
useful64 pushed a commit to useful64/build that referenced this pull request Feb 4, 2022
Revert a change in bddce2c now that rock-3a building succeeds and provides a usable image (armbian#3271)
useful64 pushed a commit to useful64/build that referenced this pull request Feb 4, 2022
* Sync kernel config with radxa and remove packaging patch

* Merge the rockchip64 legacy config as well

* Lower priority of EFI partitioning against DOS partitioning which is used by Armbian

Co-authored-by: Catalin Toda <catalinii@yahoo.com>
useful64 pushed a commit to useful64/build that referenced this pull request Feb 4, 2022
Revert a change in bddce2c now that rock-3a building succeeds and provides a usable image (armbian#3271)
@amazingfate
Copy link
Contributor

@catalinii hello, I'm working on spi nor flash + NVME boot on rock-3a these days, I find that EFI is necessary for NVME and rockchip_set_ethaddr. I still can't boot from spi and I'm trying to make it work.

@catalinii
Copy link
Contributor Author

@amazingfate please see this patch: https://github.com/armbian/build/blob/master/patch/u-boot/u-boot-rk35xx/board_rock-3a/0001-Lower-the-priority-of-EFI-to-be-after-DOS-partition.patch .

This patch was added because of EFI vs DOS first partition size mismatch and the first EFI partition was too small for the uboot to load the kernel/dtb.

@amazingfate
Copy link
Contributor

@amazingfate please see this patch: https://github.com/armbian/build/blob/master/patch/u-boot/u-boot-rk35xx/board_rock-3a/0001-Lower-the-priority-of-EFI-to-be-after-DOS-partition.patch .

This patch was added because of EFI vs DOS first partition size mismatch and the first EFI partition was too small for the uboot to load the kernel/dtb.

Root cause of this issue is rockchip legacy u-boot has bad support for ext4 filesystem. Neither EFI nor DOS would make u-boot load kernel successfully. Your patch disabling the EFI mode will make rockchip_set_ethaddr not work, which is responsible for generating ethernet mac address in the uboot vnvm partition. If it doesn't work, every boot will have a random ethernet mac address.
I also tried to update the ext4 driver from the mainline, but still can't get my NVME SSD boot.
Finnaly I made a vfat boot partition on my NVME SSD and now everything works fine(without the EFI disabling patch).

@catalinii
Copy link
Contributor Author

If you can think of a another workaround for sd card u-boot I think we can remove the patch.

@amazingfate
Copy link
Contributor

If you can think of a another workaround for sd card u-boot I think we can remove the patch.

I build a image with mainline kernel and burn it to my SD card, but I can't reproduce your issue. Here is log:

U-Boot 2017.09-armbian (May 24 2022 - 17:55:21 +0000)

Model: Radxa ROCK 3 Model A
PreSerial: 2, raw, 0xfe660000
DRAM:  7.7 GiB
Sysmem: init
Relocation Offset: ed34a000
Relocation fdt: eb9f7740 - eb9fecd0
CR: M/C/I
Using default environment

PCIe-0 Link Fail
no mmc device at slot 1
dwmmc@fe2b0000: 1 (SD), dwmmc@fe2c0000: 2, sdhci@fe310000: 0
Bootdev(atags): mmc 1
MMC1: Legacy, 52Mhz
PartType: DOS
No misc partition
boot mode: None
FIT: No boot partition
No resource partition
No resource partition
Failed to load DTB, ret=-19
Failed to get kernel dtb, ret=-19
I2c0 speed: 100000Hz
vsel-gpios- not found! Error: -2
vdd_cpu 900000 uV
PMIC:  RK8090 (on=0x02, off=0x08)
vdd_logic init 900000 uV
vdd_gpu init 900000 uV
vdd_npu init 900000 uV
io-domain: OK
Model: Radxa ROCK 3 Model A
rockchip_set_serialno: could not find efuse/otp device
CLK: (sync kernel. arm: enter 816000 KHz, init 816000 KHz, kernel 0N/A)
  apll 816000 KHz
  dpll 780000 KHz
  gpll 1188000 KHz
  cpll 1000000 KHz
  npll 24000 KHz
  vpll 24000 KHz
  hpll 24000 KHz
  ppll 200000 KHz
  armclk 816000 KHz
  aclk_bus 150000 KHz
  pclk_bus 50000 KHz
  aclk_top_high 300000 KHz
  aclk_top_low 200000 KHz
  hclk_top 150000 KHz
  pclk_top 50000 KHz
  aclk_perimid 300000 KHz
  hclk_perimid 150000 KHz
  pclk_pmu 100000 KHz
No misc partition
Net:   No ethernet found.
Hit key to stop autoboot('CTRL+C'):  0
failed to find reset-gpios property

Device 0: unknown device
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1...
Found U-Boot script /boot/boot.scr
3185 bytes read in 16 ms (194.3 KiB/s)
## Executing script at 00c00000
Boot script loaded from mmc 1
199 bytes read in 14 ms (13.7 KiB/s)
18449298 bytes read in 1568 ms (11.2 MiB/s)
30769664 bytes read in 2588 ms (11.3 MiB/s)
112076 bytes read in 98 ms (1.1 MiB/s)
** File not found /boot/dtb/rockchip/overlay/rk35xx-fixup.scr **
Fdt Ramdisk skip relocation
No misc partition
## Loading init Ramdisk from Legacy Image at 0a200000 ...
   Image Name:   uInitrd
   Image Type:   AArch64 Linux RAMDisk Image (gzip compressed)
   Data Size:    18449234 Bytes = 17.6 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 0x0a100000
   Booting using the fdt blob at 0x0a100000
   reserving fdt memory region: addr=a100000 size=81000
   Using Device Tree in place at 000000000a100000, end 000000000a183fff
can't found rockchip,drm-logo, use rockchip,fb-logo
WARNING: could not set reg FDT_ERR_BADOFFSET.
failed to reserve fb-loader-logo memory
Adding bank: 0x00200000 - 0xf0000000 (size: 0xefe00000)
Adding bank: 0x100000000 - 0x200000000 (size: 0x100000000)
Total: 5644.470 ms

Starting kernel ...


Armbian 22.05.0-trunk Jammy ttyS2

rock-3a login:

@catalinii
Copy link
Contributor Author

We can remove it then..

@amazingfate amazingfate mentioned this pull request May 25, 2022
8 tasks
@amazingfate
Copy link
Contributor

@catalinii here is the root cause: https://forum.armbian.com/topic/12352-orange-pi-4/page/3/#comment-94322
There is a known behaviour of newer Rockchip blobs that recovers GPT partitions from a GPT recovery partition table if it finds one and then it cannot boot because there is nothing the blob expects in the recovered partitions.
I remember this happening when one used a vendor prepared image on the sdcard (usually GPT) and then afterwards written the Armbian one (MBR) to the same card.
Because the image is only written to the beginning of the media the recovery GPT partition table stays intact and then it is recovered by a blob which renders the image unusable.
Erasing the recovery partiton table (or the whole card) fixes the issue.

@catalinii
Copy link
Contributor Author

Thanks I noticed that something is off trying to switch between android and armbian for rock 3a, but this explains it.

Last time I used wipefs which did the trick but I think this post explains it.
Thanks for pointing it out.
Do you know if there is a way of documenting this at least @piter75 ?

I am assuming more people will trip over this.

@igorpecovnik
Copy link
Member

Do you know if there is a way of documenting

IMO for start at least adding some warning / known issue / link to this conversation at the download pages.

@catalinii
Copy link
Contributor Author

Do you know where the source of the download page is?

I could add so the message to u-boot...

@igorpecovnik
Copy link
Member

Do you know where the source of the download page is?

WP, have sent you to email.

@catalinii
Copy link
Contributor Author

@piter75 is the code restoring the gpt part of u-boot? If yes can you point out where?

@piter75
Copy link
Member

piter75 commented Jun 10, 2022

@catalinii for rk3399 the GPT restoration was part of the Rockchip's proprietary loader blob IIRC.
For rk3568 we use u-boot's spl as loader so I guess it must be somewhere in Rockchip's u-boot tree.
I did not look for it yet though.

@catalinii
Copy link
Contributor Author

Thx for the pointer

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

Successfully merging this pull request may close these issues.

5 participants