Linux Development :  Bluewater Systems Support Forum
Covers issues with Linux development, such as tool chains, packages, kernel issues etc... 
Updating kernel and File System
Posted by: IGW ()
Date: September 17, 2009 05:29PM

Hi all,

I have been trying to update the file system and kernel on a Snapper 9260.

I am booting from an uImage I download from an NFS share and the file system is on the (same) NFS share.

To update/refresh the file system in flash I mounted mtdblock4 and copied everything from the NFS file system to the mount (I created the /proc folder but I did not copy the stuff within - doing so hangs the Snapper):
mount /dev/mtdblock4 /mnt
then "cp -a" everything apart from the /proc folder then manually create the /proc folder.

This seemed to go OK.

To update the kernel I followed the instructions in the FAQ and this also seemed to go OK.

However, when I try to boot from flash it is unsuccessful. Following is the terminal dump of the boot process.

I am sure I have done something wrong but I don't know what.

The yaffs boot commands (uboot) are (or should be) unchanged from the factory settings.

Thanks,
Ian
****************************
>Start Snapper 9260 Bootstrap...


U-Boot 1.1.6 (Jun 7 2009 - 20:04:47)

Processor: AT91SAM9xx Series
Processor Speed: 180.07 MHz
Peripheral Speed: 090.03 MHz
External Crystal: 18.432 MHz
USB Speed: 48.08 MHz
Core: ARM926EJS, version: 2
Internal SRAM: 8KB
RAM Configuration:
Bank #0: 20000000 64 MB
NAND: 256 MiB
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
Initing power domains...

Loading from NAND 256MiB 3,3V 8-bit, offset 0x80000
Failed to read block @0x80000 (val = -74)
** Read error

PHY Mode: Default
End of Autonegotiation
BOOTP broadcast 1
DHCP client bound to address 192.168.7.100
TFTP from server 192.168.7.1; our IP address is 192.168.7.100
Filename '/tftpboot/snapper/uImage'.
Load address: 0x23000000
Loading: *
TFTP error: 'You are not unlocked for reading' (2)
Starting again

BOOTP broadcast 1
DHCP client bound to address 192.168.7.100
TFTP from server 192.168.7.1; our IP address is 192.168.7.100
Filename '/tftpboot/snapper/uImage'.
Load address: 0x23000000
Loading: *
TFTP error: 'You are not unlocked for reading' (2)
Starting again

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: Ryan ()
Date: September 20, 2009 10:16PM

It appears that the kernel image is corrupted. The U-Boot scripts first try to boot from NAND, if a valid image is not present, it then trys to boot from the network. I'm not sure why the network boot is failing, although it looks like it may be a problem with your TFTP server.

From U-Boot can you do:
nand dump 0x80000
and post the result here.

You may need to reflash the kernel from Linux:
mtdtool --eraseall Kernel
mtdtool --write Kernel /path/to/linux-2.6.29/arch/arm/boot/uImage

~Ryan

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: IGW ()
Date: September 21, 2009 07:14AM

I thought I had tried to re-flash the kernel. I will try again and make sure though.

The nand dump gives:

Snapper> nand dump 0x80000
Page 00080000 dump:
00 00 00 00 12 90 40 09 02 00 00 00 00 00 00 00
20 00 00 00 20 00 00 00 f2 89 5e b2 05 02 02 00
00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00
00 00 20 00 00 00 00 00 00 00 20 00 00 00 00 00
00 00 20 00 00 00 00 00 00 00 20 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 30 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 0c 00 00 00 01 00 00 00
00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 02 00 00 00 01 00 00 00
00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00
0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
43 08 00 00 00 00 00 00 00 00 00 00 0c 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00
00 00 00 00 00 00 00 00 0c 00 00 00 e2 ff ff eb
00 00 a0 e3 9a 0f 07 ee 17 0f 08 ee 10 0f 11 ee
05 0a 80 e3 10 00 00 00 00 00 00 49 00 00 00 00
00 00 00 00 08 00 20 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
OOB:
ff ff 21 00 00 00 02 00
00 00 01 00 00 00 00 08
00 00 2a 5e 9d c3 01 00
00 00 fe ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff 01 28 b4 00
Snapper>
CTRL-A Z for help |115200 8N1 | NOR | Minicom 2.3 | VT102 | Online 131:09

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: Ryan ()
Date: September 21, 2009 02:34PM

Thats definitely corrupted. The first four bytes should be the uImage magic number (0x27051956), and the kernel name should start at offset 0x1f. Can you try reflashing the kernel and then see if it boots from NAND.

~Ryan

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: IGW ()
Date: September 21, 2009 05:03PM

Ryan,

Thanks. I did re-flash and here is the first few lines of the nand dump:
Snapper> nand dump 0x80000
Page 00080000 dump:
27 05 19 56 ba 90 7e 8f 4a b0 8e 52 00 16 00 98
20 00 80 00 20 00 80 00 f2 89 5e b2 05 02 02 00
4c 69 6e 75 78 2d 32 2e 36 2e 32 39 53 6f 6e 6f
6d 65 64 69 63 61 6c 62 75 69 6c 64 00 00 00 00
00 00 a0 e1 00 00 a0 e1 00 00 a0 e1 00 00 a0 e1
00 00 a0 e1 00 00 a0 e1 00 00 a0 e1 00 00 a0 e1
02 00 00 ea 18 28 6f 01 00 00 00 00 98 00 16 00

Still doesn't boot though. I reset the Snapper 9260 and just let it fall through to the FLASH boot. I get the same problem as before:

>Start Snapper 9260 Bootstrap...


U-Boot 1.1.6 (Jun 7 2009 - 20:04:47)

Processor: AT91SAM9xx Series
Processor Speed: 180.07 MHz
Peripheral Speed: 090.03 MHz
External Crystal: 18.432 MHz
USB Speed: 48.08 MHz
Core: ARM926EJS, version: 2
Internal SRAM: 8KB
RAM Configuration:
Bank #0: 20000000 64 MB
NAND: 256 MiB
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
Initing power domains...

Loading from NAND 256MiB 3,3V 8-bit, offset 0x80000
Failed to read block @0x80000 (val = -74)
** Read error


Thanks for your on-going help,
Ian

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: Ryan ()
Date: September 21, 2009 05:38PM

Can you boot to Linux via the network and do a verify on the kernel to make sure it is being written to NAND correctly:
mtdtool --verify Kernel /path/to/uImage

Also, can you try loading it manually in U-Boot:
nand read $bootaddr 0x80000 0x20000
If that works, you can dump the contents from memory and compare it to the uImage file in a hex editor:
md $bootaddr

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: IGW ()
Date: September 21, 2009 10:22PM

Ryan,

The verify is OK - Flash and the uImage match.

trying to read the flash manually in uBoot fails:
Snapper> nand read $bootaddr 0x80000 0x20000

NAND read: device 0 offset 0x80000, size 0x20000
Failed to read block @0x80000 (val = -74)
0 bytes read: ERROR

It seems reads from addresses higher than 0x70000 are failing, reads at 0x60000 and, I guess, lower are working OK:
Snapper> nand read $bootaddr 0x60000 0x20000
NAND read: device 0 offset 0x60000, size 0x20000
131072 bytes read: OK

Snapper> nand read $bootaddr 0x70000 0x20000
NAND read: device 0 offset 0x70000, size 0x20000
Failed to read block @0x70000 (val = -74)
0 bytes read: ERROR

Snapper> nand read $bootaddr 0x80000 0x20000
NAND read: device 0 offset 0x80000, size 0x20000
Failed to read block @0x80000 (val = -74)
0 bytes read: ERROR

I have used nand and mtdtool to look at the info for the device and partitions - seem OK, but I could be missing something.

Ian

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: IGW ()
Date: September 21, 2009 11:32PM

I just tried to update the kernel on another module. It now shows the same problem.

Prior to the update I was able to do a uboot nand read from 0x80000 just fine.

After doing an nfs boot and running the following commands:
mtdtool --quick_erase Kernel
mtdtool --write Kernel uImage
the uBoot nand read command fails like the other module. (My new image is in the root of the nfs-based file system - it is the same image as I am booting from for the nfs boot).

I did verify the write using mtdtool - it was OK.

After updating the image in FLASH I ran "poweroff" and then reset the module. The normal boot failed.

Clearly I am doing something wrong, but I thought I was following instructions correctly.

Ian

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: Ryan ()
Date: September 22, 2009 07:04PM

I'm not sure whats going on here. It could be an issue with mtdtool in Linux, can you try flashing the kernel from U-Boot as follows:

Load the uImage into memory via tftp:
setenv autoload n
bootp
tftp $bootaddr /tftp/path/to/uImage
You should see something like this:
TFTP from server 192.168.2.2; our IP address is 192.168.2.179
Filename '/tftpboot/home/ryan/work/linux-2.6.29/arch/arm/boot/uImage'.
Load address: 0x23000000
Loading: 1216kB: ############################################################
	 ###########################
done
Bytes transferred = 1245436 (1300fc hex)

Now erase the kernel partition:
nand erase 0x80000 0x3fffff

and then write the kernel from memory to nand, the size argument is the value returned from the tftp transfer:
nand write $bootaddr 0x80000 0x1300fc

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: Ryan ()
Date: September 22, 2009 07:05PM

Oops, missed a bit. After thats all done, you can either reboot, or do:
setenv autoload
boot

~Ryan

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: IGW ()
Date: September 22, 2009 08:10PM

I tried the uBoot-based write process, Ryan. Still doesn't work. It is now complaining about "not page aligned data". They must be huge pages!

The mtdtool I used was downloaded from your site using the ipkg-cl tool.

Thanks,
Ian

Here is the capture of the process I followed:
*****************************************

Snapper> tftp $bootaddr uImage
TFTP from server 192.168.7.51; our IP address is 192.168.7.200
Filename 'uImage'.
Load address: 0x23000000
Loading: 1408kB: ############################################################
#########################################
done
Bytes transferred = 1442008 (1600d8 hex)
Snapper> nand erase 0x80000 0x3fffff

NAND erase: device 0 offset 0x80000, size 0x3fffff
Erasing at 0x460000 -- 100% complete.
OK
Snapper> nand write $bootaddr 0x80000 0x1600d8

NAND write: device 0 offset 0x80000, size 0x1600d8
nand_write_ecc: Attempt to write not page aligned data
0 bytes written: ERROR
Snapper>

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: Ryan ()
Date: September 22, 2009 08:13PM

Just round the size up, I thought U-Boot did this automatically:
nand write $bootaddr 0x80000 0x200000
Should work.

~Ryan

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: IGW ()
Date: September 23, 2009 12:24AM

OK - looks better. It seems to be OK, booting to my new kernel from nand now.

I did make a typo and tried to erase the Preboot partition (not enough 0's) but the nand erase command seemed to fail fortunately. I may need to refresh the nand on this unit though. Something for later. In the menatime it does seem to work OK.

I do the other module now (more carefully). Thanks for your help Ryan. Any idea what may have gone wrong. It would be good to know so I don't repeat the mistake in the future. I did think I was following the instructions carefully, especially the second time round.

Thanks and bye,
Ian

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: Ryan ()
Date: September 23, 2009 02:31PM

I think our mtdtool utility has some incompatibilities with Linux 2.6.29. It was originally developed against Linux 2.6.20 and some of the interfaces have been changed. I will look into this when I have some free time.

~Ryan

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: pas ()
Date: October 01, 2009 01:28PM

I have used the mtdtool utility successfully with 2.6.29 after enabling "Software ECC" in the kernel config.

Regards,

Pete

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: pteh ()
Date: March 11, 2010 11:17PM

Hi,

I have additional questions.

1. I'm trying to write yaffs image from u-boot. Can you show me how to do it from u-boot via tftp?

2. Where can I get information about the start of memory addresses where U-boot is written, Kernel is written, Filesystem is written, etc?

3. Few of my Snapper module has the following bad blocks in file systems. How do I fix it?

<code>

yaffs: dev is 32505860 name is "mtdblock4"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.4, "mtdblock4"
yaffs: auto selecting yaffs2
block 85 is bad
block 503 is bad
2 bad blocks total

</code>


Regards,

pteh

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: andre ()
Date: March 12, 2010 03:18AM

For information regarding the start address, look at the mtd_partition structure in board-snapper9260.c in the Linux kernel.

Regarding bad blocks, there is nothing that can be done, and it is not a problem. All NAND chips are shipped from manufacture with some blocks marked factory bad. These markers often cannot be erased. A chip with < 3% bad blocks is considered acceptable, although we have never seen one come from the factory with > 1%. It is a normal side effect of using NAND flash, and these messages can safely be ignored.

Andre

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: Stephen ()
Date: March 18, 2010 11:50PM

Hi,

How do I load my filesystem into flash from u-boot?

I've set up a directory that is to be my target filesystem, with all my cross-compiled binaries there. I used Bluewater Systems mkyaffs2image to make the yaffs image.

To load my yaffs image to snapper's u-boot, I used:
tftp 0x21100000 rootfs.yaffs
nand erase 0x480000 [my rootfs partition size]
nand write 0x21100000 0x480000 [my rootfs.yaffs length]

At this point, I expect to see my filesystem in mtdblock4 from Linux, but there's nothing in mtdblock4. I booted from a ramdisk, mounted mtdblock, but don't see any file inside.

What did I do wrong and how do I correct it?

Any help is appreciated. Thanks in advance.


Stephen

Options: ReplyQuote
Re: Updating kernel and File System
Posted by: andre ()
Date: March 21, 2010 06:57PM

The YAFFS images require the OOB data to be written as well as the standard NAND data. NAND images a little bit tricky in this way. U-Boot does not include support for writing OOB images by default. The easiest method is to use the SAMBA tool, which supports raw images using the "nand_write_raw_file" command. Alternatively you can use the mtdtool program from within Linux, using the mtdtool --write_raw option.

Regards,
Andre

Options: ReplyQuote


Your Name: 
Your Email: 
Subject: 
Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
This is a moderated forum. Your message will remain hidden until it has been approved by a moderator or administrator
This forum powered by Phorum.

Applications

rs1

rs_2

rs_3

rs_4