From owner-p4-projects@FreeBSD.ORG Tue May 2 22:39:07 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id EA8BA16A4E4; Tue, 2 May 2006 22:39:06 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C6BBE16A4CF for ; Tue, 2 May 2006 22:39:06 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9061A43D46 for ; Tue, 2 May 2006 22:39:06 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k42Md6X5056601 for ; Tue, 2 May 2006 22:39:06 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k42Md6pl056593 for perforce@freebsd.org; Tue, 2 May 2006 22:39:06 GMT (envelope-from imp@freebsd.org) Date: Tue, 2 May 2006 22:39:06 GMT Message-Id: <200605022239.k42Md6pl056593@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 96573 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 May 2006 22:39:07 -0000 http://perforce.freebsd.org/chv.cgi?CH=96573 Change 96573 by imp@imp_hammer on 2006/05/02 22:38:41 checkpoint FPGA burning routine. Affected files ... .. //depot/projects/arm/src/sys/boot/arm/at91/boot0spi/main.c#9 edit Differences ... ==== //depot/projects/arm/src/sys/boot/arm/at91/boot0spi/main.c#9 (text) ==== @@ -39,34 +39,40 @@ AT91C_BASE_PIOC, AT91C_PIO_PC12 }; +#define BURN_FPGA 1 int main(void) { - int len; + int len, i, j, off; char *addr = (char *)SDRAM_BASE + (1 << 20); /* Load to base + 1MB */ -#if 0 +#ifdef BURN_FPGA char *addr2 = (char *)SDRAM_BASE + (2 << 20); /* Load to base + 2MB */ char *addr3 = (char *)SDRAM_BASE + (3 << 20); /* Load to base + 2MB */ #endif SPI_InitFlash(); -#if 0 while ((len = xmodem_rx(addr)) == -1) continue; - printf("Downloaded %u bytes.\r\n", len); +#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); - SPI_WriteFlash(15 * FLASH_PAGE_SIZE, addr, len); - printf("Reading back %u bytes from flash\r\n", len); - SPI_ReadFlash(15 * FLASH_PAGE_SIZE, addr2, len); - if (p_memcmp(addr3, addr2, len) != 0) - printf("Readback failed\r\n"); - else - printf("Readback OK\r\n"); + for (i = 0; i < len; i+= FLASH_PAGE_SIZE) { + for (j = 0; j < 10; j++) { + off = i + 15 * FLASH_PAGE_SIZE; + 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) + break; + } + if (j >= 10) + printf("Bad Readback at %u\r\n", i); + } #else len = 212482; SPI_ReadFlash(15 * FLASH_PAGE_SIZE, addr, len); + printf("Downloaded %u bytes... burning FPGA...\r\n", len); fpga_init(&main_fpga); fpga_clear(&main_fpga); fpga_write_bytes(&main_fpga, addr, len);