MIPS Linux kernel in qemu trips on initrd - linux-kernel

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

Related

Kernel panic after ubi rootfs size increased

I'm currently working with LTIB tool to generate linux kernel 3.0.25, with u-boot-2009-08, for iMX6 solo core board.
I use mfg tool to flash. When I installed new packages, the rootfs size changed from 147 to 162MiB. Since then, I can't boot anymore, the ubi doesn't get attached.
I have a kernel panic with the following logs :
**UBI error: process_eb: bad image sequence number 1588612812 in PEB 720, expected 1344834100**
UBI error: ubi_attach_mtd_dev: failed to attach by scanning, error -22
UBI error: ubi_init: cannot attach mtd9
UBIFS error (pid 1): ubifs_mount: cannot open "ubi0:root", error -19
VFS: Cannot open root device "ubi0:root" or unknown-block(0,0)
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
UBI error screenshot
Kernel Panic Screenshot
To get rid of this, I changed the u-boot mfg CONFIG_BOOTARGS as follows :
#define CONFIG_BOOTARGS "console=ttymxc1,115200 rdinit=/linuxrc mtdparts=gpmi-
nand:4m(boot),256k(bootenv),2m(splashscreen),10m(ramdisk),5m(kernel),5m(flasherkernel),256k(updater
),256k(flag1),256k(flag2),170m(rootfs),32m(userpart1),32m(userpart2),-(userpart)"\
Here's the ubinize.cfg :
[ubifs]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=170MiB
vol_type=dynamic
vol_name=root
vol_flags=autoresize
And the ubi generation commands :
sudo mkfs.ubifs -r $ROOTFS -m 4096 -e 253952 -c 1184 -o ubifs.img
sudo ubinize -o $BUILT_IMG/ubi.img -m 4096 -p 256KiB ubinize.cfg
And the flash commands :
$ flash_eraseall /dev/mtd9 # Erasing Rootfs partition
$ send" file="files/ubi.img # Sending Root filesystem
$ ubiformat /dev/mtd9 -f $FILE -s 4096 -O 4096 # Flashing Root Filesystem
Any idea ?
Thanks

Vanilla kernel build on Rasperry Pi 1 B+

Attempting to build mainline vanilla kernel (4.9) and boot on a Raspberry Pi 1 B+. Have followed instructions here. Currently boot hangs with the following output
Net: No ethernet found. starting USB...
USB0: Core Release: 2.80a
scanning bus 0 for devices... 3 USB Device(s) found
scanning usb for storage devices... 0 Starage Device(s) found
Hit any key to stap autoboot: 0
switch to partition #0, OK
mmc0 is current device
Scanning mmc 0:1
Found U-Boot script /boot.scr.uimg
reading /boot.scr.uimg 326 bytes read in 25 ms (12.7KiB/s)
## Exectuting script at 02000000 switch to partitions #0, OK
mmc0 is current device
reading ZImage
4064616 bytes read in 389 Ms (10MiB/s)
reading bcm2835-rpi-b-plus.dtb
7101 bytes read in 31 Ms (223.6KiB/s)
Kernel image # 0x1000000 [ 0x000000 _0x3e0568 ]
## Flattened Device Tree blob at 00000100
Booting using the fdt blob at 0x000100
Using Device Tree in place at 00000100, end 00004cbc
Starting kernel ...
boot.scr.uimg was built using mkimage from Ubuntu repositories
$ mkimage -V
mkimage version 2016.01+dfsg1-2ubuntu3
$ mkimage -A arm -O linux -T script -C none -n boot.scr -d boot.scr boot.scr.uimg
boot.scr is as listed in the instructions.
mmc dev 0
setenv fdtfile bcm2835-rpi-b-plus.dtb
setenv bootargs earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootwait
fatload mmc 0:1 ${kernel_addr_r} zImage
fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}
bootz ${kernel_addr_r} - ${fdt_addr_r}

Can't format a usb volume using fdisk

I tried to format a usb flash disk to FAT32 using fdisk /dev/sdb(I created a new partition and saved changes with w) and mkfs.vfat -F 32 /dev/sdb but when i eject and mount the volume again,it looks like it's empty.
dmesg | tail
outputs:
[ 8583.830684] usb-storage 3-2:1.0: USB Mass Storage device detected
[ 8583.830801] scsi host5: usb-storage 3-2:1.0
[ 8584.864614] scsi 5:0:0:0: Direct-Access Generic Flash Disk 5.00 PQ: 0 ANSI: 2
[ 8584.865005] sd 5:0:0:0: Attached scsi generic sg1 type 0
[ 8584.865070] sd 5:0:0:0: [sdb] 31283200 512-byte logical blocks: (16.0 GB/14.9 GiB)
[ 8584.865194] sd 5:0:0:0: [sdb] Write Protect is off
[ 8584.865196] sd 5:0:0:0: [sdb] Mode Sense: 0b 00 00 08
[ 8584.865314] sd 5:0:0:0: [sdb] No Caching mode page found
[ 8584.865318] sd 5:0:0:0: [sdb] Assuming drive cache: write through
[ 8584.870170] sd 5:0:0:0: [sdb] Attached SCSI removable disk
mkfs.vfat -F 32 /dev/sdb
Running this command overwrites any partitioning of the disk. You should have used
mkfs.vfat -F 32 /dev/sdb1
instead. This will create the filesystem on the first partition of sdb.

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

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.

How to mount ext2 fs?

fdisk is used to create mmcblk0p3 on the 64G SD card.
Disk /dev/mmcblk0: 63.8 GB, 63864569856 bytes
255 heads, 63 sectors/track, 7764 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 * 2 6 40162+ c Win95 FAT32 (LBA)
/dev/mmcblk0p2 7 130 996030 83 Linux
/dev/mmcblk0p3 131 7764 61320105 83 Linux
The fs is then formatted like this:
$ mke2fs -L media /dev/mmcblk0p3
Filesystem label=media
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
3833856 inodes, 15330026 blocks
766501 blocks (5%) reserved for the super user
First data block=0
Maximum filesystem blocks=16777216
468 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, ...
Mount point /media definitely exists and $ mount /dev/mmcblk0p3 /media works fine when mmcblk0p3 is a FAT32 FS on a Win95 FAT32 partition. I need to change from FAT32 to ext2 since the FAT32 partition 3 is too easily hosed in this embedded Linux target (power cycle, USB mass storage disconnects, etc.). An Ubuntu 10.04 desktop system has been used to verify that the partition type is ext2 and is able to mount the SD card partition but this needs to work on the embedded Linux target. The kernel version is 2.6.32-17-ridgerun with BusyBox v1.18.2.
Why does $ mount /dev/mmcblk0p3 /media cause mount: mounting /dev/mmcblk0p3 on /media failed: Invalid argument?
Why does mount -t ext2 /dev/mmcblk0p3 /media cause mount: mounting /dev/mmcblk0p3 on /media failed: No such device?
Why does $ mount /dev/mmcblk0p3 /media cause mount: mounting
/dev/mmcblk0p3 on /media failed: Invalid argument?
The kernel can probably mount the filesystem, but it wrongly guess its type.
Why does mount -t ext2 /dev/mmcblk0p3 /media cause mount: mounting
/dev/mmcblk0p3 on /media failed: No such device?
If, after you specified -t, you get a problem like that, it is very likely that the kernel cannot mount the requested filesystem for you. Check if there is a module for that filesystem and it is loaded.
lsmod # show modules
modprobe ext2 # load module
Sources : http://www.silas.net.br/doc.notes/unix/linux/busybox-troubleshooting.html
As far as I know ext2 modules are already loaded by default. But it won't hurt to check.
The problem here I think is the ambiguity due to mke2fs. mke2fs can be used to create ext2/ext3/ext4 filesystems. You have to specify the file system via -t option. Try doing this :
#mkfs -t ext2 /dev/hda1
#mkfs.ext2 /dev/hda1
You missed out -t option in your command making mke2fs format it with filesystem in default conf.

Resources