Linux Kernel - ERROR: Failed to allocate 0x6b3c bytes below 0x1000000 - linux-kernel

I'm including my rootfs (CONFIG_INITRAMFS_SOURCE) into my kernel, so the kernel has now a size of 17Mb:
$ ls -la uImage
-rw-r--r-- 1 kkr kkr 17669274 Dec 1 18:59 uImage
$ d2h 17669274
0x10D9C9A
Since it's compressed, it would occupied uncompressed 39Mb:
$ dd if=uImage of=uImage-x.gz bs=64 skip=1
$ file uImage-x.gz
uImage-x.gz: gzip compressed data, max compression, from Unix
$ gunzip uImage-x.gz
$ ls -la uImage-x
-rw-r--r-- 1 kkr kkr 39852288 Dec 1 19:18 uImage-x
$ d2h 39852288
0x2601900
Why cannot I start my kernel via uBoot with this commands?
=> setenv bootargs console=$consoledev,$baudrate $othbootargs
=> tftp 0x3000000 $bootfile
Speed: 100, half duplex
Using eTSEC1 device
TFTP from server 192.168.32.3; our IP address is 192.168.32.32
Filename 'uImage-powerpc'.
Load address: 0x3000000
Loading: #####################################################
done
Bytes transferred = 17669274 (10d9c9a hex)
=> tftp 0x2700000 $fdtfile;
Speed: 100, half duplex
Using eTSEC1 device
TFTP from server 192.168.32.3; our IP address is 192.168.32.32
Filename 'sat_92107.100.00C_p2020.dtb'.
Load address: 0x2700000
Loading: ##
done
Bytes transferred = 15164 (3b3c hex)
=> bootm 0x3000000 - 0x2700000
## Booting kernel from Legacy Image at 03000000 ...
Image Name: Linux-4.0.0-AOA00.01-00662-g07ae
Created: 2015-12-01 17:59:21 UTC
Image Type: PowerPC Linux Kernel Image (gzip compressed)
Data Size: 17669210 Bytes = 16.9 MiB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
## Flattened Device Tree blob at 02700000
Booting using the fdt blob at 0x02700000
Uncompressing Kernel Image ... OK
ERROR: Failed to allocate 0x6b3c bytes below 0x1000000.
device tree - allocation error
Since the kernel itself needs 0x10d9c9a bytes (compressed) or 0x2601900 bytes (uncompressed) there is no chance to place the devicetree below 0x1000000. Is this value (16Mb) configurable? Does my extracted kernel have be less than 16Mb otherwise?

Yes, this value is configurable in U-Boot by setting the environment variables bootm_low and bootm_size to hexadecimal values. In your case, it's 0x0 and 0x20000000, respectively.
See section "Environment Variables" of the big README file in the U-Boot source tree.

Related

U-boot tftp ramdisk Bad Trap when loading larger rootfs

I'm booting kernel on my board with u-boot ramdisk image which is 39.8 MB. It boots successfully. When I try another u-boot image which has 74.7 MB size, load adress of ramdisk changing and its giving
'Loading Ramdisk to ff8c0000, end 03fffd63... Bad Trap at PC:7fef8cb0'
and board hangs with ' ###ERROR ### Please RESET the board ###'
Commands I use for booting with tftp:
tftp 30000000 uImage.bin
tftp 32000000 DTB.dtb
tftp 40000000 rootfs.ext2.gz.u-boot
bootm 30000000 40000000 32000000
I also tried different tftp adresses.
Scenario remains same.
How can I solve this situation?
Edit: Full Console log:
=> bootm 30000000 40000000 32000000 WARNING: adjusting available memory to 30000000
Booting kernel from Legacy Image at 30000000 ...
Image Name: Linux-4.19.26+gc0c2141
Image Type: PowerPC Linux Kernel Image (gzip compressed)
Data Size: 7140198 Bytes = 6.8 MiB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
Loading init Ramdisk from Legacy Image at 40000000 ...
Image Name: core-image-x11-t1042d4rdb-64b-20
Image Type: PowerPC Linux RAMDisk Image (uncompressed)
Data Size: 74710371 Bytes = 71.2 MiB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
Flattened Device Tree blob at 32000000
Booting using the fdt blob at 0x32000000
Uncompressing Kernel Image ... OK
Loading Ramdisk to ff8c0000, end 03fffd63 ... Bad trap at PC:
7fef8cb0, SR: 0
NIP: 7FEF8CB0 XER: 20000000 LR: 7FF16C60 REGS: 7faedae0 TRAP: 0d00
DAR: FFFFEFFC
MSR: 00021200 EE: 0 PR: 0 FP: 0 ME: 1 IR/DR: 00
GPR00: 00000003 7FAEDBD0 7FAEDE98 FF8C0000 4073F038 0473FD60 FFFFF000
5E2AE23B GPR08: DE633873 00000020 00000001 7FAEDBE0 7FFCB808 08200800
7FAF52E8 00000000 GPR16: 00000000 00000000 306CF3A6 30000000 00000001
30000040 00000000 7FF957A8 GPR24: 7FAF533C 7FFCB6FC 7FFCB718 40000040
04000000 7FFCB6F8 7FF78540 0473FD63 Call backtrace: 7FFCB6F8 7FF176CC
7FF0D9D4 7FEFA26C 7FF1B088 7FF0BC44 7FF0BE08 7FF0C3B8 7FF1A664
7FF09CDC 7FF0CCC4 7FF4FF3C 7FF0D1D0 7FEF1040 Exception in kernel pc
7fef8cb0 signal 0
ERROR ### Please RESET the board ###
You are loading the kernel image at 0x30000000. Afterwards you are loading the device tree at 0x30000000.
0x32000000 - 0x30000000 = 0x2000000 = 33554432
So when loading the device tree you are overwriting the kernel image.
If the area between 0x3f000000 and 0x40000000 is not used otherwise, choosing 0x3f000000 for the device tree should solve your problem.
What I understood so far is, the adress in
'Bad trap at PC: 7fef8cb0'
7fef8cb0 nearly equals 1,998995945 GB and start adress of Ramdisk seems ff8c0000 which nearly equals 3,992919922 GB.
Why U-boot is arranged so many memory for a ~70 MB ramdisk image ?

MIPS Linux kernel in qemu trips on initrd

I grabbed initrd and vmlinux (kernel 4.9.0) images from http://ftp.debian.org/debian/dists/Debian9.5/main/installer-mips/20170615+deb9u4/images/malta/netboot, installed and booted Qemu just fine:
$ qemu-system-mips -M malta -m 1G -hda ./debian-mips.qcow2 \
-initrd $initrd \
-kernel $vmlinux \
-append "nokaslr root=/dev/sda1" -nographic
Then I cross-compiled fresh kernel 4.18.0 using the same config as for 4.9.0, but this time Qemu fails to boot:
...
[ 4.036903] NET: Registered protocol family 17
[ 4.045894] rtc_cmos 70.rtc: setting system clock to 2018-07-23 02:26:58 UTC (1532312818)
[ 4.076247] Freeing unused kernel memory: 1528K
[ 4.076491] This architecture does not have kernel memory protection.
Loading, please wait...
starting version 232
[ 4.685538] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[ 4.703542] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[ 4.754874] random: udevadm: uninitialized urandom read (16 bytes read)
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... Begin: Waiting for suspend/resume device ... Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
...
done.
Gave up waiting for suspend/resume device
done.
Begin: Waiting for root file system ... Begin: Running /scripts/local-block ...
done.
done.
Gave up waiting for root file system device. Common problems:
- Boot args (cat /proc/cmdline)
- Check rootdelay= (did the system wait long enough?)
- Missing modules (cat /proc/modules; ls /dev)
ALERT! /dev/sda1 does not exist. Dropping to a shell!
BusyBox v1.22.1 (Debian 1:1.22.0-19+b3) built-in shell (ash)
Enter 'help' for a list of built-in commands.
(initramfs)
I believe I have all the required drivers/hardware support compiled in, since I'm using the same .config file. Also, I mounted my qemu image, and did make modules_install in there, so the image does have the correct modules matching the kernel version.
UPDATE
So I enabled all the drivers under DeviceDrivers/ATA/ATAPI/MFM/RLL support (DEPRECATED) and DeviceDrivers/Serial ATA and Parallel ATA drivers (libata), rebuild the kernel, installed it in qemu image, booted up:
[ 4.437168] ata2.00: ATAPI: QEMU DVD-ROM, 2.5+, max UDMA/100
[ 4.442551] ata1.00: ATA-7: QEMU HARDDISK, 2.5+, max UDMA/100
[ 4.443553] ata1.00: 20971520 sectors, multi 16: LBA48
[ 4.478753] scsi 0:0:0:0: Direct-Access ATA QEMU HARDDISK 2.5+ PQ: 0 ANSI: 5
[ 4.490907] sd 0:0:0:0: Attached scsi generic sg0 type 0
[ 4.498621] sd 0:0:0:0: [sda] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
[ 4.501629] sd 0:0:0:0: [sda] Write Protect is off
[ 4.508063] scsi 1:0:0:0: CD-ROM QEMU QEMU DVD-ROM 2.5+ PQ: 0 ANSI: 5
[ 4.518142] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 4.539178] sr 1:0:0:0: [sr0] scsi3-mmc drive: 4x/4x cd/rw xa/form2 tray
[ 4.540712] cdrom: Uniform CD-ROM driver Revision: 3.20
[ 4.564806] sr 1:0:0:0: Attached scsi generic sg1 type 5
[ 4.569555] sda: sda1 sda2 < sda5 >
[ 4.588040] sd 0:0:0:0: [sda] Attached SCSI disk
[ 5.102260] Freeing unused kernel memory: 1556K
[ 5.102988] This architecture does not have kernel memory protection.
Loading, please wait...
starting version 232
[ 7.297015] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[ 7.341169] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[ 7.527445] random: udevadm: uninitialized urandom read (16 bytes read)
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
Begin: Will now check root file system ... fsck from util-linux 2.29.2
[/sbin/fsck.ext4 (1) -- /dev/sda1] fsck.ext4 -a -C0 /dev/sda1
/dev/sda1: clean, 29311/628320 files, 454566/2512640 blocks
done.
mount: mounting /dev/sda1 on /root failed: No such device
done.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... mount: mounting /dev on /root/dev failed: No such file or directory
mount: mounting /dev on /root/dev failed: No such file or directory
done.
mount: mounting /run on /root/run failed: No such file or directory
run-init: current directory on the same filesystem as the root: error 0
Target filesystem doesn't have requested /sbin/init.
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
No init found. Try passing init= bootarg.
What else is possibly going wrong here?
Thanks.
The kernel configuration has to include the following options for correct FS mount procedure :
a) Device Drivers/Serial ATA and Parallel ATA drivers (libata) -- CONFIG_ATA_SFF, CONFIG_ATA_BMDMA, CONFIG_ATA_PIIX
b) Device Drivers/Generic Driver Options -- CONFIG_DEVTMPFS

Is it possible: TFTP in u-boot to load root filesystem to SD card? (I don't want NFS)

I know we can use NFS, but I just don't want to use it.
(don't want to keep network connection to NFS server all the time).
I know we can use tftp in u-boot to load kernel and device-tree!
But can we use tftp in u-boot to download root-filesystem, put it in the right partition of SD card, and boot?
If yes, how to do it? (I googled, but found no answers)
Thanks,
Jerry
I use TFTP in uboot to flash my rootfs (for debug purposes) on my internal eMMC. It's nearly the same case as you.
First download in you RAM the filesystem:
tftpboot ${rootfs_addr} ${tftppath}/${rootfs_file}
rootfs_addr will be the RAM address, I use 0x10800000.
tftppath is the TFTP path (depends on your configuration)
rootfs_file is the ext4 or ext3 file
Then update the mmc device (you can run mmc listto show SD u-boot number)
mmc dev 2
Here I set the device to the number 2, you need to set it corresponding to the mmc list command.
Then write the content of the RAM to the SD:
setexpr rootfsblksz ${filesize} / 200
setexpr rootfsblksz ${rootfsblksz} + 1
mmc write ${rootfs_addr} 6000 ${rootfsblksz}
Description:
I create a rootfsblksz variable, it converts the number of bytes downloaded to a number of blocks. filesizeis set automatically when we use TFTP, it represents the size of the last downloaded file (in Bytes).
Here my block is 512Bytes (0x200)
I add +1 to the blocksize (to be shure to have all the data)
I write it on the eMMC (or SD) at the address 0x6000 (in blocks) -> 24 576 blocks -> 12 582 912 (in Bytes) -> 12MB because my ext partition is at 12MB offset
Hope it helps!

Linux: boot arguments with U-Boot and Flat Image Tree (FIT)

I am trying to get my own build of U-Boot to boot Linux on a Jetson TK1 board. As we are pushing for verified boot I am using the Flat Image Tree (unifying kernel image, device tree blob, ...) to describe my system. U-Boot can load the ITB file and tries to start the kernel but the system hangs after this message.
I assume that this is because no boot arguments are passed to the kernel (the original startup adds loads of arguments) but I am a little dumbfounded on how to pass the arguments to the kernel. I tried setting the bootargs environment variable but this did not change the situation.
How do I pass kernel arguments to the kernel when using an ITB file?
Command line arguments (taken from the APPEND command of the examples extlinux.conf):
console=ttyS0,115200n8 console=tty1 no_console_suspend=1
lp0_vec=2064#0xf46ff000 video=tegrafb mem=1862M#2048M memtype=255 ddr_die=2048M#2048M
section=256M pmuboard=0x0177:0x0000:0x02:0x43:0x00 vpr=151M#3945M tsec=32M#3913M
otf_key=c75e5bb91eb3bd947560357b64422f85 usbcore.old_scheme_first=1 core_edp_mv=1150
core_edp_ma=4000 tegraid=40.1.1.0.0 debug_uartport=lsport,3 power_supply=Adapter
audio_codec=rt5640 modem_id=0 android.kerneltype=normal usb_port_owner_info=0
fbcon=map:1 commchip_id=0 usb_port_owner_info=0 lane_owner_info=6 emc_max_dvfs=0
touch_id=0#0 tegra_fbmem=32899072#0xad012000 board_info=0x0177:0x0000:0x02:0x43:0x00
root=/dev/mmcblk0p1 rw rootwait tegraboot=sdmmc gpt
Content of ITS file:
/dts-v1/;
/ {
description = "Simple image with single Linux kernel and FDT blob";
#address-cells = <1>;
images {
kernel#1 {
description = "Vanilla Linux kernel";
data = /incbin/("./zImage");
type = "kernel";
arch = "arm";
os = "linux";
compression = "none";
load = <0x81008000>;
entry = <0x81008000>;
hash#1 {
algo = "crc32";
};
hash#2 {
algo = "sha1";
};
};
fdt#1 {
description = "Flattened Device Tree blob";
data = /incbin/("./tegra124-pm375.dtb");
type = "flat_dt";
arch = "arm";
compression = "none";
hash#1 {
algo = "crc32";
};
hash#2 {
algo = "sha1";
};
};
};
configurations {
default = "conf#1";
conf#1 {
description = "Boot Linux kernel with FDT blob";
kernel = "kernel#1";
fdt = "fdt#1";
};
};
};
U-Boot Output:
Tegra124 (Jetson TK1) # fatload mmc 1 0x90000000 /kernel_fdt.itb
reading /kernel_fdt.itb
5946200 bytes read in 497 ms (11.4 MiB/s)
Tegra124 (Jetson TK1) # bootm 0x90000000
## Loading kernel from FIT Image at 90000000 ...
Using 'conf#1' configuration
Verifying Hash Integrity ... OK
Trying 'kernel#1' kernel subimage
Description: Vanilla Linux kernel
Type: Kernel Image
Compression: uncompressed
Data Start: 0x900000ec
Data Size: 5910168 Bytes = 5.6 MiB
Architecture: ARM
OS: Linux
Load Address: 0x00000000
Entry Point: 0x00000000
Hash algo: crc32
Hash value: c5b4b377
Hash algo: sha1
Hash value: f001007efe83f563425bfe0659186a32395c946c
Verifying Hash Integrity ... crc32+ sha1+ OK
## Loading fdt from FIT Image at 90000000 ...
Using 'conf#1' configuration
Trying 'fdt#1' fdt subimage
Description: Flattened Device Tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x905a30ac
Data Size: 34678 Bytes = 33.9 KiB
Architecture: ARM
Hash algo: crc32
Hash value: e466b23e
Hash algo: sha1
Hash value: ec909ae16e62233d0ed1e1f4c909085abc9b5879
Verifying Hash Integrity ... crc32+ sha1+ OK
Booting using the fdt blob at 0x905a30ac
Loading Kernel Image ... OK
Using Device Tree in place at 905a30ac, end 905ae821
Starting kernel ...
The salient issue is that the system seems to hang after U-Boot outputs the text
Starting kernel ...
If an uncompressed kernel Image file has been loaded, then the actual kernel startup code would be executed next.
But if a uImage or zImage file has been loaded (which are also reported as "uncompressed" because they are self-extracting), then the next code executed would be the decompression routine that is attached to the zImage file. Normally this decompression routine will output text such as
Uncompressing Linux............ done, booting the kernel.
before the actual kernel startup code would be executed, before any processing of the kernel command line, before any processing of the Device Tree blob, and prior to any console output from the kernel (including earlyprintk).
There's a discrepancy between the kernel load & start addresses specified in the image header
Load Address: 0x00000000
Entry Point: 0x00000000
versus what is specified in the DT:
load = <0x81008000>;
entry = <0x81008000>;
Since the kernel image is temporarily loaded at
## Loading kernel from FIT Image at 90000000 ...
the addresses in the DT would seem to be correct, and the addresses in the image header are bogus.
Assuming that there is no physical RAM at 0x00000000, the result will be that the kernel image is copied (or decompressed) to the bogus load address of 0, and then the kernel image will be executed by branching to the bogus entry point of 0. The CPU is likely to hang trying to execute garbage from nonexistent memory, and that correlates perfectly with what you report.
Solution is (1) confirm that the kernel is linked to the correct address and (2) to specify the correct addresses in the mkimage command using the -a and -e command options.
This correction should at least get you past this one point.
When using device tree, you still use bootargs to provide arguments.
Check that:
You have compiled the tree (using compiler scripts/dtc/dtc inside the Linux kernel)
Support for device tree is enabled in the kernel config (symbol CONFIG_USE_OF) (where OF stands for "Open Firmware")
You provided U-Boot the address of the tree: bootm <uImage address> - <dtb address>
Serial console is enabled in the kernel config under Device Drivers -> Character Devices -> Serial Drivers
Console is enabled in bootargs (e.g., console=ttyS0,115200)
I experienced the same or similar issue. My solution (or work around) for this issue was to set the U-Boot environment variables initrd_high and fdt_high to an address in RAM before the relocated U-boot (in my case 8effffff).

Linux-2.6.10 MIPS restarts after "Starting kernel ..."

I'm using old Linux-2.6.10 with ramdisk for MIPS arch. I was needed to enlarge my initrd for debug purposes. So, I did this. But with big initrd (~2.1MB) my board restarts faultly.
MY-BOARD # run bootnet
Using Board Eth. device
TFTP from server 192.168.1.10; our IP address is 192.168.1.1
Filename 'uImage'.
Load address: 0x80800000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
##################################################
done
Bytes transferred = 3247396 (318d24 hex)
## Booting image at 80800000 ...
Image Name: Linux-2.6.10 with ramdisk
Created: 2014-01-13 8:27:39 UTC
Image Type: MIPS Linux Kernel Image (gzip compressed)
Data Size: 3247332 Bytes = 3.1 MB
Load Address: 80100000
Entry Point: 8057b000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Starting kernel ...
Error: Boot failed!
My u-boot environment:
Type "printenv" to view boot options.
Hit any key to stop autoboot: 0
MY-BOARD # printenv
bootargs=console=ttyS0,115200 nofpu mem=30M root=/dev/ram0 rw
bootcmd=cp.b 0xad040000 0x80800000 0x400000; bootm 0x80800000
bootdelay=3
baudrate=115200
ethaddr=00:06:0D:00:00:00
ipaddr=192.168.1.1
serverip=192.168.1.10
preboot=echo; echo Type "printenv" to view boot options.; echo;
netmask=255.255.255.0
u-bootfile=u-boot.bin
prog-ub=run load-ub update-ub
load-ub=tftp 80504000 $(u-bootfile)
update-ub=protect off 1:0-4; cp.b AD000000 80500000 4000; cp.b AD03F000 8053F000 1000; erase 0xAD000000 0xAD03ffff; cp.b 80500000 AD000000 0x40000
imget=tftp 0x80800000 $(imname); erase 0xad000000 0xad7e0000; cp.b 0x80800000 0xad000000 $(filesize)
progkn=tftp 0x80800000 uImage; erase 0xad040000 0xad43ffff; cp.b 0x80800000 0xad040000 $(filesize)
progjffs=tftp 0x80800000 jffs; erase 0xad240000 0xad53ffff; cp.b 0x80800000
0xad240000 $(filesize)
bootnet=tftp 0x80800000 uImage; bootm 0x80800000
stdin=serial
stdout=serial
stderr=serial
ethact=Board Eth.
Environment size: 980/4092 bytes
MY-BOARD #
Does somebody know or remember how to fix this? I also use old U-Boot 1.1.2. U-Boot reaches "Starting kernel ..." and jump to the kernel entry point, theKernel() function. There is restart then ("Error: Boot failed!").
The kernel so old that it hasn't early_printk to debug itself. Imho, U-Boot is ok, and I miss some initrd option (I made all visible kernel .config). With small embedded initrd image (~700kB) Linux boot smoothly. In both cases initrd has the same size (8192K).
p.s.: I am sorry for imperfect English.

Resources