Skip to content

Commit 4840514

Browse files
authored
bootable: fixes for non-serial console, fdt handling, and rk-vendor uinitrd (#269)
#### bootable: u-boot rk vendor: fixes for uinitrd; pass tink params; add blade3 board - actually enables vendor/boot.scr-based bootables to work #### 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 #### common: log_file_bat(): work with Debian's bat pkg; never use pager - `bat` is called `batcat` in Debian's `bat` package - `--paging=never` so it won't hang #### bootable: u-boot (extlinux/boot.scr): always include `tty0` console - otherwise only serial output #### bootable: grub: always include `tty0` console - otherwise only serial output
2 parents f4ede19 + 6f057c9 commit 4840514

File tree

4 files changed

+41
-10
lines changed

4 files changed

+41
-10
lines changed

bash/bootable/armbian-u-boot.sh

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function build_bootable_armbian_uboot_rockchip() {
4141
function list_bootable_armbian_uboot_rockchip_vendor() {
4242
declare -g -A bootable_boards=()
4343
bootable_boards["r58x"]="BOARD=mekotronics-r58x-pro BRANCH=vendor"
44+
bootable_boards["blade3"]="BOARD=mixtile-blade3 BRANCH=vendor"
4445
}
4546

4647
function build_bootable_armbian_uboot_rockchip_vendor() {
@@ -187,6 +188,19 @@ function write_uboot_script_or_extlinux() {
187188
function write_uboot_script() {
188189
declare fat32_root_dir="${1}"
189190
declare boot_cmd_file="${fat32_root_dir}/boot.cmd"
191+
192+
# It is absolutely unlikely that a (vendor/legacy) boot script will be used with a board that has fdtfile preset correctly.
193+
# Thus check UBOOT_KERNEL_DTB is set, or bomb.
194+
if [[ -z "${UBOOT_KERNEL_DTB}" ]]; then
195+
log error "UBOOT_KERNEL_DTB is unset -- vendor/boot.scr requires a DTB to be set"
196+
exit 2
197+
fi
198+
199+
declare -g -a bootable_tinkerbell_kernel_params=()
200+
fill_array_bootable_tinkerbell_kernel_parameters "${BOARD}"
201+
declare tinkerbell_args="${bootable_tinkerbell_kernel_params[*]}"
202+
203+
declare console_extra_args="${bootable_info['CONSOLE_EXTRA_ARGS']:-""}"
190204
cat <<- BOOT_CMD > "${boot_cmd_file}"
191205
# Hook u-boot bootscript; mkimage -C none -A arm -T script -d /boot.cmd /boot.scr
192206
echo "Starting Tinkerbell Hook boot script..."
@@ -195,7 +209,7 @@ function write_uboot_script() {
195209
setenv ramdisk_addr_r "0x40000000"
196210
test -n "\${distro_bootpart}" || distro_bootpart=1
197211
echo "Boot script loaded from \${devtype} \${devnum}:\${distro_bootpart}"
198-
setenv bootargs "${UBOOT_EXTLINUX_CMDLINE}"
212+
setenv bootargs "${UBOOT_EXTLINUX_CMDLINE} console=tty0 console=${UBOOT_KERNEL_SERIALCON}${console_extra_args} ${tinkerbell_args}"
199213
echo "Booting with: \${bootargs}"
200214
201215
echo "Loading initramfs... \${ramdisk_addr_r} /uinitrd"
@@ -212,6 +226,9 @@ function write_uboot_script() {
212226
booti \${kernel_addr_r} \${ramdisk_addr_r} \${fdt_addr_r}
213227
BOOT_CMD
214228

229+
log info "Marking uinitrd.wanted..."
230+
touch "${fat32_root_dir}/uinitrd.wanted" # marker file for utility run during fat32 image creation; see create_image_fat32_root_from_dir()
231+
215232
log_file_bat "${boot_cmd_file}" "info" "Produced Armbian u-boot boot.cmd/boot.scr"
216233

217234
return 0
@@ -221,7 +238,7 @@ function write_uboot_extlinux() {
221238
declare fat32_root_dir="${1}"
222239

223240
declare console_extra_args="${bootable_info['CONSOLE_EXTRA_ARGS']:-""}"
224-
declare bootargs="${UBOOT_EXTLINUX_CMDLINE} console=${UBOOT_KERNEL_SERIALCON}${console_extra_args}"
241+
declare bootargs="${UBOOT_EXTLINUX_CMDLINE} console=tty0 console=${UBOOT_KERNEL_SERIALCON}${console_extra_args}"
225242
log info "Writing extlinux.conf; kernel cmdline: ${bootargs}"
226243

227244
declare -g -a bootable_tinkerbell_kernel_params=()
@@ -231,14 +248,25 @@ function write_uboot_extlinux() {
231248
mkdir -p "${fat32_root_dir}/extlinux"
232249
declare extlinux_conf="${fat32_root_dir}/extlinux/extlinux.conf"
233250
cat <<- EXTLINUX_CONF > "${extlinux_conf}"
234-
DEFAULT hook
235-
LABEL hook
251+
DEFAULT Tinkerbell Hook ${BOARD} ${BRANCH}
252+
LABEL Tinkerbell Hook ${BOARD} ${BRANCH}
236253
linux /vmlinuz
237254
initrd /initramfs
238255
append ${bootargs} ${tinkerbell_args}
239-
fdt /dtb/${UBOOT_KERNEL_DTB}
240256
EXTLINUX_CONF
241-
# @TODO: fdtdir when UBOOT_KERNEL_DTB is unset
257+
258+
# If UBOOT_KERNEL_DTB is not set, just pass the fdtdir
259+
if [[ -z "${UBOOT_KERNEL_DTB}" ]]; then
260+
log info "UBOOT_KERNEL_DTB is unset; using fdtdir instead"
261+
cat <<- EXTLINUX_CONF_FDTDIR >> "${extlinux_conf}"
262+
fdtdir /dtb/
263+
EXTLINUX_CONF_FDTDIR
264+
else
265+
log info "UBOOT_KERNEL_DTB is set (${UBOOT_KERNEL_DTB}); using it in extlinux.conf"
266+
cat <<- EXTLINUX_CONF_DTB >> "${extlinux_conf}"
267+
fdt /dtb/${UBOOT_KERNEL_DTB}
268+
EXTLINUX_CONF_DTB
269+
fi
242270

243271
log_file_bat "${extlinux_conf}" "info" "Produced Armbian u-boot extlinux.conf"
244272

bash/bootable/fat32-image.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ function create_image_fat32_root_from_dir() {
2222
set -x
2323
2424
# Hack: transform the initramfs using mkimage to a u-boot image # @TODO refactor this out of here
25-
if [ -f /work/input/initramfs ]]; then
25+
ls -lah /work/input
26+
if [[ -f /work/input/uinitrd.wanted ]]; then
2627
mkimage -A arm64 -O linux -T ramdisk -C gzip -n uInitrd -d /work/input/initramfs /work/input/uinitrd
27-
#rm -f /work/input/initramfs
28+
rm -f /work/input/initramfs /work/input/uinitrd.wanted
2829
ls -lah /work/input/uinitrd
2930
fi
3031

bash/bootable/grub.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function build_bootable_grub() {
1414

1515
declare hook_id="${bootable_info['INVENTORY_ID']}"
1616
declare bootable_img="bootable_grub_${OUTPUT_ID}.img"
17-
declare kernel_command_line="console=${bootable_info['SERIAL_CONSOLE']}" # @TODO: common stuff for tink, etc
17+
declare kernel_command_line="console=tty0 console=${bootable_info['SERIAL_CONSOLE']}"
1818

1919
declare has_dtbs="${bootable_info['DTB']}"
2020
[[ -z "${has_dtbs}" ]] && has_dtbs="no"

bash/common.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ function log_file_bat() {
4747
extra_bat_args+=("--language=${bat_language}")
4848
fi
4949
if command -v bat > /dev/null; then
50-
bat --color=always "${extra_bat_args[@]}" "${file}"
50+
bat --color=always --paging=never "${extra_bat_args[@]}" "${file}"
51+
elif command -v batcat > /dev/null; then
52+
batcat --color=always --paging=never "${extra_bat_args[@]}" "${file}"
5153
else
5254
log "${level}" "'bat' utility not installed; install it to see file contents in logs."
5355
fi

0 commit comments

Comments
 (0)