Date:2011-03-02 03:42:35 (9 years 8 months ago)
Author:Xiangfu Liu
Commit:ff3182da41eef87f6707159e6616f354a488f8b6
Message:add new command: reset, then we can reboot device after reflash

Files: usbboot/src/cmd.c (1 diff)
usbboot/src/cmd.h (1 diff)
usbboot/src/command_line.c (1 diff)
usbboot/src/ingenic_usb.c (1 diff)
usbboot/src/ingenic_usb.h (2 diffs)
usbboot/xburst_include/target/usb_boot.h (1 diff)
usbboot/xburst_stage2/boothandler.c (7 diffs)
usbboot/xburst_stage2/udc.c (1 diff)

Change Details

usbboot/src/cmd.c
962962out:
963963    return res;
964964}
965
966int device_reset(int ops)
967{
968    if (usb_ingenic_reset(&ingenic_dev, ops) < 1)
969        return -1;
970
971    return 1;
972}
usbboot/src/cmd.h
3333int debug_memory(int obj, unsigned int start, unsigned int size);
3434int debug_gpio(int obj, unsigned char ops, unsigned char pin);
3535int debug_go(void);
36int device_reset(int ops);
3637
3738#endif /* __CMD_H__ */
usbboot/src/command_line.c
204204        debug_go();
205205    else if (!strcmp("memtest", com_argv[0]))
206206        handle_memtest();
207    else if (!strcmp("reset", com_argv[0]))
208        device_reset(0);
207209    else if (!strcmp("help", com_argv[0]))
208210        handle_help();
209211    else if (!strcmp("exit", com_argv[0]))
usbboot/src/ingenic_usb.c
406406
407407    return 1;
408408}
409
410int usb_ingenic_reset(struct ingenic_dev *ingenic_dev, int ops)
411{
412    int status;
413    status = usb_control_msg(ingenic_dev->usb_handle,
414          /* bmRequestType */ USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
415          /* bRequest */ VR_RESET,
416          /* wValue */ ops,
417          /* wIndex */ 0,
418          /* Data */ 0,
419          /* wLength */ 0,
420                              USB_TIMEOUT);
421
422    if (status != 0) {
423        fprintf(stderr, "Error - "
424            "reset XBurst device: %i\n", status);
425        return -1;
426    }
427
428    return 1;
429}
usbboot/src/ingenic_usb.h
3535#define VR_NAND_OPS 0x07
3636#define VR_SDRAM_OPS 0x08
3737#define VR_CONFIGRATION 0x09
38#define VR_GET_NUM 0x0a
38#define VR_RESET 0x0a
3939
4040#define JZ4740V1 1
4141#define JZ4750V1 2
...... 
7777                    int len);
7878int usb_ingenic_nand_ops(struct ingenic_dev *ingenic_dev, int ops);
7979int usb_read_data_from_ingenic(struct ingenic_dev *ingenic_dev,unsigned char *buff, unsigned int len);
80int usb_ingenic_reset(struct ingenic_dev *ingenic_dev, int ops);
8081
8182#endif /* __INGENIC_USB_H__ */
usbboot/xburst_include/target/usb_boot.h
4444    VR_NAND_OPS,
4545    VR_SDRAM_OPS,
4646    VR_CONFIGRATION,
47    VR_OTHER
47    VR_RESET
4848};
4949
5050#endif /* __USB_BOOT_H__ */
usbboot/xburst_stage2/boothandler.c
5151extern void *memcpy(void *dest, const void *src, size_t count);
5252
5353u32 ret_dat;
54u32 start_addr; //program operation start address or sector
55u32 ops_length; //number of operation unit ,in byte or sector
54u32 start_addr; /* program operation start address or sector */
55u32 ops_length; /* number of operation unit ,in byte or sector */
5656u32 ram_addr;
5757
5858void dump_data(unsigned int *p, int size)
...... 
117117{
118118    USB_DeviceRequest *dreq = (USB_DeviceRequest *)buf;
119119    ram_addr=(((u32)dreq->wValue)<<16)+(u32)dreq->wIndex;
120    //dprintf("\n RAM ADDRESS :%x", ram_addr);
121120    return ERR_OK;
122121}
123122
...... 
127126    USB_DeviceRequest *dreq = (USB_DeviceRequest *)buf;
128127    f=(void *) ((((u32)dreq->wValue)<<16)+(u32)dreq->wIndex);
129128    __dcache_writeback_all();
130    //stop udc connet before execute program!
131    jz_writeb(USB_REG_POWER,0x0); //High speed
132    //dprintf("\n Execute program at %x",(u32)f);
129    /* stop udc connet before execute program! */
130    jz_writeb(USB_REG_POWER,0x0); /* High speed */
131
133132    f();
134133    return ERR_OK;
135134}
...... 
273272    switch ((dreq->wValue)&0xf)
274273    {
275274    case SDRAM_LOAD:
276        //dprintf("\n Request : SDRAM_LOAD!");
277275        ret_dat = (u32)memcpy((u8 *)start_addr,Bulk_out_buf,ops_length);
278276        handshake_PKT[0] = (u16) ret_dat;
279277        handshake_PKT[1] = (u16) (ret_dat>>16);
...... 
291289    switch (Hand.fw_args.cpu_id)
292290    {
293291    case 0x4740:
294        //Init nand flash
295292        nand_init_4740(Hand.nand_bw, Hand.nand_rc, Hand.nand_ps,
296293                   Hand.nand_ppb, Hand.nand_bbpage, Hand.nand_bbpos,
297294                   Hand.nand_force_erase, Hand.nand_eccpos);
...... 
307304        nand_mark_bad = nand_mark_bad_4740;
308305        break;
309306    case 0x4760:
310        //Init nand flash
311307        nand_init_4760(Hand.nand_bw, Hand.nand_rc, Hand.nand_ps,
312308                   Hand.nand_ppb, Hand.nand_bchbit, Hand.nand_eccpos,
313309                   Hand.nand_bbpos, Hand.nand_bbpage, Hand.nand_force_erase);
...... 
351347}
352348
353349
350int RESET_Handle(u8 *buf)
351{
352    dprintf("\n RESET Device");
353    __wdt_select_extalclk();
354    __wdt_select_clk_div64();
355    __wdt_set_data(100);
356    __wdt_set_count(0);
357    __tcu_start_wdt_clock();
358    __wdt_start();
359    while(1);
360}
usbboot/xburst_stage2/udc.c
418418        SDRAM_OPS_Handle(buf);
419419        Bulk_out_size = 0;
420420        break;
421    case VR_RESET:
422        ret_state = RESET_Handle(buf);
423        break;
421424    }
422425}
423426

Archive Download the corresponding diff file



interactive