Raspberry 3: booting a Kernel by using U-Boot - linux-kernel

I am playing around with a Raspberry 3 and try to boot a Linux Kernel by using U-Boot.
I've built a Linux Kernel (from github.com/raspberrypi), and Busbox-Userland.
This Kernel boots and works just fine, when booting 'directly' (that means without U-Boot).
Now I've built U-Boot (Mainline, denx.de/u-boot.git), which also seems to work.
It boots and is accessible (both by HDMI/USB and [after adding pi3-disable-bt-Overlay]).
But now I am stuck; the Kernel won't start from within U-Boot.
I tried the following commands:
setenv fdtfile bcm2710-rpi-3-b.dtb
mmc dev 0
fatload mmc 0:1 ${kernel_addr_r} kernel7.img
fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}
setenv bootargs earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootfstype=ext2 rootwait noinitrd
bootz ${kernel_addr_r} - ${fdt_addr_r}
U-Boot's output is then:
[...]
reading kernel7.img
[...]
Kernel image # 0x1000000 [ 0x000000 - 0x40e630 ]
## Flattened Device Tree blob at 0x000100
Booting using fdt blob at 0x000100
Using Device Tree in place at 0000100, end 00006b1a
Starting kernel...
And then the Monitor turns black and shows "no signal", also the serial console doesn't show any more information.
I've played around with the bootargs that are provided to the Kernel, but I didn't find a working scenario.
Does anybody have an idea?
As I said, both the U-Boot and the Kernel seem to work, but U-Boot can't boot the Kernel...
Thanks,
VanDahlen

I know this is a very old question but for me it helped to not manually load the device tree file and use ${fdt_addr} instead of ${fdt_addr_r} in bootz.
So...
mmc dev 0
fatload mmc 0:1 ${kernel_addr_r} kernel7.img
setenv bootargs earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootfstype=ext2 rootwait noinitrd
bootz ${kernel_addr_r} - ${fdt_addr}
...should work.

Have you tried loading the kernel at a different address? i.e. at $loadaddr instead of $kernel_addr_r. Make sure kernel is getting loaded at the right address.

Related

What does fatload mmc and bootm means in the uboot?

I am unable to understand these commands like
fatload mmc 0 0x3000000 uImage
fatload mmc 0 0x2A00000 devicetree.dtb
bootm 0x3000000 - 0x2A00000
#fatload mmc 0 0x3000000 uImage.
What is it doing? Is it loading uImage as a fat partition and loading at the RAM address 0x3000000?
bootm 0x3000000 - 0x2A00000 - ?
Does it mean boot from the RAM address 0x3000000 to 0x2A00000?
U-Boot runs code placed in (processor's) RAM, although it can also read data from other media. The boot process normally takes place in two steps:
Reading the OS image from media (Ethernet, flash, USB, MMC) into RAM
Jumping to the first instruction of the image in RAM
uImage is the (most probably Linux) kernel.
xxx.dtb is your device tree in compiled form. It contains the hardware information, so that the information can be kept separately from the kernel.
Now, to read an image from an MMC card formatted in FAT, the command is:
fatload mmc <dev>[:partition] <loadAddress> <bootfilename>
So the 2 fatload commands are loading the 2 files from MMC card into the processor's memory/RAM.
Now, regarding the bootm : This command starts a kernel image running. The syntax is :
bootm <address of kernel> <address of ramdisk> <address of dtb>
Addresses of ramdisk and/or dtb can be omitted if the kernel is configured in such a away that it doesn't need it/them.
In your case you are not using ramdisk hence the dash - in the middle.

Uboot: How to automatically load kernel image onto raspberry pi?

I am trying to load a new kernel image onto my raspberry pi. I've got u-boot-2018-11 and trying to have the kernel load automatically with uEnv.txt but there is not change in the out put with or without the text file. I have also tried boot.scr and boot.scr.uimg but nothing seems to work. I don't know for sure what to put into those files but uboot doesn't even recognize them.
For the uEnv.txt I put...
uenvcmd=fatload mmc 0:6 0x08000000 kernel8.img; fatload mmc 0:6 0x09000000 rpi-3b-plus.dtb;bootm 0x08000000 - 0x09000000;
So the u-boot I am using doesn't recognize uEnv.txt and I wasn't putting the correct stuff in the other two things. What I ended up doing was..
setenv bootcmd 'fatload mmc 0:6 0x08000000 kernel8.img; fatload mmc 0:6 0x09000000 rpi-3b-plus.dtb;bootm 0x08000000 - 0x09000000;'
saveenv
and that works

earlyprintk not work as expected, kernel hung during booting

I am booting the kernel (arm, cortexa15), and the kernel hung at:
## Booting kernel from Legacy Image at 40007fc0 ...
Image Name: Linux-4.4.138-cip25-rt19-yocto-s
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 5510400 Bytes = 5.3 MiB
Load Address: 40008000
Entry Point: 40008000
Verifying Checksum ... OK
## Flattened Device Tree blob at 40f00000
Booting using the fdt blob at 0x40f00000
XIP Kernel Image ... OK
Loading Device Tree to 40ef1000, end 40effb37 ... OK
Starting kernel ...
I tried to enable earlyprintk to know where the kernel stuck.
CONF_PRINTK=y
CONF_EARLY_PRINTK=y
CONFIG_DEBUG_LL=y (low-level debug)
# CONFIG_DEBUG_ICEDCC is not set
and set bootargs:
> setenv bootargs ${bootargs_base} earlyprintk
But, there is not message printed on console. Anyone can help ?

Uboot hangs after "Starting kernel" message

I compiled a linux kernel for my Toshiba AC100 and want to boot it via uboot.
Problem: After displaying the message "Starting Kernel" nothing happens.
The flag CONFIG_DEBUG_LL was set but there is still no output after this message.
I have another precompiled kernel (but too old to use) which comes with its own dtb file and this one boots (same bootargs as the non-booting kernel).
Observation: If I change the dbt file for this kernel it shows the same behavior as the non-booting kernel, just displaying the "Starting kernel" line.
So I guess my problem is related to the dbt file I use for my kernel.
Are there any methods to check if the dbt file is right for my board?
What else could I do to get some information what the problem is?
The entry in the boot.scr:
setenv bootargs 'root=/dev/mmcblk0p7 rootfstype=ext4 earlyprintk=vga console=tty0 mem=448M#0'
setenv bootmenu_4 "Boot Arch Linux =ext2load mmc 0:7 0x1000000 /boot/zImage; ext2load mmc 0:7 0x2000000 /boot/tegra20-paz00.dtb; bootz 0x1000000 - 0x2000000"
And here's the output form u-boot:
2255488 bytes read in 116 ms (18.5 MiB/s)
14153 bytes read in 82 ms (168 KiB/s)
Kernel image # 0x1000000 [ 0x000000 - 0x226a80 ]
## Flattened Device Tree blob at 02000000
Booting using the fdt blob at 0x2000000
Loading Device Tree to 0fff9000, end 0ffff748 ... OK
Starting kernel ...
I tried also to extract the config from the working kernel and built a new kernel with this config, but this one does not work, too (does not matter which dtb file I use).
EDIT:
Finally I solved it by changing the kernel config from
CONFIG_TEGRA_DEBUG_UART_AUTO_ODMDATA
to
CONFIG_TEGRA_DEBUG_UARTA
After this, the kernel boots fine.

How to set up the Machine Type (arch_id) for Linux Kernel Arm Cross-Compile

I would like to know how to set the correct MACH_TYPE or arch_id for the kernel. I searched and found at least 2 references where the kernel would hang at "Starting Kernel ... ". These came with the same answer. Correctly set your Machine Type. But then neither mentions how to do so. Anyone know how to do this?
Pretty good explanation for the hang. and Another good description.
Both of these are close to what I am experiencing when I try to boot my kernel. It gets stuck on "Starting Kernel..." and won't continue. I have built the kernel several times from .configs that were supposed to be exactly for my model.
Timesys (LinuxLink) provides a .config that is supposed to match the kernel that they provide with their free build service. But that doesn't work either. If I use their pre-built kernel it boots up no problem. So I know it is not my u-boot or how I have configured my SD-card. The problem must come from the kernel build.
I run my make like: make ARCH=arm CROSS_COMPILE=${PATH_TO_TOOLCHAIN}/bin/armv7l-timesys-linux-gnueabi- uImage and make my image as follows: sudo mkimage -A arm -O linux -T kernel -C none -a 0x70800000 -e 0x70800000 -n "Linux-2.6.35-ts-armv7l" -d arch/arm/boot/uImage ../../uImage
I am working with a Freescale i.MX53 Eval Board. When I try to run the kernel:
U-Boot 2009.08-dirty (Aug 02 2013 - 19:57:03)
CPU: Freescale i.MX53 family 2.1V at 800 MHz
mx53 pll1: 800MHz
mx53 pll2: 400MHz
mx53 pll3: 432MHz
mx53 pll4: 455MHz
ipg clock : 66666666Hz
ipg per clock : 33333333Hz
uart clock : 66666666Hz
cspi clock : 108000000Hz
ahb clock : 133333333Hz
axi_a clock : 400000000Hz
axi_b clock : 200000000Hz
emi_slow clock: 133333333Hz
ddr clock : 400000000Hz
esdhc1 clock : 80000000Hz
esdhc2 clock : 80000000Hz
esdhc3 clock : 80000000Hz
esdhc4 clock : 80000000Hz
nfc clock : 26666666Hz
Board: MX53-LOCO 1.0 Rev. B
Boot Reason: [POR]
Boot Device: SD
I2C: ready
DRAM: 1 GB
MMC: FSL_ESDHC: 0,FSL_ESDHC: 1
In: serial
Out: serial
Err: serial
Serial reinitilized!
Net: got MAC address from IIM: 00:04:9f:01:f7:ce
FEC0 [PRIME]
Hit any key to stop autoboot: 0
mmc0 is current device
MMC read: dev # 0, block # 2048, count 8192 ... 8192 blocks read: OK
## Booting kernel from Legacy Image at 70800000 ...
Image Name: Linux-2.6.35-ts-armv7l
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2999932 Bytes = 2.9 MB
Load Address: 70800000
Entry Point: 70800000
Verifying Checksum ... OK
XIP Kernel Image ... OK
OK
Starting kernel ...
u-boot env:
bootdelay=3
baudrate=115200
netdev=eth0
ethprime=FEC0
uboot=u-boot.bin
kernel=uImage
nfsroot=/opt/eldk/arm
bootargs_base=setenv bootargs console=ttymxc0,115200
bootargs_nfs=setenv bootargs ${bootargs} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
bootcmd_net=run bootargs_base bootargs_nfs; tftpboot ${loadaddr} ${kernel}; bootm
bootcmd=run bootcmd_mmc
ethact=FEC0
lcd=video=mxcdi0fb:RGB24,SEIKO-WVGA di0_primary
bootargs_mmc=setenv bootargs ${bootargs} gpu_nommu ${lcd} ip=dhcp root=/dev/mmcblk0p1 rootwait rw
bootargs=console=ttymxc0,115200 gpu_nommu video=mxcdi0fb:RGB24,SEIKO-WVGA di0_primary ip=dhcp root=/dev/mmcblk0p1 rootwait rw
bootcmd_mmc=run bootargs_base bootargs_mmc; mmc dev 0; mmc read ${loadaddr} 0x800 0x2000; bootm
loadaddr=0x70800000
stdin=serial
stdout=serial
stderr=serial
The issue is that a double u-boot header has been applied to the image. As per unixsmurf.

Resources