2011-08-05 16:24:30 having problems writing kernel to NAND flash
David Anderson (UNITED STATES)
Message: 102843
I'm trying to write a kernel image to NAND flash and I am running into a few problems. In uboot I have no problem erasing the NAND flash and then writing the kernel image to it then reading it and then having linux boot from the NAND flash. However, I would like to be able to do the same thing after booting into linux.
I've tried a few different ways of doing this, including the cp, dd, and nandwrite commands. When I erase the NAND flash and use the cp command like so:
cp uImage /dev/mtd0
I get the following error:
nand_do_write_ops: Attempt to write not page aligned data
cp: write error: Invalid Argument
I've also tried the dd command which doesn't give me an error, but it doesn't seem to do what I need it to do:
dd if=mnt/tftpboot/uImage of=dev/mtdblock0
7659+1 records in
7659+1 records out
And the last thing I've tried was the nandwrite command which I thought would definitely work, but I get an error similar to when I use the cp command:
nandwrite /dev/mtd0 uImage
Unknown flash (not normal NAND)
I've looked through the source code for the nandwrite command and it seems like this error again has something to do with the not page aligned data, but I can not figure out how to fix this issue. I've searched all over for a solution and have found some old threads with people who have tried to do the same thing, but none of the solutions have helped thus far. Does anyone have any idea what the problem could be and how to fix it.
Thanks,
Dave
QuoteReplyEditDelete
2011-08-07 22:29:07 Re: having problems writing kernel to NAND flash
Aaron Wu (CHINA)
Message: 102849
You need to check your MTD partition definition in the board file to make sure your NAND is really mapped to /dev/mtdblock0.
QuoteReplyEditDelete
2011-08-07 23:24:08 Re: having problems writing kernel to NAND flash
Sonic Zhang (CHINA)
Message: 102850
please paste your kernel boot up mtd messages here.
QuoteReplyEditDelete
2011-08-07 23:27:02 Re: having problems writing kernel to NAND flash
Sonic Zhang (CHINA)
Message: 102851
Which hardware board and uClinux-dist release do you use?
How do you connect the NAND to your board?
QuoteReplyEditDelete
2011-08-08 13:45:55 Re: having problems writing kernel to NAND flash
David Anderson (UNITED STATES)
Message: 102855
I'm using a custom board with a custom uClinux-dist. Another thing worth mentioning is that the nandtest command works fine, so I'm a little confused as to why that would work, but the nandwrite would not.
Here is the U-boot and kernel startup:
U-Boot 2011.06 (ADI-2011R1-pre) (Aug 01 2011 - 11:13:46)
CPU: ADSP bf537-0.3 (Detected Rev: 0.3) (spi flash boot)
Board: **** BF537 **** board
Clock: VCO: 524.288 MHz, Core: 524.288 MHz, System: 131.072 MHz
RAM: 64 MiB
NAND: ONFI flash detected
ONFI param page 0 valid
nand_get_flash_type: unknown NAND device: Manufacturer ID: 0xf8, Chip ID: 0xf8
No NAND device found!!!
2048 MiB
SF: Detected SST25VF064C with page size 4 KiB, total 8 MiB
In: serial
Out: serial
Err: serial
KGDB: [on serial] ready
Net: Switch 88E6060 rev 2.
bfin_mac
Hit any key to stop autoboot: 0
Loading from NAND 2GiB, offset 0x0
NAND read from offset 0 failed -74
** Read error
Wrong Image Format for bootm command
ERROR: can't get kernel image!
bfin> run ramboot
Using bfin_mac device
TFTP from server 10.1.1.17; our IP address is 10.1.7.1
Filename 'uImage’.
Load address: 0x1000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
########
done
Bytes transferred = 3929685 (3bf655 hex)
## Booting kernel from Legacy Image at 01000000 ...
Image Name: bf537-2.6.34.7-ADI-2010R1-svn203
Created: 2011-08-04 20:19:30 UTC
Image Type: Blackfin Linux Kernel Image (gzip compressed)
Data Size: 3929621 Bytes = 3.7 MiB
Load Address: 00001000
Entry Point: 002435b4
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Starting Kernel at = 002435b4
Linux version 2.6.34.7-ADI-2010R1-svn203 (root@buffalo) (gcc version 4.3.5 (ADI-2010R1-RC4) ) #6 PREEMPT Thu Aug 4 16:11
register early platform devices
bootconsole [early_shadow0] enabled
bootconsole [early_BFuart0] enabled
early printk enabled on early_BFuart0
Board Memory: 64MB
Kernel Managed Memory: 64MB
Memory map:
fixedcode = 0x00000400-0x00000490
text = 0x00001000-0x00192fd8
rodata = 0x00192fd8-0x0020d720
bss = 0x0020e000-0x00221be0
data = 0x00221be0-0x00238000
stack = 0x00236000-0x00238000
init = 0x00238000-0x00730000
available = 0x00730000-0x03e00000
DMA Zone = 0x03e00000-0x04000000
Hardware Trace Active and Enabled
Boot Mode: 3
Reset caused by Software reset
Blackfin support (C) 2004-2010 Analog Devices, Inc.
Compiled for ADSP-BF537 Rev 0.3
Blackfin Linux support by blackfin.uclinux.org/
Processor Speed: 524 MHz core clock and 131 MHz System Clock
NOMPU: setting up cplb tables
Instruction Cache Enabled for CPU0
External memory: cacheable in instruction cache
Data Cache Enabled for CPU0
External memory: cacheable (write-back) in data cache
Built 1 zonelists in Zone order, mobility grouping off. Total pages: 15748
Kernel command line: root=/dev/mtdblock0 rw clkin_hz=16384000 earlyprintk=serial,uart0,57600 console=ttyBF0,57600 ip=10f
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: 55560k/65536k RAM, (5088k init code, 1607k kernel code, 661k data, 2048k dma, 572k reserved)
Hierarchical RCU implementation.
NR_IRQS:138
Configuring Blackfin Priority Driven Interrupts
console [ttyBF0] enabled, bootconsole disabled
console [ttyBF0] enabled, bootconsole disabled
Calibrating delay loop... 1044.48 BogoMIPS (lpj=2088960)
Security Framework initialized
Mount-cache hash table entries: 512
Blackfin Scratchpad data SRAM: 4 KB
Blackfin L1 Data A SRAM: 16 KB (15 KB free)
Blackfin L1 Data B SRAM: 16 KB (16 KB free)
Blackfin L1 Instruction SRAM: 48 KB (33 KB free)
NET: Registered protocol family 16
Blackfin DMA Controller
stamp_init(): registering device resources
bio: create slab <bio-0> at 0
bfin-spi bfin-spi.0: Blackfin on-chip SPI Controller Driver, Version 1.0, regs_base@ffc00500, dma channel@7
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@ffc01400
Advanced Linux Sound Architecture Driver Version 1.0.22.1.
Switching to clocksource bfin_cs_cycles
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
msgmni has been set to 108
io scheduler noop registered
io scheduler cfq registered (default)
mtty_init
dma_alloc_init: dma_page @ 0x0269a000 - 512 pages at 0x03e00000
mtty_serial.tx_circ_buf: ptr=0x3e00000,len=0x14000,wridx=0x0,rdidx=0x0,isfull=0x0
mtty_serial.rx_circ_buf: ptr=0x3e14010,len=0x14000,wridx=0x0,rdidx=0x0,isfull=0x0
bfin-uart: Blackfin serial driver
bfin-uart.0: ttyBF0 at MMIO 0xffc00400 (irq = 18) is a BFIN-UART
brd: module loaded
ONFI flash detected
ONFI param page 0 valid
NAND device: Manufacturer ID: 0x2c, Chip ID: 0x48 (Micron MT29F16G08ABACAWP)
Scanning device for bad blocks
Bad eraseblock 90 at 0x000002d00000
Bad eraseblock 91 at 0x000002d80000
RedBoot partition parsing not available
Creating 2 MTD partitions on "gen_nand":
0x000000000000-0x000000400000 : "linux kernel(nand)"
0x000000400000-0x000080000000 : "file system(nand)"
PPP generic driver version 2.4.2
bfin_mii_bus: probed
bfin_mac: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:04, irq=-1, mdc_clk=2500000Hz(mdc_div=25)@sclk=131MHz)
bfin_mac bfin_mac.0: Blackfin on-chip Ethernet MAC driver, Version 1.1
usbcore: registered new interface driver libusual
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
i2c /dev entries driver
bfin-wdt: initialized: timeout=20 sec (nowayout=1)
##### audio_init invoked ########
Audio interface
Initializing aud_dev instance=0, aud_dev=0xff800000
bfin-spiaudio: bf5xx_spiaudio_init
soc_spiaudio_probe invoked !!!
bfin-spiaudio: bf5xx_probe
dma rx:5 tx:6, err irq:46, regs:ffc00900
spiaudio: Legerity FXS Codec 0.0
spiaudio_spi_probe invoked
spiaudio_init invoked
bfin-spiaudio: bf5xx_spiaudio_init_dev
register_codec_device -- invoked codec_handle=0x205d080, num=0 ,codec_id=13
register_sport_device -- invoked sport_dev=0x26ad0e0, num=0
starting SPORT PCLK for SPORT=0
start_sport_pclk() - sclk: 00000083
leaving bf5xx_spiaudio_init_dev
ALSA device list:
No soundcards found.
TCP cubic registered
NET: Registered protocol family 17
IP-Config: Gateway not on directly connected network.
Freeing unused kernel memory: 5088k freed
_____________________________________
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-08-03 18:17:16 EDT) hush - the humble shell
root:/> cat /proc/m
/proc/maps /proc/misc /proc/mounts
/proc/meminfo /proc/modules /proc/mtd
root:/> cat /proc/mtd
dev: size erasesize name
mtd0: 00400000 00080000 "linux kernel(nand)"
mtd1: 7fc00000 00080000 "file system(nand)"
root:/>
And here are the nandtest results:
root:/> nandtest -p 10 /dev/mtd0
ECC corrections: 0
ECC failures : 0
Bad blocks : 0
BBT blocks : 0
00380000: checking...
Finished pass 1 successfully
00380000: checking...
Finished pass 2 successfully
00380000: checking...
Finished pass 3 successfully
00380000: checking...
Finished pass 4 successfully
00380000: checking...
Finished pass 5 successfully
00380000: checking...
Finished pass 6 successfully
00380000: checking...
Finished pass 7 successfully
00380000: checking...
Finished pass 8 successfully
00380000: checking...
Finished pass 9 successfully
00380000: checking...
Finished pass 10 successfully
root:/>
Thanks for the help,
Dave
QuoteReplyEditDelete
2011-08-08 22:29:39 Re: having problems writing kernel to NAND flash
Aaron Wu (CHINA)
Message: 102858
Then I think you should check the options for you mtdtools, like add a -p for your nandwrite for page alignment.
QuoteReplyEditDelete
2011-08-09 05:08:13 Re: having problems writing kernel to NAND flash
Gilles Ganault (FRANCE)
Message: 102861
Dave > I've looked through the source code for the nandwrite command and it seems like this error again has something to do with the not page aligned data, but I can not figure out how to fix this issue.
I don't have the technical knowledge to tell if your problem is due to this, but a uClinux-dist-based project uses an application ("zeropad") to massage the image before flashing the NAND with it. Here's the thread that I started to inquire about that application.
QuoteReplyEditDelete
2011-08-09 08:58:02 Re: having problems writing kernel to NAND flash
David Anderson (UNITED STATES)
Message: 102867
Where might I find this zeropad application? Is that something that is usually included in the uClinux-dist? I'll play around with it some more today and see how it goes.
Thanks,
Dave
QuoteReplyEditDelete
2011-08-09 23:10:42 Re: having problems writing kernel to NAND flash
Aaron Wu (CHINA)
Message: 102871
First, when you use mtd tools like nandwrite, have you tried my suggestion to add a -p option for page alignment? Second, dd a uImage to the NAND device does not make any sense in real application, of course if it's only for raw data read/write test it's OK, suggest you to build a Flash file system like jffs2 or UBIFS on your NAND MTD device. Please search keyword "jffs2" or "UBIFS" in our document wiki for details.
QuoteReplyEditDelete
2011-08-10 10:37:44 Re: having problems writing kernel to NAND flash
David Anderson (UNITED STATES)
Message: 102883
I have tried the -p option like you suggested and I still get the same error [Unknown flash (not normal nand)]. One thing I was wondering about is that when I looked at the source code for the nandwrite command, that error seems to be caused by checking to see if the device is page aligned. Is it possible that the command just can't work with the NAND as is?? I'm fairly new to this stuff so I'm not really sure if that is even a valid concern.
I will look into the jffs2 stuff to see if I can get something like that working. Thanks for your help.
-Dave
QuoteReplyEditDelete
2011-08-10 10:47:41 Re: having problems writing kernel to NAND flash
David Anderson (UNITED STATES)
Message: 102884
Is there a reason you recommended jffs2 or UBIFS over yaffs or is it just personal preference? When I was looking into the jffs2 stuff, some of the articles I came across mention yaffs as being better than jffs2 at the moment. Is there any reason I would not want to use yaffs in this particular situation??
Thanks again,
Dave
QuoteReplyEditDelete
2011-08-10 23:06:25 Re: having problems writing kernel to NAND flash
Aaron Wu (CHINA)
Message: 102889
Yaffs is no longer support by blackfin uclinux distribution, you can choose either jffs2 or UBIFS. For official support and feature list of this two you may consult: www.linux-mtd.infradead.org/doc/general.html
QuoteReplyEditDelete
2011-08-15 11:09:17 Re: having problems writing kernel to NAND flash
David Anderson (UNITED STATES)
Message: 102933
I've looked into using jffs2 and it seemed like that is exactly what I would like to use, but after I configure the kernel to use it I get an error when I try to make the kernel image. The error I get is:
error: lzo/lzo1x.h: No such file or directory
I've talked to a couple people about this error and the only thing I could get was that it has something to do with compression. I've tried using all different kinds of compression from the advanced compression options and I still get the same error. Does anyone no and other kind of solution to this problem or what might be causing it?
Thanks,
David Anderson
QuoteReplyEditDelete
2011-08-15 23:18:09 Re: having problems writing kernel to NAND flash
Aaron Wu (CHINA)
Message: 102935
Could you sart a new help thread for your compile issue? Also please post your whole log error here.
QuoteReplyEditDelete
2011-08-16 15:02:57 Re: having problems writing kernel to NAND flash
James Kosin (UNITED STATES)
Message: 102947
David,
What kind of NAND flash are you using? I've experienced this error with the nandwrite utility also; but, patched my version to support the OOB mapping for my NAND.
In my case, we are using the Micron NAND flash and it is reporting different size for the OOB area and the nandwrite utility is compiled to abort with this error if not one of the standard sizes it recognizes.
at about line 291 (in nandwrite.c), there is a large if() statement that determines the valid configurations.
/* Make sure device page sizes are valid */
if (!(meminfo.oobsize == 16 && meminfo.writesize == 512) &&
!(meminfo.oobsize == 8 && meminfo.writesize == 256) &&
!(meminfo.oobsize == 64 && meminfo.writesize == 2048) &&
!(meminfo.oobsize == 128 && meminfo.writesize == 4096) &&
!(meminfo.oobsize == 218 && meminfo.writesize == 4096) &&
!(meminfo.oobsize == 224 && meminfo.writesize == 4096))
{
fprintf(stderr, "Unknown flash (not normal NAND)\n");
close(fd);
exit (EXIT_FAILURE);
}
I added the last two tests just for my NAND flash I'm using. You may have to do something similar.
James
QuoteReplyEditDelete
2011-08-16 17:51:20 Re: having problems writing kernel to NAND flash
David Anderson (UNITED STATES)
Message: 102950
That looks like it could solve my problem. I will have to try it out probably tomorrow to see what happens. And if that doesn't work I will start a new thread about my jffs2 problem.
Thanks guys,
David Anderson
QuoteReplyEditDelete
2011-08-18 13:11:26 Re: having problems writing kernel to NAND flash
James Kosin (UNITED STATES)
Message: 103004
David,
This error is due to the compiler dependancies that you haven't satisfied yet.
docs.blackfin.uclinux.org/doku.php?id=installing_linux
This should fix the compiler issues, note: you may have to update some package names or remove some from the list. Debian has depracated and renamed some since the Wiki was last updated.
James
QuoteReplyEditDelete
2011-09-06 05:23:20 Re: having problems writing kernel to NAND flash
wuwei li (AFGHANISTAN)
Message: 103307
Hi:
Are you solved that problem ?
I have got the same problem now ,
as:
Open the mtd_device in nandwrite
get the device info!
mtd info:
eze:1048576
oob_size: 0
flags: 5
type: 3
eraser size : 131072
oobblock: 0
Unknown flash (not normal NAND).
The type of the flash is error I think, because the NAND_FLASH_TYPE is 4.
I don't konw where error.
that progress was part of mtd-utils .
Thank you!
wu
QuoteReplyEditDelete