Date: Wed, 3 May 2006 21:51:55 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 96620 for review Message-ID: <200605032151.k43Lptli076074@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=96620 Change 96620 by imp@imp_hammer on 2006/05/03 21:51:23 Add support for updating the boot flash (I), the FPGA (F) and Reset (R) commands. This should remove the need for jumpers most of the time... Affected files ... .. //depot/projects/arm/src/sys/boot/arm/at91/bootspi/env_vars.c#2 edit .. //depot/projects/arm/src/sys/boot/arm/at91/bootspi/loader_prompt.c#3 edit .. //depot/projects/arm/src/sys/boot/arm/at91/bootspi/loader_prompt.h#3 edit Differences ... ==== //depot/projects/arm/src/sys/boot/arm/at91/bootspi/env_vars.c#2 (text+ko) ==== @@ -204,5 +204,6 @@ currentOffset = 0; DumpBootCommands(); + printf("Autoboot...\r\n"); Bootloader(ReadCharFromEnvironment); } ==== //depot/projects/arm/src/sys/boot/arm/at91/bootspi/loader_prompt.c#3 (text+ko) ==== @@ -32,7 +32,7 @@ #include "loader_prompt.h" #include "env_vars.h" #include "lib.h" - +#include "spi_flash.h" /******************************* GLOBALS *************************************/ @@ -62,6 +62,9 @@ {COMMAND_TFTP, "tftp"}, {COMMAND_WRITE, "w"}, {COMMAND_XMODEM, "x"}, + {COMMAND_RESET, "R"}, + {COMMAND_REPLACE_FLASH_VIA_XMODEM, "I"}, + {COMMAND_REPLACE_FPGA_VIA_XMODEM, "F"}, {COMMAND_FINAL_FLAG, 0} }; @@ -164,6 +167,34 @@ } +static void +UpdateFlash(int offset) +{ + char *addr = (char *)SDRAM_BASE + (1 << 20); /* Load to base + 1MB */ + char *addr2 = (char *)SDRAM_BASE + (2 << 20); /* Load to base + 2MB */ + char *addr3 = (char *)SDRAM_BASE + (3 << 20); /* Load to base + 2MB */ + int len, i, j, off; + + while ((len = xmodem_rx(addr)) == -1) + continue; + printf("\r\nDownloaded %u bytes.\r\n", len); + p_memcpy(addr3, addr, (len + FLASH_PAGE_SIZE - 1) / + FLASH_PAGE_SIZE * FLASH_PAGE_SIZE); + printf("Writing %u bytes to flash at %u\r\n", len, offset); + for (i = 0; i < len; i+= FLASH_PAGE_SIZE) { + for (j = 0; j < 10; j++) { + off = i + offset * FLASH_PAGE_SIZE; + printf("%u/%u\r", off, len + offset); + SPI_WriteFlash(off, addr + i, FLASH_PAGE_SIZE); + SPI_ReadFlash(off, addr2 + i, FLASH_PAGE_SIZE); + if (p_memcmp(addr3 + i, addr2 + i, FLASH_PAGE_SIZE) == 0) + break; + } + if (j >= 10) + printf("Bad Readback at %u\r\n", i); + } +} + /* * .KB_C_FN_DEFINITION_START * void ParseCommand(char *) @@ -237,19 +268,22 @@ case COMMAND_HELP: // dump command info printf("Commands:\r\n" - "\tc\r\n" - "\td\r\n" - "\te\r\n" - "\tip\r\n" - "\tserver_ip\r\n" - "\tm\r\n" - "\ttftp\r\n" - "\ts\r\n" + "\tc\r\n" + "\td\r\n" + "\te\r\n" + "\tip\r\n" + "\tserver_ip\r\n" + "\tm\r\n" + "\ttftp\r\n" + "\ts\r\n" #ifdef SUPPORT_TAG_LIST - "\tt\r\n" + "\tt\r\n" #endif - "\tw\r\n" - "\tx\r\n"); + "\tw\r\n" + "\tx\r\n" + "\tI\r\n" + "\tR\r\n" + "\tF\r\n"); break; case COMMAND_LOCAL_IP: @@ -310,14 +344,26 @@ break; case COMMAND_XMODEM: - { // "x <address>" // download X-modem record at address if (argc > 1) xmodem_rx((char *)p_ASCIIToHex(argv[1])); break; - } + + case COMMAND_RESET: + printf("Reset\r\n"); + reset(); + while (1) continue; + break; + case COMMAND_REPLACE_FPGA_VIA_XMODEM: + printf("Updating FPGA image\r\n"); + UpdateFlash(15); + break; + case COMMAND_REPLACE_FLASH_VIA_XMODEM: + printf("Updating FLASH image\r\n"); + UpdateFlash(0); + break; default: break; } ==== //depot/projects/arm/src/sys/boot/arm/at91/bootspi/loader_prompt.h#3 (text+ko) ==== @@ -40,6 +40,9 @@ COMMAND_TFTP, COMMAND_WRITE, COMMAND_XMODEM, + COMMAND_RESET, + COMMAND_REPLACE_FLASH_VIA_XMODEM, + COMMAND_REPLACE_FPGA_VIA_XMODEM, COMMAND_FINAL_FLAG } e_cmd_t;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605032151.k43Lptli076074>