2011-06-15 10:35:09 Upgrading just kernel on NAND?
Gilles Ganault (FRANCE)
Message: 101287
Hello,
The NAND holds two partitions: /dev/mtd1 for the kernel, and /dev/mtd2 for the Ubifs root filesystem.
Apparently, uImage = vmImage + rootfs.ext2, where vmImage is the Uboot-friendly, compressed kernel.
Since /dev/mtd2 already holds the root filesystem, upgrading the kernel with uImage would waste space since it has rootfs.ext2 appended, so I tried to use vmImage instead:
1. Booted appliance with uImage
2. Formated /dev/mtd2 with rootfs.ubi.img
3. Rebooted
4. set bootargs ubi.mtd=2 root=ubi0:rootfs rw rootfstype=ubifs
5. Downloaded vmImage through tftp
6. Ran vmImage: The root filesystem seems to load OK, but uClinux complains after mounting it:
...
UBIFS: mounted UBI device 0, volume 0, name "rootfs"
UBIFS: file system size: 251596800 bytes (245700 KiB, 239 MiB, 1950 LEBs)
UBIFS: journal size: 9033728 bytes (8822 KiB, 8 MiB, 71 LEBs)
UBIFS: media format: w4/r0 (latest is w4/r0)
UBIFS: default compressor: lzo
UBIFS: reserved for root: 0 bytes (0 KiB)
VFS: Mounted root (ubifs filesystem) on device 0:10.
Freeing unused kernel memory: 104k freed
Instruction fetch CPLB miss
<5> - CPLB miss on an instruction fetch.
Deferred Exception context
CURRENT PROCESS:
COMM=init PID=1 CPU=0
TEXT = 0x02240000-0x02242994 DATA = 0x0211f994-0x0211fdcc
BSS = 0x0211fdcc-0x02260000 USER-STACK = 0x0227fed0
return address: [0x02248c60]; contents of:
0x02248c40: 5d08 0000 0712 0000 5d0c 0000 0712 0000
0x02248c50: 5d10 0000 0712 0000 0000 0000 0000 0000
0x02248c60: [e300] 0002 3127 6f06 3068 3071 307a e100
0x02248c70: 0c64 e140 0000 e101 4b0c e141 0000 e102
ADSP-BF532-0.5 400(MHz CCLK) 133(MHz SCLK) (mpu off)
Next, I tried booting with vmlinux, but Uboot won't allow this ("Bad Magic Number").
How can compile just the uClinux kernel, without rootfs.ubifs appended?
Thank you.
QuoteReplyEditDelete
2011-06-15 23:36:09 Re: Upgrading just kernel on NAND?
Sonic Zhang (CHINA)
Message: 101294
You can disable initramfs and ext2 fs support in kernel and build a new uImage.
QuoteReplyEditDelete
2011-06-16 07:02:49 Re: Upgrading just kernel on NAND?
Gilles Ganault (FRANCE)
Message: 101320
Thanks Sonic for the tip, but no go :-/
I use the following to have the kernel use the NAND for the root filesystem:
uboot> print bootargs
bootargs=ethaddr=00:09:45:56:72:9b console=ttyBF0,115200 rootfstype=ubifs ubi.mtd=2 root=ubi0:rootfs rw
uboot> tftp 0x1000000 vmImage
uboot> bootm 0x1000000
After reading this thread, I recompiled the kernel with MPU: The kernel is stuck at "VFS: Mounted root (ubifs filesystem) on device 0:10", and doesn't display any more information. I must hard-reboot the appliance.
Next, I disabled MPU, and also disabled both Initramfs and ext2 fs, but got a kernel panic:
...
List of all partitions:
1f00 8504 mtdblock0 (driver?)
No filesystem could mount root, tried: vfat msdos
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,0)
Next, I disabled Initramfs, but kept ext2:
...
VFS: Mounted root (ubifs filesystem) on device 0:10.
Freeing unused kernel memory: 96k freed
Instruction fetch CPLB miss
<5> - CPLB miss on an instruction fetch.
Deferred Exception context
Finally, I disabled ext2 and kept Initramfs: Same error as above ("Instruction fetch CPLB miss").
Has someone successfully built kernel with no attached root filesystem?
Thank you.
QuoteReplyEditDelete
2011-06-16 08:04:34 Re: Upgrading just kernel on NAND?
Gilles Ganault (FRANCE)
Message: 101322
BTW, with Initramfs and ext2 disabled, there's no uImage, that's why I use vmImage:
/usr/src/uClinux-dist-2010R1-RC5# ll images/
-rw-r--r-- 1 root root 5289984 2011-06-16 14:05 rootfs.ubifs
-rw-r--r-- 1 root root 1131241 2011-06-16 14:05 vmImage
-rwxr-xr-x 1 root root 2698290 2011-06-16 14:05 vmlinux*
QuoteReplyEditDelete
2011-06-19 13:36:56 Re: Upgrading just kernel on NAND?
Mike Frysinger (UNITED STATES)
Message: 101457
like the documentation says, the vmImage doesnt have a rootfs attached. there is no code in the dist which will ever attach a flash based fs to the kernel.
post the full crash message. also post your kernel configs (run `make bugreport` and post the tarball as an attachment).
QuoteReplyEditDelete
2011-06-20 05:01:31 Re: Upgrading just kernel on NAND?
Gilles Ganault (FRANCE)
Message: 101471
> like the documentation says, the vmImage doesnt have a rootfs attached. there is no code in the dist which will ever attach a flash based fs to the kernel.
Is the issue specifically with flash, while it's possible to compile just the kernel (without a basic root fs in ext2 attached to it, provided all the modules are statically compiled in the kernel) and have it find the root fs elsewhere (hard-drive) through the "root=" option?
Currently, vmImage is about 1MB while with the attached ext2 fs, it goes up to 3.5MB. That's why I was wondering if I could avoid attaching the 2.5 mini-root fs since a root fs is available in the NAND.
QuoteReplyEditDelete
2011-06-20 07:44:18 Re: Upgrading just kernel on NAND?
Mike Frysinger (UNITED STATES)
Message: 101474
like the documentation says, vmImage never has a rootfs attached. only uImages have rootfs's.
the crash you're seeing most likely has nothing to do with this. you'd have to post the full output and not just a snippet.
QuoteReplyEditDelete
2011-06-20 08:48:46 Re: Upgrading just kernel on NAND?
Gilles Ganault (FRANCE)
Message: 101476
I attached the log when running vmImage and using the root filesystem in the NAND
vmImage.ubifs.txt
QuoteReplyEditDelete
2011-06-20 11:00:26 Re: Upgrading just kernel on NAND?
Mike Frysinger (UNITED STATES)
Message: 101487
please tweak your config as the log hinted and post a new one:
No trace since you do not have CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE enabled
QuoteReplyEditDelete
2011-06-20 18:06:56 Re: Upgrading just kernel on NAND?
Gilles Ganault (FRANCE)
Message: 101499
I recompiled vmImage with "CONFIG_DEBUG_BFIN_NO_KERN_HW=y" and attached the log.
vmImage.ubifs.txt
QuoteReplyEditDelete
2011-06-23 10:05:30 Re: Upgrading just kernel on NAND?
James Kosin (UNITED STATES)
Message: 101612
Mike,
Here it looks like the kernel may still be trying to boot from the RAMFS?
mtd: Giving out device 3 to rootfs
James
QuoteReplyEditDelete
2011-06-23 18:27:17 Re: Upgrading just kernel on NAND?
Gilles Ganault (FRANCE)
Message: 101631
Thanks James, but the kernel always says "mtd: Giving out device 3 to rootfs", no matter which image I'm booting (uImage or vmImage), with the root filesystem in the second partition of the NAND formatted as Ubifs.
"rootfs" is the name I chose in ubi.cfg before running "ubinize".
I made sure that all modules are statically compiled in the kernel, thus not needing an attached initramfs root fs. Still crashes :-/
Has someone successfully used vmImage with a root filesystem on a flash memory?
QuoteReplyEditDelete
2011-06-24 08:19:42 Re: Upgrading just kernel on NAND?
James Kosin (UNITED STATES)
Message: 101656
Gilles,
Don't know.... I started to try but every attempt to use the rootfs.jffs2 file created in my case ended up with failure. As a result, I just have part of my file system '/home' broken off into the NAND partition and not the entire filesystem.
This way, I have a secure OS layer that shouldn't need updating and a /home area for our applications that may change. Do let me know if you find out anything, I've not been able to find good documentation anywhere on how to do it properly for the blackfin. I'm using the bf537....
James
QuoteReplyEditDelete
2011-06-24 09:51:46 Re: Upgrading just kernel on NAND?
Gilles Ganault (FRANCE)
Message: 101661
Thanks for the feedback. I use Ubifs instead of Jffs2, and would rather have the whole root fs on the NAND so as to keep as much RAM available since it only has 64MB.
I can live with a 3.5MB kernel + ext2 RAM fs, but I wanted to check if it weren't possible to strip the root fs and only use the 1MB kernel.
QuoteReplyEditDelete
2011-06-24 14:43:54 Re: Upgrading just kernel on NAND?
Mike Frysinger (UNITED STATES)
Message: 101666
that makes it look like userspace is crashing for some reason. i wonder if all the files are being loaded correctly out of the rootfs ...
then since userspace failed, you get:
Kernel panic - not syncing: Attempted to kill init!
and then the kernel panics and aborts as expected
are you able to boot up a kernel with an ext2 attached to it, then mount the ubifs from there, and then chroot into the mount and execute programs ?
QuoteReplyEditDelete
2011-06-24 14:44:36 Re: Upgrading just kernel on NAND?
Mike Frysinger (UNITED STATES)
Message: 101667
yes, what you desire should be doable. we just have to figure out why it isnt working.
QuoteReplyEditDelete
2011-06-25 07:07:06 Re: Upgrading just kernel on NAND?
Gilles Ganault (FRANCE)
Message: 101684
Yes, I can successfully boot up with uImage (ie. kernel + ext2 root fs), mount the Ubifs partition, chroot to it, and run applications from /bin:
root:~> ubiattach /dev/ubi_ctrl -m 2
root:~> mdev -s
root:~> ubinfo /dev/ubi0 -a
root:~> mount -t ubifs ubi0:rootfs /mnt
UBIFS: recovery needed
UBIFS: recovery completed
UBIFS: mounted UBI device 0, volume 0, name "rootfs"
UBIFS: file system size: 251596800 bytes (245700 KiB, 239 MiB, 1950 LEBs)
UBIFS: journal size: 9033728 bytes (8822 KiB, 8 MiB, 71 LEBs)
UBIFS: media format: w4/r0 (latest is w4/r0)
UBIFS: default compressor: lzo
UBIFS: reserved for root: 0 bytes (0 KiB)
root:~> chroot /mnt
/ # cd bin
/bin # ./version
kernel: Linux release 2.6.34.7-ADI-2010R1, build #76 Wed Jun 22 01:03:10 CEST 2011
toolchain: bfin-linux-uclibc-gcc release gcc version 4.3.5 (ADI-2010R1-RC4)
user-dist: release 2010R1, build #88 Wed Jun 15 15:17:45 CEST 2011
/bin # ./scanelf -qn strace
libgcc_s.so.1,libc.so.0 strace
If the kernel boots OK and I can mount the Ubifs partition from the second partition in the NAND, what could cause the kernel to abort?
QuoteReplyEditDelete
2011-06-29 09:06:49 Re: Upgrading just kernel on NAND?
James Kosin (UNITED STATES)
Message: 101863
Mike,
I'm sure it is related to the issues I've had, just don't know where to start. Since there isn't good documentation on what files need to be loaded where or the layout of the filesystem on the NAND.
Are there any kernel parameters that need to be passed in differently for booting from a non-ramfs filesystem? All examples are a bit vauge on this issue and not sure how to correct.
Are there any kernel modules that need to be added (or removed) to a working setup to allow the boot to work correctly when done via the external non-ramfs filesystem for root? Again, no examples have really covered this yet everyone says it works PPC seems to be light-years ahead in the examples but ... sadly don't apply many times in our case. :-(
Looking forward to a solution! ;-)
James
QuoteReplyEditDelete
2011-06-30 01:38:19 Re: Upgrading just kernel on NAND?
Mike Frysinger (UNITED STATES)
Message: 101879
booting a rootfs out of nand is no different from booting a rootfs out of any other device. the filesystem layout is the same across them all.
the linux-2.6.x/Documentation/kernel-parameters.txt file covers all command line options. really there is just the standard "root=" and "rootfstype=" you need to worry about.
in order to boot off of a device, you need to have that driver built into the kernel. modules play no role. (there is the extended initramfs possibility of using modules to load a rootfs, but that's probably way beyond what you care about).
QuoteReplyEditDelete
2011-07-01 01:41:27 Re: Upgrading just kernel on NAND?
Aaron Wu (CHINA)
Message: 101948
I just have a try on the BF548 ez-kit, looks like it's working fine.
bfin> set bootargs ubi.mtd=7 root=ubi0:ubifs1 rw rootfstype=ubifs earlyprintk=serial,uart1,57600 console=ttyBF1,57600
bfin>
bfin> bootm
## Booting kernel from Legacy Image at 01000000 ...
Image Name: -2.6.34.7-ADI-2010R1-svn9516
Created: 2011-06-23 6:12:31 UTC
Image Type: Blackfin Linux Kernel Image (gzip compressed)
Data Size: 7375133 Bytes = 7 MiB
Load Address: 00001000
Entry Point: 0033c8b4
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Starting Kernel at = 0033c8b4
Linux version 2.6.34.7-ADI-2010R1-svn9516 (root@lab-desktop) (gcc version 4.3.5 (ADI-2010R1-RC4) ) #88 Thu Jun 23 14:12:21 CST 2011
register early platform devices
bootconsole [early_shadow0] enabled
bootconsole [early_BFuart1] enabled
early printk enabled on early_BFuart1
Board Memory: 64MB
Kernel Managed Memory: 64MB
Memory map:
fixedcode = 0x00000400-0x00000490
text = 0x00001000-0x00223be0
rodata = 0x00223be0-0x002e8100
bss = 0x002e9000-0x003014dc
data = 0x003014dc-0x0032a000
stack = 0x00328000-0x0032a000
init = 0x0032a000-0x00da6000
available = 0x00da6000-0x03e00000
DMA Zone = 0x03e00000-0x04000000
Hardware Trace Active and Enabled
Boot Mode: 1
Reset caused by Software reset
Blackfin support (C) 2004-2010 Analog Devices, Inc.
Compiled for ADSP-BF548 Rev 0.2
Blackfin Linux support by blackfin.uclinux.org/
Processor Speed: 525 MHz core clock and 131 MHz System Clock
NOMPU: setting up cplb tables
Instruction Cache Enabled for CPU0
External memory: cacheable in instruction cache
L2 SRAM : uncacheable in instruction cache
Data Cache Enabled for CPU0
External memory: cacheable (write-through) in data cache
L2 SRAM : uncacheable in data cache
Built 1 zonelists in Zone order, mobility grouping off. Total pages: 15748
Kernel command line: ubi.mtd=7 root=ubi0:ubifs1 rw rootfstype=ubifs earlyprintk=serial,uart1,57600 console=ttyBF1,57600
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory available: 48944k/65536k RAM, (10736k init code, 2186k kernel code, 1050k data, 2048k dma, 572k reserved)
Hierarchical RCU implementation.
NR_IRQS:295
Configuring Blackfin Priority Driven Interrupts
Console: colour dummy device 80x25
console [ttyBF1] enabled, bootconsole disabled
console [ttyBF1] enabled, bootconsole disabled
Calibrating delay loop... 1044.48 BogoMIPS (lpj=2088960)
Mount-cache hash table entries: 512
Blackfin Scratchpad data SRAM: 4 KB
Blackfin L1 Data A SRAM: 16 KB (16 KB free)
Blackfin L1 Data B SRAM: 16 KB (16 KB free)
Blackfin L1 Instruction SRAM: 48 KB (42 KB free)
Blackfin L2 SRAM: 128 KB (128 KB free)
NET: Registered protocol family 16
Blackfin DMA Controller
ezkit_init(): registering device resources
bio: create slab <bio-0> at 0
SCSI subsystem initialized
spi spi0.2: Warning: SPI CPHA not set: Slave Select not under software control!
See Documentation/blackfin/bfin-spi-notes.txt
bfin-spi bfin-spi.0: Blackfin on-chip SPI Controller Driver, Version 1.0, regs_base@ffc00500, dma channel@4
bfin-spi bfin-spi.1: Blackfin on-chip SPI Controller Driver, Version 1.0, regs_base@ffc02300, dma channel@5
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
i2c-bfin-twi i2c-bfin-twi.0: Blackfin BF5xx on-chip I2C TWI Contoller, regs_base@ffc00700
i2c-bfin-twi i2c-bfin-twi.1: Blackfin BF5xx on-chip I2C TWI Contoller, regs_base@ffc02200
Advanced Linux Sound Architecture Driver Version 1.0.22.1.
cfg80211: Calling CRDA to update world regulatory domain
musb_hdrc: version 6.0, pio, host, debug=0
musb_hdrc musb_hdrc.0: MUSB HDRC host driver
musb_hdrc musb_hdrc.0: new USB bus registered, assigned bus number 1
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
musb_hdrc musb_hdrc.0: USB Host mode controller at ffc03c00 using PIO, IRQ 82
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
Slow work thread pool: Starting up
Slow work thread pool: Ready
msgmni has been set to 95
alg: No test for stdrng (krng)
io scheduler noop registered (default)
bf54x-lq043: FrameBuffer initializing...
dma_alloc_init: dma_page @ 0x02df5000 - 512 pages at 0x03e00000
Console: switching to colour frame buffer device 80x24
bfin-otp: initialized
bfin-uart: Blackfin serial driver
bfin-uart.1: ttyBF1 at MMIO 0xffc02000 (irq = 48) is a BFIN-UART
brd: module loaded
register bfin atapi driver
scsi0 : pata-bf54x
ata1: PATA max UDMA/66 irq 68
physmap platform flash device: 02000000 at 20000000
physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank
Intel/Sharp Extended Query Table at 0x010A
Intel/Sharp Extended Query Table at 0x010A
Intel/Sharp Extended Query Table at 0x010A
Intel/Sharp Extended Query Table at 0x010A
Intel/Sharp Extended Query Table at 0x010A
Using buffer write method
Using auto-unlock on power-up/resume
cfi_cmdset_0001: Erase suspend on write enabled
RedBoot partition parsing not available
Using physmap partition information
Creating 3 MTD partitions on "physmap-flash.0":
0x000000000000-0x000000080000 : "bootloader(nor)"
0x000000080000-0x000000480000 : "linux kernel(nor)"
0x000000480000-0x000001000000 : "file system(nor)"
m25p80 spi0.1: m25p16 (2048 Kbytes)
Creating 2 MTD partitions on "m25p80":
0x000000000000-0x000000080000 : "bootloader(spi)"
0x000000080000-0x000000200000 : "linux kernel(spi)"
BF5xx on-chip NAND FLash Controller Driver, Version 1.2 (c) 2007 Analog Devices, Inc.
bf5xx-nand bf5xx-nand.0: data_width=8, wr_dly=3, rd_dly=3
NAND device: Manufacturer ID: 0x20, Chip ID: 0xda (ST Micro NAND 256MiB 3,3V 8-bit)
Creating 3 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x000000000000-0x000000080000 : "bootloader(nand)"
0x000000080000-0x000000c80000 : "linux kernel(nand)"
0x000000c80000-0x000010000000 : "file system(nand)"
UBI: attaching mtd7 to ubi0
UBI: physical eraseblock size: 131072 bytes (128 KiB)
UBI: logical eraseblock size: 129024 bytes
UBI: smallest flash I/O unit: 2048
UBI: sub-page size: 512
UBI: VID header offset: 512 (aligned 512)
UBI: data offset: 2048
ata1.00: ATA-7: FUJITSU MHW2040AT, 0000000B, max UDMA/100
ata1.00: 78140160 sectors, multi 16: LBA
ata1.00: configured for UDMA/66
blk_queue_max_segments: set to minimum 1
scsi 0:0:0:0: Direct-Access ATA FUJITSU MHW2040A 0000 PQ: 0 ANSI: 5
sd 0:0:0:0: [sda] 78140160 512-byte logical blocks: (40.0 GB/37.2 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't
support DPO or FUA
sda: sda1
sd 0:0:0:0: [sda] Attached SCSI disk
UBI: attached mtd7 to ubi0
UBI: MTD device name: "file system(nand)"
UBI: MTD device size: 243 MiB
UBI: number of good PEBs: 1946
UBI: number of bad PEBs: 2
UBI: max. allowed volumes: 128
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 2
UBI: available PEBs: 1597
UBI: total number of reserved PEBs: 349
UBI: number of PEBs reserved for bad PEB handling: 19
UBI: max/mean erase counter: 7/1
UBI: image sequence number: 0
UBI: background thread "ubi_bgt0d" started, PID 357
smsc911x: Driver version 2008-10-21.
smsc911x-mdio: probed
eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:01, irq=-1)
net eth0: MAC Address: 00:e0:22:fe:be:df
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
input: bf54x-keys as /devices/platform/bf54x-keys/input/input0
rtc-bfin rtc-bfin: rtc core: registered rtc-bfin as rtc0
i2c /dev entries driver
bfin-wdt: initialized: timeout=20 sec (nowayout=0)
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
dma rx:0 tx:1, err irq:10, regs:ffc00800
AD1980 SoC Audio Codec
asoc: AC97 <-> bf5xx-ac97 mapping ok
ALSA device list:
#0: bf5xx-board (AD1980)
TCP cubic registered
NET: Registered protocol family 17
lib80211: common routines for IEEE802.11 drivers
rtc-bfin rtc-bfin: setting system clock to 1970-01-22 13:41:14 UTC (1863674)
Freeing unused kernel memory: 10736k freed
usb 1-1: new high speed USB device using musb_hdrc and address 2
_____________________________________
a8888b. / Welcome to the uClinux distribution \
d888888b. / _ _ \
8P"YP"Y88 / | | |_| __ __ (TM) |
8|o||o|88 _____/ | | _ ____ _ _ \ \/ / |
8' .88 \ | | | | _ \| | | | \ / |
8`._.' Y8. \ | |__ | | | | | |_| | / \ |
d/ `8b. \ \____||_|_| |_|\____|/_/\_\ |
dP . Y8b. \ For embedded processors including |
d8:' " `::88b \ the Analog Devices Blackfin /
d8" 'Y88b \___________________________________/
:8P ' :888
8a. : _a88P For further information, check out:
._/"Yaa_: .| 88P| - blackfin.uclinux.org/
\ YP" `| 8P `. - docs.blackfin.uclinux.org/
/ \.___.d| .' - www.uclinux.org/
`--..__)8888P`._.' jgs/a:f - www.analog.com/blackfin
Have a lot of fun...
BusyBox v1.16.2 (2011-05-09 15:20:10 CST) hush - the humble shell
root:/> ls
QuoteReplyEditDelete
2011-07-01 10:26:59 Re: Upgrading just kernel on NAND?
James Kosin (UNITED STATES)
Message: 101982
Thanks Mike,
I'll give it another try when I have some time.
James