From: Heiko Schocher Date: Wed, 11 Jul 2007 16:39:11 +0000 (+0200) Subject: [PCS440EP] - Show on the DIAG LEDs, if the SHA1 check failed X-Git-Tag: v1.3.0-rc1~35^2~5 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=96e1d75be8193ca79e4215a368bf9d7f2362450f;p=u-boot [PCS440EP] - Show on the DIAG LEDs, if the SHA1 check failed - now the Flash ST M29W040B is supported (not tested) - fix the "led" command - fix compile error, if BUILD_DIR is used Signed-off-by: Heiko Schocher --- diff --git a/Makefile b/Makefile index 47e4e670ab..c45700e08d 100644 --- a/Makefile +++ b/Makefile @@ -268,7 +268,7 @@ $(obj)u-boot.img: $(obj)u-boot.bin -d $< $@ $(obj)u-boot.sha1: $(obj)u-boot.bin - ./tools/ubsha1 $(obj)u-boot.bin + $(obj)./tools/ubsha1 $(obj)u-boot.bin $(obj)u-boot.dis: $(obj)u-boot $(OBJDUMP) -d $< > $@ diff --git a/board/pcs440ep/flash.c b/board/pcs440ep/flash.c index 70014407c6..c5a62e2543 100644 --- a/board/pcs440ep/flash.c +++ b/board/pcs440ep/flash.c @@ -82,6 +82,7 @@ void flash_print_info(flash_info_t *info) case FLASH_MAN_AMD: printf ("AMD "); break; case FLASH_MAN_FUJ: printf ("FUJITSU "); break; case FLASH_MAN_SST: printf ("SST "); break; + case FLASH_MAN_STM: printf ("ST Micro"); break; case FLASH_MAN_EXCEL: printf ("Excel Semiconductor "); break; case FLASH_MAN_MX: printf ("MXIC "); break; default: printf ("Unknown Vendor "); break; @@ -118,6 +119,8 @@ void flash_print_info(flash_info_t *info) break; case FLASH_SST040: printf ("SST39LF/VF040 (4 Mbit, uniform sector size)\n"); break; + case STM_ID_M29W040B: printf ("ST Micro M29W040B (4 Mbit, uniform sector size)\n"); + break; default: printf ("Unknown Chip Type\n"); break; } @@ -193,6 +196,9 @@ static ulong flash_get_size(vu_long *addr, flash_info_t *info) case (CFG_FLASH_WORD_SIZE)SST_MANUFACT: info->flash_id = FLASH_MAN_SST; break; + case (CFG_FLASH_WORD_SIZE)STM_MANUFACT: + info->flash_id = FLASH_MAN_STM; + break; case (CFG_FLASH_WORD_SIZE)EXCEL_MANUFACT: info->flash_id = FLASH_MAN_EXCEL; break; @@ -226,6 +232,11 @@ static ulong flash_get_size(vu_long *addr, flash_info_t *info) info->sector_count = 8; info->size = 0x0080000; /* => 0.5 MB */ break; + case (CFG_FLASH_WORD_SIZE)STM_ID_M29W040B: + info->flash_id += FLASH_AM040; + info->sector_count = 8; + info->size = 0x0080000; /* => 0,5 MB */ + break; case (CFG_FLASH_WORD_SIZE)AMD_ID_LV800T: info->flash_id += FLASH_AM800T; diff --git a/board/pcs440ep/pcs440ep.c b/board/pcs440ep/pcs440ep.c index ada6b82c92..0e34a76cb9 100644 --- a/board/pcs440ep/pcs440ep.c +++ b/board/pcs440ep/pcs440ep.c @@ -85,8 +85,9 @@ static void status_led_blink (void) /* set all LED which are on, to state BLINKING */ for (i = 0; i < 4; i++) { - if (val & 0x08) status_led_set (i, STATUS_LED_BLINKING); - val = val << 1; + if (val & 0x01) status_led_set (3 - i, STATUS_LED_BLINKING); + else status_led_set (3 - i, STATUS_LED_OFF); + val = val >> 1; } } @@ -113,12 +114,14 @@ void show_boot_progress (int val) status_led_set (1, STATUS_LED_ON); status_led_set (2, STATUS_LED_ON); break; +#if 0 case 64: /* starting Ethernet configuration */ status_led_set (0, STATUS_LED_OFF); status_led_set (1, STATUS_LED_OFF); status_led_set (2, STATUS_LED_ON); break; +#endif case 80: /* loading Image */ status_led_set (0, STATUS_LED_ON); @@ -404,6 +407,9 @@ static void pcs440ep_checksha1 (void) int ret; char *cs_test; + status_led_set (0, STATUS_LED_OFF); + status_led_set (1, STATUS_LED_OFF); + status_led_set (2, STATUS_LED_ON); ret = pcs440ep_sha1 (1); if (ret == 0) return; @@ -751,28 +757,41 @@ void hw_watchdog_reset(void) ************************************************************************/ int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { - int rcode = 0; + int rcode = 0, i; ulong pattern = 0; - pattern = simple_strtoul (argv[1], NULL, 10); - if (pattern > 200) { + pattern = simple_strtoul (argv[1], NULL, 16); + if (pattern > 0x400) { + int val = GET_LEDS; + printf ("led: %x\n", val); + return rcode; + } + if (pattern > 0x200) { status_led_blink (); hang (); return rcode; } - if (pattern > 100) { + if (pattern > 0x100) { status_led_blink (); return rcode; } pattern &= 0x0f; - set_leds (pattern); + for (i = 0; i < 4; i++) { + if (pattern & 0x01) status_led_set (i, STATUS_LED_ON); + else status_led_set (i, STATUS_LED_OFF); + pattern = pattern >> 1; + } return rcode; } U_BOOT_CMD( led, 2, 1, do_led, - "led - set the led\n", - NULL + "led [bitmask] - set the DIAG-LED\n", + "[bitmask] 0x01 = DIAG 1 on\n" + " 0x02 = DIAG 2 on\n" + " 0x04 = DIAG 3 on\n" + " 0x08 = DIAG 4 on\n" + " > 0x100 set the LED, who are on, to state blinking\n" ); #if defined(CONFIG_SHA1_CHECK_UB_IMG) diff --git a/doc/README.sha1 b/doc/README.sha1 new file mode 100644 index 0000000000..92dc8fffae --- /dev/null +++ b/doc/README.sha1 @@ -0,0 +1,57 @@ +SHA1 usage: +----------- + +In the U-Boot Image for the pcs440ep board is a SHA1 checksum integrated. +This SHA1 sum is used, to check, if the U-Boot Image in Flash is not +corrupted. + +The following command is available: + +=> help sha1 +sha1 address len [addr] calculate the SHA1 sum [save at addr] + -p calculate the SHA1 sum from the U-Boot image in flash and print + -c check the U-Boot image in flash + +"sha1 -p" + calculates and prints the SHA1 sum, from the Image stored in Flash + +"sha1 -c" + check, if the SHA1 sum from the Image stored in Flash is correct + + +It is possible to calculate a SHA1 checksum from a memoryrange with: + +"sha1 address len" + +If you want to store a new Image in Flash for the pcs440ep board, +which has no SHA1 sum, you can do the following: + +a) cp the new Image on a position in RAM (here 0x300000) + (for this example we use the Image from Flash, stored at 0xfffa0000 and + 0x60000 Bytes long) + +"cp.b fffa0000 300000 60000" + +b) Initialize the SHA1 sum in the Image with 0x00 + The SHA1 sum is stored in Flash at: + CFG_MONITOR_BASE + CFG_MONITOR_LEN + SHA1_SUM_POS + for the pcs440ep Flash: 0xfffa0000 + 0x60000 + -0x20 + = 0xffffffe0 + for the example in RAM: 0x300000 + 0x60000 + -0x20 + = 0x35ffe0 + + note: a SHA1 checksum is 20 bytes long. + +"mw.b 35ffe0 0 14" + +c) now calculate the SHA1 sum from the memoryrange and write + the calculated checksum at the right place: + +"sha1 300000 60000 35ffe0" + +Now you have a U-Boot-Image for the pcs440ep board with the correct SHA1 sum. + +If you do a "./MAKEALL pcs440ep" or a "make all" to get the U-Boot image, +the correct SHA1 sum will be automagically included in the U-Boot image. + +Heiko Schocher, 11 Jul 2007 diff --git a/include/configs/pcs440ep.h b/include/configs/pcs440ep.h index 69d97d66ea..5ee97c1279 100644 --- a/include/configs/pcs440ep.h +++ b/include/configs/pcs440ep.h @@ -197,16 +197,16 @@ #define CONFIG_STATUS_LED 1 /* Status LED enabled */ #define CONFIG_BOARD_SPECIFIC_LED 1 -#define STATUS_LED_BIT 0x08 /* LED 1 is on GPIO_PPC_1 */ +#define STATUS_LED_BIT 0x08 /* DIAG1 is on GPIO_PPC_1 */ #define STATUS_LED_PERIOD ((CFG_HZ / 2) / 5) /* blink at 5 Hz */ #define STATUS_LED_STATE STATUS_LED_OFF -#define STATUS_LED_BIT1 0x04 /* LED 2 is on GPIO_PPC_2 */ +#define STATUS_LED_BIT1 0x04 /* DIAG2 is on GPIO_PPC_2 */ #define STATUS_LED_PERIOD1 ((CFG_HZ / 2) / 5) /* blink at 5 Hz */ #define STATUS_LED_STATE1 STATUS_LED_ON -#define STATUS_LED_BIT2 0x02 /* LED 3 is on GPIO_PPC_3 */ +#define STATUS_LED_BIT2 0x02 /* DIAG3 is on GPIO_PPC_3 */ #define STATUS_LED_PERIOD2 ((CFG_HZ / 2) / 5) /* blink at 5 Hz */ #define STATUS_LED_STATE2 STATUS_LED_OFF -#define STATUS_LED_BIT3 0x01 /* LED 4 is on GPIO_PPC_4 */ +#define STATUS_LED_BIT3 0x01 /* DIAG4 is on GPIO_PPC_4 */ #define STATUS_LED_PERIOD3 ((CFG_HZ / 2) / 5) /* blink at 5 Hz */ #define STATUS_LED_STATE3 STATUS_LED_OFF