Skip to content

Commit 0c91988

Browse files
committed
bootable: u-boot: handle UBOOT_KERNEL_DTB being unset better
- require it for boot.scr scenario - allow it for extlinux.conf, setup fdtdir - better extlinux LABEL Signed-off-by: Ricardo Pardini <[email protected]>
1 parent 4bdafb9 commit 0c91988

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

bash/bootable/armbian-u-boot.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ function write_uboot_script() {
188188
declare fat32_root_dir="${1}"
189189
declare boot_cmd_file="${fat32_root_dir}/boot.cmd"
190190

191+
# It is absolutely unlikely that a (vendor/legacy) boot script will be used with a board that has fdtfile preset correctly.
192+
# Thus check UBOOT_KERNEL_DTB is set, or bomb.
193+
if [[ -z "${UBOOT_KERNEL_DTB}" ]]; then
194+
log error "UBOOT_KERNEL_DTB is unset -- vendor/boot.scr requires a DTB to be set"
195+
exit 2
196+
fi
197+
191198
declare console_extra_args="${bootable_info['CONSOLE_EXTRA_ARGS']:-""}"
192199
cat <<- BOOT_CMD > "${boot_cmd_file}"
193200
# Hook u-boot bootscript; mkimage -C none -A arm -T script -d /boot.cmd /boot.scr
@@ -233,14 +240,25 @@ function write_uboot_extlinux() {
233240
mkdir -p "${fat32_root_dir}/extlinux"
234241
declare extlinux_conf="${fat32_root_dir}/extlinux/extlinux.conf"
235242
cat <<- EXTLINUX_CONF > "${extlinux_conf}"
236-
DEFAULT hook
237-
LABEL hook
243+
DEFAULT Tinkerbell Hook ${BOARD} ${BRANCH}
244+
LABEL Tinkerbell Hook ${BOARD} ${BRANCH}
238245
linux /vmlinuz
239246
initrd /initramfs
240247
append ${bootargs} ${tinkerbell_args}
241-
fdt /dtb/${UBOOT_KERNEL_DTB}
242248
EXTLINUX_CONF
243-
# @TODO: fdtdir when UBOOT_KERNEL_DTB is unset
249+
250+
# If UBOOT_KERNEL_DTB is not set, just pass the fdtdir
251+
if [[ -z "${UBOOT_KERNEL_DTB}" ]]; then
252+
log info "UBOOT_KERNEL_DTB is unset; using fdtdir instead"
253+
cat <<- EXTLINUX_CONF_FDTDIR >> "${extlinux_conf}"
254+
fdtdir /dtb/
255+
EXTLINUX_CONF_FDTDIR
256+
else
257+
log info "UBOOT_KERNEL_DTB is set (${UBOOT_KERNEL_DTB}); using it in extlinux.conf"
258+
cat <<- EXTLINUX_CONF_DTB >> "${extlinux_conf}"
259+
fdt /dtb/${UBOOT_KERNEL_DTB}
260+
EXTLINUX_CONF_DTB
261+
fi
244262

245263
log_file_bat "${extlinux_conf}" "info" "Produced Armbian u-boot extlinux.conf"
246264

0 commit comments

Comments
 (0)