Commit 96e1d75be8193ca79e4215a368bf9d7f2362450f

Authored by Heiko Schocher
1 parent 4ef218f6fd

[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 <hs@denx.de>

Showing 5 changed files with 101 additions and 14 deletions Side-by-side Diff

... ... @@ -268,7 +268,7 @@
268 268 -d $< $@
269 269  
270 270 $(obj)u-boot.sha1: $(obj)u-boot.bin
271   - ./tools/ubsha1 $(obj)u-boot.bin
  271 + $(obj)./tools/ubsha1 $(obj)u-boot.bin
272 272  
273 273 $(obj)u-boot.dis: $(obj)u-boot
274 274 $(OBJDUMP) -d $< > $@
board/pcs440ep/flash.c
... ... @@ -82,6 +82,7 @@
82 82 case FLASH_MAN_AMD: printf ("AMD "); break;
83 83 case FLASH_MAN_FUJ: printf ("FUJITSU "); break;
84 84 case FLASH_MAN_SST: printf ("SST "); break;
  85 + case FLASH_MAN_STM: printf ("ST Micro"); break;
85 86 case FLASH_MAN_EXCEL: printf ("Excel Semiconductor "); break;
86 87 case FLASH_MAN_MX: printf ("MXIC "); break;
87 88 default: printf ("Unknown Vendor "); break;
... ... @@ -118,6 +119,8 @@
118 119 break;
119 120 case FLASH_SST040: printf ("SST39LF/VF040 (4 Mbit, uniform sector size)\n");
120 121 break;
  122 + case STM_ID_M29W040B: printf ("ST Micro M29W040B (4 Mbit, uniform sector size)\n");
  123 + break;
121 124 default: printf ("Unknown Chip Type\n");
122 125 break;
123 126 }
... ... @@ -193,6 +196,9 @@
193 196 case (CFG_FLASH_WORD_SIZE)SST_MANUFACT:
194 197 info->flash_id = FLASH_MAN_SST;
195 198 break;
  199 + case (CFG_FLASH_WORD_SIZE)STM_MANUFACT:
  200 + info->flash_id = FLASH_MAN_STM;
  201 + break;
196 202 case (CFG_FLASH_WORD_SIZE)EXCEL_MANUFACT:
197 203 info->flash_id = FLASH_MAN_EXCEL;
198 204 break;
... ... @@ -225,6 +231,11 @@
225 231 info->flash_id += FLASH_AM040;
226 232 info->sector_count = 8;
227 233 info->size = 0x0080000; /* => 0.5 MB */
  234 + break;
  235 + case (CFG_FLASH_WORD_SIZE)STM_ID_M29W040B:
  236 + info->flash_id += FLASH_AM040;
  237 + info->sector_count = 8;
  238 + info->size = 0x0080000; /* => 0,5 MB */
228 239 break;
229 240  
230 241 case (CFG_FLASH_WORD_SIZE)AMD_ID_LV800T:
board/pcs440ep/pcs440ep.c
... ... @@ -85,8 +85,9 @@
85 85  
86 86 /* set all LED which are on, to state BLINKING */
87 87 for (i = 0; i < 4; i++) {
88   - if (val & 0x08) status_led_set (i, STATUS_LED_BLINKING);
89   - val = val << 1;
  88 + if (val & 0x01) status_led_set (3 - i, STATUS_LED_BLINKING);
  89 + else status_led_set (3 - i, STATUS_LED_OFF);
  90 + val = val >> 1;
90 91 }
91 92 }
92 93  
93 94  
... ... @@ -113,12 +114,14 @@
113 114 status_led_set (1, STATUS_LED_ON);
114 115 status_led_set (2, STATUS_LED_ON);
115 116 break;
  117 +#if 0
116 118 case 64:
117 119 /* starting Ethernet configuration */
118 120 status_led_set (0, STATUS_LED_OFF);
119 121 status_led_set (1, STATUS_LED_OFF);
120 122 status_led_set (2, STATUS_LED_ON);
121 123 break;
  124 +#endif
122 125 case 80:
123 126 /* loading Image */
124 127 status_led_set (0, STATUS_LED_ON);
... ... @@ -404,6 +407,9 @@
404 407 int ret;
405 408 char *cs_test;
406 409  
  410 + status_led_set (0, STATUS_LED_OFF);
  411 + status_led_set (1, STATUS_LED_OFF);
  412 + status_led_set (2, STATUS_LED_ON);
407 413 ret = pcs440ep_sha1 (1);
408 414 if (ret == 0) return;
409 415  
410 416  
411 417  
412 418  
413 419  
... ... @@ -751,28 +757,41 @@
751 757 ************************************************************************/
752 758 int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
753 759 {
754   - int rcode = 0;
  760 + int rcode = 0, i;
755 761 ulong pattern = 0;
756 762  
757   - pattern = simple_strtoul (argv[1], NULL, 10);
758   - if (pattern > 200) {
  763 + pattern = simple_strtoul (argv[1], NULL, 16);
  764 + if (pattern > 0x400) {
  765 + int val = GET_LEDS;
  766 + printf ("led: %x\n", val);
  767 + return rcode;
  768 + }
  769 + if (pattern > 0x200) {
759 770 status_led_blink ();
760 771 hang ();
761 772 return rcode;
762 773 }
763   - if (pattern > 100) {
  774 + if (pattern > 0x100) {
764 775 status_led_blink ();
765 776 return rcode;
766 777 }
767 778 pattern &= 0x0f;
768   - set_leds (pattern);
  779 + for (i = 0; i < 4; i++) {
  780 + if (pattern & 0x01) status_led_set (i, STATUS_LED_ON);
  781 + else status_led_set (i, STATUS_LED_OFF);
  782 + pattern = pattern >> 1;
  783 + }
769 784 return rcode;
770 785 }
771 786  
772 787 U_BOOT_CMD(
773 788 led, 2, 1, do_led,
774   - "led - set the led\n",
775   - NULL
  789 + "led [bitmask] - set the DIAG-LED\n",
  790 + "[bitmask] 0x01 = DIAG 1 on\n"
  791 + " 0x02 = DIAG 2 on\n"
  792 + " 0x04 = DIAG 3 on\n"
  793 + " 0x08 = DIAG 4 on\n"
  794 + " > 0x100 set the LED, who are on, to state blinking\n"
776 795 );
777 796  
778 797 #if defined(CONFIG_SHA1_CHECK_UB_IMG)
  1 +SHA1 usage:
  2 +-----------
  3 +
  4 +In the U-Boot Image for the pcs440ep board is a SHA1 checksum integrated.
  5 +This SHA1 sum is used, to check, if the U-Boot Image in Flash is not
  6 +corrupted.
  7 +
  8 +The following command is available:
  9 +
  10 +=> help sha1
  11 +sha1 address len [addr] calculate the SHA1 sum [save at addr]
  12 + -p calculate the SHA1 sum from the U-Boot image in flash and print
  13 + -c check the U-Boot image in flash
  14 +
  15 +"sha1 -p"
  16 + calculates and prints the SHA1 sum, from the Image stored in Flash
  17 +
  18 +"sha1 -c"
  19 + check, if the SHA1 sum from the Image stored in Flash is correct
  20 +
  21 +
  22 +It is possible to calculate a SHA1 checksum from a memoryrange with:
  23 +
  24 +"sha1 address len"
  25 +
  26 +If you want to store a new Image in Flash for the pcs440ep board,
  27 +which has no SHA1 sum, you can do the following:
  28 +
  29 +a) cp the new Image on a position in RAM (here 0x300000)
  30 + (for this example we use the Image from Flash, stored at 0xfffa0000 and
  31 + 0x60000 Bytes long)
  32 +
  33 +"cp.b fffa0000 300000 60000"
  34 +
  35 +b) Initialize the SHA1 sum in the Image with 0x00
  36 + The SHA1 sum is stored in Flash at:
  37 + CFG_MONITOR_BASE + CFG_MONITOR_LEN + SHA1_SUM_POS
  38 + for the pcs440ep Flash: 0xfffa0000 + 0x60000 + -0x20
  39 + = 0xffffffe0
  40 + for the example in RAM: 0x300000 + 0x60000 + -0x20
  41 + = 0x35ffe0
  42 +
  43 + note: a SHA1 checksum is 20 bytes long.
  44 +
  45 +"mw.b 35ffe0 0 14"
  46 +
  47 +c) now calculate the SHA1 sum from the memoryrange and write
  48 + the calculated checksum at the right place:
  49 +
  50 +"sha1 300000 60000 35ffe0"
  51 +
  52 +Now you have a U-Boot-Image for the pcs440ep board with the correct SHA1 sum.
  53 +
  54 +If you do a "./MAKEALL pcs440ep" or a "make all" to get the U-Boot image,
  55 +the correct SHA1 sum will be automagically included in the U-Boot image.
  56 +
  57 +Heiko Schocher, 11 Jul 2007
include/configs/pcs440ep.h
... ... @@ -197,16 +197,16 @@
197 197 #define CONFIG_STATUS_LED 1 /* Status LED enabled */
198 198 #define CONFIG_BOARD_SPECIFIC_LED 1
199 199  
200   -#define STATUS_LED_BIT 0x08 /* LED 1 is on GPIO_PPC_1 */
  200 +#define STATUS_LED_BIT 0x08 /* DIAG1 is on GPIO_PPC_1 */
201 201 #define STATUS_LED_PERIOD ((CFG_HZ / 2) / 5) /* blink at 5 Hz */
202 202 #define STATUS_LED_STATE STATUS_LED_OFF
203   -#define STATUS_LED_BIT1 0x04 /* LED 2 is on GPIO_PPC_2 */
  203 +#define STATUS_LED_BIT1 0x04 /* DIAG2 is on GPIO_PPC_2 */
204 204 #define STATUS_LED_PERIOD1 ((CFG_HZ / 2) / 5) /* blink at 5 Hz */
205 205 #define STATUS_LED_STATE1 STATUS_LED_ON
206   -#define STATUS_LED_BIT2 0x02 /* LED 3 is on GPIO_PPC_3 */
  206 +#define STATUS_LED_BIT2 0x02 /* DIAG3 is on GPIO_PPC_3 */
207 207 #define STATUS_LED_PERIOD2 ((CFG_HZ / 2) / 5) /* blink at 5 Hz */
208 208 #define STATUS_LED_STATE2 STATUS_LED_OFF
209   -#define STATUS_LED_BIT3 0x01 /* LED 4 is on GPIO_PPC_4 */
  209 +#define STATUS_LED_BIT3 0x01 /* DIAG4 is on GPIO_PPC_4 */
210 210 #define STATUS_LED_PERIOD3 ((CFG_HZ / 2) / 5) /* blink at 5 Hz */
211 211 #define STATUS_LED_STATE3 STATUS_LED_OFF
212 212