Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Jul 2012 04:55:42 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r238188 - head/sys/boot/arm/at91/boot0spi
Message-ID:  <201207070455.q674tgl8014122@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Sat Jul  7 04:55:42 2012
New Revision: 238188
URL: http://svn.freebsd.org/changeset/base/238188

Log:
  Generalize this for loading the loader into the SPI. Plus trim about
  100 bytes from the binary with silly tricks.  Hope to get this small
  enough to run on the models that have 4k SRAM.  We are close compiled
  for the at91rm9200, but still need to trim for the target.

Modified:
  head/sys/boot/arm/at91/boot0spi/main.c

Modified: head/sys/boot/arm/at91/boot0spi/main.c
==============================================================================
--- head/sys/boot/arm/at91/boot0spi/main.c	Sat Jul  7 04:51:59 2012	(r238187)
+++ head/sys/boot/arm/at91/boot0spi/main.c	Sat Jul  7 04:55:42 2012	(r238188)
@@ -29,31 +29,26 @@
 #include "at91rm9200_lowlevel.h"
 #include "spi_flash.h"
 
-#define LOADER_OFFSET 0
-#define FPGA_OFFSET  (15 * FLASH_PAGE_SIZE)
-#define OFFSET FPGA_OFFSET
+#define OFFSET 0
 
-int
+void
 main(void)
 {
 	int len, i, j, off, sec;
 	char *addr = (char *)SDRAM_BASE + (1 << 20); /* download at + 1MB */
 	char *addr2 = (char *)SDRAM_BASE + (2 << 20); /* readback to + 2MB */
-	char *addr3 = (char *)SDRAM_BASE + (3 << 20); /* extra copy at + 3MB */
 
 	SPI_InitFlash();
 	printf("Waiting for data\n");
 	while ((len = xmodem_rx(addr)) == -1)
 		continue;
-	// Need extra copy at addr3
-	memcpy(addr3, addr, (len + FLASH_PAGE_SIZE - 1) / FLASH_PAGE_SIZE * FLASH_PAGE_SIZE);
-	printf("Writing %u bytes to flash at %u\n", len, OFFSET);
+	printf("Writing %u bytes at %u\n", len, OFFSET);
 	for (i = 0; i < len; i+= FLASH_PAGE_SIZE) {
+		off = i + OFFSET;
 		for (j = 0; j < 10; j++) {
-			off = i + 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)
+			if (p_memcmp(addr + i, addr2 + i, FLASH_PAGE_SIZE) == 0)
 				break;
 		}
 		if (j >= 10)
@@ -64,5 +59,4 @@ main(void)
 	    continue;
 	printf("Done\n");
 	reset();
-	return (1);
 }



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