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

bootscripts: Allwinner: Bugfix: Remove "allwinner/" from 3 boards configurations #7535

Merged
merged 8 commits into from
Dec 9, 2024

Conversation

The-going
Copy link
Contributor

@The-going The-going commented Dec 2, 2024

Description

Fix the script for it to work correctly and the three configuration files that use this script.

Remove "allwinner/" from all board configurations that use the boot script mechanism
so that the script works correctly.
Tell the user only the actual actions.
Make the script work silently when testing path options and report only the actual file
being uploaded.
Delete the duplicate iteration.

Inform interested users:
@pyavitz @JohnTheCoolingFan @amazingfate @DGxInfinitY

How Has This Been Tested?

  • Test build image
  • Make an emulation of variants of an incorrectly assembled DTB package.
    Where the vendor folder does not exist or the DTB file name is incorrect.

@github-actions github-actions bot added size/medium PR with more then 50 and less then 250 lines Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... and removed size/medium PR with more then 50 and less then 250 lines labels Dec 2, 2024
@igorpecovnik
Copy link
Member

2c

  • all others families must have the same mechanism
  • upgrade must work

@The-going
Copy link
Contributor Author

  • all others families must have the same mechanism

Yes, it is very desirable.

@The-going
Copy link
Contributor Author

The-going commented Dec 3, 2024

[🌱] artifact [ armbian-base-files :: armbian-base-files() ]
jq: error: syntax error, unexpected '/', expecting $end (Unix shell quoting issues?) at <top-level>, line 1:
/home/leo/armbian/.tmp/work-8a8eca9e-3d59-46f4-87d7-cd2a3bc6278a/tmp.QEMp5fi1QC
jq: 1 compile error
[🚸] Could not find package filename for 'base-files' in distro repo [ looking for base-files, found_package_filename is  ]
[🚸] Command failed, retrying in 15s [ apt_find_upstream_package_version_and_download_url base-files ]
jq: error: syntax error, unexpected '/', expecting $end (Unix shell quoting issues?) at <top-level>, line 1:
/home/leo/armbian/.tmp/work-8a8eca9e-3d59-46f4-87d7-cd2a3bc6278a/tmp.qLXMl97IDZ
jq: 1 compile error

What's it? How to deal with it?

=====
It was a normal network outage.
I just waited until the address started pinging and started the build again.
But the error message does not correspond to reality.

@pyavitz
Copy link
Collaborator

pyavitz commented Dec 3, 2024

[🌱] artifact [ armbian-base-files :: armbian-base-files() ]
jq: error: syntax error, unexpected '/', expecting $end (Unix shell quoting issues?) at <top-level>, line 1:
/home/leo/armbian/.tmp/work-8a8eca9e-3d59-46f4-87d7-cd2a3bc6278a/tmp.QEMp5fi1QC
jq: 1 compile error
[🚸] Could not find package filename for 'base-files' in distro repo [ looking for base-files, found_package_filename is  ]
[🚸] Command failed, retrying in 15s [ apt_find_upstream_package_version_and_download_url base-files ]
jq: error: syntax error, unexpected '/', expecting $end (Unix shell quoting issues?) at <top-level>, line 1:
/home/leo/armbian/.tmp/work-8a8eca9e-3d59-46f4-87d7-cd2a3bc6278a/tmp.qLXMl97IDZ
jq: 1 compile error

What's it? How to deal with it?

===== It was a normal network outage. I just waited until the address started pinging and started the build again. But the error message does not correspond to reality.

Happens to me as well. #7514 (comment)

@The-going
Copy link
Contributor Author

Build image and start on board:

mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot/boot.scr
4328 bytes read in 2 ms (2.1 MiB/s)
## Executing script at 4fc00000
U-boot loaded from SD
Boot script loaded from mmc
240 bytes read in 2 ms (117.2 KiB/s)
Load fdt: /boot/dtb/allwinner/sun50i-a64-bananapi-m64.dtb
41803 bytes read in 5 ms (8 MiB/s)
Working FDT set to 4fa00000
3821 bytes read in 3 ms (1.2 MiB/s)
Applying kernel provided DT fixup script (sun50i-a64-fixup.scr)
## Executing script at 45000000
11007902 bytes read in 513 ms (20.5 MiB/s)
24301576 bytes read in 1129 ms (20.5 MiB/s)

OK!

Test 2:
If fdtfile=allwinner/sun50i-a64-bananapi-m64.dtb

U-boot loaded from SD
Boot script loaded from mmc
250 bytes read in 1 ms (244.1 KiB/s)
The file allwinner/sun50i-a64-bananapi-m64.dtb was not found in the path /boot/dtb/allwinner
Load fdt: /boot/dtb/allwinner/sun50i-a64-bananapi-m64.dtb
41803 bytes read in 4 ms (10 MiB/s)
Working FDT set to 4fa00000
Failed to load '/boot/dtb/overlay/sun50i-a64-fixup.scr'
11007902 bytes read in 513 ms (20.5 MiB/s)
24301576 bytes read in 1128 ms (20.5 MiB/s)
Moving Image from 0x40080000 to 0x40200000, end=41a00000
## Loading init Ramdisk from Legacy Image at 4ff00000 ...
   Image Name:   uInitrd
   Image Type:   AArch64 Linux RAMDisk Image (gzip compressed)
   Data Size:    11007838 Bytes = 10.5 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 4fa00000
   Booting using the fdt blob at 0x4fa00000
Working FDT set to 4fa00000
   Loading Ramdisk to 49580000, end 49fff75e ... OK
   Loading Device Tree to 000000004950d000, end 000000004957ffff ... OK
Working FDT set to 4950d000

Starting kernel ...

For the DTB file, the error was handled correctly, the kernel loaded,
but overlays are not available. And this is easily fixed by removing
the vendor's name from the DTB file name.

Test 3:
dtb -> dtb-6.11.9-edge-sunxi64/allwinner

ls /boot/dtb/
overlay                               sun50i-a64-sopine-baseboard.dtb         sun50i-h616-bigtreetech-pi.dtb
sun50i-a100-allwinner-perf1.dtb       sun50i-a64-teres-i.dtb                  sun50i-h616-orangepi-zero2.dtb
sun50i-a64-amarula-relic.dtb          sun50i-h313-tanix-tx1.dtb               sun50i-h616-x96-mate.dtb
sun50i-a64-bananapi-m64.dtb           sun50i-h313-x96q-lpddr3.dtb             sun50i-h618-bananapi-m4-zero.dtb
sun50i-a64-nanopi-a64.dtb             sun50i-h5-bananapi-m2-plus.dtb          sun50i-h618-longanpi-3h.dtb
.....
U-boot loaded from SD
Boot script loaded from mmc
240 bytes read in 2 ms (117.2 KiB/s)
The file sun50i-a64-bananapi-m64.dtb was not found in the path /boot/dtb/allwinner
Load fdt: /boot/dtb/sun50i-a64-bananapi-m64.dtb
41803 bytes read in 5 ms (8 MiB/s)
Working FDT set to 4fa00000
3821 bytes read in 3 ms (1.2 MiB/s)
Applying kernel provided DT fixup script (sun50i-a64-fixup.scr)
## Executing script at 45000000
11007902 bytes read in 513 ms (20.5 MiB/s)
24301576 bytes read in 1128 ms (20.5 MiB/s)

OK!

Test 4:
The nonexistent name of the DTB in the file armbianEnv.txt .

...... ERROR....

In the board/sunxi/board.c#L826 file, this is a hard-coded value.
As fdtfile=allwinner/sun50i-a64-bananapi-m64.dtb

I can fix this with a patch, but other users who will use other versions of u-boot
or other folders for patches or board configurations that do not have a record of the DTB file name....
In general, this is not an option.

@The-going The-going marked this pull request as draft December 3, 2024 20:02
@pyavitz
Copy link
Collaborator

pyavitz commented Dec 3, 2024

I don't understand why Armbian uses dtb . Wouldn't it make more sense to have everything under /boot/$platform which in this case the $fdtfile var is already looking for.

Hit any key to stop autoboot:  0 
=> echo $fdtfile
amlogic/meson-gxl-s905x-libretech-cc.dtb

It seems to me this is just adding an extra layer of confusion to the boot process.

Of course this can be adjusted by setting your own var in the script.

=> setenv armbianfdt dtb/$fdtfile 
=> echo $armbianfdt
dtb/amlogic/meson-gxl-s905x-libretech-cc.dtb

Using this logic the overlay dir can also be set as a var.

=> setenv platform dtb/amlogic
=> setenv olydir $platform/overlay
=> echo $olydir
dtb/amlogic/overlay

I don't do exactly this, but something like it in a boot.cmd script I've been working on.
https://github.com/pyavitz/debian-image-builder/blob/feature/files/boot/boot.cmd

Anyway, I think removing the vendors name and or platform would be a bad idea.

EDIT:
Ah I see what ur suggesting. Link dtb to the platform dir that resides inside the dtb package dtb -> dtb-6.11.9-edge-sunxi64/allwinner

Copy link
Contributor

@JohnTheCoolingFan JohnTheCoolingFan left a comment

Choose a reason for hiding this comment

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

Tested on BigTreeTech CB1, no issues

@The-going
Copy link
Contributor Author

The-going commented Dec 4, 2024

Description of the problem:

The kernel and in particular the linux-dtb package may have been assembled
incorrectly and may or may not contain the vendor's name in the path,
there may also be a link to dtb -> dtb-6.11.9-edge-sunxi64/allwinner
or a file armbianEnv.txt it can be edited manually and contain a non-existing file name.
In this case, we get the board cannot load.

What do we have with the values of the variables by default in the u-boot?

sunxi:
${prefix}dtb=/boot/dtb
${fdtfile}=sun8i-*.dtb

sunxi64:
${prefix}dtb=/boot/dtb
${fdtfile}=allwinner/sun50i-*.dtb

And it's hard-coded in the u-boot itself. In the board/sunxi/board.c#L826 file.
It makes little sense to change this in the source code.
In this regard, the question:
How can we remove "allwinner/" from the filename string using only the u-boot shell?

@The-going
Copy link
Contributor Author

How can we remove "allwinner/" from the filename string using only the u-boot shell?

I have found a solution! This is the setexpr command.
CONFIG_CMD_SETEXPR=y
CONFIG_REGEX=y
We need these two u-boot configuration parameters and they are present.

Test 4:
dtb -> dtb-6.11.9-edge-sunxi64/allwinner
The nonexistent name of the DTB in the file armbianEnv.txt

Found U-Boot script /boot/boot.scr
4476 bytes read in 2 ms (2.1 MiB/s)
## Executing script at 4fc00000
sfdt_f=sun50i-a64-bananapi-m64.dtb
deffdt_file=sun50i-a64-bananapi-m64.dtb
U-boot loaded from SD
Boot script loaded from mmc
243 bytes read in 1 ms (237.3 KiB/s)
The file sun50i-a64-bananapi-m64-V7.dtb was not found in the path /boot/dtb/allwinner
Load fdt: /boot/dtb/sun50i-a64-bananapi-m64.dtb
41803 bytes read in 5 ms (8 MiB/s)
Working FDT set to 4fa00000
3821 bytes read in 3 ms (1.2 MiB/s)
Applying kernel provided DT fixup script (sun50i-a64-fixup.scr)
## Executing script at 45000000
11007902 bytes read in 513 ms (20.5 MiB/s)
24301576 bytes read in 1129 ms (20.5 MiB/s)

It cannot download a non-existent file and downloads the file by default.
The path is broken at the same time.

The file sun50i-a64-bananapi-m64-V7.dtb was not found in the path /boot/dtb/allwinner
Load fdt: /boot/dtb/sun50i-a64-bananapi-m64.dtb

@github-actions github-actions bot added the size/medium PR with more then 50 and less then 250 lines label Dec 4, 2024
@The-going The-going marked this pull request as ready for review December 4, 2024 19:28
@The-going
Copy link
Contributor Author

Test's:
dtb -> dtb-6.11.9-edge-sunxi64/allwinner
dtb -> dtb-6.11.9-edge-sunxi64

fdtfile=sun50i-a64-bananapi-m64.dtb
fdtfile=allwinner/sun50i-a64-bananapi-m64.dtb

fdtfile=sun50i-a64-bananapi-m64-V7.dtb
fdtfile=allwinner/sun50i-a64-bananapi-m64-V7.dtb
For these incorrect options, the message will be the same.
There is no difference whether we specify the vendor or not.

The file sun50i-a64-bananapi-m64-V7.dtb was not found in the path /boot/dtb/allwinner
Load fdt: /boot/dtb/allwinner/sun50i-a64-bananapi-m64.dtb

2x4=8 OK!

@The-going
Copy link
Contributor Author

The-going commented Dec 5, 2024

Test's for sunxi on board bananapi-m3:

2x4=8 OK!

Check for updates and reboots as well.
@igorpecovnik We have something broken in the system scripts for updating.
There are two cores installed on my system: current and edge.
After the update, I see a mess:

leo@bananapim3:~$ uname -r
6.6.62-current-sunxi
...
dtb -> dtb-6.11.9-edge-sunxi
uInitrd -> uInitrd-6.11.9-edge-sunxi
zImage -> vmlinuz-6.6.62-current-sunxi
....

I am surprised at this avant-garde behavior.
I hadn't noticed this before.

After testing:
Do not inform the user if the fixup.scr file was not found.

@The-going
Copy link
Contributor Author

I'm done with this

@The-going
Copy link
Contributor Author

After the update, I see a mess:

leo@bananapim3:~$ uname -r
6.6.62-current-sunxi
...
dtb -> dtb-6.11.9-edge-sunxi
uInitrd -> uInitrd-6.11.9-edge-sunxi
zImage -> vmlinuz-6.6.62-current-sunxi
....

I just downloaded this package and installed it manually.
Everything went right.
It looks like what's wrong with debian

Copy link
Collaborator

@pyavitz pyavitz left a comment

Choose a reason for hiding this comment

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

Tested on the BPI-M4-Zero

@igorpecovnik
Copy link
Member

igorpecovnik commented Dec 7, 2024

There are two cores installed on my system: current and edge.

You should only have one kernel installed.

Tested on the BPI-M4-Zero

Allwinner is good with this PR and should we alter all build configs at once? What about others - amlogic, rockchip, exotics ... are we confident to just change?

Yes, its some work.

@The-going
Copy link
Contributor Author

The-going commented Dec 7, 2024

What about others

rockchip64 - I can do it and check it out.

But let's first combine this into the main one and look at the reaction of users for 2-3 months.

I've rebased this relative to the main branch.

Set the expected default path to /boot/dtb/allwinner and
start analyzing if the DTB file is not found in this path.

The folder with the vendor's name is now part of the path,
not part of the file name. This greatly facilitates the analysis
of various possible options in a simple u-boot shell.
Inform the user about the actual file that will be uploaded
on the first iteration. Inform the user that it cannot be
downloaded only once if the first iteration was unsuccessful.
In the second iteration, we check the path that does not
contain the vendor folder. But this will also be done if
the real path contains the vendor's folder and the vendor's
name is contained in the DTB file name as
    fdtfile=allwinner/sun50i-*-bananapi-*.dtb.
However, overlays will not be available.
Remove "allwinner/" from all board configurations that
use the boot script mechanism so that the script works
correctly.

Signed-off-by: The-going <[email protected]>
Use the DTB name from the u-boot default for the third
iteration if the provided DTB name was not found. Also
delete the duplicate of the previous iteration.
Make the script work silently when testing path options
and report only the actual file being uploaded.
Delete the duplicate iteration.
After that, the script successfully loads the DTB file from
two possible paths and overlays. If the file does not exist,
then the default file will be uploaded.
Do not inform the user if the fixup.scr file was not found.
@The-going
Copy link
Contributor Author

Now we can set two variables in the file armbianEnv.txt
fdtdir=/path/to/dtb/allwinner
fdtfile=name-board.dtb
Any path can be set.

@igorpecovnik igorpecovnik added Ready to merge Reviewed, tested and ready for merge 02 Milestone: First quarter release labels Dec 9, 2024
@igorpecovnik igorpecovnik merged commit 24e7bcf into armbian:main Dec 9, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
02 Milestone: First quarter release Hardware Hardware related like kernel, U-Boot, ... Needs review Seeking for review Ready to merge Reviewed, tested and ready for merge size/medium PR with more then 50 and less then 250 lines
Development

Successfully merging this pull request may close these issues.

4 participants