linux kernel starting issue (file system corrupted) on nand flash memory

lolhangman

Reputable
Feb 2, 2015
2
0
4,510
Hi everyone !

To make it short : I need a way to erase flash memory on my arm device to be able to install a linux kernel + file system again.

So, let me introduce my hardware. It is a panelpc (like an android tablet) armv7, flash memory, touch screnn etc. brand is INEWTEK, whith samsung memory

I am working in a smal company, and we buy this panelpc, install our (linux kernel+file system) and software on it (replacing the existing one (linux kernel+file system)) then sell it.

I did it a lot of time without issue.

But last time, after doing it, I tested the device and I had an issue with the screen. So I wanted to install the original os (linux kernel+file system) on it and of course it crashed.

since then I am not able to install any linux kernel ont it anymore.

This is exactly what I am doing every time :

Code:
1/ connect to serial port (COM1)
2/
setenv serverip 192.168.0.5 // for tftp
setenv ipaddr 192.168.0.20 // panelpc ip
tftp 20008000 u-boot.bin
nand erase 0 40000
nand write 20008000 0 40000

// kernel on mtd3 / jffs2
tftp 20008000 PROD-zImageMTD3
nand erase 40000 3C0000
nand write 20008000 40000 3C0000

// RFS
tftp 20008000 PROD-zImageMTD2 // mtd2 / CRAMFS
bootm 20008000
date -s 021716482012
hwclock --systohc -u
cd /tmp
mkdir mnt
tftp -g -r PROD-RFS-2014-06-12.tar 192.168.0.5 // RFS 
flash_eraseall -j /dev/mtd3
mount -t jffs2 /dev/mtdblock3 mnt
ls mnt
tar -xf PROD-RFS-2014-06-12.tar -C mnt
ls mnt
umount mnt
reboot

So this worked (if I didn't crash the panelpc first ;)

Then as I had an issue with the screen I tried to re-install the original linux given with the panelpc (following given instruction and given files).

Code:
1/ connect to serial port (COM1)
2/
setenv bootargs root=/dev/mtdblock2  rootfstype=cramfs init=/linuxrc console=ttySAC1,115200
setenv serverip 192.168.0.5
setenv ipaddr 192.168.0.20
setenv user sdkim 
setenv board nt 
tftp 20008000 u-boot2.bin
nand erase 0 40000
nand write 20008000 0 40000 
tftp 20008000 zImage
nand erase 80000 500000
nand write 20008000 80000 500000 
tftp 20008000 linux-ramdisk.gz
nand erase 400000 300000
nand write 20008000 400000 300000 
tftp 20008000 usr.jffs2
nand erase 1c00000 3000000
nand write.jffs2 20008000 1c00000 0x2ab3c04 
nand read 20008000 80000 300000
bootm 20008000

I got this error :
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)

Here is the trace:
PHP:
Hit any key to stop autoboot:  0
SMDKC100 # setenv bootargs root=/dev/mtdblock2  rootfstype=cramfs init=/linuxrc console=ttySAC1,115200
SMDKC100 # setenv serverip 192.168.0.5
SMDKC100 # setenv ipaddr 192.168.0.20
SMDKC100 # setenv user sdkim
SMDKC100 # setenv board nt
SMDKC100 # tftp 20008000 u-boot2.bin
smc911x: initializing
smc911x: detected LAN9215 controller
smc911x: phy initialized
smc911x: MAC 00:40:5c:26:0a:5b
Using smc911x device
TFTP from server 192.168.0.5; our IP address is 192.168.0.20
Filename 'u-boot2.bin'.
Load address: 0x20008000
Loading: ###########################################
done
Bytes transferred = 216024 (0x34bd8)
SMDKC100 # nand erase 0 40000

NAND erase: device 0 offset 0x0, size 0x40000
Erasing at 0x20000 -- 100% complete.
OK
SMDKC100 # nand write 20008000 0 40000

NAND write: device 0 offset 0x0, size 0x40000
 262144 bytes written: OK
SMDKC100 # tftp 20008000 zImage
smc911x: initializing
smc911x: detected LAN9215 controller
smc911x: phy initialized
smc911x: MAC 00:40:5c:26:0a:5b
Using smc911x device
TFTP from server 192.168.0.5; our IP address is 192.168.0.20
Filename 'zImage'.
Load address: 0x20008000
Loading: #################################################################
         #################################################################
         ##
done
Bytes transferred = 2334796 (0x23a04c)
SMDKC100 # nand erase 80000 500000

NAND erase: device 0 offset 0x80000, size 0x500000
Erasing at 0x560000 -- 100% complete.
OK
SMDKC100 # nand write 20008000 80000 500000

NAND write: device 0 offset 0x80000, size 0x500000
 5242880 bytes written: OK

SMDKC100 # tftp 20008000 linux-ramdisk.gz
smc911x: initializing
smc911x: detected LAN9215 controller
smc911x: phy initialized
smc911x: MAC 00:40:5c:26:0a:5b
Using smc911x device
TFTP from server 192.168.0.5; our IP address is 192.168.0.20
Filename 'linux-ramdisk.gz'.
Load address: 0x20008000
Loading: #################################################################
         #################################################################
         ###################
done
Bytes transferred = 2424428 (0x24fe6c)
SMDKC100 # nand erase 400000 300000

NAND erase: device 0 offset 0x400000, size 0x300000
Erasing at 0x6e0000 -- 100% complete.
OK
SMDKC100 # nand write 20008000 400000 300000

NAND write: device 0 offset 0x400000, size 0x300000
 3145728 bytes written: OK
SMDKC100 # tftp 20008000 usr.jffs2
smc911x: initializing
smc911x: detected LAN9215 controller
smc911x: phy initialized
smc911x: MAC 00:40:5c:26:0a:5b
Using smc911x device
TFTP from server 192.168.0.5; our IP address is 192.168.0.20
Filename 'usr.jffs2'.
Load address: 0x20008000
Loading: #################################################################
         #################################################################
         #################################################################
         ######################################################
         32 MB received
         #################################################################
         #################################################################
         ###############################################
done
Bytes transferred = 44776452 (0x2ab3c04)
NAND erase: device 0 offset 0x1c00000, size 0x3000000
Skipping bad block at  0x03820000
Erasing at 0x4be0000 -- 100% complete.
SMDKC100 # nand read 20008000 80000 300000

NAND read: device 0 offset 0x80000, size 0x300000
 3145728 bytes read: OK

SMDKC100 # bootm 20008000
Boot with zImage

Starting kernel ...

Uncompressing Linux....................................................................................................................................................... done, booting the kernel.
Linux version 2.6.29 (sdkim@sdkim-desktop) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-202) ) #379 Thu Apr 5 17:41:53 KST 2012
CPU: ARMv7 Processor [412fc081] revision 1 (ARMv7), cr=10c5387f
CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine: SMDKC100
Ignoring unrecognised tag 0x41001099
Memory policy: ECC disabled, Data cache writeback
CPU S5PC100 (id 0x43100000)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S5PC100: PLL settings, A=1600000000, M=264000000, E=67500000, H=24000000
S5PC100: ARMCLK=800000000, HCLKD0=160000000, PCLKD0=80000000, HCLK=132000000, PCLK=66000000
mout_apll: source is fout_apll (1), rate is 1600000000
mout_epll: source is fout_epll (1), rate is 67500000
mout_mpll: source is mpll (1), rate is 264000000
mout_hpll: source is srclk (1), rate is 24000000
mmc_bus: source is dout_mpll (1), rate is 44000000
mmc_bus: source is dout_mpll (1), rate is 66000000
mmc_bus: source is dout_mpll (1), rate is 66000000
usb-host-bus: source is dout_mpll (1), rate is 132000000
uclk1: source is dout_mpll (1), rate is 66000000
sclk_spi: source is dout_mpll2 (1), rate is 66000000
sclk_spi: source is dout_mpll2 (1), rate is 66000000
sclk_spi: source is dout_mpll2 (1), rate is 66000000
sclk_audio: source is mout_epll (0), rate is 67500000
audio-bus: source is mout_epll (0), rate is 67500000
audio-bus: source is mout_epll (0), rate is 67500000
audio-bus: source is fout_epll (0), rate is 67500000
sclk_irda: source is dout_mpll (1), rate is 132000000
sclk_pwi: source is srclk (0), rate is 0
sclk_fimd: source is dout_mpll (1), rate is 132000000
sclk_fimc: source is dout_mpll (1), rate is 132000000
sclk_fimc: source is dout_mpll (1), rate is 132000000
sclk_fimc: source is dout_mpll (1), rate is 132000000
sclk_mixer: source is clk_27m (0), rate is 27000000
s5pc1xx: 10485760 bytes system memory reserved for fimc0 at 0x206e1000
s5pc1xx: 6291456 bytes system memory reserved for fimc1 at 0x210e1000
s5pc1xx: 6291456 bytes system memory reserved for fimc2 at 0x216e1000
s5pc1xx: 33554432 bytes system memory reserved for mfc at 0x21ce1000
s5pc1xx: 3686400 bytes system memory reserved for jpeg at 0x23ce1000
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 65024
Kernel command line: root=/dev/mtdblock2 rootfstype=cramfs init=/linuxrc console=ttySAC1,115200
PID hash table entries: 1024 (order: 10, 4096 bytes)
Console: colour dummy device 80x30
console [ttySAC1] enabled
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 256MB = 256MB total
Memory: 195840KB available (4344K code, 410K data, 160K init)
Calibrating delay loop... 797.90 BogoMIPS (lpj=1994752)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 324 bytes
S5PC1XX GPIO Driver Init
NET: Registered protocol family 16
s5pc1xx Power Management init, (c) 2009 Samsung Electronics
GPIO-103 autorequested
GPIO-93 autorequested
s3c24xx-pwm s3c24xx-pwm.0: tin at 33000000, tdiv at 33000000, tin=divclk, base 0
s3c24xx-pwm s3c24xx-pwm.1: tin at 33000000, tdiv at 33000000, tin=divclk, base 8
S5PC100: Initialising architecture
S3C PL330-DMA Controller Driver, (c) 2008-2009 Samsung Electronics
Total 24 DMA channels will be initialized.
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Bluetooth: Core ver 2.15
NET: Registered protocol family 31
Bluetooth: HCI device and connection manager initialized
Bluetooth: HCI socket layer initialized
cfg80211: Using static regulatory domain info
cfg80211: Regulatory domain: US
        (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
        (2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2700 mBm)
        (5170000 KHz - 5190000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
        (5190000 KHz - 5210000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
        (5210000 KHz - 5230000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
        (5230000 KHz - 5330000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
        (5735000 KHz - 5835000 KHz @ 40000 KHz), (600 mBi, 3000 mBm)
cfg80211: Calling CRDA for country: US
NET: Registered protocol family 2
IP route cache hash table entries: 2048 (order: 1, 8192 bytes)
TCP established hash table entries: 8192 (order: 4, 65536 bytes)
TCP bind hash table entries: 8192 (order: 5, 163840 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
TCP reno registered
NET: Registered protocol family 1
NetWinder Floating Point Emulator V0.97 (double precision)
ashmem: initialized
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
yaffs Apr  2 2012 19:01:15 Installing.
msgmni has been set to 382
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
        s3cfb_register start..
        s3cfb_probe start..
s3cfb s3cfb: [fb0] dma: 0x2fa00000, cpu: 0xff000000, size: 0x00177000
Console: switching to colour frame buffer device 100x30
s3cfb s3cfb: registered successfully
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
s5pc100-uart.0: s3c2410_serial0 at MMIO 0xec000000 (irq = 16) is a S3C6400/10
s5pc100-uart.1: s3c2410_serial1 at MMIO 0xec000400 (irq = 20) is a S3C6400/10
s5pc100-uart.2: s3c2410_serial2 at MMIO 0xec000800 (irq = 24) is a S3C6400/10
s5pc100-uart.3: s3c2410_serial3 at MMIO 0xec000c00 (irq = 28) is a S3C6400/10
brd: module loaded
eth0 (smc911x): not using net_device_ops yet
eth0: LAN9215 (rev 0) at 0x88000000 IRQ 42
eth0: Ethernet addr: 00:aa:bb:cc:dd:ee
rtl8150: v0.6.2 (2004/08/27):rtl8150 based usb-ethernet driver
usbcore: registered new interface driver rtl8150
usbcore: registered new interface driver asix
usbcore: registered new interface driver cdc_ether
usbcore: registered new interface driver net1080
usbcore: registered new interface driver cdc_subset
usbcore: registered new interface driver zaurus
Linux video capture interface: v2.00
S5PC100 MFC Driver, (c) 2009 Samsung Electronics
S3C G3D Driver, (c) 2007-2009 Samsung Electronics
s3c_g3d version : 0x1020100
G3D_RESERVED_MEM_SIZE : 32 MB
G3D_CHUNK_SIZE : 2 MB
G3D_CHUNK_NUM : 16
g3d is registered successfully!<4>Driver 'sd' needs updating - please use bus_type methods
S3C NAND Driver, (c) 2008 Samsung Electronics
S3C NAND Driver is using hardware ECC.
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Creating 4 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x000000000000-0x000000040000 : "Bootloader"
0x000000040000-0x000000400000 : "Kernel"
0x000000400000-0x000001c00000 : "Rootfs"
0x000001c00000-0x000010000000 : "UserData(Yaffs)"
usbmon: debugfs is not available
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 87, io mem 0xed400000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
        #SDKIM s3c6410_otg_drv_probe vbus on
s3c_otghcd s3c_otghcd: S3C OTGHCD
s3c_otghcd s3c_otghcd: new USB bus registered, assigned bus number 2
s3c_otghcd s3c_otghcd: irq 88, io mem 0xed200000
usb usb2: configuration #1 chosen from 1 choice
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 1 port detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
android init
mice: PS/2 mouse device common for all mice
mvC100-buttons successfully loaded
input: mvC100-buttons as /class/input/input0
S3C Touchscreen driver, (c) 2008 Samsung Electronics
S3C TouchScreen got loaded successfully : 12 bits
input: S3C TouchScreen as /class/input/input1
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2410-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c2410-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
s3c2410-i2c s3c2410-i2c.0: slave address 0x10
s3c2410-i2c s3c2410-i2c.0: bus frequency set to 375 KHz
s3c2410-i2c s3c2410-i2c.0: i2c-0: S3C I2C adapter
s3c2410-i2c s3c2410-i2c.1: slave address 0x10
s3c2410-i2c s3c2410-i2c.1: bus frequency set to 375 KHz
s3c2410-i2c s3c2410-i2c.1: i2c-1: S3C I2C adapter
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
Bluetooth: Virtual HCI driver ver 1.2
Bluetooth: HCI UART driver ver 2.2
Bluetooth: Generic Bluetooth SDIO driver ver 0.1
cpuidle: using governor ladder
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
s3c-sdhci s3c-sdhci.0: clock source 0: hsmmc (132000000 Hz)
s3c-sdhci s3c-sdhci.0: clock source 1: hsmmc (132000000 Hz)
s3c-sdhci s3c-sdhci.0: clock source 2: mmc_bus (44000000 Hz)
Registered led device: mmc0::
mmc0: SDHCI controller on samsung-hsmmc [s3c-sdhci.0] using ADMA
usbcore: registered new interface driver usbhid
usbhid: v2.6:USB HID core driver
Advanced Linux Sound Architecture Driver Version 1.0.18a.
No device for DAI WM8725 PAIFRX
No device for DAI WM8725 PAIFTX
asoc: WM8725 PAIFRX <-> s5p-i2s-v5 mapping ok
asoc: WM8725 PAIFTX <-> s5p-i2s-v5 mapping ok
wm8725_probe Registered sound card
ALSA device list:
  #0: smdk (WM8725)
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
lib80211: common routines for IEEE802.11 drivers
VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 2
s3c-fimc: fimc_configure_subdev: v4l2 subdev board registering failed
s3c-fimc: controller 0 registered successfully
s3c-fimc: fimc_configure_subdev: v4l2 subdev board registering failed
s3c-fimc: controller 1 registered successfully
s3c-fimc: controller 2 registered successfully
s3c2410-rtc s3c2410-rtc: setting system clock to 2015-01-29 16:54:58 UTC (1422550498)
List of all partitions:
1f00             256 mtdblock0 (driver?)
1f01            3840 mtdblock1 (driver?)
1f02           24576 mtdblock2 (driver?)
1f03          233472 mtdblock3 (driver?)
No filesystem could mount root, tried:  cramfs
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)




Now I am not able to install our linux anymore I get tis error whatever linux I try to install :
SCTP: Hash tables configured (established 8192 bind 16384)
VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 2
s3c2410-rtc s3c2410-rtc: setting system clock to 2015-01-30 10:37:45 UTC (1422614265)
VFS: Mounted root (jffs2 filesystem).
Freeing init memory: 512K
Warning: unable to open an initial console.
Failed to execute /linuxrc. Attempting defaults...
Kernel panic - not syncing: No init found. Try passing init= option to kernel.





So I need to be able to install our linux again.
I would like to know if somebody understand the issue (cause I don't..I was just following the tutorial) or if you know a way to erase the memoty and install our linux again or may be dumb the memory of a working panelpc and put this memory image on the not working panelpc.

Whet I think is that the filesystem is corrupted and the kernel crash at starting because of that. But I don't know how to erase filesystem.


Thanks a lot if you read me ;p
 
Solution
Bringing up an embedded not x board is not as simple as plugging in a USB and rebooting.
It seems that your uBoot is still alive, and your problem seems to be missing command-line parameter to your kernel. I would go with your question on some specific Embedded Linux forum (check LinkedIn forum)
 
As long as you have access to u-boot you can perform arbitrary in-place manipulation of any block devices that u-boot can read from or write to.

The bottom of your boot log shows that the kernel is unable to mount the rootfs located on /dev/mtdblock2 of type cramfs. Earlier on you're performing modificiations to a NAND volume located on /dev/mtdblock3. You can set the boot device using the bootargs environment variable in u-boot, just set rootfs=/dev/<blockdevice><partition>.

I can't be of much more help because your post is quite hard to follow.
 

lolhangman

Reputable
Feb 2, 2015
2
0
4,510
Thanks for your help, I tried using /dev/mtdblock3 but nothing changed.

I probably was not clear enough on my issue.

1/ install my own linux system via serial port and nand command (u-boot + kernel + rootfs)
=> worked as usually

2/ found a screen issue, so decided to install the "original" linux system (u-boot + kernel + ramdisk + rootfs)
=> got the issue "No filesystem could mount root, tried: cramfs"

3/ try to install my own linux system again
=> got the issue
Warning: unable to open an initial console.
[21474569.815000] Failed to execute /linuxrc. Attempting defaults...
[21474569.820000] Kernel panic - not syncing: No init found. Try passing init=


but I already did that (before booting) : setenv bootargs root=/dev/mtdblock3 rootfstype=jffs2 init=/linuxrc console=ttySAC1,115200


So I understand that my kernel do not find the good way to boot on my rootfs. I just don't know why.

it may be very simple but....I just don't know
 


there's no need to pass in the rootfstype kernel argument. The kernel will automatically try and identify the filesystem type by testing the filesystem drivers that it has compiled in. The same is true for init, it's looking for /sbin/init on the rootfs by default.

What you should do is create an uncompressed filesystem image of an ext2 partition (note that the kernel needs to have support for this compiled in), download that to the device via u-boot and store it in the device's memory, then overwrite one of the NAND partitions using u-boot.

`dd if=/dev/zero of=~/diskimage.img bs=1M count=128` this will create a 128MiB zeroed file

`sudo losetup /dev/loop0 ~/diskimage.img` this will mount the image as a block device, usually on /dev/loop0 but you can run losetup without arguments to find out. Note that losetup was written by an imbecile so getting it to work properly is needlessly hard and it often doesn't behave as expected

`sudo mkfs.ext2 /dev/loop0` this will create an ext2 file system on the loopback device

`mkdir ~/temp` create a temporary mount point

`sudo mount /dev/loop0 ~/temp` mount the loopback device

`mount | grep temp` to verify that the fs is mounted at that mount point

Now, extract your sysroot into that folder

`sudo umount ~/temp` unmount the filesystem

`sudo losetup -D` unmount the loopback device

Now you can load that file onto the device using u-boot's tftp subsystem and use the nand subsystem to write it to the correct partition. If the rootfs image is too big you can break it into chunks, just calculate the appropriate offset within the partition and make sure that the partition is big enough.
 
Solution