[U-Boot-Users] Assigning crc32 result to a variable

Wolfgang Denk wd at denx.de
Mon May 22 22:23:28 CEST 2006


In message <200605222141.08815.antonio.dibacco at aruba.it> you wrote:
> But I would like to use the result of crc32 in a hush script!!!

Yes, so do it. where exactly is the problem?

> > > Is it possible to assign the result from crc32 to a variable in u-boot?
> >
> > No, but you can store it in  a  memory  location,  where  it  can  be
> > tested/processed as well.

Example:

Find location of a good U-boot image in memory:

	=> imls
	Image at 40040000:
	   Image Name:   Linux-2.4.25
	   Created:      2005-11-18   0:30:24 UTC
	   Image Type:   PowerPC Linux Kernel Image (gzip compressed)
	   Data Size:    731546 Bytes = 714.4 kB
	   Load Address: 00000000
	   Entry Point:  00000000
	   Verifying Checksum ... OK

Dump header information:

	=> md 40040000 10
	40040000: 27051956 c47eeeff 437d20a0 000b299a    '..V.~..C} ...).
	40040010: 00000000 00000000 776ed878 05070201    ........wn.x....
	40040020: 4c696e75 782d322e 342e3235 00000000    Linux-2.4.25....
	40040030: 00000000 00000000 00000000 00000000    ................

So we know that 0x000b299a (at offset 0x0C) is the data  length,  and
0x776ed878  (at  offset  0x18)  is  the  data  CRC;  the  data starts
immediately after the header, i. e. at 0x40040040.

Clear memory word at address 0x0000 and verify:

	=> mw 0 0 1
	=> md 0 1
	00000000: 00000000    ....

Test if the value stored at address 0x0000 is the correct image checksum:

	=> if itest *0 == 776ed878 ; then echo CRC ok ; else echo CRC bad ; fi
	CRC bad

It ain't - as expected.

Calculate image checksum and store at address 0:

	=> crc32 40040040 000b299a 0
	CRC32 for 40040040 ... 400f29d9 ==> 776ed878

Verify manually:

	=> md 0 1
	00000000: 776ed878    wn.x

Verify using hush shell commands:

	=> if itest *0 == 776ed878 ; then echo CRC ok ; else echo CRC bad ; fi
	CRC ok


Next question, please.

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Text processing has made it possible to right-justify any idea, even
one which cannot be justified on any other grounds."
                                                 -- J. Finnegan, USC.




More information about the U-Boot mailing list