Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 May 2006 19:39:54 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 96610 for review
Message-ID:  <200605031939.k43Jds8q095702@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=96610

Change 96610 by imp@imp_hammer on 2006/05/03 19:39:25

	round the size to burn/compare to be a full flash page.

Affected files ...

.. //depot/projects/arm/src/sys/boot/arm/at91/boot0spi/main.c#10 edit

Differences ...

==== //depot/projects/arm/src/sys/boot/arm/at91/boot0spi/main.c#10 (text) ====

@@ -41,6 +41,9 @@
 
 #define BURN_FPGA 1
 
+//#define OFFSET (15 * FLASH_PAGE_SIZE)
+#define OFFSET 0
+
 int
 main(void)
 {
@@ -52,18 +55,19 @@
 #endif
 
 	SPI_InitFlash();
+	printf("Waiting for data\r\n");
 	while ((len = xmodem_rx(addr)) == -1)
 		continue;
 #ifdef BURN_FPGA
 	printf("\r\nDownloaded %u bytes.\r\n", len);
-	p_memcpy(addr3, addr, len);
-	printf("Writing %u bytes to flash\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 + 15 * FLASH_PAGE_SIZE;
+			off = i + OFFSET;
 			SPI_WriteFlash(off, addr + i, FLASH_PAGE_SIZE);
 			SPI_ReadFlash(off, addr2 + i, FLASH_PAGE_SIZE);
-			if (p_memcmp(addr3 + off, addr2 + off, FLASH_PAGE_SIZE) == 0)
+			if (p_memcmp(addr3 + i, addr2 + i, FLASH_PAGE_SIZE) == 0)
 				break;
 		}
 		if (j >= 10)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605031939.k43Jds8q095702>