?? patch-u-boot-at91rm9200-dataflash.dat
字號:
diff -purN u-boot-1.0.0.orig/CHANGELOG u-boot-1.0.0.test/CHANGELOG--- u-boot-1.0.0.orig/CHANGELOG Thu Oct 30 22:49:38 2003+++ u-boot-1.0.0.test/CHANGELOG Fri Nov 7 20:35:54 2003@@ -2,6 +2,11 @@ Changes for U-Boot 1.0.0: ====================================================================== +* Patch by Nicolas Lacressonniere, 12 Nov 2003:+ Modifications for Atmel AT91RM9200DK ARM920T based development kit+ - Add Atmel DataFlash AT45DB1282 support+ - Add the possibility to set the environment variables in DataFlash+ * Fix parameter passing to standalone images with bootm command * Patch by Kyle Harris, 30 Oct 2003:diff -purN u-boot-1.0.0.orig/README u-boot-1.0.0.test/README--- u-boot-1.0.0.orig/README Mon Oct 20 01:22:11 2003+++ u-boot-1.0.0.test/README Fri Nov 7 20:24:42 2003@@ -1742,6 +1742,20 @@ to save the current settings. The size in bytes of the EEPROM device. +- CFG_ENV_IS_IN_DATAFLASH:++ Define this if you have a DataFlash memory device which you + want to use for the environment.++ - CFG_ENV_OFFSET:+ - CFG_ENV_ADDR:+ - CFG_ENV_SIZE:++ These three #defines specify the offset and size of the+ environment area within the total memory of your DataFlash placed+ at the specified address.++ - CFG_SPI_INIT_OFFSET Defines offset to the initial SPI buffer area in DPRAM. Thediff -purN u-boot-1.0.0.orig/common/Makefile u-boot-1.0.0.test/common/Makefile--- u-boot-1.0.0.orig/common/Makefile Thu Oct 9 22:09:04 2003+++ u-boot-1.0.0.test/common/Makefile Fri Nov 7 15:46:59 2003@@ -42,7 +42,7 @@ COBJS = main.o ACEX1K.o altera.o bedbug. cmd_reginfo.o cmd_scsi.o cmd_spi.o cmd_usb.o cmd_vfd.o \ command.o console.o devices.o dlmalloc.o docecc.o \ environment.o env_common.o \- env_flash.o env_eeprom.o env_nvram.o env_nowhere.o exports.o \+ env_flash.o env_dataflash.o env_eeprom.o env_nvram.o env_nowhere.o exports.o \ flash.o fpga.o \ hush.o kgdb.o lists.o lynxkdi.o miiphybb.o miiphyutil.o \ s_record.o soft_i2c.o soft_spi.o spartan2.o \diff -purN u-boot-1.0.0.orig/common/cmd_flash.c u-boot-1.0.0.test/common/cmd_flash.c--- u-boot-1.0.0.orig/common/cmd_flash.c Tue Oct 14 21:43:56 2003+++ u-boot-1.0.0.test/common/cmd_flash.c Fri Nov 7 16:31:36 2003@@ -307,7 +307,9 @@ int do_protect (cmd_tbl_t *cmdtp, int fl ulong bank, addr_first, addr_last; int i, p, n, sect_first, sect_last; int rcode = 0;-+#ifdef CONFIG_HAS_DATAFLASH+ int status;+#endif if (argc < 3) { printf ("Usage:\n%s\n", cmdtp->usage); return 1;@@ -322,7 +324,28 @@ int do_protect (cmd_tbl_t *cmdtp, int fl return 1; } +#ifdef CONFIG_HAS_DATAFLASH+ if ( (strcmp(argv[2], "all") != 0) && (strcmp(argv[2], "bank") != 0) ){++ addr_first = simple_strtoul(argv[2], NULL, 16);+ addr_last = simple_strtoul(argv[3], NULL, 16);++ if (addr_dataflash(addr_first) && addr_dataflash(addr_last) ){++ status = dataflash_real_protect(p,addr_first,addr_last);+ if (status < 0){+ printf("Bad DataFlash sector specification\n");+ return 1;+ }+ printf("%sProtect %d DataFlash Sectors\n",+ p ? "" : "Un-", status);+ return 0;+ }+ }+#endif+ if (strcmp(argv[2], "all") == 0) {+ for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) { info = &flash_info[bank-1]; if (info->flash_id == FLASH_UNKNOWN) {diff -purN u-boot-1.0.0.orig/common/cmd_mem.c u-boot-1.0.0.test/common/cmd_mem.c--- u-boot-1.0.0.orig/common/cmd_mem.c Thu Sep 18 11:21:35 2003+++ u-boot-1.0.0.test/common/cmd_mem.c Fri Nov 7 19:18:14 2003@@ -136,13 +136,19 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int fl uint *uip = (uint *)linebuf; ushort *usp = (ushort *)linebuf; u_char *ucp = (u_char *)linebuf;-+#ifdef CONFIG_HAS_DATAFLASH+ int rc;+#endif printf("%08lx:", addr); linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes; #ifdef CONFIG_HAS_DATAFLASH- if (read_dataflash(addr, (linebytes/size)*size, linebuf) != -1){-+ if ((rc = read_dataflash(addr, (linebytes/size)*size, linebuf)) == DATAFLASH_OK){+ /* if outside dataflash */+ /*if (rc != 1) {+ dataflash_perror (rc);+ return (1);+ }*/ for (i=0; i<linebytes; i+= size) { if (size == 4) { printf(" %08x", *uip++);@@ -430,7 +436,12 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int fl /* Check if we are copying from DataFlash to RAM */ if (addr_dataflash(addr) && !addr_dataflash(dest) && (addr2info(dest)==NULL) ){- read_dataflash(addr, count * size, (char *) dest);+ int rc;+ rc = read_dataflash(addr, count * size, (char *) dest);+ if (rc != 1) {+ dataflash_perror (rc);+ return (1);+ } return 0; } diff -purN u-boot-1.0.0.orig/common/cmd_nvedit.c u-boot-1.0.0.test/common/cmd_nvedit.c--- u-boot-1.0.0.orig/common/cmd_nvedit.c Fri Jul 11 10:03:18 2003+++ u-boot-1.0.0.test/common/cmd_nvedit.c Fri Nov 7 15:46:59 2003@@ -49,8 +49,8 @@ #include <net.h> #endif -#if !defined(CFG_ENV_IS_IN_NVRAM) && !defined(CFG_ENV_IS_IN_EEPROM) && !defined(CFG_ENV_IS_IN_FLASH) && !defined(CFG_ENV_IS_NOWHERE)-# error Define one of CFG_ENV_IS_IN_NVRAM, CFG_ENV_IS_IN_EEPROM, CFG_ENV_IS_IN_FLASH, CFG_ENV_IS_NOWHERE+#if !defined(CFG_ENV_IS_IN_NVRAM) && !defined(CFG_ENV_IS_IN_EEPROM) && !defined(CFG_ENV_IS_IN_FLASH) && !defined(CFG_ENV_IS_IN_DATAFLASH) && !defined(CFG_ENV_IS_NOWHERE)+# error Define one of CFG_ENV_IS_IN_NVRAM, CFG_ENV_IS_IN_EEPROM, CFG_ENV_IS_IN_FLASH, CFG_ENV_IS_IN_DATAFLASH, CFG_ENV_IS_NOWHERE #endif #define XMK_STR(x) #xdiff -purN u-boot-1.0.0.orig/common/env_dataflash.c u-boot-1.0.0.test/common/env_dataflash.c--- u-boot-1.0.0.orig/common/env_dataflash.c Thu Jan 1 01:00:00 1970+++ u-boot-1.0.0.test/common/env_dataflash.c Fri Nov 7 15:53:35 2003@@ -0,0 +1,104 @@+/* LowLevel function for DataFlash environment support+ * Author : Gilles Gastaldi (Atmel)+ *+ * This program is free software; you can redistribute it and/or+ * modify it under the terms of the GNU General Public License as+ * published by the Free Software Foundation; either version 2 of+ * the License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with this program; if not, write to the Free Software+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,+ * MA 02111-1307 USA+ *+ */+#include <common.h>++#if defined(CFG_ENV_IS_IN_DATAFLASH) /* Environment is in DataFlash */++#include <command.h>+#include <environment.h>+#include <linux/stddef.h>+#include <malloc.h>+#include <dataflash.h>++env_t *env_ptr = NULL;++char * env_name_spec = "dataflash";++extern int read_dataflash (unsigned long addr, unsigned long size, char+*result);+extern int write_dataflash (unsigned long addr_dest, unsigned long addr_src,+ unsigned long size);+extern int AT91F_DataflashInit (void);+extern uchar default_environment[];+/* extern int default_environment_size; */+++uchar env_get_char_spec (int index)+{+ uchar c;+ read_dataflash (CFG_ENV_ADDR+index+offsetof(env_t,data),1,&c);+ return (c);+}++void env_relocate_spec (void)+{+ read_dataflash (CFG_ENV_ADDR,CFG_ENV_SIZE,(uchar *)env_ptr);+}++int saveenv(void)+{+/* env must be copied to do not alter env structure in memory*/+unsigned char temp[CFG_ENV_SIZE];+int i;+ memcpy(temp, env_ptr, CFG_ENV_SIZE);+ return write_dataflash (CFG_ENV_ADDR, (unsigned long)temp, CFG_ENV_SIZE);+}++/************************************************************************+ * Initialize Environment use+ *+ * We are still running from ROM, so data use is limited+ * Use a (moderately small) buffer on the stack+ */+int env_init(void)+{+ DECLARE_GLOBAL_DATA_PTR;+ + ulong crc, len, new;+ unsigned off;+ uchar buf[64];+ if (gd->env_valid == 0){+ AT91F_DataflashInit(); /* prepare for DATAFLASH read/write */++ /* read old CRC */+ read_dataflash (CFG_ENV_ADDR+offsetof(env_t,crc),sizeof(ulong),&crc);+ new = 0;+ len = ENV_SIZE;+ off = offsetof(env_t,data);+ while (len > 0) {+ int n = (len > sizeof(buf)) ? sizeof(buf) : len;+ read_dataflash (CFG_ENV_ADDR+off,n , buf);+ new = crc32 (new, buf, n);+ len -= n;+ off += n;+ }+ if (crc == new) {+ gd->env_addr = offsetof(env_t,data);+ gd->env_valid = 1;+ } else {+ gd->env_addr = (ulong)&default_environment[0];+ gd->env_valid = 0;+ }+ }+ + return (0);+}++#endif /* CFG_ENV_IS_IN_DATAFLASH */diff -purN u-boot-1.0.0.orig/cpu/at91rm9200/at45.c u-boot-1.0.0.test/cpu/at91rm9200/at45.c--- u-boot-1.0.0.orig/cpu/at91rm9200/at45.c Fri Jun 27 23:32:32 2003+++ u-boot-1.0.0.test/cpu/at91rm9200/at45.c Fri Nov 7 15:47:52 2003@@ -26,6 +26,7 @@ #include <dataflash.h> #define SPI_CLK 5000000+#define AT91C_TIMEOUT_WRDY 200000 #define AT91C_SPI_PCS0_SERIAL_DATAFLASH 0xE /* Chip Select 0 : NPCS0 %1110 */ #define AT91C_SPI_PCS3_DATAFLASH_CARD 0x7 /* Chip Select 3 : NPCS3 %0111 */ @@ -145,10 +146,20 @@ AT91S_DataFlashStatus AT91F_DataFlashSen /* fill the command buffer */ pDataFlash->pDataFlashDesc->command[0] = OpCode;- pDataFlash->pDataFlashDesc->command[1] = (unsigned char)((adr & 0x00FF0000) >> 16);- pDataFlash->pDataFlashDesc->command[2] = (unsigned char)((adr & 0x0000FF00) >> 8);- pDataFlash->pDataFlashDesc->command[3] = (unsigned char)(adr & 0x000000FF) ;- pDataFlash->pDataFlashDesc->command[4] = 0;+ if (pDataFlash->pDevice->pages_number >= 16384)+ {+ pDataFlash->pDataFlashDesc->command[1] = (unsigned char)((adr & 0x0F000000) >> 24);+ pDataFlash->pDataFlashDesc->command[2] = (unsigned char)((adr & 0x00FF0000) >> 16);+ pDataFlash->pDataFlashDesc->command[3] = (unsigned char)((adr & 0x0000FF00) >> 8);+ pDataFlash->pDataFlashDesc->command[4] = (unsigned char)(adr & 0x000000FF);+ }+ else+ { + pDataFlash->pDataFlashDesc->command[1] = (unsigned char)((adr & 0x00FF0000) >> 16);+ pDataFlash->pDataFlashDesc->command[2] = (unsigned char)((adr & 0x0000FF00) >> 8);+ pDataFlash->pDataFlashDesc->command[3] = (unsigned char)(adr & 0x000000FF) ;+ pDataFlash->pDataFlashDesc->command[4] = 0;+ } pDataFlash->pDataFlashDesc->command[5] = 0; pDataFlash->pDataFlashDesc->command[6] = 0; pDataFlash->pDataFlashDesc->command[7] = 0;@@ -230,6 +241,7 @@ AT91S_DataFlashStatus AT91F_DataFlashCon unsigned char *dataBuffer, int sizeToRead ) {+ AT91S_DataFlashStatus status; /* Test the size to read in the device */ if ( (src + sizeToRead) > (pDataFlash->pDevice->pages_size * (pDataFlash->pDevice->pages_number))) return DATAFLASH_MEMORY_OVERFLOW;@@ -239,8 +251,9 @@ AT91S_DataFlashStatus AT91F_DataFlashCon
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -