From b812465bfff2111e149a44d7041c1d62d7e1519c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Fri, 18 Jun 2010 01:47:39 +0000 Subject: [PATCH] as3525: bootloader USB mode not working yet : an empty drive is detected won't link on fuzev1: drivers allocated in usb_storage.c are too large git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26905 a1c6a512-1295-4272-9138-f99709370657 --- bootloader/sansa_as3525.c | 28 +++++++++++++++++++++ firmware/export/config.h | 3 ++- firmware/target/arm/as3525/usb-drv-as3525.c | 6 +++++ firmware/usb.c | 3 ++- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/bootloader/sansa_as3525.c b/bootloader/sansa_as3525.c index 9248921eed..e63bb2c749 100644 --- a/bootloader/sansa_as3525.c +++ b/bootloader/sansa_as3525.c @@ -27,6 +27,11 @@ #include #include "config.h" #include "lcd.h" +#ifdef USE_ROCKBOX_USB +#include "usb.h" +#include "usb_core.h" +#include "sysfont.h" +#endif /* USE_ROCKBOX_USB */ #include "backlight.h" #include "button-target.h" #include "common.h" @@ -82,6 +87,29 @@ void main(void) if(ret < 0) error(EATA,ret); +#ifdef USE_ROCKBOX_USB + usb_init(); + if(usb_detect() == USB_INSERTED) + { + const char msg[] = "Bootloader USB mode"; + reset_screen(); + lcd_putsxy( (LCD_WIDTH - (SYSFONT_WIDTH * sizeof(msg))) / 2, + (LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg); + lcd_update(); + + usb_core_enable_driver(USB_DRIVER_MASS_STORAGE, true); + usb_enable(true); + + while(usb_detect() == USB_INSERTED) + sleep(HZ); + + usb_enable(false); + + reset_screen(); + lcd_update(); + } +#endif /* USE_ROCKBOX_USB */ + if(!disk_init(IF_MV(0))) panicf("disk_init failed!"); diff --git a/firmware/export/config.h b/firmware/export/config.h index 5be2c99dcb..22178e4bd4 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -916,7 +916,8 @@ Lyre prototype 1 */ #if (defined(TOSHIBA_GIGABEAT_S) || \ (defined(CREATIVE_ZVx) || \ defined(CPU_TCC77X) || defined(CPU_TCC780X))) || \ - (CONFIG_USBOTG == USBOTG_JZ4740) || defined(IPOD_NANO2G) + (CONFIG_USBOTG == USBOTG_JZ4740) || defined(IPOD_NANO2G) || \ + CONFIG_USBOTG == USBOTG_AS3525 #define USB_ENABLE_STORAGE #endif diff --git a/firmware/target/arm/as3525/usb-drv-as3525.c b/firmware/target/arm/as3525/usb-drv-as3525.c index 45dadebc85..fe3b38fdb5 100644 --- a/firmware/target/arm/as3525/usb-drv-as3525.c +++ b/firmware/target/arm/as3525/usb-drv-as3525.c @@ -684,8 +684,10 @@ int usb_drv_recv(int ep, void *ptr, int len) endpoints[ep][1].len = len; endpoints[ep][1].rc = -1; +#ifndef BOOTLOADER /* remove data buffer from cache */ invalidate_dcache(); +#endif /* DMA setup */ uc_desc->status = USB_DMA_DESC_BS_HST_RDY | USB_DMA_DESC_LAST | @@ -734,8 +736,10 @@ void ep_send(int ep, void *ptr, int len) endpoints[ep][0].len = len; endpoints[ep][0].rc = -1; +#ifndef BOOTLOADER /* Make sure data is committed to memory */ clean_dcache(); +#endif logf("xx%s\n", make_hex(ptr, len)); @@ -843,10 +847,12 @@ static void handle_out_ep(int ep) logf("EP%d OUT token, st:%08x len:%d frm:%x data=%s epstate=%d\n", ep, dma_mst, dma_len, dma_frm, make_hex(uc_desc->data_ptr, dma_len), endpoints[ep][1].state); +#ifndef BOOTLOADER /* * If parts of the just dmaed range are in cache, dump them now. */ dump_dcache_range(uc_desc->data_ptr, dma_len); +#endif } else{ logf("EP%d OUT token, st:%08x frm:%x (no data)\n", ep, dma_mst, dma_frm); diff --git a/firmware/usb.c b/firmware/usb.c index e27a3c3dc2..baf6af7d69 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -51,7 +51,8 @@ (defined(HAVE_USBSTACK) && (defined(OLYMPUS_MROBE_500))) || \ (defined(HAVE_USBSTACK) && (defined(IPOD_NANO2G))) || \ defined(CPU_TCC77X) || defined(CPU_TCC780X) || \ - (CONFIG_USBOTG == USBOTG_JZ4740) + (CONFIG_USBOTG == USBOTG_JZ4740) || \ + (defined(USE_ROCKBOX_USB) && CONFIG_USBOTG == USBOTG_AS3525) #define USB_FULL_INIT #endif