From 5efe4234263d182ae2c9b054b1047059cf543d5e Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Thu, 17 Sep 2009 09:41:08 +0800 Subject: [PATCH 01/13] fix the GPL warning when make .deb package --- usbboot/debian/copyright | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usbboot/debian/copyright b/usbboot/debian/copyright index 57d76c8..d332bbb 100644 --- a/usbboot/debian/copyright +++ b/usbboot/debian/copyright @@ -21,11 +21,11 @@ The Debian packaging is copyright 2009, MIPS Technologies, Inc. Maciej W. Rozycki Lucifer at Ingenic Semiconductor Inc. -is licensed under the GPL, see `/usr/share/common-licenses/GPL'. +is licensed under the GPL, see `/usr/share/common-licenses/GPL-3'. You are free to distribute this software under the terms of the GNU General Public License either version 3 of the License, or (at your option) any later version. On Debian systems, the complete text of the GNU General Public -License can be found in the file `/usr/share/common-licenses/GPL'. +License can be found in the file `/usr/share/common-licenses/GPL-3'. From 3e030a84f87a60fb9cb232db796e8f4500ded9e8 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 17 Sep 2009 10:22:28 +0800 Subject: [PATCH 02/13] fix usbboot skips empty pages during write --- usbboot/xburst_stage2/nandflash_4740.c | 27 ++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/usbboot/xburst_stage2/nandflash_4740.c b/usbboot/xburst_stage2/nandflash_4740.c index e7e0b24..a2c8d77 100644 --- a/usbboot/xburst_stage2/nandflash_4740.c +++ b/usbboot/xburst_stage2/nandflash_4740.c @@ -541,11 +541,17 @@ u32 nand_read_4740(void *buf, u32 startpage, u32 pagecount, int option) u32 nand_program_4740(void *context, int spage, int pages, int option) { + size_t datasize; u32 i, j, cur, rowaddr; u8 *tmpbuf; u32 ecccnt,oobsize_sav,ecccnt_sav,eccpos_sav; u8 ecc_buf[256]; + datasize = pagesize; + if (option != NO_OOB) + datasize += oobsize; + + if (wp_pin) __gpio_set_pin(wp_pin); restart: @@ -581,19 +587,16 @@ restart: } } - //if NO_OOB do not perform vaild check! - if ( option != NO_OOB ) { - for ( j = 0 ; j < pagesize + oobsize; j ++) { - if (tmpbuf[j] != 0xff) - break; - } + for (j = 0; j < datasize; ++j) { + if (tmpbuf[j] != 0xff) + break; + } - if ( j == oobsize + pagesize ) { - tmpbuf += ( pagesize + oobsize ) ; - i ++; - cur ++; - continue; - } + if (j == datasize) { + tmpbuf += datasize; + ++i; + ++cur; + continue; } if (pagesize == 512) From 5fd478b936cef23560b12a608206bdabc09c2fb6 Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Wed, 30 Sep 2009 23:47:29 -0400 Subject: [PATCH 03/13] cleanup output, fix not exit when error --- usbboot/src/cmd.c | 61 +++++++++++++++------------- usbboot/src/ingenic_usb.c | 10 ++--- usbboot/src/ingenic_usb.h | 10 +++-- usbboot/xburst_stage2/boothandler.c | 63 ++++++++++++----------------- usbboot/xburst_stage2/main.c | 6 +-- usbboot/xburst_stage2/serial.c | 10 +++-- 6 files changed, 80 insertions(+), 80 deletions(-) diff --git a/usbboot/src/cmd.c b/usbboot/src/cmd.c index e985556..f931196 100644 --- a/usbboot/src/cmd.c +++ b/usbboot/src/cmd.c @@ -222,12 +222,14 @@ int nand_program_check(struct nand_in *nand_in, unsigned int *start_page) { unsigned int i, page_num, cur_page = -1; + unsigned int start_addr; unsigned short temp; + int status = -1; printf(" Writing NAND page %d len %d...\n", nand_in->start, nand_in->length); if (nand_in->length > (unsigned int)MAX_TRANSFER_SIZE) { printf(" Buffer size too long!\n"); - return -1; + goto err; } #ifdef CONFIG_NAND_OUT @@ -237,15 +239,17 @@ int nand_program_check(struct nand_in *nand_in, (nand_out->status)[i] = 0; /* set all status to fail */ #endif - if (usb_get_ingenic_cpu(&ingenic_dev) < 3) { + int cpu = usb_get_ingenic_cpu(&ingenic_dev); + if (cpu != BOOT4740 && cpu != BOOT4750) { printf(" Device unboot! Boot it first!\n"); - return -1; + goto err; } + ingenic_dev.file_buff = nand_in->buf; ingenic_dev.file_len = nand_in->length; usb_send_data_to_ingenic(&ingenic_dev); for (i = 0; i < nand_in->max_chip; i++) { - if ((nand_in->cs_map)[i]==0) + if ((nand_in->cs_map)[i] == 0) continue; if (nand_in->option == NO_OOB) { page_num = nand_in->length / hand.nand_ps; @@ -259,50 +263,47 @@ int nand_program_check(struct nand_in *nand_in, } temp = ((nand_in->option << 12) & 0xf000) + ((i<<4) & 0xff0) + NAND_PROGRAM; - usb_send_data_address_to_ingenic(&ingenic_dev, nand_in->start); - usb_send_data_length_to_ingenic(&ingenic_dev, page_num); - usb_ingenic_nand_ops(&ingenic_dev, temp); + if (usb_send_data_address_to_ingenic(&ingenic_dev, nand_in->start) != 1) + goto err; + if (usb_send_data_length_to_ingenic(&ingenic_dev, page_num) != 1) + goto err; + if (usb_ingenic_nand_ops(&ingenic_dev, temp) != 1) + goto err; + if (usb_read_data_from_ingenic(&ingenic_dev, ret, 8) != 1) + goto err; - usb_read_data_from_ingenic(&ingenic_dev, ret, 8); printf(" Finish! (len %d start_page %d page_num %d)\n", nand_in->length, nand_in->start, page_num); - usb_send_data_address_to_ingenic(&ingenic_dev, nand_in->start); /* Read back to check! */ + usb_send_data_address_to_ingenic(&ingenic_dev, nand_in->start); usb_send_data_length_to_ingenic(&ingenic_dev, page_num); switch (nand_in->option) { case OOB_ECC: temp = ((OOB_ECC << 12) & 0xf000) + ((i << 4) & 0xff0) + NAND_READ; - usb_ingenic_nand_ops(&ingenic_dev, temp); - printf(" Checking %d bytes...", nand_in->length); - usb_read_data_from_ingenic(&ingenic_dev, check_buf, - page_num * (hand.nand_ps + hand.nand_os)); - usb_read_data_from_ingenic(&ingenic_dev, ret, 8); + start_addr = page_num * (hand.nand_ps + hand.nand_os); break; case OOB_NO_ECC: /* do not support data verify */ temp = ((OOB_NO_ECC << 12) & 0xf000) + ((i << 4) & 0xff0) + NAND_READ; - usb_ingenic_nand_ops(&ingenic_dev, temp); - printf(" Checking %d bytes...", nand_in->length); - usb_read_data_from_ingenic(&ingenic_dev, check_buf, - page_num * (hand.nand_ps + hand.nand_os)); - usb_read_data_from_ingenic(&ingenic_dev, ret, 8); + start_addr = page_num * (hand.nand_ps + hand.nand_os); break; case NO_OOB: temp = ((NO_OOB << 12) & 0xf000) + ((i << 4) & 0xff0) + NAND_READ; - usb_ingenic_nand_ops(&ingenic_dev, temp); - printf(" Checking %d bytes...", nand_in->length); - usb_read_data_from_ingenic(&ingenic_dev, check_buf, - page_num * hand.nand_ps); - usb_read_data_from_ingenic(&ingenic_dev, ret, 8); + start_addr = page_num * hand.nand_ps; break; default: ; } + printf(" Checking %d bytes...", nand_in->length); + usb_ingenic_nand_ops(&ingenic_dev, temp); + usb_read_data_from_ingenic(&ingenic_dev, check_buf, start_addr); + usb_read_data_from_ingenic(&ingenic_dev, ret, 8); + cur_page = (ret[3] << 24) | (ret[2] << 16) | (ret[1] << 8) | (ret[0] << 0); @@ -329,11 +330,14 @@ int nand_program_check(struct nand_in *nand_in, nand_markbad(&bad); } - printf(" End at Page: %d\n",cur_page); + printf(" End at Page: %d\n", cur_page); } *start_page = cur_page; - return 0; + + status = 1; +err: + return status; } int nand_erase(struct nand_in *nand_in) @@ -551,6 +555,7 @@ int init_nand_in(void) int nand_prog(void) { + int status = -1; char *image_file; char *help = " Usage: nprog (1) (2) (3) (4) (5)\n" " (1)\tstart page number\n" @@ -595,7 +600,9 @@ int nand_prog(void) printf(" %d", (nand_out.status)[i]); #endif - return 1; + status = 1; +err: + return status; } int nand_query(void) diff --git a/usbboot/src/ingenic_usb.c b/usbboot/src/ingenic_usb.c index 6b622cd..e74971d 100644 --- a/usbboot/src/ingenic_usb.c +++ b/usbboot/src/ingenic_usb.c @@ -166,12 +166,12 @@ int usb_get_ingenic_cpu(struct ingenic_dev *ingenic_dev) ingenic_dev->cpu_info_buff[8] = '\0'; printf(" CPU data: %s\n", ingenic_dev->cpu_info_buff); - if (!strcmp(ingenic_dev->cpu_info_buff,"JZ4740V1")) return 1; - if (!strcmp(ingenic_dev->cpu_info_buff,"JZ4750V1")) return 2; - if (!strcmp(ingenic_dev->cpu_info_buff,"Boot4740")) return 3; - if (!strcmp(ingenic_dev->cpu_info_buff,"Boot4750")) return 4; + if (!strcmp(ingenic_dev->cpu_info_buff,"JZ4740V1")) return JZ4740V1; + if (!strcmp(ingenic_dev->cpu_info_buff,"JZ4750V1")) return JZ4750V1; + if (!strcmp(ingenic_dev->cpu_info_buff,"Boot4740")) return BOOT4740; + if (!strcmp(ingenic_dev->cpu_info_buff,"Boot4750")) return BOOT4750; - return 0; + return -1; } int usb_ingenic_flush_cache(struct ingenic_dev *ingenic_dev) diff --git a/usbboot/src/ingenic_usb.h b/usbboot/src/ingenic_usb.h index 9af7b72..76444c5 100644 --- a/usbboot/src/ingenic_usb.h +++ b/usbboot/src/ingenic_usb.h @@ -37,11 +37,16 @@ #define VR_CONFIGRATION 0x09 #define VR_GET_NUM 0x0a +#define JZ4740V1 1 +#define JZ4750V1 2 +#define BOOT4740 3 +#define BOOT4750 4 + #define STAGE_ADDR_MSB(addr) ((addr) >> 16) #define STAGE_ADDR_LSB(addr) ((addr) & 0xffff) -#define USB_PACKET_SIZE 512 -#define USB_TIMEOUT 5000 +#define USB_PACKET_SIZE 512 +#define USB_TIMEOUT 5000 #define VENDOR_ID 0x601a #define PRODUCT_ID 0x4740 @@ -73,4 +78,3 @@ int usb_ingenic_nand_ops(struct ingenic_dev *ingenic_dev, int ops); int usb_read_data_from_ingenic(struct ingenic_dev *ingenic_dev,unsigned char *buff, unsigned int len); #endif /* __INGENIC_USB_H__ */ - diff --git a/usbboot/xburst_stage2/boothandler.c b/usbboot/xburst_stage2/boothandler.c index b166b6a..16d615c 100644 --- a/usbboot/xburst_stage2/boothandler.c +++ b/usbboot/xburst_stage2/boothandler.c @@ -83,13 +83,6 @@ void config_hand() Hand.nand_eccpos=hand_p->nand_eccpos; Hand.nand_bbpos=hand_p->nand_bbpos; Hand.nand_bbpage=hand_p->nand_bbpage; -// memcpy( &Hand.fw_args, (unsigned char *)(start_addr + 0x8), 32 ); - -// serial_putc(Hand.nand_eccpos + 48); -// serial_putc(Hand.nand_bbpos + 48); -// serial_putc(Hand.nand_bbpage + 48); - /* dprintf("\n Hand : bw %d rc %d ps %d ppb %d erase %d pn %d os %d", */ - /* Hand.nand_bw,Hand.nand_rc,Hand.nand_ps,Hand.nand_ppb,Hand.nand_force_erase,Hand.nand_pn,Hand.nand_os); */ serial_put_hex(Hand.fw_args.cpu_id); serial_put_hex(Hand.fw_args.ext_clk); #endif @@ -98,11 +91,12 @@ void config_hand() int GET_CUP_INFO_Handle() { char temp1[8]="Boot4740",temp2[8]="Boot4750"; - dprintf("\n GET_CPU_INFO!"); - if ( Hand.fw_args.cpu_id == 0x4740 ) - HW_SendPKT(0,temp1,8); + dprintf("\n GET_CPU_INFO:\t"); + serial_put_hex(Hand.fw_args.cpu_id); + if (Hand.fw_args.cpu_id == 0x4740) + HW_SendPKT(0, temp1, 8); else - HW_SendPKT(0,temp2,8); + HW_SendPKT(0, temp2, 8); udc_state = IDLE; return ERR_OK; } @@ -111,7 +105,7 @@ int SET_DATA_ADDERSS_Handle(u8 *buf) { USB_DeviceRequest *dreq = (USB_DeviceRequest *)buf; start_addr=(((u32)dreq->wValue)<<16)+(u32)dreq->wIndex; - dprintf("\n SET ADDRESS:"); + dprintf("\n SET ADDRESS:\t"); serial_put_hex(start_addr); return ERR_OK; } @@ -120,7 +114,7 @@ int SET_DATA_LENGTH_Handle(u8 *buf) { USB_DeviceRequest *dreq = (USB_DeviceRequest *)buf; ops_length=(((u32)dreq->wValue)<<16)+(u32)dreq->wIndex; - dprintf("\n DATA_LENGTH :"); + dprintf("\n DATA_LENGTH:\t"); serial_put_hex(ops_length); return ERR_OK; } @@ -219,20 +213,18 @@ int NAND_OPS_Handle(u8 *buf) } break; case NAND_ERASE: - dprintf("\n Request : NAND_ERASE!"); + dprintf("\n Request : NAND_ERASE"); ret_dat = nand_erase(ops_length,start_addr, Hand.nand_force_erase); handshake_PKT[0] = (u16) ret_dat; handshake_PKT[1] = (u16) (ret_dat>>16); HW_SendPKT(1,handshake_PKT,sizeof(handshake_PKT)); udc_state = IDLE; - dprintf("\n Request : NAND_ERASE_FINISH!"); + dprintf(" ... finished."); break; case NAND_READ: dprintf("\n Request : NAND_READ!"); -// dprintf("\n Option : %x",option); - switch (option) - { + switch (option) { case OOB_ECC: ret_dat = nand_read(Bulk_in_buf,start_addr,ops_length,OOB_ECC); handshake_PKT[0] = (u16) ret_dat; @@ -255,21 +247,20 @@ int NAND_OPS_Handle(u8 *buf) udc_state = BULK_IN; break; } - dprintf("\n Request : NAND_READ_FUNISH!"); + dprintf(" ... finished."); break; case NAND_PROGRAM: dprintf("\n Request : NAND_PROGRAM!"); -// dprintf("\n Option : %x",option); ret_dat = nand_program((void *)Bulk_out_buf, start_addr,ops_length,option); - dprintf("\n NAND_PROGRAM finish!"); handshake_PKT[0] = (u16) ret_dat; handshake_PKT[1] = (u16) (ret_dat>>16); HW_SendPKT(1,handshake_PKT,sizeof(handshake_PKT)); udc_state = IDLE; + dprintf(" ... finished."); break; case NAND_READ_TO_RAM: - dprintf("\n Request : NAND_READNAND!"); + dprintf("\n Request : NAND_READ_TO_RAM!"); nand_read((u8 *)ram_addr,start_addr,ops_length,NO_OOB); __dcache_writeback_all(); handshake_PKT[3]=(u16)ERR_OK; @@ -293,7 +284,7 @@ int SDRAM_OPS_Handle(u8 *buf) switch ((dreq->wValue)&0xf) { case SDRAM_LOAD: -// dprintf("\n Request : SDRAM_LOAD!"); + //dprintf("\n Request : SDRAM_LOAD!"); ret_dat = (u32)memcpy((u8 *)start_addr,Bulk_out_buf,ops_length); handshake_PKT[0] = (u16) ret_dat; handshake_PKT[1] = (u16) (ret_dat>>16); @@ -312,16 +303,10 @@ void Borad_Init() { case 0x4740: //Init nand flash - nand_init_4740(Hand.nand_bw,Hand.nand_rc,Hand.nand_ps,Hand.nand_ppb, - Hand.nand_bbpage,Hand.nand_bbpos,Hand.nand_force_erase,Hand.nand_eccpos); + nand_init_4740(Hand.nand_bw, Hand.nand_rc, Hand.nand_ps, + Hand.nand_ppb, Hand.nand_bbpage, Hand.nand_bbpos, + Hand.nand_force_erase, Hand.nand_eccpos); - dprintf("\nnand_ps, nand_ppb, nand_bbpage, nand_bbpos, nand_eccpos\n"); - serial_put_hex(Hand.nand_ps); - serial_put_hex(Hand.nand_ppb); - serial_put_hex(Hand.nand_bbpage); - serial_put_hex(Hand.nand_bbpos); - serial_put_hex(Hand.nand_eccpos); - nand_program = nand_program_4740; nand_erase = nand_erase_4740; nand_read = nand_read_4740; @@ -355,21 +340,23 @@ void Borad_Init() int CONFIGRATION_Handle(u8 *buf) { + dprintf("\n Configuration:\t"); + USB_DeviceRequest *dreq = (USB_DeviceRequest *)buf; - switch ((dreq->wValue)&0xf) - { + switch ((dreq->wValue)&0xf) { case DS_flash_info: - dprintf("\n configration :DS_flash_info_t!"); + dprintf("DS_flash_info_t!"); config_flash_info(); break; case DS_hand: - dprintf("\n configration :DS_hand_t!"); + dprintf("DS_hand_t!"); config_hand(); break; - default:; - + default: + ; } + Borad_Init(); return ERR_OK; } diff --git a/usbboot/xburst_stage2/main.c b/usbboot/xburst_stage2/main.c index 43f0502..6d87dd4 100644 --- a/usbboot/xburst_stage2/main.c +++ b/usbboot/xburst_stage2/main.c @@ -57,11 +57,11 @@ void c_main(void) if ( fw_args->use_uart > 3 ) fw_args->use_uart = 0; UART_BASE = 0xB0030000 + fw_args->use_uart * 0x1000; - serial_puts("Start address is :"); + serial_puts("\n Stage2 start address is :\t"); serial_put_hex(start_addr); - serial_puts("Address offset is:"); + serial_puts("\n Address offset is:\t"); serial_put_hex(offset); - serial_puts("GOT correct to :"); + serial_puts("\n GOT correct to :\t"); serial_put_hex(got_start); usb_main(); diff --git a/usbboot/xburst_stage2/serial.c b/usbboot/xburst_stage2/serial.c index acb110f..f5bc593 100644 --- a/usbboot/xburst_stage2/serial.c +++ b/usbboot/xburst_stage2/serial.c @@ -89,9 +89,9 @@ void serial_init(void) void serial_put_hex(unsigned int d) { - unsigned char c[12]; + unsigned char c[9]; char i; - for(i = 0; i < 8;i++) + for(i = 0; i < 8; i++) { c[i] = (d >> ((7 - i) * 4)) & 0xf; if(c[i] < 10) @@ -99,7 +99,9 @@ void serial_put_hex(unsigned int d) else c[i] += (0x41 - 10); } - c[8] = '\n'; - c[9] = 0; + + c[8] = 0; + + serial_puts("0x"); serial_puts(c); } From fa5c72f0950460b62a11e639d38621cfe4a86fae Mon Sep 17 00:00:00 2001 From: Mikhail Gusarov Date: Tue, 3 Nov 2009 23:02:24 +0600 Subject: [PATCH 04/13] Typo fix Signed-off-by: Mikhail Gusarov --- usbboot/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usbboot/configure.ac b/usbboot/configure.ac index cca8fb6..d7c7459 100644 --- a/usbboot/configure.ac +++ b/usbboot/configure.ac @@ -22,7 +22,7 @@ exit -1 ]) AC_CHECK_LIB([gcc], [main]) AC_CHECK_LIB([m], [main]) AC_CHECK_LIB([usb], [main], [], [ -echo "Error! You need to have libconfuse. \n" +echo "Error! You need to have libusb. \n" echo "Maybe run 'sudo apt-get install libusb-dev' under debian" exit -1 ]) From 9356e3dff061cc8b0e42e740f06ccde1b6d15168 Mon Sep 17 00:00:00 2001 From: Mikhail Gusarov Date: Tue, 3 Nov 2009 23:02:25 +0600 Subject: [PATCH 05/13] Use autoconf-provided variables instead of absolute paths Signed-off-by: Mikhail Gusarov --- usbboot/src/Makefile.am | 11 +++++------ usbboot/src/main.c | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/usbboot/src/Makefile.am b/usbboot/src/Makefile.am index 90e256a..a26f03b 100644 --- a/usbboot/src/Makefile.am +++ b/usbboot/src/Makefile.am @@ -1,4 +1,4 @@ -AM_CFLAGS = -pedantic -Wall -W -O1 -g3 -std=gnu99 -lusb -lconfuse +AM_CFLAGS = -pedantic -Wall -W -O1 -g3 -std=gnu99 -lusb -lconfuse -DCFGDIR=\"$(cfgdir)\" xburst-tools_version.h: echo -e '#ifndef XBURST_TOOLS_VERSION' \ @@ -10,15 +10,14 @@ bin_PROGRAMS = usbboot usbboot_SOURCES = cmd.c command_line.c ingenic_cfg.c \ ingenic_usb.c main.c -prefix = /usr -datadir = /usr/share/xburst-tools -data_DATA = ../xburst_stage1/xburst_stage1.bin \ +pkgdatadir = $(datadir)/xburst-tools +pkgdata_DATA = ../xburst_stage1/xburst_stage1.bin \ ../xburst_stage2/xburst_stage2.bin -cfgdir = /etc/xburst-tools +cfgdir = $(sysconfdir)/xburst-tools cfg_DATA = ../doc/usbboot.cfg -EXTRA_DIST = $(datadir) $(cfgdir) +EXTRA_DIST = $(pkgdatadir) $(cfgdir) ../xburst_stage1/xburst_stage1.bin: $(MAKE) CROSS_COMPILE=mipsel-openwrt-linux- -C ../xburst_stage1 diff --git a/usbboot/src/main.c b/usbboot/src/main.c index d34f583..5197059 100644 --- a/usbboot/src/main.c +++ b/usbboot/src/main.c @@ -26,7 +26,7 @@ #include "ingenic_usb.h" #include "ingenic_cfg.h" -#define CONFIG_FILE_PATH "/etc/xburst-tools/usbboot.cfg" +#define CONFIG_FILE_PATH (CFGDIR "xburst-tools/usbboot.cfg") extern struct ingenic_dev ingenic_dev; extern struct hand hand; From f7c651790ca09018901f4fc74f58359c57cbd0ef Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Wed, 4 Nov 2009 01:51:33 +0800 Subject: [PATCH 06/13] fix the configure file path --- usbboot/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usbboot/src/main.c b/usbboot/src/main.c index 5197059..457562d 100644 --- a/usbboot/src/main.c +++ b/usbboot/src/main.c @@ -26,7 +26,7 @@ #include "ingenic_usb.h" #include "ingenic_cfg.h" -#define CONFIG_FILE_PATH (CFGDIR "xburst-tools/usbboot.cfg") +#define CONFIG_FILE_PATH (CFGDIR "/usbboot.cfg") extern struct ingenic_dev ingenic_dev; extern struct hand hand; From e5ece9bb3117c0e340419b53cc275a65f32e6c2b Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Wed, 4 Nov 2009 12:57:30 +0800 Subject: [PATCH 07/13] don't have .cpp file. --- usbboot/xburst_stage2/Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/usbboot/xburst_stage2/Makefile b/usbboot/xburst_stage2/Makefile index 497ba0c..773e7f2 100644 --- a/usbboot/xburst_stage2/Makefile +++ b/usbboot/xburst_stage2/Makefile @@ -29,10 +29,9 @@ DEBUG_CFLAGS = -g -Wa,-a=$(basename $@).lst # registers work. Since other register accesses might be affected too it seems the best # is to disable this optimization right now. CFLAGS = -mips32 -O2 -fno-exceptions -fno-zero-initialized-in-bss \ - -ffunction-sections -fomit-frame-pointer -msoft-float -G 0 $(DEBUG_CFLAGS) \ + -ffunction-sections -fomit-frame-pointer -msoft-float -G 0 -fpie \ -I$(XBURST_INCLUDE_PATH) -I$(INFLASH_SRC_PATH) LDFLAGS = -nostdlib -T target.ld $(CFLAGS) -LIBS = -lstdc++ -lc -lm -lgcc OBJS = main.o udc.o cache.o serial.o boothandler.o nandflash_4740.o nandflash_4750.o @@ -47,8 +46,6 @@ xburst_stage2.elf: head.o $(OBJS) .c.o: $(CC) $(CFLAGS) -o $@ -c $< -.cpp.o: - $(CC) $(CFLAGS) -fno-rtti -fvtable-gc -o $@ -c $< .S.o: $(CC) $(CFLAGS) -o $@ -c $< From 29c5fc7479304d4b6b9b407aaf1c0b72aab0f0ce Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Wed, 4 Nov 2009 22:10:28 +0800 Subject: [PATCH 08/13] set sysconfdir to etc --- usbboot/debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usbboot/debian/rules b/usbboot/debian/rules index 63c28c7..7ed5fa5 100755 --- a/usbboot/debian/rules +++ b/usbboot/debian/rules @@ -33,7 +33,7 @@ endif ifneq "$(wildcard /usr/share/misc/config.guess)" "" cp -f /usr/share/misc/config.guess config.guess endif - ./configure $(CROSS) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" + ./configure $(CROSS) --prefix=/usr --sysconfdir=/etc --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" build: build-stamp From 7c7245e7dbc6fb37e66dc99793c740d01f12da1f Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Thu, 3 Dec 2009 12:59:45 +0800 Subject: [PATCH 09/13] only need uart0 --- xbboot/target-stage1/stage1.c | 1 - 1 file changed, 1 deletion(-) diff --git a/xbboot/target-stage1/stage1.c b/xbboot/target-stage1/stage1.c index fcfc6ef..add11e9 100644 --- a/xbboot/target-stage1/stage1.c +++ b/xbboot/target-stage1/stage1.c @@ -89,7 +89,6 @@ void gpio_init() __gpio_as_nand(); __gpio_as_sdram_32bit(); __gpio_as_uart0(); - __gpio_as_uart1(); } void pll_init() From 4c8e0f17631b8a2ad828e0a9700fc6ac7f012af6 Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Sun, 6 Dec 2009 01:21:27 +0800 Subject: [PATCH 10/13] fix-compile-error-with-new-openwrt-toolchain --- xbboot/target-echokernel/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbboot/target-echokernel/Makefile b/xbboot/target-echokernel/Makefile index ebd1467..08b8031 100644 --- a/xbboot/target-echokernel/Makefile +++ b/xbboot/target-echokernel/Makefile @@ -25,7 +25,7 @@ DEBUG_CFLAGS = -g -Wa,-a=$(basename $@).lst # registers work. Since other register accesses might be affected too it seems the best # is to disable this optimization right now. CFLAGS = -mips32 -O2 -fno-exceptions -fno-unit-at-a-time -fno-zero-initialized-in-bss \ - -ffunction-sections -fomit-frame-pointer -msoft-float -G 0 $(DEBUG_CFLAGS) + -ffunction-sections -fomit-frame-pointer -msoft-float -G 0 $(DEBUG_CFLAGS) -fPIC LDFLAGS = -nostdlib -T target.ld $(CFLAGS) LIBS = -lstdc++ -lc -lm -lgcc VPATH = ../target-common From 71d4baa6b0823ffbfcaaf5637a55918546e5a20c Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Sun, 6 Dec 2009 01:22:31 +0800 Subject: [PATCH 11/13] add nand init for u-boot --- xbboot/target-stage1/stage1.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/xbboot/target-stage1/stage1.c b/xbboot/target-stage1/stage1.c index add11e9..6df03b3 100644 --- a/xbboot/target-stage1/stage1.c +++ b/xbboot/target-stage1/stage1.c @@ -35,15 +35,17 @@ void gpio_init(); void pll_init(); void serial_init(); void sdram_init(); +void nand_init(); void c_main(void) { load_args(); gpio_init(); - pll_init(); serial_init(); + pll_init(); serial_puts("XBurst boot stage1...\n"); sdram_init(); + nand_init(); serial_puts("stage 1 finished: GPIO, clocks, SDRAM, UART setup - now jump back to BOOT ROM...\n"); } @@ -89,6 +91,8 @@ void gpio_init() __gpio_as_nand(); __gpio_as_sdram_32bit(); __gpio_as_uart0(); + __gpio_as_lcd_18bit(); + __gpio_as_msc(); } void pll_init() @@ -201,7 +205,14 @@ void sdram_init() REG_EMC_RTCSR = 0; /* Disable clock for counting */ /* Fault DMCR value for mode register setting*/ - dmcr0 = (ARG_BUS_WIDTH_16< Date: Sun, 6 Dec 2009 01:27:44 +0800 Subject: [PATCH 12/13] clean the Makefile and README --- Makefile | 73 ----------------------------------- README | 73 ----------------------------------- xbboot/scripts/boot-uboot.sh | 12 ++++++ xbboot/scripts/boot-zImage.sh | 12 ++++++ 4 files changed, 24 insertions(+), 146 deletions(-) delete mode 100644 Makefile create mode 100755 xbboot/scripts/boot-uboot.sh create mode 100755 xbboot/scripts/boot-zImage.sh diff --git a/Makefile b/Makefile deleted file mode 100644 index d3c736e..0000000 --- a/Makefile +++ /dev/null @@ -1,73 +0,0 @@ -# "PanGu Makefile" - for setting up the PanGu development environment -# -# Copyright 2009 (C) Qi Hardware inc., -# Author: Xiangfu Liu -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# version 3 as published by the Free Software Foundation. - -# 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., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA - -# for the device stage -FLASH_TOOL_PATH = ./usbboot -STAGE1_PATH = $(FLASH_TOOL_PATH)/xburst_stage1 -STAGE2_PATH = $(FLASH_TOOL_PATH)/xburst_stage2 -CROSS_COMPILE ?= mipsel-openwrt-linux- - -CFLAGS="-O2" - -### u-boot -.PHONY: u-boot -u-boot: - git clone git://github.com/xiangfu/qi-u-boot.git u-boot - cd u-boot && \ - make qi_lb60_config && \ - make - -### kernel -.PHONY: kernel -kernel: - git clone git://github.com/xiangfu/qi-kernel.git kernel - cd kernel && \ - make pi_defconfig && \ - make uImage - -### flash-boot -.PHONY: usbboot -usbboot: stage1 stage2 - cd $(FLASH_TOOL_PATH) - ./autogen.sh && \ - ./configure && \ - make - -stage1: - make CROSS_COMPILE=$(CROSS_COMPILE) -C $(STAGE1_PATH) - -stage2: - make CROSS_COMPILE=$(CROSS_COMPILE) -C $(STAGE2_PATH) - -### clean up -distclean: clean clean-usbboot - -clean: - -clean-usbboot: - make clean CROSS_COMPILE=$(CROSS_COMPILE) -C $(STAGE1_PATH) - make clean CROSS_COMPILE=$(CROSS_COMPILE) -C $(STAGE2_PATH) - make clean -C $(FLASH_TOOL_PATH) - -help: - @make --print-data-base --question | \ - awk '/^[^.%][-A-Za-z0-9_]*:/ \ - { print substr($$1, 1, length($$1)-1) }' | \ - sort | \ - pr --omit-pagination --width=80 --columns=1 diff --git a/README b/README index d12d9e5..e69de29 100644 --- a/README +++ b/README @@ -1,73 +0,0 @@ -Prepare for Reflash Device --------------------- -=serial console= - at the back of Ben Nanonote, there is "GND", "TXD" and "RXD", - you can get serial output from those pins - you need a TTL <-> RS232 converter. because the Ben Nanonote serial - console is TTL. here[1] is the serial PIN in the board. - -=toolchain= - $ git clone git://github.com/lindnermarek/openwrt-x-burst.git[2] - $ git checkout --track -b x-burst origin/x-burst - $ make menuconfig - (select 'XBurst JZ47x0 [2.6]' in 'Target System') - $ make - then you will get toolchain under /PATH/TO/openwrt-x-burst/staging_dir/ - toolchain-mipsel_gcc-4.1.2_uClibc-0.9.30.1/usr/bin - -=xburst-tools (usbboot tools)= - you can get source code at git://github.com/xiangfu/xburst-tools.git[3] - $ cd /PATH/TO/xburst-tools/usbboot - $ ./autogen.sh && ./configure && make && sudo make install - then you got the 'usbboot' command. that is for the reflash. - -=u-boot= - in openWRT menuconfig-->Target Images-->Build U-Boot bootloader --> - U-Boot target board (NEW) --> input 'qi_lb60 - - here[4] is the u-boot github URL - $ make qi_lb60_config - $ make - there is 'u-boot-nand.bin' is for Ben - - -How To Reflash --------------------- -1. plug the Ben to your computer. direct connect. no usb hub. -2. short the two pin ('boot from usb' show in [1]) -3. press 'RESET' at the back of Ben -4. in you computer run [5] and [6]. then you flashed the bootloader and kernel - to nand flash. -5. rootfs: format your SD card. - the first partition must VFAT and others is EXT2. - we can put the kernel(uImage) in the first partition. put the rootfs in second partition. - uncompress openwrt rootfs to second partition of SD card -6. now you can boot your Ben. - ----- -[1] http://www.openmobilefree.net/?p=61 -[2] here is the web site -http://github.com/lindnermarek/openwrt-x-burst/commits/x-burst - now we put the code in github.com -[3] in folder 'usbboot', here is the tar package and Debian package. - http://cloud.github.com/downloads/xiangfu/xburst-tools/xburst-tools_0.0_200906.tar.gz - http://cloud.github.com/downloads/xiangfu/xburst-tools/xburst-tools_0.0_200906-1_i386.deb -[4] http://github.com/xiangfu/qi-u-boot/tree - [master] is the last u-boot. - command: "mmc init;fatload mmc 0 0x80600000 uImage;bootm" is for boot the kernel in sd card. -[5] flash.u-boot.sh --------- -#!/bin/bash -U_BOOT=/PATH/TO/u-boot-nand.bin -sudo ../usbboot/src/usbboot -c "\ -boot;\ -nprog 0 $U_BOOT 0 0 -n" - -[6] flash.kernel.sh ----------- -#!/bin/bash -START_PAGE=2048 -KERNEL=/PATH/TO/KERNEL_UIMAGE -sudo usbboot -c "boot" -sudo usbboot -c "nprog $START_PAGE $KERNEL 0 0 -n" - diff --git a/xbboot/scripts/boot-uboot.sh b/xbboot/scripts/boot-uboot.sh new file mode 100755 index 0000000..b6d6345 --- /dev/null +++ b/xbboot/scripts/boot-uboot.sh @@ -0,0 +1,12 @@ +#!/bin/bash +../host-app/xbboot set_addr 0x80002000 +../host-app/xbboot bulk_write ../target-stage1/stage1.bin +../host-app/xbboot start1 0x80002000 +../host-app/xbboot get_info + +../host-app/xbboot flush_cache + +../host-app/xbboot set_addr 0x80100000 +../host-app/xbboot bulk_write $1 +../host-app/xbboot flush_cache +../host-app/xbboot start2 0x80100000 diff --git a/xbboot/scripts/boot-zImage.sh b/xbboot/scripts/boot-zImage.sh new file mode 100755 index 0000000..8599252 --- /dev/null +++ b/xbboot/scripts/boot-zImage.sh @@ -0,0 +1,12 @@ +#!/bin/bash +../host-app/xbboot set_addr 0x80002000 +../host-app/xbboot bulk_write ../target-stage1/stage1.bin +../host-app/xbboot start1 0x80002000 +../host-app/xbboot get_info + +../host-app/xbboot flush_cache + +../host-app/xbboot set_addr 0x80600000 +../host-app/xbboot bulk_write $1 +../host-app/xbboot flush_cache +../host-app/xbboot start2 0x80600000 From d3fd6c89544b0b0960c4b4eaf72d5b71119668ff Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Mon, 14 Dec 2009 10:43:04 +0800 Subject: [PATCH 13/13] this make the [power] + [u] usbboot mode work. --- usbboot/src/ingenic_usb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usbboot/src/ingenic_usb.c b/usbboot/src/ingenic_usb.c index e74971d..28d43d3 100644 --- a/usbboot/src/ingenic_usb.c +++ b/usbboot/src/ingenic_usb.c @@ -320,8 +320,10 @@ int usb_ingenic_upload(struct ingenic_dev *ingenic_dev, int stage) rqst = VR_PROGRAM_START2; } + usleep(100); if (usb_ingenic_start(ingenic_dev, rqst, stage_addr) < 1) return -1; + usleep(100); if (usb_get_ingenic_cpu(ingenic_dev) < 1) return -1;