Grub on BPI-R2: kernel starting problem

Hi everyone.

Just wondering if anyone has tried to run OS using GRUB, and if it was successfull?

For now i’ve installed grub (u-boot 2020-01-bpi-r2 from Frank’s repo), i’m able to run it, but i can’t load linux kernel ftom grub.

u-boot env for grub run:

...
boot19=load mmc 0:1 ${loadaddr} /grub/arm-uboot/core.img; bootm ${loadaddr}
...
bootmenu_4=5. Run GRUB.=run boot19 
...

Grub Menu:

GNU GRUB  version 2.05_alpha20200110                                                                                                                                                                                          
                                                                                                                                                                                                                                                   
+----------------------------------------------------------------------------+                                                                                                                                                                     
|*Gentoo GNU/Linux                                                           |                                                                                                                                                                     
| Advanced options for Gentoo GNU/Linux                                      |                                                                                                                                                                     
|                                                                            |                                                                                                                                                                     
|                                                                            |                                                                                                                                                                     
|                                                                            |                                                                                                                                                                     
|                                                                            |                                                                                                                                                                     
|                                                                            |                                                                                                                                                                     
|                                                                            |                                                                                                                                                                     
|                                                                            |                                                                                                                                                                     
|                                                                            |                                                                                                                                                                     
|                                                                            |                                                                                                                                                                     
|                                                                            |                                                                                                                                                                     
+----------------------------------------------------------------------------+                                                                                                                                                                     
                                                                                                                                                                                                                                                   
     Use the ^ and v keys to select which entry is highlighted.                                                                                                                                                                                    
     Press enter to boot the selected OS, `e' to edit the commands                                                                                                                                                                                 
     before booting or `c' for a command-line.

cgub.cfg:

menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-4d920cff-b900-40c2-90c8-ffc716a6656f' {
        load_video
        insmod gzio
        insmod part_msdos
        insmod fat
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root  4449-36D1
        else
          search --no-floppy --fs-uuid --set=root 4449-36D1
        fi
        echo    'Loading Linux 5.5.0-rc1-arm+ ...'
        devicetree /bpi-r2.dts
        linux   /vmlinuz-5.5.0-rc1-arm+ root=UUID=4d920cff-b900-40c2-90c8-ffc716a6656f ro root=/dev/sdb1 rootfstype=ext4 rootwait console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200 
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-5.5.0-rc1-arm+.img
}

root=UUID=4d920cff-b900-40c2-90c8-ffc716a6656f ro root=/dev/sdb1 - are the same drive

/etc/default/grub:

GRUB_DISTRIBUTOR="Gentoo"

GRUB_TERMINAL="console serial"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"

GRUB_DEFAULT=0

GRUB_TIMEOUT=5

GRUB_CMDLINE_LINUX="root=/dev/sdb1 rootfstype=ext4 rootwait console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200"

Kernel is my 5.5-merged-lima branch based on Frank’s 5.5-merged. It runs w/o any problebs when built by build.sh script for u-boot.

After attempt to boot it prints Loading Linux 5.5.0-rc1-arm+ ... halts for 3-5 secs and resets.

P.S. Looks like uboot has some type of watchdog and restart board after some period of inactivity, if it’s really u-boot, where can i edit timeouts?

uboot has watchdog timeout, but it is ~20 sec of inactivity and shows message before do the reset…

have not tried using grub because one bootloader is enough for me :wink: what do you want to archive with it?

More familiar environment for me, no u-boot image ‘magic’,no uboot env - easy to update kernel, easy to use initramfs(useful for mdadm, zfs, dmraid, etc), new experience :wink:

Where can I disable it or edit timeout? Not very convinient when r2 reboots during reading manuals :slight_smile:.

I didn’t catched the message.

maybe by disabling the watchdog-driver…imho timeout cannot be increased

if not maybe you can start timer again if it is timed-out

1 Like

It is hardware timer. You should put grup to update watchdog timer regular interval. I don’t know how but I guess that broblem is solved in grub somehow.

1 Like

Fixed!

The problem was in wrong grub loading address.

Works great with:

load mmc 0:1 0x88000000 /grub/arm-uboot/core.img; bootm 0x88000000

Kernel loads, and works great:

Loading Devicetree ...                                                                                                                                                                                                                                  
Loading Linux 5.5.0-rc1-arm+ ...                                                                                                                                                                                                                    
Loading initial ramdisk ...                                                                                                                                                                                                                         
Done, starting ...                                                                                                                                                                                                                                      
[    0.000000] Booting Linux on physical CPU 0x0                                                                                                                                                                                                    
[    0.000000] Linux version 5.5.0-rc1-arm+ (root@bpi-r2-gentoo) (gcc version 9.2.0 (Gentoo 9.2.0-r2 p3)) #1 SMP Wed Jan 29 23:02:39 PST 2020                                                                                                       
[    0.000000] CPU: ARMv7 Processor [410fc073] revision 3 (ARMv7), cr=10c5387d                                                                                                                                                                      
[    0.000000] CPU: div instructions available: patching division code                                                                                                                                                                              
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache                                                                                                                                                             
[    0.000000] OF: fdt: Machine model: Bananapi BPI-R2                                                                                                                                                                                              
[    0.000000] Memory policy: Data cache writealloc                                                                                                                                                                                                 
[    0.000000] [WMT-CONSYS-HW][W]reserve_memory_consys_fn: name: consys-reserve-memory, base: 0xffe00000, size: 0x100000                                                                                                                            
[    0.000000] OF: reserved mem: initialized node consys-reserve-memory, compatible id mediatek,consys-reserve-memory                                                                                                                               
[    0.000000] cma: Reserved 64 MiB at 0xfb800000

Menuenty for my boot:

    menuentry 'Gentoo GNU/Linux, with Linux 5.5.0-rc1-arm+' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.5.0-rc1-arm+-advanced-4d920cff-b900-40c2-90c8-ffc716a6656f' {
            load_video
            insmod gzio
            insmod part_msdos
            insmod fat
            if [ x$feature_platform_search_hint = xy ]; then
              search --no-floppy --fs-uuid --set=root  4449-36D1
            else
              search --no-floppy --fs-uuid --set=root 4449-36D1
            fi
            echo  'Loading Devicetree ...'
            devicetree /bpi-r2.dtb
            echo    'Loading Linux 5.5.0-rc1-arm+ ...'
            linux   /vmlinuz-5.5.0-rc1-arm+ root=UUID=4d920cff-b900-40c2-90c8-ffc716a6656f ro root=/dev/sdb1 rootfstype=ext4 rootwait console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200 
            echo    'Loading initial ramdisk ...'
            initrd  /initramfs-5.5.0-rc1-arm+.img
            echo  'Done, starting ...'
    }

P.S. grub is installed to /boot using:

bpi-r2-gentoo ~ # grub-install /boot
Installing for arm-uboot platform.
grub-install: warning: no hints available for your platform. Expect reduced performance.
grub-install: warning: WARNING: no platform-specific install was performed.
Installation finished. No error reported.

P.P.S. My personal benefits using GRUB is to update, install and/or use multiple kernels without modifying u-boot env. :sunglasses:

Small HOWTO:

  • build u-boot (i use Frank’s 2020-01-bpi-r2)

Grub requires u-boot with enabled U-Boot API (enabled from menuconfig)

and

diff --git a/include/configs/mt7623.h b/include/configs/mt7623.h
index e5182aeea8..50c3fc66b0 100644
--- a/include/configs/mt7623.h
+++ b/include/configs/mt7623.h
@@ -15,6 +15,10 @@
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_INITRD_TAG
 #define CONFIG_CMDLINE_TAG
+#define CONFIG_SYS_MMC_MAX_DEVICE      2
+#define CONFIG_SYS_SCSI_MAX_DEVICE     2
+#define CONFIG_CMD_EXT2
+#define CONFIG_CMD_ECHO
   
 #define CONFIG_SYS_MAXARGS             8
 #define CONFIG_SYS_BOOTM_LEN           SZ_64M

(define CONFIG_SYS_MMC_MAX_DEVICE 2 is likely not needed)

  • Install grub

First install grub-uboot package (in gentoo: emerge -av grub with GRUB_PLATFORMS="uboot" defined )

2nd - install grub to /boot: grub-install /boot

  • Modify /etc/default/grub (to enable serial console and add kernel boot barameters):

/etc/default/grub:

GRUB_TERMINAL="console serial"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
...
GRUB_CMDLINE_LINUX="root=/dev/sdb1 rootfstype=ext4 rootwait console=earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200"
  • Create and modify grub config (/boot/grub/grub.cfg)

create:

grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.5.0-rc1-arm+
Found initrd image: /boot/initramfs-5.5.0-rc1-arm+.img
Found linux image: /boot/kernel-5.5.0-bananapi
Found linux image: /boot/kernel-5.4.0-bananapi
done

in my case it detects kernels and initramfs files placed in /boot

modify /boot/grub/grub.cfg: in my case i had to add devicetree /bpi-r2.dtb to each menuentry, and some verbose messages, but as i know there is a way to automate it by editing grub templates.

And the last…

  • modify uboot env to boot grub

I’ve changed 1 of boot entry envs to:

boot19=load mmc 0:1 0x88000000 /grub/arm-uboot/core.img; bootm 0x88000000
...
bootmenu_4=5. Run GRUB.=run boot19
2 Likes

Sorry for necroing the post, but I am playing with new BPi-R2 just now.

Have you found a way to boot uImage with Initrd packaged in the image itself? GRUB apparently doesn’t recognize it as a kernel…so I can’t use grub-mkconfig to populate grub.cfg

GRUB itself loads fine.

root@ap-unimatrix:/boot# ls
bananapi  grub  uImage-5.15.173-bpi-r2-main
root@ap-unimatrix:/boot# ll
total 48993
drwxr-xr-x  4 root root    16384 Jan  1  1970 ./
drwxr-xr-x 18 root root       21 Dec 12 20:44 ../
drwxr-xr-x  3 root root     4096 Jun 29 16:39 bananapi/
drwxr-xr-x  5 root root     4096 Dec 12 20:45 grub/
-rwxr-xr-x  1 root root 50131833 Dec 12 16:11 uImage-5.15.173-bpi-r2-main*
root@ap-unimatrix:/boot# grub-mkconfig -o /boot/grub/grub.cfg
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Warning: didn't find any valid initrd or kernel.
Warning: didn't find any valid initrd or kernel.
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
done
root@ap-unimatrix:/boot# 

uImage is uboot image…grup afaik only supports image.gz (should be same as vmlinuz). Note that you need to configure dtb additionally

Regarding initrd this should be also in Image.gz when configured via kernel config option

OK, back to building then. Should be relatively easy to change the format. so far, GRUB works fine. But I will have to produce new image+ramdisk.

Having GRUB is important, because then I’ll be able to use ZFS snapshot feature to its maximum.

Thanks.

uImage is built by concatenating image.gz +dtb and adding uboot header in build.sh. you do not need to rebuild it,just use other file (in arch/arm afaik)

Makes sense. Thank you. I already have initramfs image too…

Found it. zImage should be the file I want. technically it is vmlinuz.

image

But apparently I still do have wrong zImage:

error: invalid zImage.

Will deal with it over night. As for menu configuration (grub.cfg), I do have this:

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
        if [ "${grub_platform}" = xen ]; then insmod xzio; insmod lzopio; fi
        insmod part_msdos
        insmod fat
        search --no-floppy --fs-uuid --set=root 49DC-AF1E
        devicetree /bananapi/bpi-r2/linux/dtb/bpi-r2.dtb
        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=768M 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
        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
                if [ "${grub_platform}" = xen ]; then insmod xzio; insmod lzopio; fi
                insmod part_msdos
                insmod fat
                search --no-floppy --fs-uuid --set=root 49DC-AF1E
                devicetree /bananapi/bpi-r2/linux/dtb/bpi-r2.dtb
                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=768M 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
                echo 'Loading initial ramdisk ...'
                initrd  "/initrd.img-5.15.173-bpi-r2-main"
        }
}

GRUB loads, but every second load, it crashes and system reboots. So you reboot the machine, load GRUB, it crashes, reboots, loads GRUB, and then it works (apart from having incorrect image format for now).

Update: it looks like GRUB refuses to work with zImage format. It requires bzImage. Removing the initramfs from kernel slimmed it back to ~9MB. Hence:

make bzImage

Also, I noticed that I can’t stay in GRUB for too long, otherwise the system will reset. Probably some kind of watchdog (found this mailing list, will test).

As for GRUB refusing to boot my kernel, the error is the same:

error: invalid zImage

I am not certain on why, I made certain that zImage file found in arch/arm/boot/zImage is what I want, and I’ve put it to /boot/vmlinuz-5.15.173-bpi-r2-main

grub-mkconfig -o /boot/grub/grub.cfg

Finds the kernel as well as initrd, and adds them to GRUB menu. but for some reason, the image is not considered the right one.

Update: anyway, uBoot calls me a boss now too. Resolved. At least when it comes to the annoying timeout from watchdog. GRUB now loads and the board isn’t self-rebooting after ~15s. I updated my uEnv.txt (I am preferring the one built-in to uBoot, but be my guest):

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
#default bootargs will be overidden by buildargs
bootargs=console=ttyS0,115200 root=/dev/mmcblk1p2 rw rootwait ip=dhcp
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

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=768M debug=0 initcall_debug=0 ipv6.disable=1 fsck.mode=force fsck.repair=yes init_on_alloc=0
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}"
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=run buildargs-grub;printenv bootargs;wdt dev watchdog@10007000; wdt stop;fatload ${device} ${partition-mmc} ${loadaddr} /grub/arm-uboot/core.img; bootm
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

image

I had to rebuild u-boot with CONFIG_CMD_WDT

All Boot options now works. I will focus on GRUB itself, as I still do face the issue with wrong zImage.

GRUB still can’t load properly any kernel. Dunno if as a result of disabling WDT timer, but now it spews u-boot’s error message: Could not initialize timer (err -11)

This user also uses zImage and got further,but also had the reboot issue

https://dev1galaxy.org/viewtopic.php?id=4449

Maybe your grub misses some compression algorithm?

Btw. See here for the reboot issue: Grub on BPI-R2: kernel starting problem - #6 by DeadMeat

Maybe @deadmeat can tell which kernel binary he used…

Yes, I started with @Deadmeat 's thread to learn from it. For the timer which auto-reboots the host - that is resolved. My problem is that now when I try to load any image from GRUB (which itself works fine now, even its built-in shell), I get that reset timer error…which is basically endless, and I have to reset the board. Looks like it is a consequence of disabling WMT timer.

OP of first link uses EFI, thus grub-efi-arm, but I do use grub-uboot, which is needed to chain to u-Boot through u-Boot API (which is enabled in my u-boot.bin)

According to this post, I may be missing the timer setup. But so far, I haven’t yet checked on how to modify the device tree.

Have you tried with wdt enabled and different load address for grub? deadmeat had same issue with the reboots

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.