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

bootscript: sunxi: Add a dtb file path analyzer #7484

Merged
merged 2 commits into from
Nov 18, 2024

Conversation

The-going
Copy link
Contributor

@The-going The-going commented Nov 16, 2024

Description

Device tree files and overlay files are interconnected
and always located in the same place, separated by
the overlay subdirectory.
${fdtdir}/${fdtfile}
${fdtdir}/overlay/${overlay_prefix}-${overlay_file}.dtbo

By default, we are trying to download a dtb file from
the /boot/dtb folder, which is a link to the real folder.
Depending on the time and type of build, this link may
point directly to the target folder or to a subdirectory,
i.e. possible path options:
/boot/dtb/overlay
/boot/dtb/allwinner/overlay
In the file armbianEnv.txt we can also see:
fdtfile=sun8i-*.dtb
or
fdtfile=allwinner/sun8i-*.dtb

Thus, when the user has frozen the kernel and updated
the BSP package, or vice versa, updated only the kernel,
the following options are possible in the paths after
their concatenation in the script:
/boot/dtb/sun8i-*.dtb
/boot/dtb/allwinner/sun8i-*.dtb
/boot/dtb/allwinner/allwinner/sun8i-*.dtb
But only one is real.

Define and remember default path variables.
Provide the user with the ability to specify the path
to the target folder as:
fdtdir=/path/to/dir
Check the existence of the dtb file in all reasonable
paths and set the path to it.
If not found, download the default file from the default path.

How Has This Been Tested?

  • Test A
  • Test B

I think I've tested a lot of options.
But it only seems so.

@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, ... labels Nov 16, 2024
@igorpecovnik
Copy link
Member

Do we need to merge this to current release?

@The-going
Copy link
Contributor Author

The-going commented Nov 18, 2024

Do we need to merge this to current release?

Yes.
After that, I will be able to return the location of the files to the path:
/boot/dtb/allwinner/overlay
And it will be safe!

@igorpecovnik
Now, at each iteration of the search, there will be a message that the file was not found in the path.
If a false directory and a false file are specified, there may be 4 such messages and the latter will inform you about the correct download.

Scanning mmc 0:1...
Found U-Boot script /boot/boot.scr
5426 bytes read in 7 ms (756.8 KiB/s)
## Executing script at 43100000
U-boot loaded from SD
277 bytes read in 5 ms (53.7 KiB/s)
File /boot/dtb/allwinner/sun8i-a83t-bananapi-m3.dtb is not exist
File /boot/dtb/allwinner/sun8i-a83t-bananapi-m3.dtb is not exist
10694724 bytes read in 472 ms (21.6 MiB/s)
8985616 bytes read in 395 ms (21.7 MiB/s)
Found mainline kernel configuration
37011 bytes read in 22 ms (1.6 MiB/s)
Load fdt: /boot/dtb/sun8i-a83t-bananapi-m3.dtb
Working FDT set to 43000000
Failed to load '/boot/dtb/overlay/sun8i-a83t-fixup.scr'
Kernel image @ 0x42000000 [ 0x000000 - 0x891c10 ]
## Loading init Ramdisk from Legacy Image at 43400000 ...
   Image Name:   uInitrd
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)

What do you think?

@The-going
Copy link
Contributor Author

By the way, I encountered this problem in rockchip when I was just using the package manager to change three possible kernel boot options.
For one option, I had to redo the symbolic link /boot/dtb

@igorpecovnik igorpecovnik added the 11 Milestone: Fourth quarter release label Nov 18, 2024
@igorpecovnik
Copy link
Member

there will be a message that the file was not found in the path.

OK, I assume we have no option to silence that?

@The-going
Copy link
Contributor Author

The-going commented Nov 18, 2024

echo "File ${deffdt_dir}/${fdtfile} is not exist"
Two out of five possible outputs:

File /boot/dtb/allwinner/sun8i-a83t-bananapi-m3.dtb is not exist
File /boot/dtb/allwinner/sun8i-a83t-bananapi-m3.dtb is not exist

If # echo "File ${deffdt_dir}/${fdtfile} is not exist"
There will be only one message about the actual path found.
Load fdt: /boot/dtb/sun8i-a83t-bananapi-m3.dtb
Today I thought it was wise.
For debugging, the user can uncomment.

Device tree files and overlay files are interconnected
and always located in the same place, separated by
the overlay subdirectory.
${fdtdir}/${fdtfile}
${fdtdir}/overlay/${overlay_prefix}-${overlay_file}.dtbo

By default, we are trying to download a dtb file from
the /boot/dtb folder, which is a link to the real folder.
Depending on the time and type of build, this link may
point directly to the target folder or to a subdirectory,
i.e. possible path options:
/boot/dtb/overlay
/boot/dtb/allwinner/overlay
In the file armbianEnv.txt we can also see:
fdtfile=sun8i-*.dtb
or
fdtfile=allwinner/sun8i-*.dtb

Thus, when the user has frozen the kernel and updated
the BSP package, or vice versa, updated only the kernel,
the following options are possible in the paths after
their concatenation in the script:
/boot/dtb/sun8i-*.dtb
/boot/dtb/allwinner/sun8i-*.dtb
/boot/dtb/allwinner/allwinner/sun8i-*.dtb

Define and remember default path variables.
Provide the user with the ability to specify the path
to the target folder as:
fdtdir=/path/to/dir
Check the existence of the dtb file in all reasonable
paths and set the path to it.
If not found, download the default file from the default path.

Signed-off-by: The-going <[email protected]>
@The-going
Copy link
Contributor Author

Done

@igorpecovnik igorpecovnik added the Ready to merge Reviewed, tested and ready for merge label Nov 18, 2024
@igorpecovnik igorpecovnik merged commit 3e07d3e into armbian:main Nov 18, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
11 Milestone: Fourth 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.

2 participants