0% found this document useful (0 votes)
131 views

(HOWTO) Using GRUB As Bootloader (Second Stage After U-Boot)

U boot grub odroid

Uploaded by

Soukous Lover
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
131 views

(HOWTO) Using GRUB As Bootloader (Second Stage After U-Boot)

U boot grub odroid

Uploaded by

Soukous Lover
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

[HOWTO] Using GRUB as bootloader (second stage after U... https://forum.odroid.com/viewtopic.php?

t=26894

 Quick links  FAQ  Register  Login

 Board index ‹ ODROID-XU3/XU4/MC1/HC1/HC2 ‹ Linux Kernel 4.14 Debugging Party

[HOWTO] Using GRUB as bootloader (second stage after U-Boot)


 First unread post • 11 posts • Page 1 of 1
Post Reply  

[HOWTO] Using GRUB as 


bootloader (second stage
after U-Boot) OverSun
 by OverSun » Tue May 02, 2017 10:21 pm
Posts: 1452
Joined: Mon Apr 29, 2013 5:12 pm
I don't know about most of users, but I play with kernel a lot and changing languages_spoken: english
kernels on Odroid is real pain in the back when using u-boot. The thing is Has thanked: 0
Been thanked: 2 times
too simple, every time I want to test a kernel I need to type a ton of stuff to
Contact: 
backup the current kernel, roll a testing kernel, boot, reboot, etc. Also
"make install" from a kernel source tree is not really compatible with the
u-boot, and u-boot options are not really accessible convenient way from
the command line.
So here is a way to make U-Boot call GRUB as its first stage and not the
real kernel. And from GRUB already you can do whatever you want
standard Linux way. Plus all its configs are really vendor updates
compatible, meaning ubuntu updates targeted to grub and kernel
initramfs can apply normally.

1. You would need these packages installed into your ubuntu:


- u-boot-tools (or uboot-mkimage for older ubuntu versions)
- grub-uboot
- unfortunately, you would need grub2.02-beta3 at least, which is
available as package only starting from ubuntu 17.04. Or from sources.

2. Most recent (mainline) u-boot version


- git checkout git://git.denx.de/u-boot.git
- make odroid-xu3_defconfig
- make nconfig
- enable "API -> U-Boot API" in the configuration menus
- add "#define CONFIG_SYS_MMC_MAX_DEVICE 2" into
include/configs/odroid_xu3.h to make the API compile
- compile, get the u-boot-dtb.bin, flash it to your card

3. grub-install /boot
this will install all the GRUB files into the /boot directory

1 of 6 06/05/2019 à 14:04
[HOWTO] Using GRUB as bootloader (second stage after U... https://forum.odroid.com/viewtopic.php?t=26894

4. create a simple grub.cfg file with an entry to boot, for example (note
that I have /boot directory, because I don't use separate partition for boot
files, and also UUID definitely is going to be different for you):

CODE: SELECT ALL

menuentry 'Kernel' {
devicetree /boot/exynos5422-odroidxu4.dtb
initrd /boot/initrd.img-4.9.25
linux /boot/vmlinuz-4.9.25 console=tty1 console=ttySAC2,115200n8 root
}

5. to make U-Boot call GRUB as the loader you need this to be bootcmd
of U-Boot (My /boot is not a separate partition and I don't use fat32
partition to store kernels, my system is on first partition of the card and all
ext4):

CODE: SELECT ALL

ext4load mmc 0:1 0x43300000 /boot/grub/arm-uboot/core.img


bootm 0x43300000

that will load standard GRUB menu with the menuentry you provided.
Even if the menuentry would be wrong - it's much easier to work with
kernels and parameters from the GRUB menu and editor

Tips and tricks.

To make grub-mkconfig work successfully you would need:


add your default kernel parameters to GRUB_CMDLINE_LINUX="", so all
the stuff like "console=, blah-blah-blah..." is always added to every kernel
line
in the file /etc/grub.d/10_linux two things are needed,
add "echo ' devicetree /boot/exynos5422-odroidxu4.dtb'" right before "if
test -d /sys/firmware/efi && test -e "${linux}.efi.signed"; then", so
devicetree entry is always added into every kernel menuentry
remove everything related to "recordfail". GRUB called from u-boot can
access mmc read only and doesn't work with saving options.
After these changes grub-mkconfig can generate grub.cfg files absolutely
standard way it does on normal ubuntu system

Reboot doesn't work. =(


For some reason first stage GRUB called from u-boot after a reboot
cannot find mmc to call second stage. I'm not really sure whose fail this is
- u-boot, GRUB or linux itself, but this major issue basically renders all
that idea a good proof of concept thing that is not really ready to be used
live.

Last edited by OverSun on Sat May 20, 2017 12:29 am, edited 1 time in total.

Re: [HOWTO] Using GRUB as 


bootloader (second stage after
U-B
 by mad_ady » Wed May 03, 2017 2:39 am

2 of 6 06/05/2019 à 14:04
[HOWTO] Using GRUB as bootloader (second stage after U... https://forum.odroid.com/viewtopic.php?t=26894

Wow, when it works boot.ini will be a thing of the past... mad_ady

Posts: 5751
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2,
N2
Location: Bucharest, Romania
Has thanked: 46 times
Been thanked: 24 times
Contact: 

Re: [HOWTO] Using GRUB as 


bootloader (second stage after
U-B
 by rooted » Wed May 03, 2017 8:24 pm

This is the way it should work, I will get into this soon. Thanks OverSun rooted

Posts: 6456
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Is the eMMC driver built into the kernel? I don't think it's a module. Location: Gulf of Mexico, US
Has thanked: 8 times
Been thanked: 6 times
I would also try the direct location to your menu entry (/dev/mmbblk0p2), Contact: 
just an idea.

Re: [HOWTO] Using GRUB as 


phaseshifter

bootloader (second stage after Posts: 3312


Joined: Fri May 08, 2015 9:12 am
U-B languages_spoken: english
 by phaseshifter » Wed May 03, 2017 8:42 pm ODROIDs: U-2,U3+,,XU-3,,XU3-
LITE,,XU-4
i am definitely a noob at this can you put the code down so a noob could C1+,,C-2,,,
N-1,,N-2 @15 V D.C ,,...other odroid
follow..sorry coding is not my forte..i can follow some of your grub acc`s as well
bootloader...some i dont ..i dont want to break the flash i have all ready Has thanked: 21 times
Been thanked: 26 times
Contact: 

Re: [HOWTO] Using GRUB as 


bootloader (second stage after
U-B
OverSun
 by OverSun » Wed May 03, 2017 8:45 pm
Posts: 1452
Nah, that's a first stage GRUB failure. Joined: Mon Apr 29, 2013 5:12 pm
languages_spoken: english
Related to the thing that first stage doesn't see partitions. Has thanked: 0
So the scheme is this - GRUB has two stages, the first one is absolutely Been thanked: 2 times
simple as a stick - it has only one ability - find a disk with the second Contact: 
stage and load it into extended memory. The first stage is that core.img
u-boot loads.
What's happening is that after the reboot u-boot initialises mmc the way,
this first stage can't find partitions on the card. I honestly think that this is
some reset procedure not triggered right for the mmc storage driver of
-XU4 in the new u-boot. I saw discussion or commits exactly about that
"mmc right reset sequence", but where?..
So what's happening is that during normal boot u-boot loads from the
mmcblk0boot0 partition, loads core.img from mmcblk0p1 and then
core.img (which is almost GRUB already) finds (hd0,1) disk and all the

3 of 6 06/05/2019 à 14:04
[HOWTO] Using GRUB as bootloader (second stage after U... https://forum.odroid.com/viewtopic.php?t=26894

files and modules for real grub on it, loads them and shows the menu.
After the reset u-boot loads, it loads core.img successfully, but then this
core.img sees only (hd0) and no partitions on it, so it cannot find the
GRUB second stage.

This could be either u-boot mmc driver reset sequence flaw (I suspect
most) specific for -XU4, core.img (GRUB first stage flaw) generic for
ARM's, or Linux weird flaw that does something to the card during reboot
and doesn't release it successfully...
Also this happens not 100% of time, it's 50/50, sometimes it boots after
reset, sometimes not.
Well, I'm not looking deeply into that right now, for me it's ok like this. It
doesn't bother me to unplug/plug the board since I'm experimenting
anyway. But the grub is waaaaay more easier as the system than u-boot
to tinker with.

Re: [HOWTO] Using GRUB as 


bootloader (second stage after
U-B
OverSun
 by OverSun » Wed May 03, 2017 8:46 pm
Posts: 1452
Joined: Mon Apr 29, 2013 5:12 pm
languages_spoken: english
 phaseshifter wrote:
Has thanked: 0
i am definitely a noob at this can you put the code down so a noob Been thanked: 2 times
could follow..sorry coding is not my forte..i can follow some of your Contact: 
grub bootloader...some i dont ..i dont want to break the flash i have all
ready

I wouldn't advise you to try that if you don't know what you're doing. Just
wait when it's stable and rolled out by vendor if they decide to go that
way.
The process itself right now is pretty complicated to setup and has a flaw
that doesn't make it useful 100%.

Re: [HOWTO] Using GRUB as 


bootloader (second stage after
U-B
 by rooted » Thu May 04, 2017 8:12 am

Find out what happens from uboot when "reset" is issued, this triggers a rooted
full 'hard' boot in my testing. Posts: 6456
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 8 times
Been thanked: 6 times
Contact: 

Re: [HOWTO] Using GRUB as 


back2future

bootloader (second stage after Posts: 208


Joined: Sun Jul 23, 2017 3:19 pm
U-B languages_spoken: english
 by back2future » Sun Jul 23, 2017 10:04 pm Has thanked: 7 times
Been thanked: 0

4 of 6 06/05/2019 à 14:04
[HOWTO] Using GRUB as bootloader (second stage after U... https://forum.odroid.com/viewtopic.php?t=26894

Kernel 3.10.x for xu4 supports cpu's in hyp mode. Contact: 


( Compiling U-Boot and Grub works, but from my side, qemu related
testing this setup is useless, with -cpu and -machine provided by qemu,
so far.
One previous problem was having first partition sector 1 at block 2048
instead of higher number and is now for example at 4096. )
U-Boot 2017.07 is running and grub-2.02~beta3 is available on serial
console 115200,8,1.
Can't recommend following u-boot config for boot.scr
setenv panel HDMI
setenv stdout serial,vga
setenv stderr serial,vga
, but may it's useful for someone else here.

 OverSun wrote:
For some reason first stage GRUB called from u-boot after a reboot
cannot find mmc to call second stage.

Maybe there is a chance in editing .../grub/arm-uboot/load.cfg, line1:


search.fs_uuid?

Next, Kernel 4.9.x.

Thanks for your advice.

naturally beYOnd spectrum


https://www.linaro.org/events/workshop/ ... #resources
https://fossasia.org/about/#background

Re: [HOWTO] Using GRUB as 


tc424

bootloader (second stage after Posts: 21


Joined: Sat Mar 03, 2018 10:26 pm
U-B languages_spoken: english
 by tc424 » Wed Aug 29, 2018 2:11 am ODROIDs: HC-1
Has thanked: 0
Been thanked: 0

 OverSun wrote: Contact: 


[..] After the reset u-boot loads, it loads core.img successfully, but then
this core.img sees only (hd0) and no partitions on it, so it cannot find
the GRUB second stage.

This could be either u-boot mmc driver reset sequence flaw (I suspect
most) specific for -XU4, core.img (GRUB first stage flaw) generic for
ARM's, or Linux weird flaw that does something to the card during
reboot and doesn't release it successfully...

Strangely, I've seen something similar with the USB connected on-board
devices on the HC1 (NIC & SATA) - my root is on SATA connected SSD,
and after anything but a clean reboot from a properly started normal
ODROID kernel, there is a high likelihood of one or the other or both USB
devices not coming up. After that a power cycle seems to be required, but

5 of 6 06/05/2019 à 14:04
[HOWTO] Using GRUB as bootloader (second stage after U... https://forum.odroid.com/viewtopic.php?t=26894

I will try to the u-boot reset command next time.

I've sure I've seen recent mentions (commit log maybe?) of fixes to u-boot
initialization code to address something like this, but can't remember
where...

S.

Re: [HOWTO] Using GRUB as 


tjjh89017

bootloader (second stage after Posts: 1


Joined: Mon Oct 08, 2018 4:21 am
U-B languages_spoken: Chinese
 by tjjh89017 » Mon Oct 08, 2018 4:27 am ODROIDs: XU4
Has thanked: 0
I found this script for debian installer. Been thanked: 0

They use `grub-efi-arm` for boot after u-boot. Contact: 


hardkernel u-boot (xu4-2017 branch) enable EFI loader by default.
Maybe this will be a way to boot kernel via EFI and follow the distro kernel
to use.

https://github.com/tkiapril/debian-xu4/ ... mkimage.sh


Re: [HOWTO] Using GRUB as 


tc424

bootloader (second stage after Posts: 21


Joined: Sat Mar 03, 2018 10:26 pm
U-B languages_spoken: english
 by tc424 » Mon Oct 08, 2018 5:12 am ODROIDs: HC-1
Has thanked: 0
Thanks, that's interesting! Much as it's actually been quite nice not to Been thanked: 0

have to deal with grub for once, I do probably need a more automated Contact: 
approach to kernel management.. so this is worth a look..

  11 posts • Page 1 of 1
Post Reply   

 Return to “Linux Kernel 4.14 Debugging Party” Jump to 

WHO IS ONLINE
Users browsing this forum: No registered users and 3 guests

 Board index  The team  Members  Delete cookies All times are UTC+09:00

Powered by phpBB® Forum Software © phpBB Limited


Privacy | Terms

6 of 6 06/05/2019 à 14:04

You might also like