1*4882a593SmuzhiyunSHA1 usage: 2*4882a593Smuzhiyun----------- 3*4882a593Smuzhiyun 4*4882a593SmuzhiyunIn the U-Boot Image for the pcs440ep board is a SHA1 checksum integrated. 5*4882a593SmuzhiyunThis SHA1 sum is used, to check, if the U-Boot Image in Flash is not 6*4882a593Smuzhiyuncorrupted. 7*4882a593Smuzhiyun 8*4882a593SmuzhiyunThe following command is available: 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun=> help sha1 11*4882a593Smuzhiyunsha1 address len [addr] calculate the SHA1 sum [save at addr] 12*4882a593Smuzhiyun -p calculate the SHA1 sum from the U-Boot image in flash and print 13*4882a593Smuzhiyun -c check the U-Boot image in flash 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun"sha1 -p" 16*4882a593Smuzhiyun calculates and prints the SHA1 sum, from the Image stored in Flash 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun"sha1 -c" 19*4882a593Smuzhiyun check, if the SHA1 sum from the Image stored in Flash is correct 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunIt is possible to calculate a SHA1 checksum from a memoryrange with: 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun"sha1 address len" 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunIf you want to store a new Image in Flash for the pcs440ep board, 27*4882a593Smuzhiyunwhich has no SHA1 sum, you can do the following: 28*4882a593Smuzhiyun 29*4882a593Smuzhiyuna) cp the new Image on a position in RAM (here 0x300000) 30*4882a593Smuzhiyun (for this example we use the Image from Flash, stored at 0xfffa0000 and 31*4882a593Smuzhiyun 0x60000 Bytes long) 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun"cp.b fffa0000 300000 60000" 34*4882a593Smuzhiyun 35*4882a593Smuzhiyunb) Initialize the SHA1 sum in the Image with 0x00 36*4882a593Smuzhiyun The SHA1 sum is stored in Flash at: 37*4882a593Smuzhiyun CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN + SHA1_SUM_POS 38*4882a593Smuzhiyun for the pcs440ep Flash: 0xfffa0000 + 0x60000 + -0x20 39*4882a593Smuzhiyun = 0xffffffe0 40*4882a593Smuzhiyun for the example in RAM: 0x300000 + 0x60000 + -0x20 41*4882a593Smuzhiyun = 0x35ffe0 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun note: a SHA1 checksum is 20 bytes long. 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun"mw.b 35ffe0 0 14" 46*4882a593Smuzhiyun 47*4882a593Smuzhiyunc) now calculate the SHA1 sum from the memoryrange and write 48*4882a593Smuzhiyun the calculated checksum at the right place: 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun"sha1 300000 60000 35ffe0" 51*4882a593Smuzhiyun 52*4882a593SmuzhiyunNow you have a U-Boot-Image for the pcs440ep board with the correct SHA1 sum. 53*4882a593Smuzhiyun 54*4882a593SmuzhiyunIf you do a "buildman -k pcs440ep" or a "make all" to get the U-Boot image, 55*4882a593Smuzhiyunwhich will be found in ../current/ipam390/ - the correct SHA1 sum will be 56*4882a593Smuzhiyunautomagically included in the U-Boot image. 57*4882a593Smuzhiyun 58*4882a593SmuzhiyunHeiko Schocher, 11 Jul 2007 59