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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/boards/bananapim3.csc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ BOOTCONFIG="Sinovoip_BPI_M3_defconfig"
OVERLAY_PREFIX="sun8i-a83t"
KERNEL_TARGET="legacy,current,edge"
KERNEL_TEST_TARGET="current"

BOOTBRANCH="tag:v2024.01"
BOOTPATCHDIR="u-boot-sunxi/board_${BOARD}"
48 changes: 44 additions & 4 deletions config/bootscripts/boot-sun50i-next.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ setenv console "both"
setenv docker_optimizations "on"
setenv bootlogo "false"

# Remember the default u-boot fdtfile
setenv deffdt_file ${fdtfile}

# Remember the default u-boot fdtdir
setenv deffdt_dir "${prefix}dtb"
if test "$fdtdir" = ""; then setenv fdtdir "${deffdt_dir}";fi

setenv vendor "allwinner"

# Print boot source
itest.b *0x10028 == 0x00 && echo "U-boot loaded from SD"
itest.b *0x10028 == 0x02 && echo "U-boot loaded from eMMC or secondary SD"
Expand All @@ -25,6 +34,37 @@ if test -e ${devtype} ${devnum} ${prefix}armbianEnv.txt; then
env import -t ${load_addr} ${filesize}
fi

# In this shell, we can only check the existence of the file.
# Make a check of reasonable ways to find the dtb file.
# Set the true value of the paths.
if test -e ${devtype} ${devnum} "${fdtdir}/${fdtfile}"; then
:
else
echo "File ${fdtdir}/${fdtfile} does not exists"
if test -e ${devtype} ${devnum} "${deffdt_dir}/${vendor}/${fdtfile}"; then
setenv fdtdir "${deffdt_dir}/${vendor}"
else
echo "File ${deffdt_dir}/${vendor}/${fdtfile} does not exists"
if test -e ${devtype} ${devnum} "${deffdt_dir}/${fdtfile}"; then
setenv fdtdir "${deffdt_dir}"
else
echo "File ${deffdt_dir}/${fdtfile} does not exists"
if test -e ${devtype} ${devnum} "${deffdt_dir}/${vendor}/${deffdt_file}"; then
setenv fdtdir "${deffdt_dir}/${vendor}"
setenv fdtfile "${deffdt_file}"
else
echo "File ${deffdt_dir}/${vendor}/${deffdt_file} does not exists"
if test -e ${devtype} ${devnum} "${deffdt_dir}/${deffdt_file}"; then
setenv fdtdir "${deffdt_dir}"
setenv fdtfile "${deffdt_file}"
else
echo "File ${deffdt_dir}/${deffdt_file} does not exists"
fi
fi
fi
fi
fi

if test "${console}" = "display" || test "${console}" = "both"; then setenv consoleargs "console=ttyS0,115200 console=tty1"; fi
if test "${console}" = "serial"; then setenv consoleargs "console=ttyS0,115200"; fi
if test "${bootlogo}" = "true"; then
Expand All @@ -41,11 +81,11 @@ setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs

if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=memory"; fi

load ${devtype} ${devnum} ${fdt_addr_r} ${prefix}dtb/${fdtfile}
load ${devtype} ${devnum} ${fdt_addr_r} ${fdtdir}/${fdtfile}
fdt addr ${fdt_addr_r}
fdt resize 65536
for overlay_file in ${overlays}; do
if load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/allwinner/overlay/${overlay_prefix}-${overlay_file}.dtbo; then
if load ${devtype} ${devnum} ${load_addr} ${fdtdir}/overlay/${overlay_prefix}-${overlay_file}.dtbo; then
echo "Applying kernel provided DT overlay ${overlay_prefix}-${overlay_file}.dtbo"
fdt apply ${load_addr} || setenv overlay_error "true"
fi
Expand All @@ -58,9 +98,9 @@ for overlay_file in ${user_overlays}; do
done
if test "${overlay_error}" = "true"; then
echo "Error applying DT overlays, restoring original DT"
load ${devtype} ${devnum} ${fdt_addr_r} ${prefix}dtb/${fdtfile}
load ${devtype} ${devnum} ${fdt_addr_r} ${fdtdir}/${fdtfile}
else
if load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/allwinner/overlay/${overlay_prefix}-fixup.scr; then
if load ${devtype} ${devnum} ${load_addr} ${fdtdir}/overlay/${overlay_prefix}-fixup.scr; then
echo "Applying kernel provided DT fixup script (${overlay_prefix}-fixup.scr)"
source ${load_addr}
fi
Expand Down
57 changes: 50 additions & 7 deletions config/bootscripts/boot-sunxi.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ setenv devnum "0"
setenv rootdev "/dev/mmcblk${devnum}p1"
setenv earlycon "off"

# Remember the default u-boot fdtfile
setenv deffdt_file ${fdtfile}

# Remember the default u-boot fdtdir
setenv deffdt_dir "${prefix}dtb"
if test "$fdtdir" = ""; then setenv fdtdir "${deffdt_dir}";fi

setenv vendor "allwinner"

# Print boot source
itest.b *0x28 == 0x00 && echo "U-boot loaded from SD"
itest.b *0x28 == 0x01 && echo "U-boot loaded from NAND"
Expand All @@ -31,13 +40,42 @@ if test "${devtype}" = "mmc"; then
setenv rootdev "/dev/mmcblk${mmc_bootdev}p1"
fi

echo "Boot script loaded from ${devtype}"

if test -e ${devtype} ${devnum} ${prefix}armbianEnv.txt; then
load ${devtype} ${devnum} ${load_addr} ${prefix}armbianEnv.txt
env import -t ${load_addr} ${filesize}
fi

# In this shell, we can only check the existence of the file.
# Make a check of reasonable ways to find the dtb file.
# Set the true value of the paths.
if test -e ${devtype} ${devnum} "${fdtdir}/${fdtfile}"; then
:
else
echo "File ${fdtdir}/${fdtfile} does not exists"
if test -e ${devtype} ${devnum} "${deffdt_dir}/${vendor}/${fdtfile}"; then
setenv fdtdir "${deffdt_dir}/${vendor}"
else
echo "File ${deffdt_dir}/${vendor}/${fdtfile} does not exists"
if test -e ${devtype} ${devnum} "${deffdt_dir}/${fdtfile}"; then
setenv fdtdir "${deffdt_dir}"
else
echo "File ${deffdt_dir}/${fdtfile} does not exists"
if test -e ${devtype} ${devnum} "${deffdt_dir}/${vendor}/${deffdt_file}"; then
setenv fdtdir "${deffdt_dir}/${vendor}"
setenv fdtfile "${deffdt_file}"
else
echo "File ${deffdt_dir}/${vendor}/${deffdt_file} does not exists"
if test -e ${devtype} ${devnum} "${deffdt_dir}/${deffdt_file}"; then
setenv fdtdir "${deffdt_dir}"
setenv fdtfile "${deffdt_file}"
else
echo "File ${deffdt_dir}/${deffdt_file} does not exists"
fi
fi
fi
fi
fi

if test "${console}" = "display"; then setenv consoleargs "console=tty1"; fi
if test "${console}" = "serial"; then setenv consoleargs "console=ttyS0,115200"; fi
if test "${console}" = "both"; then setenv consoleargs "console=ttyS0,115200 console=tty1"; fi
Expand All @@ -50,19 +88,24 @@ fi

setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} hdmi.audio=EDID:0 disp.screen0_output_mode=${disp_mode} consoleblank=0 loglevel=${verbosity} ubootpart=${partuuid} ubootsource=${devtype} usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs}"

if test "${disp_mem_reserves}" = "off"; then setenv bootargs "${bootargs} sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_fb_mem_reserve=16"; fi
if test "${disp_mem_reserves}" = "off"; then
setenv bootargs "${bootargs} sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_fb_mem_reserve=16"
fi

if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=memory"; fi

load ${devtype} ${devnum} ${ramdisk_addr_r} ${prefix}uInitrd
load ${devtype} ${devnum} ${kernel_addr_r} ${prefix}zImage

if test -e ${devtype} ${devnum} "${prefix}.next"; then
echo "Found mainline kernel configuration"
load ${devtype} ${devnum} ${fdt_addr_r} ${prefix}dtb/${fdtfile}
if load ${devtype} ${devnum} ${fdt_addr_r} ${fdtdir}/${fdtfile}; then
echo "Load fdt: ${fdtdir}/${fdtfile}"
fi
fdt addr ${fdt_addr_r}
fdt resize 65536
for overlay_file in ${overlays}; do
if load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/overlay/${overlay_prefix}-${overlay_file}.dtbo; then
if load ${devtype} ${devnum} ${load_addr} ${fdtdir}/overlay/${overlay_prefix}-${overlay_file}.dtbo; then
echo "Applying kernel provided DT overlay ${overlay_prefix}-${overlay_file}.dtbo"
fdt apply ${load_addr} || setenv overlay_error "true"
fi
Expand All @@ -75,9 +118,9 @@ if test -e ${devtype} ${devnum} "${prefix}.next"; then
done
if test "${overlay_error}" = "true"; then
echo "Error applying DT overlays, restoring original DT"
load ${devtype} ${devnum} ${fdt_addr_r} ${prefix}dtb/${fdtfile}
load ${devtype} ${devnum} ${fdt_addr_r} ${fdtdir}/${fdtfile}
else
if load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/overlay/${overlay_prefix}-fixup.scr; then
if load ${devtype} ${devnum} ${load_addr} ${fdtdir}/overlay/${overlay_prefix}-fixup.scr; then
echo "Applying kernel provided DT fixup script (${overlay_prefix}-fixup.scr)"
source ${load_addr}
fi
Expand Down
Loading