LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware - ARM (https://www.linuxquestions.org/questions/slackware-arm-108/)
-   -   slarm64 u-boot (https://www.linuxquestions.org/questions/slackware-arm-108/slarm64-u-boot-4175702361/)

rasp 10-20-2021 12:47 PM

slarm64 u-boot
 
this question may sound stupid, as it probably has been answered about a zillion times before, however I've found no answer:
why is slarm64 using u-boot in the first place, instead of just loading kernel8 ?
any pointers welcome
regards,
-rasp

lucabon 10-20-2021 09:55 PM

Quote:

Originally Posted by rasp (Post 6294062)
why is slarm64 using u-boot in the first place, instead of just loading kernel8 ?

Because the kernel (and the relative initrd.gz, if any) is usually too big to be loaded in the first place.
AllWinner chips, for example, have only a region of 32K that is automatically loaded in memory from the MMC in the boot process. Also u-boot does not fit in this small region: in fact there is the "SPL" (Secondary Program Loader) that is loaded in the boot process before u-boot and it setups the memory and MMC controller and then it loads and runs u-boot (and ATF - Arm Trusted Firmware - for aarch64).
U-boot also allow a smarter booting (e.g. from network) if something is wrong with a new kernel.

Luca

rasp 10-21-2021 03:23 AM

Quote:

Originally Posted by lucabon (Post 6294250)
Because the kernel (and the relative initrd.gz, if any) is usually too big to be loaded in the first place.
[....]
AllWinner chips, for example, have only a region of 32K that is automatically loaded in
U-boot also allow a smarter booting (e.g. from network) if something is wrong with a new kernel.

Luca

the booting 'something else' thing sounds good, although probably only applicable via serial console, no ?
nevertheless if the kernel has everything it needs to boot from, say btrfs hdd, it should be possible to have a 'old style' boot partition, loading kernel8.img right ?
(switching kernels back and forth is easy by mounting the boot partition on some other machine and changing it there....)

-rasp

lucabon 10-21-2021 04:29 AM

Quote:

Originally Posted by rasp (Post 6294302)
the booting 'something else' thing sounds good, although probably only applicable via serial console, no ?

No, you can also use network console. You have to set (from u-boot itself or with u-boot's fw_setenv):
fw_setenv serverip 10.10.10.10
fw_setenv ipaddr 10.10.10.100
fw_setenv if_netconsole 'ping $serverip'
fw_setenv start_netconsole 'setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version;'
fw_setenv preboot 'run if_netconsole start_netconsole'

And from the PC with IP 10.10.10.10:
nc -l -u -p 6666

Quote:

Originally Posted by rasp (Post 6294302)
nevertheless if the kernel has everything it needs to boot from, say btrfs hdd, it should be possible to have a 'old style' boot partition, loading kernel8.img right ?

Yes, I usually do it: creating an "old style" boot partition, put kernel (and uinitrd, if needed), and set u-boot to load kernel/initrd from the boot partition. With older armvt5-kirkwoord systems, I usually try before USB and, if it fails, load from SATA-IDE/MMC. Example of u-boot multi-boot possibility (it will try both fat and ext2 filesystem), with additional u-boot command to be placed in "boot.scr" script (for Seagate GoFlexNet NAS-like ARMv5te system):

fw_setenv fdtfile /kirkwood-goflexnet.dtb
fw_setenv zimage /zImage-armv5
fw_setenv uinitrd /uinitrd-armv5
fw_setenv initaddr 0x01100000
fw_setenv fdtaddr 0x00700000
fw_setenv kernaddr 0x00800000
fw_setenv script boot.scr
fw_setenv scriptaddr 0x00780000
fw_setenv bootargs 'console=ttyS0,115200 root=/dev/disk/by-label/slackroot'
fw_setenv bootcmd_script '$fload $bootbus ${bootdev}:${bootpart} $scriptaddr $script; source $scriptaddr'
fw_setenv bootcmdz 'bootz $kernaddr $initaddr $fdtaddr'
fw_setenv bootcmd_slk 'run bootcmd_script; $fload $bootbus ${bootdev}:${bootpart} $initaddr $uinitrd; $fload $bootbus ${bootdev}:${bootpart} $kernaddr $zimage; $fload $bootbus ${bootdev}:${bootpart} $fdtaddr $fdtfile; run bootcmdz'
fw_setenv bootcmd_ide 'setenv bootbus ide;setenv bootdev 0;setenv bootpart 1;setenv fload ext2load;run bootcmd_slk; setenv bootdev 1;run bootcmd_slk'
fw_setenv bootcmd_usb 'setenv bootbus usb;setenv bootdev 0;setenv bootpart 1;setenv fload ext2load;run bootcmd_slk; setenv fload fatload;run bootcmd_slk'
fw_setenv bootcmd 'usb start; run bootcmd_usb; ide reset; run bootcmd_ide; usb reset; run bootcmd_usb; reset'

Luca

sndwvs 10-21-2021 10:44 AM

Quote:

Originally Posted by lucabon (Post 6294250)
Because the kernel (and the relative initrd.gz, if any) is usually too big to be loaded in the first place.
AllWinner chips, for example, have only a region of 32K that is automatically loaded in memory from the MMC in the boot process. Also u-boot does not fit in this small region: in fact there is the "SPL" (Secondary Program Loader) that is loaded in the boot process before u-boot and it setups the memory and MMC controller and then it loads and runs u-boot (and ATF - Arm Trusted Firmware - for aarch64).
U-boot also allow a smarter booting (e.g. from network) if something is wrong with a new kernel.

Luca

only raspberry pi has a veiled spi bootloader, other boards may/may not have spi with a bootloader. At the moment, all the boards I have come across (except for the raspberry pi) use u-boot as a hardware initialization system with the subsequent transfer of control to the kernel, so the same approach is used in images_build_kit. But you can customize your boards without using u-boot.

rasp 10-21-2021 12:56 PM

"I love it, when a plan comes together" :-)
 
thank you all for your effort!.
to solve my own question, this is what I did now:
booted slarm64 from:slarm64-current-aarch64-xfce-raspberry_pi_4-5.14.0-build-20210902.img (using u-boot)
'stole' the boot partition contents from raspberrypios64.
put the boot stuff on a 64g usb-stick (part1/vfat)
rebuild the kernel as https://www.raspberrypi.com/document...ux_kernel.html
activated some 'extras' btrfs[*] and .config support.
gzipped 22M kernel to 8M.
copied ext4 slarm to 2nd partition usb btrfs.
changed cmdline.txt to PARTLABEL for rootfs
and hey it boots off usb/btrfs without u-boot....
-rasp


All times are GMT -5. The time now is 02:11 PM.