introduce Rockchip rockusb
v2 cover introduce Rockchip rockusb
rockusb is a protocol run between host pc and device. it help people get device info, flash image to device. this patch implement rockusb on device side
Eddie Cai (8):
usb: ums: split macro and data struct in f_mass_storage.c
usb: ums: merge storage_common.c into f_mass_storage.c
usb: ums: remove static declaration of some ums functions
usb: ums: add functions to set and get usb interface descriptor
usb: ums: add do_extra_command
cmd: add rockusb command
rockchip: config: enable rockusb support on rk3288 based board
rockusb: add a simple readme
cmd/Kconfig | 5 + cmd/Makefile | 1 + cmd/rockusb.c | 383 ++++++++++++++++++++++++++++++++++++ configs/evb-rk3288_defconfig | 2 + configs/fennec-rk3288_defconfig | 1 + configs/firefly-rk3288_defconfig | 1 + configs/miqi-rk3288_defconfig | 1 + configs/popmetal-rk3288_defconfig | 1 + configs/rock2_defconfig | 2 + configs/sandbox_defconfig | 1 + configs/tinker-rk3288_defconfig | 1 + doc/README.rockusb | 35 ++++ drivers/usb/gadget/f_mass_storage.c | 356 ++++++++++++++++++++++----------- drivers/usb/gadget/storage_common.c | 238 ---------------------- include/f_mass_storage.h | 117 +++++++++++ 15 files changed, 797 insertions(+), 348 deletions(-) create mode 100644 cmd/rockusb.c create mode 100644 doc/README.rockusb delete mode 100644 drivers/usb/gadget/storage_common.c
Signature · 1 line
2.10.2
PATCH v2 1/8 usb: ums: split macro and data struct in f_mass_storage.c
split the macro and data struct in f_mass_storage.c to f_mass_storage.h
--- drivers/usb/gadget/f_mass_storage.c | 108 --------------------------------- include/f_mass_storage.h | 116 ++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 108 deletions(-)
drivers/usb/gadget/f_mass_storage.c +0 -108
@@ -274,15 +274,6 @@ static const char fsg_string_interface[] = "Mass Storage";/*-------------------------------------------------------------------------*/ -#define GFP_ATOMIC ((gfp_t) 0) -#define PAGE_CACHE_SHIFT 12 -#define PAGE_CACHE_SIZE (1 << PAGE_CACHE_SHIFT) -#define kthread_create (...) __builtin_return_address(0) -#define wait_for_completion (...) do {} while (0) - -struct kref {int x; }; -struct completion {int x; }; -inline void set_bit (int nr,volatile void *addr) {int mask;
@@ -303,105 +294,6 @@ inline void clear_bit(int nr, volatile void *addr) *a &= ~mask; } -struct fsg_dev ; -struct fsg_common ; - -/* Data shared by all the FSG instances. */ -struct fsg_common { -struct usb_gadget *gadget; -struct fsg_dev *fsg, *new_fsg; - -struct usb_ep *ep0;/* Copy of gadget->ep0 */ -struct usb_request *ep0req;/* Copy of cdev->req */ -unsigned int ep0_req_tag; - -struct fsg_buffhd *next_buffhd_to_fill; -struct fsg_buffhd *next_buffhd_to_drain; -struct fsg_buffhd buffhds[FSG_NUM_BUFFERS ]; - -int cmnd_size; -u8 cmnd[MAX_COMMAND_SIZE ]; - -unsigned int nluns; -unsigned int lun; -struct fsg_lun luns[FSG_MAX_LUNS ]; - -unsigned int bulk_out_maxpacket; -enum fsg_state state;/* For exception handling */ -unsigned int exception_req_tag; - -enum data_direction data_dir; -u32 data_size; -u32 data_size_from_cmnd; -u32 tag; -u32 residue; -u32 usb_amount_left; - -unsigned int can_stall:1 ; -unsigned int free_storage_on_release:1 ; -unsigned int phase_error:1 ; -unsigned int short_packet_received:1 ; -unsigned int bad_lun_okay:1 ; -unsigned int running:1 ; - -int thread_wakeup_needed; -struct completion thread_notifier; -struct task_struct *thread_task; - -/* Callback functions. */ -const struct fsg_operations *ops; -/* Gadget's private data. */ -void *private_data; - -const char *vendor_name;/* 8 characters or less */ -const char *product_name;/* 16 characters or less */ -u16 release; - -/* Vendor (8 chars), product (16 chars), release (4 -* hexadecimal digits) and NUL byte */ -char inquiry_string[8 +16 +4 +1 ]; - -struct kref ref; -}; - -struct fsg_config { -unsigned nluns; -struct fsg_lun_config { -const char *filename; -char ro; -char removable; -char cdrom; -char nofua; - } luns[FSG_MAX_LUNS ]; - -/* Callback functions. */ -const struct fsg_operations *ops; -/* Gadget's private data. */ -void *private_data; - -const char *vendor_name;/* 8 characters or less */ -const char *product_name;/* 16 characters or less */ - -char can_stall; -}; - -struct fsg_dev { -struct usb_function function; -struct usb_gadget *gadget;/* Copy of cdev->gadget */ -struct fsg_common *common; - -u16 interface_number; - -unsigned int bulk_in_enabled:1 ; -unsigned int bulk_out_enabled:1 ; - -unsigned long atomic_bitflags; -#define IGNORE_BULK_OUT 0 - -struct usb_ep *bulk_in; -struct usb_ep *bulk_out; -}; -static inline int __fsg_is_set (struct fsg_common *common,const char *func,unsigned line)
include/f_mass_storage.h +116 -0
120 lines not on this page · raw message
Signature · 1 line
2.10.2
PATCH v2 1/8 usb: ums: split macro and data struct in f_mass_storage.c
Hi Eddie
Please add a cover letter that describe your changes. Comments follow
Quoted 139 lines · Eddie Cai
split the macro and data struct in
f_mass_storage.ctof_mass_storage.hSigned-off-by Eddie Cai <[email protected]>--- drivers/usb/gadget/f_mass_storage.c | 108 --------------------------------- include/f_mass_storage.h | 116 ++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 108 deletions(-)drivers/usb/gadget/f_mass_storage.c +0
-108@@ -274,15 +274,6 @@ static const char fsg_string_interface[] = "Mass Storage";/*-------------------------------------------------------------------------*/ -#define GFP_ATOMIC ((gfp_t) 0) -#define PAGE_CACHE_SHIFT 12 -#define PAGE_CACHE_SIZE (1 << PAGE_CACHE_SHIFT) -#define kthread_create (...) __builtin_return_address(0) -#define wait_for_completion (...) do {} while (0) - -struct kref {int x; }; -struct completion {int x; }; -inline void set_bit (int nr,volatile void *addr) {int mask;@@ -303,105 +294,6 @@ inline void clear_bit(int nr, volatile void *addr) *a &= ~mask; } -struct fsg_dev ; -struct fsg_common ; - -/* Data shared by all the FSG instances. */ -struct fsg_common { -struct usb_gadget *gadget; -struct fsg_dev *fsg, *new_fsg; - -struct usb_ep *ep0;/* Copy of gadget->ep0 */ -struct usb_request *ep0req;/* Copy of cdev->req */ -unsigned int ep0_req_tag; - -struct fsg_buffhd *next_buffhd_to_fill; -struct fsg_buffhd *next_buffhd_to_drain; -struct fsg_buffhd buffhds[FSG_NUM_BUFFERS ]; - -int cmnd_size; -u8 cmnd[MAX_COMMAND_SIZE ]; - -unsigned int nluns; -unsigned int lun; -struct fsg_lun luns[FSG_MAX_LUNS ]; - -unsigned int bulk_out_maxpacket; -enum fsg_state state;/* For exception handling */ -unsigned int exception_req_tag; - -enum data_direction data_dir; -u32 data_size; -u32 data_size_from_cmnd; -u32 tag; -u32 residue; -u32 usb_amount_left; - -unsigned int can_stall:1 ; -unsigned int free_storage_on_release:1 ; -unsigned int phase_error:1 ; -unsigned int short_packet_received:1 ; -unsigned int bad_lun_okay:1 ; -unsigned int running:1 ; - -int thread_wakeup_needed; -struct completion thread_notifier; -struct task_struct *thread_task; - -/* Callback functions. */ -const struct fsg_operations *ops; -/* Gadget's private data. */ -void *private_data; - -const char *vendor_name;/* 8 characters or less */ -const char *product_name;/* 16 characters or less */ -u16 release; - -/* Vendor (8 chars), product (16 chars), release (4 -* hexadecimal digits) and NUL byte */ -char inquiry_string[8 +16 +4 +1 ]; - -struct kref ref; -}; - -struct fsg_config { -unsigned nluns; -struct fsg_lun_config { -const char *filename; -char ro; -char removable; -char cdrom; -char nofua; - } luns[FSG_MAX_LUNS ]; - -/* Callback functions. */ -const struct fsg_operations *ops; -/* Gadget's private data. */ -void *private_data; - -const char *vendor_name;/* 8 characters or less */ -const char *product_name;/* 16 characters or less */ - -char can_stall; -}; - -struct fsg_dev { -struct usb_function function; -struct usb_gadget *gadget;/* Copy of cdev->gadget */ -struct fsg_common *common; - -u16 interface_number; - -unsigned int bulk_in_enabled:1 ; -unsigned int bulk_out_enabled:1 ; - -unsigned long atomic_bitflags; -#define IGNORE_BULK_OUT 0 - -struct usb_ep *bulk_in; -struct usb_ep *bulk_out; -}; -static inline int __fsg_is_set (struct fsg_common *common,const char *func,unsigned line)include/f_mass_storage.h +0
-0
include/f_mass_storage.h fsg_otg_desc = { · line 396
Quoted 7 lines
include/f_mass_storage.h +4
-0@@ -390,4 +390,120 @@ fsg_otg_desc = { };#endif + + + +
Remove empty lines
include/f_mass_storage.h fsg_otg_desc = { · line 406
Quoted 10 lines
include/f_mass_storage.h +10
-0+#define GFP_ATOMIC ((gfp_t) 0) +#define PAGE_CACHE_SHIFT 12 +#define PAGE_CACHE_SIZE (1 << PAGE_CACHE_SHIFT) +#define kthread_create (...) __builtin_return_address(0) +#define wait_for_completion (...) do {} while (0) + +struct kref {int x; }; +struct completion {int x; }; + +
ditto
Quoted 93 lines
include/f_mass_storage.h +93
-0+struct fsg_dev ; +struct fsg_common ; + +/* Data shared by all the FSG instances. */ +struct fsg_common { +struct usb_gadget *gadget; +struct fsg_dev *fsg, *new_fsg; + +struct usb_ep *ep0;/* Copy of gadget->ep0 */ +struct usb_request *ep0req;/* Copy of cdev->req */ +unsigned int ep0_req_tag; + +struct fsg_buffhd *next_buffhd_to_fill; +struct fsg_buffhd *next_buffhd_to_drain; +struct fsg_buffhd buffhds[FSG_NUM_BUFFERS ]; + +int cmnd_size; +u8 cmnd[MAX_COMMAND_SIZE ]; + +unsigned int nluns; +unsigned int lun; +struct fsg_lun luns[FSG_MAX_LUNS ]; + +unsigned int bulk_out_maxpacket; +enum fsg_state state;/* For exception handling */ +unsigned int exception_req_tag; + +enum data_direction data_dir; +u32 data_size; +u32 data_size_from_cmnd; +u32 tag; +u32 residue; +u32 usb_amount_left; + +unsigned int can_stall:1 ; +unsigned int free_storage_on_release:1 ; +unsigned int phase_error:1 ; +unsigned int short_packet_received:1 ; +unsigned int bad_lun_okay:1 ; +unsigned int running:1 ; + +int thread_wakeup_needed; +struct completion thread_notifier; +struct task_struct *thread_task; + +/* Callback functions. */ +const struct fsg_operations *ops; +/* Gadget's private data. */ +void *private_data; + +const char *vendor_name;/* 8 characters or less */ +const char *product_name;/* 16 characters or less */ +u16 release; + +/* Vendor (8 chars), product (16 chars), release (4 +* hexadecimal digits) and NUL byte */ +char inquiry_string[8 +16 +4 +1 ]; + +struct kref ref; +}; + +struct fsg_config { +unsigned nluns; +struct fsg_lun_config { +const char *filename; +char ro; +char removable; +char cdrom; +char nofua; + } luns[FSG_MAX_LUNS ]; + +/* Callback functions. */ +const struct fsg_operations *ops; +/* Gadget's private data. */ +void *private_data; + +const char *vendor_name;/* 8 characters or less */ +const char *product_name;/* 16 characters or less */ + +char can_stall; +}; + +struct fsg_dev { +struct usb_function function; +struct usb_gadget *gadget;/* Copy of cdev->gadget */ +struct fsg_common *common; + +u16 interface_number; + +unsigned int bulk_in_enabled:1 ; +unsigned int bulk_out_enabled:1 ; + +unsigned long atomic_bitflags;
include/f_mass_storage.h fsg_otg_desc = { · line 509
Quoted 10 lines
include/f_mass_storage.h +9
-0+#define IGNORE_BULK_OUT 0 + +struct usb_ep *bulk_in; + struct usb_ep *bulk_out; +}; +#endif /* __F_MASS_STORAGE_H_ */ + + +
ditto
Michael
Quoted 7 lines
--
2.10.2_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
Signature · 4 lines
| Michael Nazzareno Trimarchi Amarula Solutions BV | | COO - Founder Cruquiuskade 47 | | +31(0)851119172 Amsterdam 1018 AM NL | | [`as] http://www.amarulasolutions.com |
PATCH v2 2/8 usb: ums: merge storage_common.c into f_mass_storage.c
In reply to Eddie Caistorage_common.c is only used by f_mass_storage. so merge it.
--- drivers/usb/gadget/f_mass_storage.c | 222 ++++++++++++++++++++++++++++++++- drivers/usb/gadget/storage_common.c | 238 ------------------------------------ 2 files changed, 221 insertions(+), 239 deletions(-) delete mode 100644 drivers/usb/gadget/storage_common.c
drivers/usb/gadget/f_mass_storage.c +221 -1
@@ -270,7 +270,227 @@ static const char fsg_string_interface[] = "Mass Storage";#define FSG_NO_OTG 1#define FSG_NO_INTR_EP 1 -#include "storage_common.c" +#include <f_mass_storage.h> + +/* There is only one interface. */ + +static struct usb_interface_descriptor +fsg_intf_desc = { + .bLength =sizeof (fsg_intf_desc), + .bDescriptorType =USB_DT_INTERFACE , + + .bNumEndpoints =2 ,/* Adjusted during fsg_bind() */ + .bInterfaceClass =USB_CLASS_MASS_STORAGE , + .bInterfaceSubClass =USB_SC_SCSI ,/* Adjusted during fsg_bind() */ + .bInterfaceProtocol =USB_PR_BULK ,/* Adjusted during fsg_bind() */ + .iInterface =FSG_STRING_INTERFACE , +}; + +/* +* Three full-speed endpoint descriptors: bulk-in, bulk-out, and +* interrupt-in. +*/ + +static struct usb_endpoint_descriptor +fsg_fs_bulk_in_desc = { + .bLength =USB_DT_ENDPOINT_SIZE , + .bDescriptorType =USB_DT_ENDPOINT , + + .bEndpointAddress =USB_DIR_IN , + .bmAttributes =USB_ENDPOINT_XFER_BULK , +/* wMaxPacketSize set by autoconfiguration */ +}; + +static struct usb_endpoint_descriptor +fsg_fs_bulk_out_desc = { + .bLength =USB_DT_ENDPOINT_SIZE , + .bDescriptorType =USB_DT_ENDPOINT , + + .bEndpointAddress =USB_DIR_OUT , + .bmAttributes =USB_ENDPOINT_XFER_BULK , +/* wMaxPacketSize set by autoconfiguration */ +}; + +#ifndef FSG_NO_INTR_EP + +static struct usb_endpoint_descriptor +fsg_fs_intr_in_desc = { + .bLength =USB_DT_ENDPOINT_SIZE , + .bDescriptorType =USB_DT_ENDPOINT , + + .bEndpointAddress =USB_DIR_IN , + .bmAttributes =USB_ENDPOINT_XFER_INT , + .wMaxPacketSize =cpu_to_le16 (2 ), + .bInterval =32 ,/* frames -> 32 ms */ +}; + +#ifndef FSG_NO_OTG +# define FSG_FS_FUNCTION_PRE_EP_ENTRIES 2 +#else +# define FSG_FS_FUNCTION_PRE_EP_ENTRIES 1 +#endif + +#endif + +static struct usb_descriptor_header *fsg_fs_function[] = { +#ifndef FSG_NO_OTG + (struct usb_descriptor_header *)&fsg_otg_desc, +#endif + (struct usb_descriptor_header *)&fsg_intf_desc, + (struct usb_descriptor_header *)&fsg_fs_bulk_in_desc, + (struct usb_descriptor_header *)&fsg_fs_bulk_out_desc, +#ifndef FSG_NO_INTR_EP + (struct usb_descriptor_header *)&fsg_fs_intr_in_desc, +#endif +NULL , +}; + +/* +* USB 2.0 devices need to expose both high speed and full speed +* descriptors, unless they only run at full speed. +* +* That means alternate endpoint descriptors (bigger packets) +* and a "device qualifier" ... plus more construction options +* for the configuration descriptor. +*/ +static struct usb_endpoint_descriptor +fsg_hs_bulk_in_desc = { + .bLength =USB_DT_ENDPOINT_SIZE , + .bDescriptorType =USB_DT_ENDPOINT , + +/* bEndpointAddress copied from fs_bulk_in_desc during fsg_bind() */ + .bmAttributes =USB_ENDPOINT_XFER_BULK , + .wMaxPacketSize =cpu_to_le16 (512 ), +}; + +static struct usb_endpoint_descriptor +fsg_hs_bulk_out_desc = { + .bLength =USB_DT_ENDPOINT_SIZE , + .bDescriptorType =USB_DT_ENDPOINT , + +/* bEndpointAddress copied from fs_bulk_out_desc during fsg_bind() */ + .bmAttributes =USB_ENDPOINT_XFER_BULK , + .wMaxPacketSize =cpu_to_le16 (512 ), + .bInterval =1 ,/* NAK every 1 uframe */ +}; + +#ifndef FSG_NO_INTR_EP + +static struct usb_endpoint_descriptor +fsg_hs_intr_in_desc = { + .bLength =USB_DT_ENDPOINT_SIZE , + .bDescriptorType =USB_DT_ENDPOINT , + +/* bEndpointAddress copied from fs_intr_in_desc during fsg_bind() */ + .bmAttributes =USB_ENDPOINT_XFER_INT , + .wMaxPacketSize =cpu_to_le16 (2 ), + .bInterval =9 ,/* 2**(9-1) = 256 uframes -> 32 ms */ +}; + +#ifndef FSG_NO_OTG +# define FSG_HS_FUNCTION_PRE_EP_ENTRIES 2 +#else +# define FSG_HS_FUNCTION_PRE_EP_ENTRIES 1 +#endif + +#endif + +static struct usb_descriptor_header *fsg_hs_function[] = { +#ifndef FSG_NO_OTG + (struct usb_descriptor_header *)&fsg_otg_desc, +#endif + (struct usb_descriptor_header *)&fsg_intf_desc, + (struct usb_descriptor_header *)&fsg_hs_bulk_in_desc, + (struct usb_descriptor_header *)&fsg_hs_bulk_out_desc, +#ifndef FSG_NO_INTR_EP + (struct usb_descriptor_header *)&fsg_hs_intr_in_desc, +#endif +NULL , +}; + +/* Maxpacket and other transfer characteristics vary by speed. */ +static struct usb_endpoint_descriptor *fsg_ep_desc ( +struct usb_gadget *g, +struct usb_endpoint_descriptor *fs, +struct usb_endpoint_descriptor *hs) +{ +if (gadget_is_dualspeed (g) && g->speed ==USB_SPEED_HIGH ) +return hs; +return fs; +} + +/* Static strings, in UTF-8 (for simplicity we use only ASCII characters) */ +static struct usb_string fsg_strings[] = { +#ifndef FSG_NO_DEVICE_STRINGS + {FSG_STRING_MANUFACTURER, fsg_string_manufacturer}, + {FSG_STRING_PRODUCT, fsg_string_product}, + {FSG_STRING_SERIAL, fsg_string_serial}, + {FSG_STRING_CONFIG, fsg_string_config}, +#endif + {FSG_STRING_INTERFACE, fsg_string_interface}, + {} +}; + +static struct usb_gadget_strings fsg_stringtab = { + .language = 0x0409, /* en-us */ + .strings = fsg_strings, +}; + +/*-------------------------------------------------------------------------*/ + +/* + * If the next two routines are called while the gadget is registered, + * the caller must own fsg->filesem for writing. + */ + +static int fsg_lun_open(struct fsg_lun *curlun, unsigned int num_sectors, + const char *filename) +{ + int ro; + + /* R/W if we can, R/O if we must */ + ro = curlun->initially_ro; + + curlun->ro = ro; + curlun->file_length = num_sectors << 9; + curlun->num_sectors = num_sectors; + debug("open backing file: %s\n", filename); + + return 0; +} + +static void fsg_lun_close(struct fsg_lun *curlun) +{ +} + +/*-------------------------------------------------------------------------*/ + +/* + * Sync the file data, don't bother with the metadata. + * This code was copied from fs/buffer.c:sys_fdatasync(). + */ +static int fsg_lun_fsync_sub(struct fsg_lun *curlun) +{ + return 0; +} + +static void store_cdrom_address(u8 *dest, int msf, u32 addr) +{ + if (msf) { + /* Convert to Minutes-Seconds-Frames */ + addr >>= 2; /* Convert to 2048-byte frames */ + addr += 2*75; /* Lead-in occupies 2 seconds */ + dest[3] = addr % 75; /* Frames */ + addr /= 75; + dest[2] = addr % 60; /* Seconds */ + addr /= 60; + dest[1] = addr; /* Minutes */ + dest[0] = 0; /* Reserved */ + } else { + /* Absolute sector */ + put_unaligned_be32(addr, dest); + } +} /*-------------------------------------------------------------------------*/
drivers/usb/gadget/storage_common.c deleted +0 -238
238 lines not on this page · raw message
Signature · 1 line
2.10.2
PATCH v2 3/8 usb: ums: remove static declaration of some ums functions
In reply to Eddie Cairemove static declaration of some functions. so these functions can be called by other module
--- drivers/usb/gadget/f_mass_storage.c | 4 ++-- include/f_mass_storage.h | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/usb/gadget/f_mass_storage.c +2 -2
@@ -775,7 +775,7 @@ static void busy_indicator(void) state =0 ; } -static int sleep_thread (struct fsg_common *common) +int sleep_thread (struct fsg_common *common) {int rc =0 ;int i =0 , k =0 ;
@@ -1899,7 +1899,7 @@ static int check_command(struct fsg_common *common, int cmnd_size, } -static int do_scsi_command (struct fsg_common *common) +int do_scsi_command (struct fsg_common *common) {struct fsg_buffhd *bh;int rc;
include/f_mass_storage.h +3 -4
@@ -391,9 +391,6 @@ fsg_otg_desc = {#endif - - -#define GFP_ATOMIC ((gfp_t) 0)#define PAGE_CACHE_SHIFT 12#define PAGE_CACHE_SIZE (1 << PAGE_CACHE_SHIFT)
@@ -503,7 +500,9 @@ struct fsg_dev { struct usb_ep *bulk_out; }; -#endif /* __F_MASS_STORAGE_H_ */ +int sleep_thread (struct fsg_common *common); +int do_scsi_command (struct fsg_common *common); +#endif /* __F_MASS_STORAGE_H_ */
Signature · 1 line
2.10.2
PATCH v2 4/8 usb: ums: add functions to set and get usb interface descriptor
In reply to Eddie Caiadd functions to set and get usb interface descriptor, so people can customize usb interface descriptor
--- drivers/usb/gadget/f_mass_storage.c | 18 ++++++++++++++++++ include/f_mass_storage.h | 2 ++ 2 files changed, 20 insertions(+)
drivers/usb/gadget/f_mass_storage.c +18 -0
@@ -2870,6 +2870,24 @@ static int fsg_bind_config(struct usb_composite_dev *cdev,return rc; } +struct usb_interface_descriptor *fsg_get_usb_interface_descriptor (void ) +{ +return &fsg_intf_desc; +} + +void fsg_set_usb_interface_descriptor (struct usb_interface_descriptor *desc) +{ +if (desc) { + fsg_intf_desc.bLength = desc->bLength; + fsg_intf_desc.bDescriptorType = desc->bDescriptorType; + fsg_intf_desc.bNumEndpoints = desc->bNumEndpoints; + fsg_intf_desc.bInterfaceClass = desc->bInterfaceClass; + fsg_intf_desc.bInterfaceSubClass = desc->bInterfaceSubClass; + fsg_intf_desc.bInterfaceProtocol = desc->bInterfaceProtocol; + fsg_intf_desc.iInterface = desc->iInterface; + } +} +int fsg_add (struct usb_configuration *c) {struct fsg_common *fsg_common;
include/f_mass_storage.h +2 -0
@@ -500,6 +500,8 @@ struct fsg_dev {struct usb_ep *bulk_out; }; +struct usb_interface_descriptor *fsg_get_usb_interface_descriptor (void ); +void fsg_set_usb_interface_descriptor (struct usb_interface_descriptor *desc);int sleep_thread (struct fsg_common *common);int do_scsi_command (struct fsg_common *common);
Signature · 1 line
2.10.2
PATCH v2 5/8 usb: ums: add do_extra_command
In reply to Eddie Caiadd do_extra_command to let people deal with customized command
--- drivers/usb/gadget/f_mass_storage.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/gadget/f_mass_storage.c +7 -1
@@ -2168,6 +2168,10 @@ unknown_cmnd:return 0 ; } +int __weak do_extra_command (struct fsg_common *common) +{ +return -EINVAL ; +}/*-------------------------------------------------------------------------*/ static int received_cbw (struct fsg_dev *fsg,struct fsg_buffhd *bh)
@@ -2540,8 +2544,10 @@ int fsg_main_thread(void *common_)if (!exception_in_progress (common)) common->state =FSG_STATE_DATA_PHASE ; -if (do_scsi_command (common) ||finish_reply (common)) +if ((do_extra_command (common) &&do_scsi_command (common)) || +finish_reply (common)) {continue ; + }if (!exception_in_progress (common)) common->state =FSG_STATE_STATUS_PHASE ;
Signature · 1 line
2.10.2
PATCH v2 6/8 cmd: add rockusb command
In reply to Eddie Caithis patch add rockusb command. the usage is rockusb <USB_controller> [<devtype>] <devnum> e.g. rockusb 0 mmc 0
--- cmd/Kconfig | 5 + cmd/Makefile | 1 + cmd/rockusb.c | 383 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 389 insertions(+) create mode 100644 cmd/rockusb.c
cmd/Kconfig +5 -0
@@ -509,6 +509,11 @@ config CMD_DFU Enables the command "dfu" which is used to have U-Boot create a DFU class device via USB. +config CMD_ROCKUSB + bool "rockusb" + help + enables the rockusb command. + config CMD_USB_MASS_STORAGE bool "UMS usb mass storage" help
cmd/Makefile +1 -0
@@ -112,6 +112,7 @@ obj-$(CONFIG_CMD_READ) += read.o obj-$(CONFIG_CMD_REGINFO) += reginfo.o obj-$(CONFIG_CMD_REISER) += reiser.o obj-$(CONFIG_CMD_REMOTEPROC) += remoteproc.o +obj-$(CONFIG_CMD_ROCKUSB) += rockusb.o obj-$(CONFIG_SANDBOX) += host.o obj-$(CONFIG_CMD_SATA) += sata.o obj-$(CONFIG_CMD_SF) += sf.o
cmd/rockusb.c new file +383 -0
383 lines not on this page · raw message
Signature · 1 line
2.10.2
PATCH v2 7/8 rockchip: config: enable rockusb support on rk3288 based board
In reply to Eddie Caiall rk3288 based boards support rockusb, so enable it
--- configs/evb-rk3288_defconfig | 2 ++ configs/fennec-rk3288_defconfig | 1 + configs/firefly-rk3288_defconfig | 1 + configs/miqi-rk3288_defconfig | 1 + configs/popmetal-rk3288_defconfig | 1 + configs/rock2_defconfig | 2 ++ configs/sandbox_defconfig | 1 + configs/tinker-rk3288_defconfig | 1 + 8 files changed, 10 insertions(+)
configs/evb-rk3288_defconfig +2 -0
@@ -17,6 +17,8 @@ CONFIG_CMD_MMC=y CONFIG_CMD_SF=y CONFIG_CMD_SPI=y CONFIG_CMD_I2C=y +CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y CONFIG_CMD_GPIO=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_CACHE=y
configs/fennec-rk3288_defconfig +1 -0
@@ -18,6 +18,7 @@ CONFIG_CMD_SF=y CONFIG_CMD_SPI=y CONFIG_CMD_I2C=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y CONFIG_CMD_GPIO=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_CACHE=y
configs/firefly-rk3288_defconfig +1 -0
@@ -17,6 +17,7 @@ CONFIG_CMD_SF=y CONFIG_CMD_SPI=y CONFIG_CMD_I2C=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y CONFIG_CMD_GPIO=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_CACHE=y
configs/miqi-rk3288_defconfig +1 -0
@@ -17,6 +17,7 @@ CONFIG_CMD_SF=y CONFIG_CMD_SPI=y CONFIG_CMD_I2C=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y CONFIG_CMD_GPIO=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_CACHE=y
configs/popmetal-rk3288_defconfig +1 -0
@@ -18,6 +18,7 @@ CONFIG_CMD_SF=y CONFIG_CMD_SPI=y CONFIG_CMD_I2C=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y CONFIG_CMD_GPIO=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_CACHE=y
configs/rock2_defconfig +2 -0
@@ -16,6 +16,8 @@ CONFIG_CMD_MMC=y CONFIG_CMD_SF=y CONFIG_CMD_SPI=y CONFIG_CMD_I2C=y +CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y CONFIG_CMD_GPIO=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_CACHE=y
configs/sandbox_defconfig +1 -0
@@ -33,6 +33,7 @@ CONFIG_CMD_SF=y CONFIG_CMD_SPI=y CONFIG_CMD_I2C=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y CONFIG_CMD_REMOTEPROC=y CONFIG_CMD_GPIO=y CONFIG_CMD_TFTPPUT=y
configs/tinker-rk3288_defconfig +1 -0
@@ -18,6 +18,7 @@ CONFIG_CMD_SF=y CONFIG_CMD_SPI=y CONFIG_CMD_I2C=y CONFIG_CMD_USB=y +CONFIG_CMD_ROCKUSB=y CONFIG_CMD_GPIO=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_CACHE=y
Signature · 1 line
2.10.2
PATCH v2 8/8 rockusb: add a simple readme
In reply to Eddie Caiadd a simple readme to introduce rockusb and tell people how to use it
--- doc/README.rockusb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 doc/README.rockusb
doc/README.rockusb new file +35 -0
@@ -0,0 +1,35 @@ +Rockusb (Rockchip USB protocol) +===================================================== + +Overview +-------- + +Rockusb protocol is widely used with Rockchip devices. +It can read/write info, image to/from devices. This +document briefly describes how to use Rockusb for upgrading +firmware (e.g. kernel, u-boot, rootfs, etc.). + +Tools +-------- +There are many tools can support Rockusb protocol. rkdeveloptool +is open source, It is maintained by Rockchip. + +Usage +-------- +The Usage of Rockusb command is +rockusb <USB_controller> [<devtype>] <devnum> +e.g. rockusb 0 mmc 0 +rockusb 0 usb 0 +On your U-Boot console, type this command to enter rockusb mode. +On your host PC. use lsusb command. you should see a usb device +using 0x2207 as its USB verdor id. Then use rkdeveloptool +sudo rkdeveloptool wl <BeginSec> <File> +to flash U-Boot image use command +sudo rkdeveloptool wl 64 <U-Boot binary> +There are plenty of Rockusb command. but wl(write lba) and +rd(reboot) command. These two command can let people flash +image to device. + +To do +----- +* Fully support Rockusb protocol
Signature · 1 line
2.10.2
v2 cover introduce Rockchip rockusb
In reply to Eddie CaiHi
Quoted 13 lines · Eddie Cai
rockusb is a protocol run between host pc and device. it help people get device info, flash image to device. this patch implement rockusb on device side
Eddie Cai (8):
usb: ums: split macro and data struct inf_mass_storage.c
usb: ums: mergestorage_common.cintof_mass_storage.c
usb: ums: remove static declaration of some ums functions
usb: ums: add functions to set and get usb interface descriptor
usb: ums: adddo_extra_command
cmd: add rockusb command
rockchip: config: enable rockusb support on rk3288 based board
rockusb: add a simple readme
Sorry cover email arrive now ;)
Michael
Quoted 27 lines
cmd/Kconfig | 5 + cmd/Makefile | 1 + cmd/rockusb.c | 383 ++++++++++++++++++++++++++++++++++++ configs/evb-rk3288_defconfig | 2 + configs/fennec-rk3288_defconfig | 1 + configs/firefly-rk3288_defconfig | 1 + configs/miqi-rk3288_defconfig | 1 + configs/popmetal-rk3288_defconfig | 1 + configs/rock2_defconfig | 2 + configs/sandbox_defconfig | 1 + configs/tinker-rk3288_defconfig | 1 + doc/README.rockusb | 35 ++++ drivers/usb/gadget/f_mass_storage.c | 356 ++++++++++++++++++++++----------- drivers/usb/gadget/storage_common.c | 238 ---------------------- include/f_mass_storage.h | 117 +++++++++++ 15 files changed, 797 insertions(+), 348 deletions(-) create mode 100644 cmd/rockusb.c create mode 100644 doc/README.rockusb delete mode 100644 drivers/usb/gadget/storage_common.c--
2.10.2_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
Signature · 4 lines
| Michael Nazzareno Trimarchi Amarula Solutions BV | | COO - Founder Cruquiuskade 47 | | +31(0)851119172 Amsterdam 1018 AM NL | | [`as] http://www.amarulasolutions.com |
v2 cover introduce Rockchip rockusb
In reply to Eddie CaiQuoted 2 lines · Eddie Cai
rockusb is a protocol run between host pc and device. it help people get device info, flash image to device. this patch implement rockusb on device side
What's the difference between these two series?
[U-Boot PATCH V2 0/9] introduce Rockchip rockusb
[U-Boot PATCH V2 0/8] introduce Rockchip rockusb
Quoted 30 lines
Eddie Cai (8):
usb: ums: split macro and data struct inf_mass_storage.c
usb: ums: mergestorage_common.cintof_mass_storage.c
usb: ums: remove static declaration of some ums functions
usb: ums: add functions to set and get usb interface descriptor
usb: ums: adddo_extra_command
cmd: add rockusb command
rockchip: config: enable rockusb support on rk3288 based board
rockusb: add a simple readmecmd/Kconfig | 5 + cmd/Makefile | 1 + cmd/rockusb.c | 383 ++++++++++++++++++++++++++++++++++++ configs/evb-rk3288_defconfig | 2 + configs/fennec-rk3288_defconfig | 1 + configs/firefly-rk3288_defconfig | 1 + configs/miqi-rk3288_defconfig | 1 + configs/popmetal-rk3288_defconfig | 1 + configs/rock2_defconfig | 2 + configs/sandbox_defconfig | 1 + configs/tinker-rk3288_defconfig | 1 + doc/README.rockusb | 35 ++++ drivers/usb/gadget/f_mass_storage.c | 356 ++++++++++++++++++++++----------- drivers/usb/gadget/storage_common.c | 238 ---------------------- include/f_mass_storage.h | 117 +++++++++++ 15 files changed, 797 insertions(+), 348 deletions(-) create mode 100644 cmd/rockusb.c create mode 100644 doc/README.rockusb delete mode 100644 drivers/usb/gadget/storage_common.c
Signature · 2 lines
Best regards, Marek Vasut