• Home
  • Help
  • Search
  • Login
  • Register
Pages: 1 [2]
Author Topic: fw_printenv offsets  (Read 10320 times)
pingtoo
Sr. Member
****

Karma: 15
Posts: 318


View Profile
« Reply #15 on: March 15, 2010, 11:13:27 AM »

I think this may be a misunderstanding or wrong terminology. the fw{print,set}env using read/write system call to do its I/O and I see no evidences about skipping OOB blocks so that is why I think it is the problem.

That is why it's called "out-of-band" data: read/write system calls by themselves will skip the OOB data. If you want to read/write OOB data, you must do it thorugh the MEMREADOOB respectively MEMWRITEOOB ioctl.

Quote
Since /dev/mtd0 is block device (I think) may be we can still do my suggestion with /dev/mtdchar0?

No, you are thinking of /dev/mtdblock0. /dev/mtd0 is a character device.

Quote
do you have u-boot source from CD or download from wiki? I see there is a drivers/mtd/nand/nand_ecc_rs.c may be that is where the 4 bit calculation code is. I read the file but it is beyond my little head can understand Grin

I got it from denx's git repository.  I just downloaded the sources from Marvell, and indeed, there it is! It's an implementation of Reed-Solomon, a popular ECC, which fits the interpretation of the data. I'll be working on the filters, I'm confident that I'll have a solution available soon!
I think there should be a /dev/mtdcharX I will check once I am home.
You can try http://www.plugcomputer.org/index.php/us/resources/downloads?func=showdown&id=58 to download the source code. This is incomplete code, you need to drop this code in to uboot-1.1.4 in order to compile.
Logged

Good Luck Smiley

pingtoo
Sr. Member
****

Karma: 15
Posts: 318


View Profile
« Reply #16 on: March 15, 2010, 03:38:51 PM »

What a idiot I am Embarrassed there is no /dev/mtdcharX. the /dev/mtdX is created by mtdchar module. I assume there is /dev/mtdcharX because the is a module name mtdblock.

Anyway, I did a nanddump  -o -b -s 0xa0000 -l 0x20000 -f /tmp/uboot-env.bin /dev/mtd0 then I was able to use sheeva-installer supplied fw_{set,print}env to print and change content of uboot-env.bin so all we need now is a patched nandwrite to write the content back.
Logged

Good Luck Smiley

e-squizo
Newbie
*

Karma: 3
Posts: 22


View Profile
« Reply #17 on: March 16, 2010, 05:47:47 AM »

Good news!

The file nand_ecc_rs.c indeed contains the algorithm used to compute the 4-bit ECC in /dev/mtd0. Using that, I have written a program that takes the output of nanddump -n -s 0xa0000 -l 0x20000 /dev/mtd0 and successfully performs error correction, checksum validation and conversion to a newline-separated text file.

In the process of getting this done, however, I noticed that Marvell has been less than careful about licensing: the header in nand_ecc_rs.c first claims that the file "contains an ECC algorithm from Toshiba that detects and corrects 1 bit errors in a 256 byte block of data," then goes on to say that the file is released under GPLv2 or later. However, the first claim is patently wrong: this is certainly not 1-bit ECC, it appears to me that the comment is there simply because it was in nand_ecc.c and someone forgot to change it. The same applies to the comments at the top of the encode/decode functions: they are identical to their counterparts in nand_ecc.c, and completely fail to properly describe the functions they supposedly document.

It seems to me to have been (very lightly) adapted from code available at The ECC Page (http://www.eccpage.com/), as an illustration of a Reed-Solomon codec (http://www.eccpage.com/rs.c). The program is distributed with the following notice:

Code:
                  Notice
                 --------
   This program may be freely modified and/or given to whoever wants it.
   A condition of such distribution is that the author's contribution be
   acknowledged by his name being left in the comments heading the program,
   however no responsibility is accepted for any financial or other loss which
   may result from some unforseen errors or malfunctioning of the program
   during use.
                                 Simon Rockliff, 26th June 1991

So, as far as I can tell, Marvell is distributing this code in violation of the author's terms :-(

So, I'm off to write the textfile-to-checsummed-environment code! Stay tuned...
Logged

e-squizo
Newbie
*

Karma: 3
Posts: 22


View Profile
« Reply #18 on: March 17, 2010, 05:56:34 AM »

Status report: I am now able to go from raw data + OOB data to a plain text representation and back!

I'm cleaning up and packaging the code to release it ASAP.
Logged

e-squizo
Newbie
*

Karma: 3
Posts: 22


View Profile
« Reply #19 on: March 17, 2010, 10:14:33 PM »

Have a blast: https://code.google.com/p/sheeva-uboot-tools/.
Logged

Pages: 1 [2]
Print
Jump to: