Yes. I tried with the same address @Deadmeat used, but that crashes that minikernel GRUB has. So I used the same address I load Linux kernel to, usually. To my understanding, that is the execution address u-Boot execute system kernel from. Putting GRUB there makes sense in order to load it. Maybe that could be the issue? That both GRUB and Kernel may share the same address? That wouldn’t make sense to cause an issue - by execution of the kernel, GRUB memory is being overwritten, as it is no longer needed. So that shouldn’t have an impact. GRUB itself works fine. I am able to enter it’s shell, run commands, etc. It no longer reboots the host. Just trying to boot my vmlinuz ended up in this weird timer error reset loop. As for WDT, I do disable it during GRUB execution, so it doesn’t intervene. That is why I can leave GRUB loaded for an hour without board resetting itself. I only had to build u-Boot with wdtcmd enabled.
For now, I am rebuilding zImage with initrd disabled (I had it enabled, but without initramfs.cpio), to test. As far as I know, zImage comes without initramfs, which is always served separately (ad-hoc built on the host usually). I in the end used the same process to create my initramfs, which I have confirmed to work. So my understanding is, that maybe having that flag enabled in kernel could confuse both GRUB and the kernel itself during boot. I already was able to start the boot, but it was being reset by watchdog (which is now disabled). So I have to backtrack what changes I did since, which may have this weird impact (that timer reset is caused by the fact that GRUB can’t load ‘serial’ driver - it is not present for arm). I have since disabled this declaration, as console could be configured for serial TTY, which also works. I will do another test once my current kernel build is ready (which, being done on the HW itself, takes up to 20 minutes - on my desktop box it is 1 minute, but then I do not rebuild whole tree and have much more horsepower). Sometimes being lazy has it price.
Update: also unsuccessful. That error plagues me…
data abort
pc : [<80201bb4>] lr : [<80201bad>]
sp : 802523a0 ip : 00000000 fp : 00002000
r10: 00000000 r9 : 00076cc0 r8 : ffb85180
r7 : 802523a0 r6 : 00076cc0 r5 : 00000000 r4 : 0000000f
r3 : 88cb089d r2 : 000003fd r1 : 00005ad8 r0 : 88cb6375
Flags: Nzcv IRQs off FIQs off Mode SVC_32 (T)
Code: c302 23e0 b9a3 2e0b (bde3) b887
Resetting CPU ...
resetting ...
Could not initialize timer (err -11)
resetting ...
Could not initialize timer (err -11)
resetting ...
Could not initialize timer (err -11)
resetting ...
Could not initialize timer (err -11)
resetting ...
Could not initialize timer (err -11)
UPDATE2:
Changed GRUB load address. Now it tries to load zImage, complain about its wrong format, and then skip back to that reset timer loop. That timer reset loop is just a consequence - basically the kernel execution process dies, and with WMT disabled, it complains about freeze (as far as I can deduce from what I found over the net).
The problem is still zImage format and the reason why it is being wrong.
UPDATE3:
I’ve noticed few problems with my setup since last posting here. All resolved, up till the GRUB boot. GRUB boots fine, it also is able to load initramfs, but I still do face bellow error while trying booting:
error: invalid zImage
u-Boot built-in configuration:
scriptaddr=0x83000000
bpi=bananapi
board=bpi-r2
service=linux
device=mmc
partition=1:1
partition-sd=1:1
partition-mmc=0:1
bootenv=uEnv.txt
kernel=uImage-5.15.173-bpi-r2-main
loadaddr=0x80200000
loadaddrgrub=0x89000000
kaddr=0x84000000
rdaddr=0x86000000
#default bootargs will be overidden by buildargs
bootargs=console=ttyS0,115200 root=/dev/mmcblk1p2 rw rootwait ip=dhcp
zfs-param=zfs.zfs_scrub_delay=8 zfs.zfs_scan_strict_mem_lim=1 zfs.zfs_scan_mem_lim_fact=80 zfs.zfs_scan_mem_lim_soft_fact=80 zfs.zfs_vdev_scrub_max_active=1 zfs.zfs_vdev_sync_read_max_active=2 zfs.zfs_top_maxinflight=3 zfs.zvol_threads=3 zfs.zfs_scan_issue_strategy=2 zfs.zfs_arc_max=83886080 zfs.zfs_scan_legacy=1 zfs.zfs_txg_timeout=8 zfs.zfs_prefetch_disable=1
console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200
root=/dev/mmcblk1p2 rootfstype=ext4 rootwait
root-mmc=/dev/mmcblk1p2 rootfstype=ext4 rootwait
root-sd=/dev/mmcblk0p2 rootfstype=ext4 rootwait
root-zfs=ZFS=rpool/ROOT/ubuntu_h1wz1w
root-grub=/dev/mmcblk1p1
root-nfs=/dev/nfs
bootfile=/boot/uImage-5.15.173-bpi-r2-main
ubootfile=/boot/u-boot.bin
#Netboot
ipaddr=10.43.17.85
netmask=255.255.255.248
serverip=10.43.16.139
#NFS
nfsip=10.43.16.139
nfsrfs=/opt/nfs/bpi-r2/ap-unimatrix
setnfsargs=setenv netbootargs "board=${board} ${console} ip=${ipaddr}:${serverip}:${serverip}:${netmask}::wan::${serverip}:10.43.16.1 root=${root-nfs} rw nfsroot=${serverip}:${nfsrfs} ${bootopts} ${graphic}";
bootnfs=run setnfsargs newboot-nfs
bootfile=uImage-5.15.173-bpi-r2-main
ubootfile=u-boot.bin
netbootargs=board=${board} ${console} ip=${ipaddr}:${serverip}:${serverip}:${netmask}::wan::${serverip}:10.43.16.1 root=${root-nfs} rw nfsroot=${serverip}:${nfsrfs},nfsvers=3,tcp nfsrootdebug ${bootopts} ${graphic}
bootopts=vmalloc=512M debug=0 initcall_debug=0 ipv6.disable=1 fsck.mode=force fsck.repair=yes init_on_alloc=0 panic=30 delayacct
graphic=video=HDMI-A-1:1280x1024D console=tty1 fbcon=map:0 drm.debug=0
buildargs=setenv bootargs "board=${board} ${console} root=${root} ${bootopts} ${graphic}"
buildargs-mmc=setenv bootargs "board=${board} ${console} root=${root-mmc} ${bootopts} ${graphic}"
buildargs-sd=setenv bootargs "board=${board} ${console} root=${root-sd} ${bootopts} ${graphic}"
buildargs-zfs=setenv bootargs "board=${board} ${console} root=${root-zfs} ${bootopts} ${graphic} ${zfs-param}"
#buildargs-grub=setenv bootargs "board=${board} ${console} root=${root-grub} ${bootopts} ${graphic}"
buildargs-nfs=setenv bootargs "board=${board} ${console} ip=${ipaddr}:${serverip}:${serverip}:${netmask}::wan::${serverip}:10.43.16.1 root=${root-nfs} rw nfsroot=${serverip}:${nfsrfs},nfsvers=3,tcp nfsrootdebug ${bootopts} ${graphic}"
checkenv=test -e ${device} ${partition} ${bpi}/${board}/${service}/${bootenv}
importenv=env import -t ${scriptaddr} ${filesize}
loadbootenv=if fatload ${device} ${partition} ${scriptaddr} ${bpi}/${board}/${service}/${bootenv};then run importenv;else echo "fatload (${bootenv}) failed";fi
resetenv=env default -a;printenv;
checksd=fatinfo ${device} 1:1
selectmmc=if run checksd; then echo Boot from SD ; setenv partition 1:1;else echo Boot from eMMC; setenv partition 0:1 ; fi;
newboot=run buildargs;printenv bootargs;fatload ${device} ${partition} ${loadaddr} ${bpi}/${board}/${service}/${kernel}; bootm
newboot-mmc=run buildargs-mmc;printenv bootargs;fatload ${device} ${partition-mmc} ${loadaddr} ${bpi}/${board}/${service}/${kernel}; bootm
newboot-sd=run buildargs-sd;printenv bootargs;fatload ${device} ${partition-sd} ${loadaddr} ${bpi}/${board}/${service}/${kernel}; bootm
newboot-zfs=run buildargs-zfs;printenv bootargs;fatload ${device} ${partition-mmc} ${loadaddr} ${bpi}/${board}/${service}/${kernel}; bootm
newboot-grub=wdt dev watchdog@10007000; wdt stop;fatload ${device} ${partition-mmc} ${loadaddrgrub} /grub/arm-uboot/core.img; bootm ${loadaddrgrub}
newboot-nfs=run buildargs-nfs;printenv bootargs;fatload ${device} ${partition-mmc} ${loadaddr} ${bpi}/${board}/${service}/${kernel}; bootm
reloadmenu=run selectmmc;if run checkenv; then run loadbootenv; else echo file not found; fi;bootmenu;
lskernel=ls ${device} ${partition} ${bpi}/${board}/${service};
lsdtb=ls ${device} ${partition} ${bpi}/${board}/${service}/dtb
askkernel=askenv kernelinput "enter uImage-name:";
askdtb=askenv dtbinput "enter dtb-name:";
askuboot=askenv ubootinput "enter uboot-name:";
#bootmenu
boot0=run loadbootenv; run importenv; run newboot-grub;
boot1=run loadbootenv; run importenv; run newboot-zfs;
boot2=run loadbootenv; run importenv; run newboot-mmc;
boot3=run loadbootenv; run importenv; run newboot-sd;
boot4=run selectmmc; run loadbootenv; run importenv; run newboot;
boot5=run loadbootenv; run importenv; run newboot-nfs;
bootmenu_default=1
bootmenu_0=1. Boot to GRUB.=run boot0
bootmenu_1=2. Boot from ZFS (SSD).=run boot1
bootmenu_2=3. Boot from EMMC (ext4).=run boot2
bootmenu_3=4. Boot from SD (ext4).=run boot3
bootmenu_4=5. Boot from SD/EMMC (env. Auto-Select).=run boot4
bootmenu_5=6. Boot from NFS.=run boot5
#automatic reload from sd/emmc
bootdelay=0
bootcmd=setenv bootdelay 5; run reloadmenu;
png=ping ${serverip}
#ip=dhcp sets ip on eth0 instead of wan
lstftp=if tftp ${loadaddr} ${serverip}:files.lst;then setexpr listend ${loadaddr} + ${filesize};mw.b ${listend} 00 2;strings ${loadaddr};else echo "tftp download failed";fi
lstftpu=if tftp ${loadaddr} ${serverip}:bootfiles.lst;then setexpr listend ${loadaddr} + ${filesize};mw.b ${listend} 00 2;strings ${loadaddr};else echo "tftp download failed";fi
#md.b ${loadaddr} 60;
ubootaddr=0x81E00000
bootnet=run lstftp;run askkernel;if printenv kernelinput ;then setenv bootfile "${kernelinput}"; fi;printenv; setenv bootargs "${netbootargs} ${console} ${graphic}";if tftp ${loadaddr} ${bootfile};then bootm;fi
ubootnet=run lstftpu;run askuboot;if printenv ubootinput ;then setenv ubootfile "${ubootinput}"; fi; if tftp ${ubootaddr} ${ubootfile};then icache off;dcache off;go ${ubootaddr};fi
#separate fdt+dto
dtaddr=0x83f00000
fdt_high=0xffffffff
loadfdt=fatload ${device} ${partition} ${dtaddr} ${bpi}/${board}/${service}/dtb/${fdt}
loadkernel=echo "loading kernel ${kernel}...";fatload ${device} ${partition} ${loadaddr} ${bpi}/${board}/${service}/${kernel}
loaddto=echo "loaddto:${dto}";fdt addr ${dtaddr};fdt resize 8192; setexpr fdtovaddr ${dtaddr} + F000;fatload ${device} ${partition} ${fdtovaddr} ${bpi}/${board}/${service}/dtb/${dto} && fdt apply ${fdtovaddr}
loaddtolist=for dto in ${dtolist} ; do run loaddto ; done
bootall=if printenv fdt; then run loadfdt; if printenv dtolist;then run loaddtolist;fi; bootm ${loadaddr} - ${dtaddr} ;else bootm; fi
newboot2=run buildargs; printenv bootargs; run loadkernel; run bootall;
#sata/ahci
initsata=pci enum;scsi scan;
partsata=0:1
dirsata=EFI/ubuntu
filesata=test.txt
kernelsata=uImage-5.15.173-bpi-r2-main
loadfilesata=fatload scsi ${partsata} ${scriptaddr} ${dirsata}/${filesata};setexpr listend ${scriptaddr} + ${filesize};mw.b ${listend} 00 2;strings ${scriptaddr};
loadkernelsata=fatload scsi ${partsata} ${loadaddr} ${dirsata}/${kernelsata};bootm
lssata=ls scsi ${partsata} ${$dirsata}
askaddr=askenv addrinput "enter address:";
lsmem=run askaddr;if printenv addrinput;then setenv baseaddr ${addrinput};run listmem; fi
listmem=if printenv baseaddr;then setenv i 0;while test ${i} -lt 10;do setenv j 0;while test ${j} -lt 10;do setenv offset "${i}${j}00";setexpr addr $baseaddr + ${offset};md $addr;setexpr j ${j} + 1; done;setexpr i ${i} + 1;done;fi
uEnv.txt at /boot/bananapi/bpi-r2/linux:
#
## uEnv.txt
#
bpi=bananapi
board=bpi-r2
chip=mt7623n
service=linux
#
kernel=uImage-5.15.173-bpi-r2-main
root=ZFS=rpool/ROOT/ubuntu_h1wz1w
#
kaddr=0x84000000
rdaddr=0x86000000
#
initsata=pci enum;scsi scan
console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200
bootargs=board=${board} console=${console} root=ZFS=rpool/ROOT/ubuntu_h1wz1w service=${service} ${bootopts}
bootopts=vmalloc=512M debug=0 initcall_debug=0 drm.debug=0 ipv6.disable=1 video=HDMI-A-1:1280x1024D fsck.mode=force fsck.repair=yes init_on_alloc=0 panic=30 delayacct zfs.zfs_scrub_delay=8 zfs.zfs_scan_strict_mem_lim=1 zfs.zfs_scan_mem_lim_fact=80 zfs.zfs_scan_mem_lim_soft_fact=80 zfs.zfs_vdev_scrub_max_active=1 zfs.zfs_vdev_sync_read_max_active=2 zfs.zfs_top_maxinflight=3 zfs.zvol_threads=3 zfs.zfs_scan_issue_strategy=2 zfs.zfs_arc_max=83886080 zfs.zfs_scan_legacy=1 zfs.zfs_txg_timeout=8 zfs.zfs_prefetch_disable=1
ahello=echo Banana Pi ${board} chip: $chip Service: $service
aboot=if fatload $device $partition $rdaddr ${bpi}/berryboot.img; then bootm $kaddr $rdaddr ; else bootm $kaddr; fi
aload_kernel=fatload $device $partition $kaddr ${bpi}/${board}/${service}/${kernel}
uenvcmd=run ahello abootargs aload_kernel aboot
## END
Boot through u-boot works fine. Both u-Boot and GRUB rebuilt from recent git. GRUB itself boots fine too. But upon trying to use it to boot the kernel, I do see the error I mentioned above.
root@ap-unimatrix:~# ls /boot/
bananapi config-5.15.173-bpi-r2-main grub initrd.img-5.15.173-bpi-r2-main vmlinuz-5.15.173-bpi-r2-main
root@ap-unimatrix:~# cat /boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
load_env
fi
if [ "${initrdfail}" = 2 ]; then
set initrdfail=
elif [ "${initrdfail}" = 1 ]; then
set next_entry="${prev_entry}"
set prev_entry=
save_env prev_entry
if [ "${next_entry}" ]; then
set initrdfail=2
fi
fi
if [ "${next_entry}" ] ; then
set default="${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
else
set default="0"
fi
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
else
menuentry_id_option=""
fi
export menuentry_id_option
if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi
function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}
function initrdfail {
if [ -n "${have_grubenv}" ]; then if [ -n "${partuuid}" ]; then
if [ -z "${initrdfail}" ]; then
set initrdfail=1
if [ -n "${boot_once}" ]; then
set prev_entry="${default}"
save_env prev_entry
fi
fi
save_env initrdfail
fi; fi
}
function recordfail {
set recordfail=1
if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}
function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
}
serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1
terminal_input console serial
terminal_output console serial
if [ "${recordfail}" = 1 ] ; then
set timeout=30
else
if [ x$feature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=10
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
set timeout=10
fi
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/10_linux ###
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/10_linux_zfs ###
function gfxmode {
set gfxpayload="${1}"
if [ "${1}" = "keep" ]; then
set vt_handoff=vt.handoff=1
else
set vt_handoff=
fi
}
if [ "${recordfail}" != 1 ]; then
if [ -e ${prefix}/gfxblacklist.txt ]; then
if hwmatch ${prefix}/gfxblacklist.txt 3; then
if [ ${match} = 0 ]; then
set linux_gfx_mode=keep
else
set linux_gfx_mode=text
fi
else
set linux_gfx_mode=text
fi
else
set linux_gfx_mode=keep
fi
else
set linux_gfx_mode=text
fi
export linux_gfx_mode
function zsyshistorymenu {
# $1: root dataset (eg rpool/ROOT/ubuntu_2zhm07@autozsys_k56fr6)
# $2: boot device id (eg 411f29ce1557bfed)
# $3: initrd (eg /BOOT/ubuntu_2zhm07@autozsys_k56fr6/initrd.img-5.4.0-21-generic)
# $4: kernel (eg /BOOT/ubuntu_2zhm07@autozsys_k56fr6/vmlinuz-5.4.0-21-generic)
# $5: kernel_version (eg 5.4.0-21-generic)
set root_dataset="${1}"
set boot_device="${2}"
set initrd="${3}"
set kernel="${4}"
set kversion="${5}"
menuentry 'Revert system only' --class ubuntu --class gnu-linux --class gnu --class os ${menuentry_id_option} 'gnulinux-${root_dataset}-${kversion}' {
recordfail
load_video
gfxmode ${linux_gfx_mode}
insmod gzio
devicetree /bananapi/bpi-r2/linux/dtb/bpi-r2.dtb
if [ "${grub_platform}" = xen ]; then insmod xzio; insmod lzopio; fi
if [ ${boot_device} = /dev/mmcblk1p1 ]; then
insmod part_msdos
insmod fat
search --no-floppy --fs-uuid --set=root 49DC-AF1E
fi
linux "${kernel}" root=ZFS="${root_dataset}" ro rootwait console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200 vmalloc=512M debug=0 initcall_debug=0 drm.debug=0 ipv6.disable=1 video=HDMI-A-1:1280x1024D fsck.mode=force fsck.repair=yes init_on_alloc=0 panic=30 zfs.zfs_scrub_delay=8 zfs.zfs_scan_strict_mem_lim=1 zfs.zfs_scan_mem_lim_fact=80 zfs.zfs_scan_mem_lim_soft_fact=80 zfs.zfs_vdev_scrub_max_active=1 zfs.zfs_vdev_sync_read_max_active=2 zfs.zfs_top_maxinflight=3 zfs.zvol_threads=3 zfs.zfs_scan_issue_strategy=2 zfs.zfs_arc_max=83886080 zfs.zfs_scan_legacy=1 zfs.zfs_txg_timeout=8 zfs.zfs_prefetch_disable=1
initrd "${initrd}"
}
menuentry 'Revert system and user data' --class ubuntu --class gnu-linux --class gnu --class os ${menuentry_id_option} 'gnulinux-${root_dataset}-${kversion}' {
recordfail
load_video
gfxmode ${linux_gfx_mode}
insmod gzio
devicetree /bananapi/bpi-r2/linux/dtb/bpi-r2.dtb
if [ "${grub_platform}" = xen ]; then insmod xzio; insmod lzopio; fi
if [ ${boot_device} = /dev/mmcblk1p1 ]; then
insmod part_msdos
insmod fat
search --no-floppy --fs-uuid --set=root 49DC-AF1E
fi
linux "${kernel}" root=ZFS="${root_dataset}" ro rootwait console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200 vmalloc=512M debug=0 initcall_debug=0 drm.debug=0 ipv6.disable=1 video=HDMI-A-1:1280x1024D fsck.mode=force fsck.repair=yes init_on_alloc=0 panic=30 zfs.zfs_scrub_delay=8 zfs.zfs_scan_strict_mem_lim=1 zfs.zfs_scan_mem_lim_fact=80 zfs.zfs_scan_mem_lim_soft_fact=80 zfs.zfs_vdev_scrub_max_active=1 zfs.zfs_vdev_sync_read_max_active=2 zfs.zfs_top_maxinflight=3 zfs.zvol_threads=3 zfs.zfs_scan_issue_strategy=2 zfs.zfs_arc_max=83886080 zfs.zfs_scan_legacy=1 zfs.zfs_txg_timeout=8 zfs.zfs_prefetch_disable=1 zsys-revert=userdata
initrd "${initrd}"
}
menuentry 'Revert system only (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os ${menuentry_id_option} 'gnulinux-${root_dataset}-${kversion}' {
recordfail
load_video
insmod gzio
devicetree /bananapi/bpi-r2/linux/dtb/bpi-r2.dtb
if [ "${grub_platform}" = xen ]; then insmod xzio; insmod lzopio; fi
if [ ${boot_device} = /dev/mmcblk1p1 ]; then
insmod part_msdos
insmod fat
search --no-floppy --fs-uuid --set=root 49DC-AF1E
fi
echo Loading Linux ${kversion} ...
linux "${kernel}" root=ZFS="${root_dataset}" ro single nomodeset rootwait console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200 vmalloc=512M debug=0 initcall_debug=0 drm.debug=0 ipv6.disable=1 video=HDMI-A-1:1280x1024D fsck.mode=force fsck.repair=yes init_on_alloc=0 panic=30 zfs.zfs_scrub_delay=8 zfs.zfs_scan_strict_mem_lim=1 zfs.zfs_scan_mem_lim_fact=80 zfs.zfs_scan_mem_lim_soft_fact=80 zfs.zfs_vdev_scrub_max_active=1 zfs.zfs_vdev_sync_read_max_active=2 zfs.zfs_top_maxinflight=3 zfs.zvol_threads=3 zfs.zfs_scan_issue_strategy=2 zfs.zfs_arc_max=83886080 zfs.zfs_scan_legacy=1 zfs.zfs_txg_timeout=8 zfs.zfs_prefetch_disable=1
echo 'Loading initial ramdisk ...'
initrd "${initrd}"
}
menuentry 'Revert system and user data (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os ${menuentry_id_option} 'gnulinux-${root_dataset}-${kversion}' {
recordfail
load_video
insmod gzio
devicetree /bananapi/bpi-r2/linux/dtb/bpi-r2.dtb
if [ "${grub_platform}" = xen ]; then insmod xzio; insmod lzopio; fi
if [ ${boot_device} = /dev/mmcblk1p1 ]; then
insmod part_msdos
insmod fat
search --no-floppy --fs-uuid --set=root 49DC-AF1E
fi
echo Loading Linux ${kversion} ...
linux "${kernel}" root=ZFS="${root_dataset}" ro single nomodeset rootwait console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200 vmalloc=512M debug=0 initcall_debug=0 drm.debug=0 ipv6.disable=1 video=HDMI-A-1:1280x1024D fsck.mode=force fsck.repair=yes init_on_alloc=0 panic=30 zfs.zfs_scrub_delay=8 zfs.zfs_scan_strict_mem_lim=1 zfs.zfs_scan_mem_lim_fact=80 zfs.zfs_scan_mem_lim_soft_fact=80 zfs.zfs_vdev_scrub_max_active=1 zfs.zfs_vdev_sync_read_max_active=2 zfs.zfs_top_maxinflight=3 zfs.zvol_threads=3 zfs.zfs_scan_issue_strategy=2 zfs.zfs_arc_max=83886080 zfs.zfs_scan_legacy=1 zfs.zfs_txg_timeout=8 zfs.zfs_prefetch_disable=1 zsys-revert=userdata
echo 'Loading initial ramdisk ...'
initrd "${initrd}"
}
}
menuentry 'Ubuntu 24.04.1 LTS' --class ubuntu --class gnu-linux --class gnu --class os ${menuentry_id_option} 'gnulinux-rpool/ROOT/ubuntu_h1wz1w-5.15.173-bpi-r2-main' {
recordfail
load_video
gfxmode ${linux_gfx_mode}
insmod gzio
devicetree /bananapi/bpi-r2/linux/dtb/bpi-r2.dtb
if [ "${grub_platform}" = xen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod fat
search --no-floppy --fs-uuid --set=root 49DC-AF1E
linux "/vmlinuz-5.15.173-bpi-r2-main" root=ZFS="rpool/ROOT/ubuntu_h1wz1w" ro rootwait console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200 vmalloc=512M debug=0 initcall_debug=0 drm.debug=0 ipv6.disable=1 video=HDMI-A-1:1280x1024D fsck.mode=force fsck.repair=yes init_on_alloc=0 panic=30 zfs.zfs_scrub_delay=8 zfs.zfs_scan_strict_mem_lim=1 zfs.zfs_scan_mem_lim_fact=80 zfs.zfs_scan_mem_lim_soft_fact=80 zfs.zfs_vdev_scrub_max_active=1 zfs.zfs_vdev_sync_read_max_active=2 zfs.zfs_top_maxinflight=3 zfs.zvol_threads=3 zfs.zfs_scan_issue_strategy=2 zfs.zfs_arc_max=83886080 zfs.zfs_scan_legacy=1 zfs.zfs_txg_timeout=8 zfs.zfs_prefetch_disable=1
initrd "/initrd.img-5.15.173-bpi-r2-main"
}
submenu 'Advanced options for Ubuntu 24.04.1 LTS' ${menuentry_id_option} 'gnulinux-advanced-rpool/ROOT/ubuntu_h1wz1w' {
menuentry 'Ubuntu 24.04.1 LTS, with Linux 5.15.173-bpi-r2-main' --class ubuntu --class gnu-linux --class gnu --class os ${menuentry_id_option} 'gnulinux-rpool/ROOT/ubuntu_h1wz1w-5.15.173-bpi-r2-main' {
recordfail
load_video
gfxmode ${linux_gfx_mode}
insmod gzio
devicetree /bananapi/bpi-r2/linux/dtb/bpi-r2.dtb
if [ "${grub_platform}" = xen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod fat
search --no-floppy --fs-uuid --set=root 49DC-AF1E
echo Loading Linux 5.15.173-bpi-r2-main ...
linux "/vmlinuz-5.15.173-bpi-r2-main" root=ZFS="rpool/ROOT/ubuntu_h1wz1w" ro rootwait console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200 vmalloc=512M debug=0 initcall_debug=0 drm.debug=0 ipv6.disable=1 video=HDMI-A-1:1280x1024D fsck.mode=force fsck.repair=yes init_on_alloc=0 panic=30 zfs.zfs_scrub_delay=8 zfs.zfs_scan_strict_mem_lim=1 zfs.zfs_scan_mem_lim_fact=80 zfs.zfs_scan_mem_lim_soft_fact=80 zfs.zfs_vdev_scrub_max_active=1 zfs.zfs_vdev_sync_read_max_active=2 zfs.zfs_top_maxinflight=3 zfs.zvol_threads=3 zfs.zfs_scan_issue_strategy=2 zfs.zfs_arc_max=83886080 zfs.zfs_scan_legacy=1 zfs.zfs_txg_timeout=8 zfs.zfs_prefetch_disable=1
echo 'Loading initial ramdisk ...'
initrd "/initrd.img-5.15.173-bpi-r2-main"
}
menuentry 'Ubuntu 24.04.1 LTS, with Linux 5.15.173-bpi-r2-main (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os ${menuentry_id_option} 'gnulinux-rpool/ROOT/ubuntu_h1wz1w-5.15.173-bpi-r2-main' {
recordfail
load_video
insmod gzio
devicetree /bananapi/bpi-r2/linux/dtb/bpi-r2.dtb
if [ "${grub_platform}" = xen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod fat
search --no-floppy --fs-uuid --set=root 49DC-AF1E
echo Loading Linux 5.15.173-bpi-r2-main ...
linux "/vmlinuz-5.15.173-bpi-r2-main" root=ZFS="rpool/ROOT/ubuntu_h1wz1w" ro single nomodeset rootwait console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200 vmalloc=512M debug=0 initcall_debug=0 drm.debug=0 ipv6.disable=1 video=HDMI-A-1:1280x1024D fsck.mode=force fsck.repair=yes init_on_alloc=0 panic=30 zfs.zfs_scrub_delay=8 zfs.zfs_scan_strict_mem_lim=1 zfs.zfs_scan_mem_lim_fact=80 zfs.zfs_scan_mem_lim_soft_fact=80 zfs.zfs_vdev_scrub_max_active=1 zfs.zfs_vdev_sync_read_max_active=2 zfs.zfs_top_maxinflight=3 zfs.zvol_threads=3 zfs.zfs_scan_issue_strategy=2 zfs.zfs_arc_max=83886080 zfs.zfs_scan_legacy=1 zfs.zfs_txg_timeout=8 zfs.zfs_prefetch_disable=1
echo 'Loading initial ramdisk ...'
initrd "/initrd.img-5.15.173-bpi-r2-main"
}
}
### END /etc/grub.d/10_linux_zfs ###
### BEGIN /etc/grub.d/25_bli ###
if [ "$grub_platform" = "efi" ]; then
insmod bli
fi
### END /etc/grub.d/25_bli ###
### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Ubuntu 24.04.1 LTS (24.04) (on /dev/mmcblk1p2)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-d079016c-d948-4fd0-bde3-37002cfb56c9' {
insmod part_msdos
insmod fat
search --no-floppy --fs-uuid --set=root 49DC-AF1E
linux /vmlinuz-5.15.173-bpi-r2-main root=/dev/mmcblk1p2
initrd /initrd.img-5.15.173-bpi-r2-main
}
submenu 'Advanced options for Ubuntu 24.04.1 LTS (24.04) (on /dev/mmcblk1p2)' $menuentry_id_option 'osprober-gnulinux-advanced-d079016c-d948-4fd0-bde3-37002cfb56c9' {
menuentry 'Ubuntu 24.04.1 LTS (24.04) (on /dev/mmcblk1p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/vmlinuz-5.15.173-bpi-r2-main--d079016c-d948-4fd0-bde3-37002cfb56c9' {
insmod part_msdos
insmod fat
search --no-floppy --fs-uuid --set=root 49DC-AF1E
linux /vmlinuz-5.15.173-bpi-r2-main root=/dev/mmcblk1p2
initrd /initrd.img-5.15.173-bpi-r2-main
}
}
set timeout_style=menu
if [ "${timeout}" = 0 ]; then
set timeout=10
fi
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###
### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg
fi
### END /etc/grub.d/41_custom ###
root@ap-unimatrix:~#
root@ap-unimatrix:~# file /boot/vmlinuz-5.15.173-bpi-r2-main
/boot/vmlinuz-5.15.173-bpi-r2-main: Linux kernel ARM boot executable zImage (little-endian)
root@ap-unimatrix:~#
root@ap-unimatrix:~# binwalk /boot/vmlinuz-5.15.173-bpi-r2-main
DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------
0 0x0 Linux kernel ARM boot executable zImage (little-endian)
30792 0x7848 gzip compressed data, maximum compression, from Unix, last modified: 1970-01-01 00:00:00 (null date)
root@ap-unimatrix:~#
I suspect the problem is in loading addresses of either GRUB, kernel, or both.
Any ideas?
I want to use GRUB, because it allows me to use ZFS snapshot feature before booting the OS. u-Boot doesn’t have such capability.
UPDATE4: So, it looks like it is tight to memory addresses.
In GRUB source, I’ve found this:
grub-core/loader/arm/linux.c
if ((grub_size_t) size > sizeof (*lh) &&
lh->magic == GRUB_LINUX_ARM_MAGIC_SIGNATURE)
;
else if (size > 0x8000 && *(grub_uint32_t *) (linux_addr) == 0xea000006
&& machine_type == GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI)
grub_memmove ((void *) linux_addr, (void *) (linux_addr + 0x8000),
size - 0x8000);
else
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("invalid zImage"));
linux_size = size;
return GRUB_ERR_NONE;
}
It looks like examples where GRUB works are all from RPi machines. Since the kernel load address is different on BPi-R2, I may as well patch the GRUB source, to properly recognize BPi-R2 kernel.