Re: [U-Boot-Users] Altera Stratix II support

adds the reset register to 85xx immap ================ sof =================== diff -x .svn -Nuar u-boot.git/include/asm-ppc/immap_85xx.h u-boot-exsw6000/include/asm-ppc/immap_85xx.h --- u-boot.git/include/asm-ppc/immap_85xx.h 2007-05-28 02:11:11.000000000 +0300 +++ u-boot-exsw6000/include/asm-ppc/immap_85xx.h 2007-05-29 10:13:11.000000000 +0300 @@ -1548,7 +1548,9 @@ char res9[12]; uint pvr; /* 0xe00a0 - Processor version register */ uint svr; /* 0xe00a4 - System version register */ - char res10[3416]; + char res9a[8]; + uint rstcr; /* 0xe00b0 - Reset control register */ + char res10[3404]; uint clkocr; /* 0xe0e00 - Clock out select register */ char res11[12]; uint ddrdllcr; /* 0xe0e10 - DDR DLL control register */ ================ eof ===================

adds the the sub command loadi to fpga. this will load an fpga image that was u-boot packed with mkimage. the image may be plain, gzip or bzip2 as with the kernel and fs images. =============== sof ======================= diff -x .svn -Nuar u-boot.git/common/cmd_fpga.c u-boot-exsw6000/common/cmd_fpga.c --- u-boot.git/common/cmd_fpga.c 2007-05-28 02:11:11.000000000 +0300 +++ u-boot-exsw6000/common/cmd_fpga.c 2007-06-03 22:13:42.000000000 +0300 @@ -32,6 +32,7 @@ #endif #include <fpga.h> #include <malloc.h> +#include <bzlib.h>
#if 0 #define FPGA_DEBUG @@ -45,6 +46,8 @@
#if defined (CONFIG_FPGA) && ( CONFIG_COMMANDS & CFG_CMD_FPGA )
+extern int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp); + /* Local functions */ static void fpga_usage (cmd_tbl_t * cmdtp); static int fpga_get_op (char *opstr); @@ -56,6 +59,89 @@ #define FPGA_LOADB 2 #define FPGA_DUMP 3 #define FPGA_LOADMK 4 +#define FPGA_LOADI 5 + +/* Load an image */ +int fpga_loadi( int devnum, void *buf) +{ + ulong addr = (ulong)(buf); + ulong data, len, checksum; + image_header_t hdr; + unsigned int unc_len; + unsigned int *punc_len = &unc_len; + int i; + + /* Copy header so we can blank CRC field for re-calculation */ +#ifdef CONFIG_HAS_DATAFLASH + if (addr_dataflash(addr)){ + read_dataflash(addr, sizeof(image_header_t), (char *)&hdr); + } else +#endif + memmove (&hdr, (char *)addr, sizeof(image_header_t)); + if (ntohl(hdr.ih_magic) != IH_MAGIC) { + puts ("Bad Magic Number\n"); + return 1; + } + data = (ulong)&hdr; + len = sizeof(image_header_t); + + checksum = ntohl(hdr.ih_hcrc); + hdr.ih_hcrc = 0; + + if (crc32 (0, (uchar *)data, len) != checksum) { + puts ("Bad Header Checksum\n"); + return 1; + } +#ifdef CONFIG_HAS_DATAFLASH + if (addr_dataflash(addr)){ + len = ntohl(hdr.ih_size) + sizeof(image_header_t); + read_dataflash(addr, len, (char *)CFG_LOAD_ADDR); + addr = CFG_LOAD_ADDR; + } +#endif + + print_image_hdr ((image_header_t *)addr); + + data = addr + sizeof(image_header_t); + len = ntohl(hdr.ih_size); + + puts (" Verifying Checksum ... "); + if (crc32 (0, (uchar *)data, len) != ntohl(hdr.ih_dcrc)) { + printf ("Bad Data CRC\n"); + return 1; + } + puts ("OK\n"); + + switch (hdr.ih_comp) { + case IH_COMP_NONE: + memmove ((char *)CFG_LOAD_ADDR,(void *)data,len); + break; + case IH_COMP_GZIP: + if (gunzip ((char *)CFG_LOAD_ADDR,unc_len,(uchar *)data, &len) != 0) { + puts ("GUNZIP ERROR - FPGA not loaded\n"); + return 1; + } + len = unc_len; + break; + +#ifdef CONFIG_BZIP2 + case IH_COMP_BZIP2: + i = BZ2_bzBuffToBuffDecompress ((char *)CFG_LOAD_ADDR,punc_len, (char *)data, len, + 1, 0); + if (i != BZ_OK) { + printf ("BUNZIP2 ERROR %d - FPGA not loaded!\n", i); + return 1; + } + len = unc_len; + break; +#endif /* CONFIG_BZIP2 */ + default: + printf ("Unimplemented compression type %d\n", hdr.ih_comp); + return 1; + } + + return fpga_load(devnum,(char *)CFG_LOAD_ADDR,len); +}
/* Convert bitstream data and load into the fpga */ int fpga_loadbitstream(unsigned long dev, char* fpgadata, size_t size) @@ -248,6 +334,10 @@ rc = fpga_load (dev, fpga_data, data_size); break;
+ case FPGA_LOADI: + rc = fpga_loadi (dev, fpga_data); + break; + case FPGA_LOADB: rc = fpga_loadbitstream(dev, fpga_data, data_size); break; @@ -298,6 +388,8 @@ op = FPGA_INFO; } else if (!strcmp ("loadb", opstr)) { op = FPGA_LOADB; + } else if (!strcmp ("loadi", opstr)) { + op = FPGA_LOADI; } else if (!strcmp ("load", opstr)) { op = FPGA_LOAD; } else if (!strcmp ("loadmk", opstr)) { @@ -313,12 +405,13 @@ }
U_BOOT_CMD (fpga, 6, 1, do_fpga, - "fpga - loadable FPGA image support\n", - "fpga [operation type] [device number] [image address] [image size]\n" - "fpga operations:\n" - "\tinfo\tlist known device information\n" - "\tload\tLoad device from memory buffer\n" - "\tloadb\tLoad device from bitstream buffer (Xilinx devices only)\n" - "\tloadmk\tLoad device generated with mkimage\n" - "\tdump\tLoad device to memory buffer\n"); + "fpga - loadable FPGA image support\n", + "fpga [operation type] [device number] [image address] [image size]\n" + "fpga operations:\n" + "\tinfo\tlist known device information\n" + "\tloadi\tLoad device from u-boot image\n" + "\tload\tLoad device from memory buffer\n" + "\tloadb\tLoad device from bitstream buffer (Xilinx devices only)\n" + "\tloadmk\tLoad device generated with mkimage\n" + "\tdump\tLoad device to memory buffer\n"); #endif /* CONFIG_FPGA && CONFIG_COMMANDS & CFG_CMD_FPGA */ =============== eof =======================

this patch correct a warining i got about const casting... ============== sof ===================== diff -x .svn -Nuar u-boot.git/common/fpga.c u-boot-exsw6000/common/fpga.c --- u-boot.git/common/fpga.c 2007-05-28 02:11:11.000000000 +0300 +++ u-boot-exsw6000/common/fpga.c 2007-06-03 22:13:42.000000000 +0300 @@ -64,7 +64,7 @@ /* fpga_no_sup * 'no support' message function */ -static void fpga_no_sup( char *fn, char *msg ) +static void fpga_no_sup(const char *fn,const char *msg ) { if ( fn && msg ) { printf( "%s: No support for %s. CONFIG_FPGA defined as 0x%x.\n", @@ -207,10 +207,6 @@ memset( desc_table, 0, sizeof(desc_table));
PRINTF( "%s: CONFIG_FPGA = 0x%x\n", __FUNCTION__, CONFIG_FPGA ); -#if 0 - PRINTF( "%s: CFG_FPGA_XILINX = 0x%x\n", __FUNCTION__, CFG_FPGA_XILINX ); - PRINTF( "%s: CFG_FPGA_ALTERA = 0x%x\n", __FUNCTION__, CFG_FPGA_ALTERA ); -#endif }
/* fpga_count ============== eof =====================

This patch adds a safety check to the cfi flash. If the config file defined a flash smaller (maybe intentionally) then the physical one. the cfi will read the actual size from the eprom and will try to initialize a buffer of the wrong size... which will cause a memory over run and unpredicted behaviour.
================ sof =================== diff -x .svn -Nuar u-boot.git/drivers/cfi_flash.c u-boot-exsw6000/drivers/cfi_flash.c --- u-boot.git/drivers/cfi_flash.c 2007-05-28 02:11:11.000000000 +0300 +++ u-boot-exsw6000/drivers/cfi_flash.c 2007-06-03 22:13:42.000000000 +0300 @@ -1281,7 +1281,7 @@ erase_region_count = (tmp & 0xffff) + 1; debug ("erase_region_count = %d erase_region_size = %d\n", erase_region_count, erase_region_size); - for (j = 0; j < erase_region_count; j++) { + for (j = 0; j < erase_region_count && sect_cnt < CFG_MAX_FLASH_SECT; j++) { info->start[sect_cnt] = sector; sector += (erase_region_size * size_ratio);
@@ -1323,6 +1323,9 @@ }
flash_write_cmd (info, 0, 0, info->cmd_reset); +#if defined(CONFIG_FORCE_FLASH_BANK_SIZE) + info->size = CONFIG_FORCE_FLASH_BANK_SIZE; +#endif return (info->size); }
================ eof ===================

This last patch will add the command bunzip2 to the u-boot shell. allowing to uncompress a buffer in memory (or flash) into another location. ============== sof ================= diff -x .svn -Nuar u-boot.git/common/cmd_bzip2.c u-boot-exsw6000/common/cmd_bzip2.c --- u-boot.git/common/cmd_bzip2.c 1970-01-01 02:00:00.000000000 +0200 +++ u-boot-exsw6000/common/cmd_bzip2.c 2007-06-03 22:37:27.000000000 +0300 @@ -0,0 +1,67 @@ +/* + * (C) Copyright 2007 + * Liberty Eran, Extricom, eran.liberty@gmail.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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> +#include <command.h> +#include <bzlib.h> + +#if defined(CONFIG_BZIP2) +int do_bunzip2 ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + ulong addr, dest, count; + unsigned int destSize; + int rc; + + if (argc != 4) { + printf ("Usage:\n%s\n", cmdtp->usage); + return 1; + } + + /* Check for size specification. + */ + addr = simple_strtoul(argv[1], NULL, 16); + dest = simple_strtoul(argv[2], NULL, 16); + count = simple_strtoul(argv[3], NULL, 16); + + if (count == 0) { + puts ("BUNZIP2 ERROR: Zero length ???\n"); + return 1; + } + + if ((rc = BZ2_bzBuffToBuffDecompress((char*)dest,&destSize,(char*)addr,count,1,0)) != BZ_OK) { + printf ("BUNZIP2 ERROR: %d\n", rc); + return 1; + } + printf("BUNZIP2: decompressed image address & size: 0x%08x 0x%x (%d)\n",dest,destSize,destSize); + return 0; + +} + +U_BOOT_CMD( + bunzip2 , 4, 4, do_bunzip2, + "bunzip2 - decompress bz2 buffers\n", + "src dest size_of_src\n" +); +#endif + + diff -x .svn -Nuar u-boot.git/common/Makefile u-boot-exsw6000/common/Makefile --- u-boot.git/common/Makefile 2007-05-28 02:11:11.000000000 +0300 +++ u-boot-exsw6000/common/Makefile 2007-06-03 22:23:57.000000000 +0300 @@ -39,7 +40,7 @@ cmd_nand.o cmd_net.o cmd_nvedit.o \ cmd_pci.o cmd_pcmcia.o cmd_portio.o \ cmd_reginfo.o cmd_reiser.o cmd_scsi.o cmd_spi.o cmd_universe.o \ - cmd_usb.o cmd_vfd.o \ + cmd_usb.o cmd_vfd.o cmd_bzip2.o \ command.o console.o cyclon2.o devices.o dlmalloc.o docecc.o \ environment.o env_common.o \ env_nand.o env_dataflash.o env_flash.o env_eeprom.o \ ============== eof =================
Thats it, Have fun, Liberty.

On 6/4/07, eran liberty eran.liberty@gmail.com wrote:
adds the reset register to 85xx immap
Applied
Andy
participants (2)
-
Andy Fleming
-
eran liberty