usb: Support for TIZEN's THOR download protocol
cover usb: Support for TIZEN's THOR download protocol
This patch series provide support for TIZEN's THOR download protocol.
Dedicated program for flashing TIZEN developer devices (TRATS, TRATS2) is called lthor (or thor for Windows) and can be found at:
git clone git://review.tizen.org/tools/lthor
or for git web:
https://review.tizen.org/git/?p=tools/lthor.git;a=summary
Presented composite USB function acts as a front end to perform correct USB communication with HOST PC.
To store the received data on the target, the DFU (Device Firmware Update) code for flashing has been reused.
This means, that the "dfu_alt_info" environment variable is used to provide information where a received file is stored.
This also means that dfu and thor can co-exists together. Thor protocol and its implementation has one advantage - it is much faster than DFU for large files transfers (especially rootfs images).
It applies on: u-boot-denx-usb/master
SHA1: 5077f96f10fe88f1f7cbe09743ac7c765f9e98c3
Test HW: Exynos4210 (TRATS)
Lukasz Majewski (10):
usb:udc:s3c: Reduce dcache invalidate range for UDC receive buffer dfu:core: Find DFU alt setting number by passing its name dfu:core: Export dfu_{get|free}_buf functions
usb:g_dnl: Replace static usb_configuration structure with
dynamically allocated one
usb:g_dnl: Add name parameter to g_dnl_bind_fixup function usb:g_dnl:f_thor: USB download function to support TIZEN's THOR
protocol
usb:g_dnl: Support for TIZEN's THOR function at generic download code cmd:thor: Support for TIZEN's download (thordown) command samsung:common:thor: Define common Samsung code to handle THOR usb
descriptor setup
trats: Update TRATS config to support TIZEN download
board/samsung/common/Makefile | 1 + board/samsung/common/thor.c | 21 + board/siemens/common/factoryset.c | 2 +- common/Makefile | 1 + common/cmd_thordown.c | 58 ++ drivers/dfu/dfu.c | 16 +- drivers/usb/gadget/Makefile | 1 + drivers/usb/gadget/f_thor.c | 1006 +++++++++++++++++++++++++++++ drivers/usb/gadget/f_thor.h | 123 ++++ drivers/usb/gadget/g_dnl.c | 38 +- drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 2 +- include/configs/trats.h | 13 +- include/dfu.h | 3 + include/g_dnl.h | 2 +- include/thor.h | 27 + 15 files changed, 1295 insertions(+), 19 deletions(-) create mode 100644 board/samsung/common/thor.c create mode 100644 common/cmd_thordown.c create mode 100644 drivers/usb/gadget/f_thor.c create mode 100644 drivers/usb/gadget/f_thor.h create mode 100644 include/thor.h
Signature · 1 line
1.7.10.4
PATCH 1/10 usb:udc:s3c: Reduce dcache invalidate range for UDC receive buffer
The s3c udc driver sends data in a max packet size. Therefore the dcache invalidate range shall be equal to max packet, not the entire DMA_BUFFER_SIZE.
--- drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +1 -1
@@ -117,7 +117,7 @@ static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req)invalidate_dcache_range ((unsigned long ) ep->dev->dma_buf[ep_num], (unsigned long ) ep->dev->dma_buf[ep_num] - +DMA_BUFFER_SIZE ); + + ep->ep.maxpacket);if (length ==0 ) pktcnt =1 ;
Signature · 1 line
1.7.10.4
PATCH v2 1/10 usb:udc:s3c: Reduce dcache invalidate range for UDC receive buffer
Dear Lukasz Majewski,
Quoted 15 lines
The s3c udc driver sends data in a max packet size. Therefore the dcache invalidate range shall be equal to max packet, not the entire
DMA_BUFFER_SIZE.Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>--- drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.cindex d7af5e9..5e3ba76 100644
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c static int setdma_rx(struct s3c_ep *ep, struct · line 121
Quoted 6 lines
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +1
-1@@ -117,7 +117,7 @@ static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req) invalidate_dcache_range((unsigned long) ep->dev->dma_buf[ep_num], (unsigned long) ep->dev->dma_buf[ep_num] - + DMA_BUFFER_SIZE); + + ep->ep.maxpacket);
Is this maxpacket _always_ multiple of cacheline big or will you need some ROUND_UP() call here ?
Best regards,
Marek Vasut
PATCH 1/10 usb:udc:s3c: Reduce dcache invalidate range for UDC receive buffer
Hi Marek,
Quoted 19 lines
Dear Lukasz Majewski,
Quoted 17 lines
The s3c udc driver sends data in a max packet size. Therefore the dcache invalidate range shall be equal to max packet, not the entire
DMA_BUFFER_SIZE.Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>--- drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.cindex d7af5e9..5e3ba76 100644 ---a/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c+++b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c(quoted diff) +0
-0@@ -117,7 +117,7 @@ static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req)
Quoted 7 lines
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req) · line 120
Quoted 4 lines
(quoted diff) +0
-0invalidate_dcache_range((unsigned long)ep->dev->dma_buf[ep_num], (unsigned long) ep->dev->dma_buf[ep_num]
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +1
-1- + DMA_BUFFER_SIZE); + + ep->ep.maxpacket);Is this maxpacket _always_ multiple of cacheline big or will you need some
ROUND_UP()call here ?
The maxpacket value is equal to 64 B for EP0 and 512 B for EP1 and EP2 (wMaxPacketSize field of the descriptor).
Moreover this invalidation is done on already memaligned buffer (which is 16 KiB). In other words, we are copying data to specially prepared buffer (per UDC device EP, not usb_request).
In my opinion the maxpacket don't need to be rounded up.
Quoted 3 lines
Best regards,
Marek Vasut
Since this is Samsung's UDC specific (not THOR download) - would it be possible to take this patch from this patch series (of course if my above rationale is acceptable for you)?
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v2 1/10 usb:udc:s3c: Reduce dcache invalidate range for UDC receive buffer
Dear Lukasz Majewski,
Quoted 31 lines
Hi Marek,
Quoted 20 lines
Dear Lukasz Majewski,
Quoted 18 lines
The s3c udc driver sends data in a max packet size. Therefore the dcache invalidate range shall be equal to max packet, not the entire
DMA_BUFFER_SIZE.Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>---
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.cindex d7af5e9..5e3ba76 100644 ---a/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c+++b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c(quoted diff) +0
-0@@ -117,7 +117,7 @@ static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req)Quoted 8 lines
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req) · line 120
Quoted 5 lines
(quoted diff) +0
-0invalidate_dcache_range((unsigned long)ep->dev->dma_buf[ep_num], (unsigned long) ep->dev->dma_buf[ep_num]
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +1
-1- + DMA_BUFFER_SIZE); + + ep->ep.maxpacket);Is this maxpacket _always_ multiple of cacheline big or will you need some
ROUND_UP()call here ?
Quoted 8 lines
The maxpacket value is equal to 64 B for EP0 and 512 B for EP1 and EP2 (wMaxPacketSize field of the descriptor).
Moreover this invalidation is done on already memaligned buffer (which is 16 KiB). In other words, we are copying data to specially prepared buffer (per UDC device EP, not
usb_request).In my opinion the maxpacket don't need to be rounded up.
So it can never happen that ep maxpacket is unaligned?
Quoted 6 lines
Quoted 2 lines
Best regards,
Marek VasutSince this is Samsung's UDC specific (not THOR download) - would it be possible to take this patch from this patch series (of course if my above rationale is acceptable for you)?
You mean for .10 ?
Best regards,
Marek Vasut
PATCH 1/10 usb:udc:s3c: Reduce dcache invalidate range for UDC receive buffer
Hi Marek,
Quoted 37 lines
Dear Lukasz Majewski,
Quoted 35 lines
Hi Marek,
Quoted 22 lines
Dear Lukasz Majewski,
Quoted 20 lines
The s3c udc driver sends data in a max packet size. Therefore the dcache invalidate range shall be equal to max packet, not the entire
DMA_BUFFER_SIZE.Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>---
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.cindex d7af5e9..5e3ba76 100644 ---a/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c+++b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c@@ -117,7 +117,7 @@ static intsetdma_rx(struct s3c_ep *ep, struct s3c_request *req)invalidate_dcache_range((unsigned long)
Quoted 7 lines
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req) · line 120
Quoted 4 lines
ep->dev->dma_buf[ep_num], (unsigned long)
ep->dev->dma_buf[ep_num]drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +1
-1- + DMA_BUFFER_SIZE); + + ep->ep.maxpacket);Is this maxpacket _always_ multiple of cacheline big or will you need some
ROUND_UP()call here ?The maxpacket value is equal to 64 B for EP0 and 512 B for EP1 and EP2 (wMaxPacketSize field of the descriptor).
Quoted 7 lines
Quoted 5 lines
Moreover this invalidation is done on already memaligned buffer (which is 16 KiB). In other words, we are copying data to specially prepared buffer (per UDC device EP, not
usb_request).In my opinion the maxpacket don't need to be rounded up.
So it can never happen that ep maxpacket is unaligned?
maxpacket can be defined as e.g. 16 Bytes (wMaxPacketSize).
However the underlying buffer (on which we perform dcache invalidation) is already cache line aware (defined with memalign).
Also we copy the usb request data there (yes I know that this is not the best possible solution). Afterwards address of this buffer is a starting point for DMA.
Since we are sending in the HW one packet at a time (with maxpacket size), then it should be enough to invalidate only up to 512 B. Previously the whole buffer (DMA_BUFFER_SIZE -> 16 KiB) was invalidated each time.
Since we are invalidating cache content corresponding to buffer mapped memory, we are safe when D-cache controller invalidates 32B (CACHE_LINE_SIZE) instead of 16B.
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines
Best regards,
Marek VasutSince this is Samsung's UDC specific (not THOR download) - would it be possible to take this patch from this patch series (of course if my above rationale is acceptable for you)?
You mean for .10 ?
This patch hasn't introduced regressions for DFU/UMS. It can be applied to .10 or to u-boot-usb/next.
Quoted 3 lines
Best regards,
Marek Vasut
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v2 1/10 usb:udc:s3c: Reduce dcache invalidate range for UDC receive buffer
Dear Lukasz Majewski,
Quoted 59 lines
Hi Marek,
Quoted 37 lines
Dear Lukasz Majewski,
Quoted 35 lines
Hi Marek,
Quoted 22 lines
Dear Lukasz Majewski,
Quoted 20 lines
The s3c udc driver sends data in a max packet size. Therefore the dcache invalidate range shall be equal to max packet, not the entire
DMA_BUFFER_SIZE.Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>---
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.cindex d7af5e9..5e3ba76 100644 ---a/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c+++b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c@@ -117,7 +117,7 @@ static intsetdma_rx(struct s3c_ep *ep, struct s3c_request *req)invalidate_dcache_range((unsigned long)
Quoted 7 lines
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req) · line 120
Quoted 4 lines
ep->dev->dma_buf[ep_num], (unsigned long)
ep->dev->dma_buf[ep_num]drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +1
-1- + DMA_BUFFER_SIZE); + + ep->ep.maxpacket);Is this maxpacket _always_ multiple of cacheline big or will you need some
ROUND_UP()call here ?The maxpacket value is equal to 64 B for EP0 and 512 B for EP1 and EP2 (wMaxPacketSize field of the descriptor).
Quoted 7 lines
Quoted 5 lines
Moreover this invalidation is done on already memaligned buffer (which is 16 KiB). In other words, we are copying data to specially prepared buffer (per UDC device EP, not
usb_request).In my opinion the maxpacket don't need to be rounded up.
So it can never happen that ep maxpacket is unaligned?
maxpacket can be defined as e.g. 16 Bytes (wMaxPacketSize).
However the underlying buffer (on which we perform dcache invalidation) is already cache line aware (defined with memalign).
Also we copy the usb request data there (yes I know that this is not the best possible solution). Afterwards address of this buffer is a starting point for DMA.
Since we are sending in the HW one packet at a time (with maxpacket size), then it should be enough to invalidate only up to 512 B. Previously the whole buffer (DMA_BUFFER_SIZE-> 16 KiB) was invalidated each time.
Quoted 3 lines
Since we are invalidating cache content corresponding to buffer mapped memory, we are safe when D-cache controller invalidates 32B (
CACHE_LINE_SIZE) instead of 16B.
I get it, but if the size is lower than CACHE_LINE_SIZE, it will not get invalidated at all. Thus the roundup might be needed.
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Best regards,
Marek VasutSince this is Samsung's UDC specific (not THOR download) - would it be possible to take this patch from this patch series (of course if my above rationale is acceptable for you)?
You mean for .10 ?
This patch hasn't introduced regressions for DFU/UMS. It can be applied to .10 or to u-boot-usb/next.
If it's not an explicit fix, this will go to -next
Best regards,
PATCH 1/10 usb:udc:s3c: Reduce dcache invalidate range for UDC receive buffer
Hi Marek,
Quoted 62 lines
Dear Lukasz Majewski,
Quoted 60 lines
Hi Marek,
Quoted 38 lines
Dear Lukasz Majewski,
Quoted 36 lines
Hi Marek,
Quoted 23 lines
Dear Lukasz Majewski,
Quoted 21 lines
The s3c udc driver sends data in a max packet size. Therefore the dcache invalidate range shall be equal to max packet, not the entire
DMA_BUFFER_SIZE.Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>---
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.cindex d7af5e9..5e3ba76 100644 ---a/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c+++b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c@@ -117,7 +117,7 @@ static intsetdma_rx(struct s3c_ep *ep, struct s3c_request *req)invalidate_dcache_range((unsigned long)
Quoted 7 lines
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req) · line 120
Quoted 4 lines
ep->dev->dma_buf[ep_num], (unsigned long)
ep->dev->dma_buf[ep_num]drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +1
-1- + DMA_BUFFER_SIZE); + + ep->ep.maxpacket);Is this maxpacket _always_ multiple of cacheline big or will you need some
ROUND_UP()call here ?The maxpacket value is equal to 64 B for EP0 and 512 B for EP1 and EP2 (wMaxPacketSize field of the descriptor).
Quoted 7 lines
Quoted 5 lines
Moreover this invalidation is done on already memaligned buffer (which is 16 KiB). In other words, we are copying data to specially prepared buffer (per UDC device EP, not
usb_request).In my opinion the maxpacket don't need to be rounded up.
So it can never happen that ep maxpacket is unaligned?
maxpacket can be defined as e.g. 16 Bytes (wMaxPacketSize).
However the underlying buffer (on which we perform dcache invalidation) is already cache line aware (defined with memalign). Also we copy the usb request data there (yes I know that this is not the best possible solution). Afterwards address of this buffer is a starting point for DMA.
Since we are sending in the HW one packet at a time (with maxpacket size), then it should be enough to invalidate only up to 512 B. Previously the whole buffer (DMA_BUFFER_SIZE-> 16 KiB) was invalidated each time.
Quoted 6 lines
Quoted 3 lines
Since we are invalidating cache content corresponding to buffer mapped memory, we are safe when D-cache controller invalidates 32B (
CACHE_LINE_SIZE) instead of 16B.I get it, but if the size is lower than
CACHE_LINE_SIZE, it will not get invalidated at all.
I've looked into the v7_dcache_inval_range() function at cache_v7.c and .... you are right here.
Cache doesn't touch the last and fist line if they aren't properly aligned. Obviously I need ROUND(CACHE_LINE_SIZE) there.
Thanks for opening my eyes....
Quoted 9 lines
Thus the roundup might be needed.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Best regards,
Marek VasutSince this is Samsung's UDC specific (not THOR download) - would it be possible to take this patch from this patch series (of course if my above rationale is acceptable for you)?
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
You mean for .10 ?
This patch hasn't introduced regressions for DFU/UMS. It can be applied to .10 or to u-boot-usb/next.
If it's not an explicit fix, this will go to -next
I will prepare v2 with rounding here.
Quoted 2 lines
Best regards,
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v2 1/10 usb:udc:s3c: Reduce dcache invalidate range for UDC receive buffer
Dear Lukasz Majewski,
Quoted 87 lines
Hi Marek,
Quoted 62 lines
Dear Lukasz Majewski,
Quoted 60 lines
Hi Marek,
Quoted 38 lines
Dear Lukasz Majewski,
Quoted 36 lines
Hi Marek,
Quoted 23 lines
Dear Lukasz Majewski,
Quoted 21 lines
The s3c udc driver sends data in a max packet size. Therefore the dcache invalidate range shall be equal to max packet, not the entire
DMA_BUFFER_SIZE.Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>---
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.cindex d7af5e9..5e3ba76 100644 ---a/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c+++b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c@@ -117,7 +117,7 @@ static intsetdma_rx(struct s3c_ep *ep, struct s3c_request *req)invalidate_dcache_range((unsigned long)
Quoted 7 lines
Review
Quoted 4 lines
ep->dev->dma_buf[ep_num], (unsigned long)
ep->dev->dma_buf[ep_num](quoted diff) +1
-1- + DMA_BUFFER_SIZE); + + ep->ep.maxpacket);Is this maxpacket _always_ multiple of cacheline big or will you need some
ROUND_UP()call here ?The maxpacket value is equal to 64 B for EP0 and 512 B for EP1 and EP2 (wMaxPacketSize field of the descriptor).
Quoted 7 lines
Quoted 5 lines
Moreover this invalidation is done on already memaligned buffer (which is 16 KiB). In other words, we are copying data to specially prepared buffer (per UDC device EP, not
usb_request).In my opinion the maxpacket don't need to be rounded up.
So it can never happen that ep maxpacket is unaligned?
maxpacket can be defined as e.g. 16 Bytes (wMaxPacketSize).
However the underlying buffer (on which we perform dcache invalidation) is already cache line aware (defined with memalign). Also we copy the usb request data there (yes I know that this is not the best possible solution). Afterwards address of this buffer is a starting point for DMA.
Since we are sending in the HW one packet at a time (with maxpacket size), then it should be enough to invalidate only up to 512 B. Previously the whole buffer (DMA_BUFFER_SIZE-> 16 KiB) was invalidated each time.Quoted 6 lines
Quoted 3 lines
Since we are invalidating cache content corresponding to buffer mapped memory, we are safe when D-cache controller invalidates 32B (
CACHE_LINE_SIZE) instead of 16B.I get it, but if the size is lower than
CACHE_LINE_SIZE, it will not get invalidated at all.I've looked into the
v7_dcache_inval_range()function atcache_v7.cand .... you are right here.
Cache doesn't touch the last and fist line if they aren't properly aligned. Obviously I needROUND(CACHE_LINE_SIZE)there.Thanks for opening my eyes....
Quoted 9 lines
Thus the roundup might be needed.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Best regards,
Marek VasutSince this is Samsung's UDC specific (not THOR download) - would it be possible to take this patch from this patch series (of course if my above rationale is acceptable for you)?
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
You mean for .10 ?
This patch hasn't introduced regressions for DFU/UMS. It can be applied to .10 or to u-boot-usb/next.
If it's not an explicit fix, this will go to -next
I will prepare v2 with rounding here.
Thanks ;-)
PATCH 2/10 dfu:core: Find DFU alt setting number by passing its name
In reply to Lukasz MajewskiNew function - dfu_get_alt() - has been added to dfu core. If present, it returns alt setting's number corresponding to passed name.
--- drivers/dfu/dfu.c | 12 ++++++++++++ include/dfu.h | 1 + 2 files changed, 13 insertions(+)
drivers/dfu/dfu.c +12 -0
@@ -440,3 +440,15 @@ struct dfu_entity *dfu_get_entity(int alt)return NULL ; } + +int dfu_get_alt (char *name) +{ +struct dfu_entity *dfu; + +list_for_each_entry (dfu, &dfu_list, list) { +if (!strncmp (dfu->name, name,strlen (dfu->name))) +return dfu->alt; + } + +return -ENODEV ; +}
include/dfu.h +1 -0
@@ -126,6 +126,7 @@ const char *dfu_get_layout(enum dfu_layout l);struct dfu_entity *dfu_get_entity (int alt);char *dfu_extract_token (char ** e,int *n);void dfu_trigger_reset (void ); +int dfu_get_alt (char *name);bool dfu_reset (void );int dfu_init_env_entities (char *interface,int dev);
Signature · 1 line
1.7.10.4
PATCH 3/10 dfu:core: Export dfu_{get|free}_buf functions
In reply to Lukasz MajewskiDefine the dfu_get_buf() and dfu_free_buf() as global functions. They are necessary for zero copy buffer management, when DFU backend is used for storing data.
Marek Vasut <[email protected]>
--- drivers/dfu/dfu.c | 4 ++-- include/dfu.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/dfu/dfu.c +2 -2
@@ -67,14 +67,14 @@ int dfu_init_env_entities(char *interface, int dev)static unsigned char *dfu_buf;static unsigned long dfu_buf_size =CONFIG_SYS_DFU_DATA_BUF_SIZE ; -static unsigned char *dfu_free_buf (void ) +unsigned char *dfu_free_buf (void ) {free (dfu_buf); dfu_buf =NULL ;return dfu_buf; } -static unsigned char *dfu_get_buf (void ) +unsigned char *dfu_get_buf (void ) {char *s;
include/dfu.h +2 -0
@@ -129,6 +129,8 @@ void dfu_trigger_reset(void);int dfu_get_alt (char *name);bool dfu_reset (void );int dfu_init_env_entities (char *interface,int dev); +unsigned char *dfu_get_buf (void ); +unsigned char *dfu_free_buf (void );int dfu_read (struct dfu_entity *de,void *buf,int size,int blk_seq_num);int dfu_write (struct dfu_entity *de,void *buf,int size,int blk_seq_num);
Signature · 1 line
1.7.10.4
PATCH 4/10 usb:g_dnl: Replace static usb_configuration structure with dynamically allocated one
In reply to Lukasz MajewskiWhen the usb_configuration structure is declared as static, it is very hard to assure, that relevant fields (as e.g. config->interfaces[]) are cleared out before new call to g_dnl related functions.
Marek Vasut <[email protected]>
--- drivers/usb/gadget/g_dnl.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/usb/gadget/g_dnl.c +16 -8
@@ -79,6 +79,8 @@ static int g_dnl_unbind(struct usb_composite_dev *cdev) {struct usb_gadget *gadget = cdev->gadget; +free (cdev->config); + cdev->config =NULL ;debug ("%s: calling usb_gadget_disconnect for " "controller '%s'\n" , shortname, gadget->name);usb_gadget_disconnect (gadget);
@@ -105,16 +107,22 @@ static int g_dnl_do_config(struct usb_configuration *c)static int g_dnl_config_register (struct usb_composite_dev *cdev) { -static struct usb_configuration config = { - .label ="usb_dnload" , - .bmAttributes =USB_CONFIG_ATT_ONE |USB_CONFIG_ATT_SELFPOWER , - .bConfigurationValue =CONFIGURATION_NUMBER , - .iConfiguration =STRING_USBDOWN , +struct usb_configuration *config; +const char *name ="usb_dnload" ; - .bind = g_dnl_do_config, - }; + config =memalign (CONFIG_SYS_CACHELINE_SIZE ,sizeof (*config)); +if (!config) +return -ENOMEM ; -return usb_add_config (cdev, &config); +memset (config,0 ,sizeof (*config)); + + config->label = name; + config->bmAttributes =USB_CONFIG_ATT_ONE |USB_CONFIG_ATT_SELFPOWER ; + config->bConfigurationValue =CONFIGURATION_NUMBER ; + config->iConfiguration =STRING_USBDOWN ; + config->bind = g_dnl_do_config; + +return usb_add_config (cdev, config); }__weak
Signature · 1 line
1.7.10.4
PATCH 5/10 usb:g_dnl: Add name parameter to g_dnl_bind_fixup function
In reply to Lukasz MajewskiNew parameter, namely *name has been added to g_dnl_bind_fixup(). It is necessary (for compatibility reasons) to assign new USB idProduct and idVendor for different usb functions.
--- board/siemens/common/factoryset.c | 2 +- drivers/usb/gadget/g_dnl.c | 4 ++-- include/g_dnl.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
board/siemens/common/factoryset.c +1 -1
@@ -275,7 +275,7 @@ int factoryset_setenv(void)return ret; } -int g_dnl_bind_fixup (struct usb_device_descriptor *dev) +int g_dnl_bind_fixup (struct usb_device_descriptor *dev,const char *name) {put_unaligned (factory_dat.usb_vendor_id, &dev->idVendor);put_unaligned (factory_dat.usb_product_id, &dev->idProduct);
drivers/usb/gadget/g_dnl.c +2 -2
@@ -126,7 +126,7 @@ static int g_dnl_config_register(struct usb_composite_dev *cdev) }__weak -int g_dnl_bind_fixup (struct usb_device_descriptor *dev) +int g_dnl_bind_fixup (struct usb_device_descriptor *dev,const char *name) {return 0 ; }
@@ -153,7 +153,7 @@ static int g_dnl_bind(struct usb_composite_dev *cdev) g_dnl_string_defs[1 ].id = id; device_desc.iProduct = id; -g_dnl_bind_fixup (&device_desc); +g_dnl_bind_fixup (&device_desc, cdev->driver->name); ret =g_dnl_config_register (cdev);if (ret) goto error;
include/g_dnl.h +1 -1
@@ -10,7 +10,7 @@#include <linux/usb/ch9.h> #include <linux/usb/gadget.h> -int g_dnl_bind_fixup (struct usb_device_descriptor *); +int g_dnl_bind_fixup (struct usb_device_descriptor *,const char *);int g_dnl_register (const char *s);void g_dnl_unregister (void );
Signature · 1 line
1.7.10.4
PATCH 6/10 usb:g_dnl:f_thor: USB download function to support TIZEN's THOR protocol
In reply to Lukasz MajewskiImplementation of USB download function which supports THOR protocol.
--- drivers/usb/gadget/Makefile | 1 + drivers/usb/gadget/f_thor.c | 1010 +++++++++++++++++++++++++++++++++++++++++++ drivers/usb/gadget/f_thor.h | 123 ++++++ include/thor.h | 27 ++ 4 files changed, 1161 insertions(+) create mode 100644 drivers/usb/gadget/f_thor.c create mode 100644 drivers/usb/gadget/f_thor.h create mode 100644 include/thor.h
drivers/usb/gadget/Makefile +1 -0
@@ -21,6 +21,7 @@ ifdef CONFIG_USB_GADGET COBJS-$(CONFIG_USB_GADGET_ATMEL_USBA) += atmel_usba_udc.o COBJS-$(CONFIG_USB_GADGET_S3C_UDC_OTG) += s3c_udc_otg.o COBJS-$(CONFIG_USB_GADGET_FOTG210) += fotg210.o +COBJS-$(CONFIG_THOR_FUNCTION) += f_thor.o COBJS-$(CONFIG_USBDOWNLOAD_GADGET) += g_dnl.o COBJS-$(CONFIG_DFU_FUNCTION) += f_dfu.o COBJS-$(CONFIG_USB_GADGET_MASS_STORAGE) += f_mass_storage.o
drivers/usb/gadget/f_thor.c new file +1010 -0
1,010 lines not on this page · raw message
drivers/usb/gadget/f_thor.h new file +123 -0
123 lines not on this page · raw message
include/thor.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* thor.h -- USB THOR Downloader protocol +* +* Copyright (C) 2013 Samsung Electronics +* Lukasz Majewski <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +* +*/ + +#ifndef __THOR_H_ +#define __THOR_H_ + +#include <linux/usb/composite.h> + +int thor_handle (void ); +int thor_init (void ); + +#ifdef CONFIG_THOR_FUNCTION +int thor_add (struct usb_configuration *c); +#else +int thor_add (struct usb_configuration *c) +{ +return 0 ; +} +#endif +#endif /* __THOR_H_ */
Signature · 1 line
1.7.10.4
PATCH v2 6/10 usb:g_dnl:f_thor: USB download function to support TIZEN's THOR protocol
Dear Lukasz Majewski,
[...]
drivers/usb/gadget/f_thor.c line 42
Quoted 8 lines
drivers/usb/gadget/f_thor.c new file +8
-0+static struct f_thor *thor_func; +static inline struct f_thor *func_to_thor (struct usb_function *f) +{ + return container_of(f, struct f_thor, usb_function); +} + +DEFINE_CACHE_ALIGN_BUFFER (char, thor_tx_data_buf,sizeof (struct rsp_box )); +DEFINE_CACHE_ALIGN_BUFFER (char, thor_rx_data_buf,sizeof (struct rqt_box ));
This should either be uint8_t or unsigned char. A buffer shall not be (signed) char.
Also, I suspect you want to use DEFINE_CACHE_ALIGN_BUFFER here, no ?
drivers/usb/gadget/f_thor.c line 47
Quoted 4 lines
drivers/usb/gadget/f_thor.c new file +4
-0+/* ********************************************************** */ +/* THOR protocol - transmission handling */ +/* ********************************************************** */ +DEFINE_CACHE_ALIGN_BUFFER (char, f_name,F_NAME_BUF_SIZE );
Ditto
Quoted 11 lines
drivers/usb/gadget/f_thor.c new file +11
-0+static unsigned long long int thor_file_size; +static int alt_setting_num; + +static void send_rsp (const struct rsp_box *rsp) +{ +/* should be copy on dma duffer */ +memcpy (thor_tx_data_buf, rsp,sizeof (struct rsp_box )); +thor_tx_data (thor_tx_data_buf,sizeof (struct rsp_box )); + +debug ("-RSP: %d, %d\n" , rsp->rsp, rsp->rsp_data); +}
drivers/usb/gadget/f_thor.c line 68
Quoted 10 lines
drivers/usb/gadget/f_thor.c new file +10
-0+ +static void send_data_rsp (s32 ack,s32 count) +{ + ALLOC_CACHE_ALIGN_BUFFER(struct data_rsp_box, rsp, + sizeof(struct data_rsp_box)); + + rsp->ack = ack; + rsp->count = count; + +/* should be copy on dma duffer */
This comment really makes no sense to me.
Quoted 37 lines
drivers/usb/gadget/f_thor.c new file +37
-0+memcpy (thor_tx_data_buf, rsp,sizeof (struct data_rsp_box )); +thor_tx_data (thor_tx_data_buf,sizeof (struct data_rsp_box )); + +debug ("-DATA RSP: %d, %d\n" , ack, count); +} + +static int process_rqt_info (const struct rqt_box *rqt) +{ + ALLOC_CACHE_ALIGN_BUFFER(struct rsp_box, rsp, sizeof(struct rsp_box)); +memset (rsp,'\0' ,sizeof (struct rsp_box )); + + rsp->rsp = rqt->rqt; + rsp->rsp_data = rqt->rqt_data; + +switch (rqt->rqt_data) { +case RQT_INFO_VER_PROTOCOL : + rsp->int_data[0 ] =VER_PROTOCOL_MAJOR ; + rsp->int_data[1 ] =VER_PROTOCOL_MINOR ; +break ; +case RQT_INIT_VER_HW : +snprintf (rsp->str_data[0 ],sizeof (rsp->str_data[0 ]), +"%x" ,checkboard ()); +break ; +case RQT_INIT_VER_BOOT : +sprintf (rsp->str_data[0 ],"%s" ,U_BOOT_VERSION ); +break ; +case RQT_INIT_VER_KERNEL : +sprintf (rsp->str_data[0 ],"%s" ,"k unknown" ); +break ; +case RQT_INIT_VER_PLATFORM : +sprintf (rsp->str_data[0 ],"%s" ,"p unknown" ); +break ; +case RQT_INIT_VER_CSC : +sprintf (rsp->str_data[0 ],"%s" ,"c unknown" ); +break ; +default : +return -EINVAL ;
drivers/usb/gadget/f_thor.c line 115
Quoted 10 lines
drivers/usb/gadget/f_thor.c new file +10
-0+ } + +send_rsp (rsp); +return true; +} + +static int process_rqt_cmd (const struct rqt_box *rqt) +{ + ALLOC_CACHE_ALIGN_BUFFER(struct rsp_box, rsp, sizeof(struct rsp_box)); +memset (rsp,'\0' ,sizeof (struct rsp_box ));
memset(rsp, 0, sizeof() ... this '\0' is unneeded, fix globally.
Quoted 5 lines
drivers/usb/gadget/f_thor.c new file +5
-0+ + rsp->rsp = rqt->rqt; + rsp->rsp_data = rqt->rqt_data; + +switch (rqt->rqt_data) {
drivers/usb/gadget/f_thor.c line 130
Quoted 10 lines
drivers/usb/gadget/f_thor.c new file +10
-0+case RQT_CMD_REBOOT : +debug ("TARGET RESET\n" ); +send_rsp (rsp); +g_dnl_unregister (); +dfu_free_entities (); +run_command ("reset" ,0 ); +break ; +case RQT_CMD_POWEROFF : +case RQT_CMD_EFSCLEAR : +send_rsp (rsp);
This case fallthrough is intentional here ?
Quoted 7 lines
drivers/usb/gadget/f_thor.c new file +7
-0+default : +printf ("Command not supported -> cmd: %d\n" , rqt->rqt_data); +return -EINVAL ; + } + +return true; +}
[...]
[...]
drivers/usb/gadget/f_thor.c line 402
Quoted 9 lines
drivers/usb/gadget/f_thor.c new file +9
-0+static struct usb_cdc_call_mgmt_descriptor thor_downloader_cdc_call = { + .bLength =sizeof (thor_downloader_cdc_call), + .bDescriptorType =0x24 ,/* CS_INTERFACE */ + .bDescriptorSubType =0x01 , + .bmCapabilities =0x00 , + .bDataInterface =0x01 , +}; + +struct usb_cdc_acm_descriptor thor_downloader_cdc_abstract = {
Why is this and the rest not static ?
Quoted 22 lines
drivers/usb/gadget/f_thor.c new file +22
-0+ .bLength = sizeof(thor_downloader_cdc_abstract), + .bDescriptorType = 0x24, /* CS_INTERFACE */ + .bDescriptorSubType = 0x02, + .bmCapabilities = 0x00, +}; + +struct usb_cdc_union_desc thor_downloader_cdc_union = { + .bLength =sizeof (thor_downloader_cdc_union), + .bDescriptorType =0x24 ,/* CS_INTERFACE */ + .bDescriptorSubType =USB_CDC_UNION_TYPE , +}; + +static struct usb_endpoint_descriptor fs_int_desc = { + .bLength =USB_DT_ENDPOINT_SIZE , + .bDescriptorType =USB_DT_ENDPOINT , + + .bEndpointAddress =3 |USB_DIR_IN , + .bmAttributes =USB_ENDPOINT_XFER_INT , + .wMaxPacketSize =__constant_cpu_to_le16 (16 ), + + .bInterval =0x9 , +};
[...]
drivers/usb/gadget/f_thor.c line 513
Quoted 7 lines
(quoted diff) +1
-1+/*------------------------------------------------------------------------ -*/ +static struct usb_request *alloc_ep_req(struct usb_ep *ep, unsignedlength) +{
drivers/usb/gadget/f_thor.c new file +4
-0+struct usb_request *req; + + req =usb_ep_alloc_request (ep,0 ); +if (req) {
if (!req)
return ...
... rest of the code ...
Quoted 9 lines
drivers/usb/gadget/f_thor.c new file +9
-0+ req->length = length; + req->buf =memalign (CONFIG_SYS_CACHELINE_SIZE , length); +if (!req->buf) { +usb_ep_free_request (ep, req); + req =NULL ; + } + } +return req; +}
[...]
Quoted 19 lines
+static void
thor_rx_tx_complete(struct usb_ep *ep, struct usb_request *req)+{drivers/usb/gadget/f_thor.c new file +17
-0+struct thor_dev *dev = thor_func->dev; +int status = req->status; + +debug ("%s: ep_ptr:%p, req_ptr:%p\n" , __func__, ep, req); +switch (status) { +case 0 :/* normal completion? */ +if (ep == dev->out_ep) + dev->rxdata =1 ; +else + dev->txdata =1 ; + +break ; + +/* this endpoint is normally active while we're configured */ +case -ECONNABORTED :/* hardware forced ep reset */ +case -ECONNRESET :/* request dequeued */ +case -ESHUTDOWN :/* disconnect from host */
drivers/usb/gadget/f_thor.c line 612
Quoted 10 lines
drivers/usb/gadget/f_thor.c new file +10
-0+/* Exeptional situation - print error message */ + +case -EOVERFLOW : +error ("ERROR:%d" , status); +default : +debug ("%s complete --> %d, %d/%d\n" , ep->name, + status, req->actual, req->length); +case -EREMOTEIO :/* short read */ +break ; + }
You might want to fix the order of these cases here.
Quoted 19 lines
drivers/usb/gadget/f_thor.c new file +19
-0+} + +static struct usb_request *thor_start_ep (struct usb_ep *ep) +{ +struct usb_request *req; + + req =alloc_ep_req (ep, ep->maxpacket); +debug ("%s: ep:%p req:%p\n" , __func__, ep, req); + +if (!req) +return NULL ; + +memset (req->buf,0 , req->length); + req->complete = thor_rx_tx_complete; + +memset (req->buf,0x55 , req->length); + +return req; +}
[...]
Quoted 7 lines
drivers/usb/gadget/f_thor.c new file +7
-0+int thor_init (void ) +{ +struct thor_dev *dev = thor_func->dev; + +/* Wait for a device enumeration and configuration settings */ +debug ("THOR enumeration/configuration setting....\n" ); +while (!dev->configuration_done)
drivers/usb/gadget/f_thor.c line 712
Quoted 10 lines
drivers/usb/gadget/f_thor.c new file +10
-0+usb_gadget_handle_interrupts (); + +thor_set_dma (thor_rx_data_buf,strlen (recv_key)); +/* detect the download request from Host PC */ +if (thor_rx_data () <0 ) { +printf ("%s: Data not received!\n" , __func__); +return -1 ; + } + +if (strncmp (thor_rx_data_buf, recv_key,strlen (recv_key)) ==0 ) {
Use min() of upper bound on the recv_key length and this strlen()
Quoted 12 lines
drivers/usb/gadget/f_thor.c new file +12
-0+puts ("Download request from the Host PC\n" ); +udelay (30 *1000 );/* 30 ms */ + +strncpy (thor_tx_data_buf, tx_key,strlen (tx_key)); +thor_tx_data (thor_tx_data_buf,strlen (tx_key)); + }else { +puts ("Wrong reply information\n" ); +return -1 ; + } + +return 0 ; +}
[...]
Quoted 7 lines
drivers/usb/gadget/f_thor.c new file +7
-0+static int thor_eps_setup (struct usb_function *f) +{ +struct usb_composite_dev *cdev = f->config->cdev; +struct usb_gadget *gadget = cdev->gadget; +struct thor_dev *dev = thor_func->dev; +struct usb_endpoint_descriptor *d; +struct usb_request *req;
drivers/usb/gadget/f_thor.c line 916
Quoted 10 lines
drivers/usb/gadget/f_thor.c new file +10
-0+struct usb_ep *ep; +int result; + + ep = dev->in_ep; + d =ep_desc (gadget, &hs_in_desc, &fs_in_desc); +debug ("(d)bEndpointAddress: 0x%x\n" , d->bEndpointAddress); + + result =usb_ep_enable (ep, d); + +if (result ==0 ) {
if (result)
goto exit;
... the rest ...
Quoted 8 lines
drivers/usb/gadget/f_thor.c new file +8
-0+ ep->driver_data = cdev;/* claim */ + req =thor_start_ep (ep); +if (req !=NULL ) { + dev->in_req = req; + }else { +usb_ep_disable (ep); + result = -EIO ; + }
drivers/usb/gadget/f_thor.c line 934
Quoted 10 lines
drivers/usb/gadget/f_thor.c new file +10
-0+ }else { + goto exit; + } + ep = dev->out_ep; + d =ep_desc (gadget, &hs_out_desc, &fs_out_desc); +debug ("(d)bEndpointAddress: 0x%x\n" , d->bEndpointAddress); + + result =usb_ep_enable (ep, d); + +if (result ==0 ) {
DTTO
Quoted 8 lines
drivers/usb/gadget/f_thor.c new file +8
-0+ ep->driver_data = cdev;/* claim */ + req =thor_start_ep (ep); +if (req !=NULL ) { + dev->out_req = req; + }else { +usb_ep_disable (ep); + result = -EIO ; + }
drivers/usb/gadget/f_thor.c line 952
Quoted 10 lines
drivers/usb/gadget/f_thor.c new file +10
-0+ }else { + goto exit; + } +/* ACM control EP */ + ep = dev->int_ep; + ep->driver_data = cdev;/* claim */ + + exit: +return result; +}
[...]
Best regards,
Marek Vasut
PATCH 6/10 usb:g_dnl:f_thor: USB download function to support TIZEN's THOR protocol
Hi Marek,
Quoted 4 lines
Dear Lukasz Majewski,
[...]
Quoted 12 lines
Quoted 9 lines
drivers/usb/gadget/f_thor.c new file +7
-0+static struct f_thor *thor_func; +static inline struct f_thor *func_to_thor (struct usb_function *f) +{ + return container_of(f, struct f_thor, usb_function); +} + +DEFINE_CACHE_ALIGN_BUFFER(char, thor_tx_data_buf, sizeof(struct
rsp_box)); +DEFINE_CACHE_ALIGN_BUFFER(char,thor_rx_data_buf,sizeof(struct rqt_box));This should either be
uint8_tor unsigned char. A buffer shall not be (signed) char.
Yes. I agree. This buffer shall be unsigned char. I will correct that.
Quoted 2 lines
Also, I suspect you want to use
DEFINE_CACHE_ALIGN_BUFFERhere, no ?
I'm a bit confused.... I do use DEFINE_CACHE_ALIGN_BUFFER for those buffers.
Quoted 7 lines
drivers/usb/gadget/f_thor.c line 47
Quoted 5 lines
drivers/usb/gadget/f_thor.c new file +4
-0+/* ********************************************************** */ +/* THOR protocol - transmission handling */ +/* ********************************************************** */ +DEFINE_CACHE_ALIGN_BUFFER (char, f_name,F_NAME_BUF_SIZE );Ditto
I believe that buffer for storing file name (f_name) shall be defined as char.
Quoted 16 lines
Quoted 16 lines
drivers/usb/gadget/f_thor.c new file +15
-0+static unsigned long long int thor_file_size; +static int alt_setting_num; + +static void send_rsp (const struct rsp_box *rsp) +{ +/* should be copy on dma duffer */ +memcpy (thor_tx_data_buf, rsp,sizeof (struct rsp_box )); +thor_tx_data (thor_tx_data_buf,sizeof (struct rsp_box )); + +debug ("-RSP: %d, %d\n" , rsp->rsp, rsp->rsp_data); +} + +static void send_data_rsp (s32 ack,s32 count) +{ + ALLOC_CACHE_ALIGN_BUFFER(struct data_rsp_box, rsp,
Quoted 8 lines
drivers/usb/gadget/f_thor.c line 68
Quoted 6 lines
drivers/usb/gadget/f_thor.c new file +6
-0+ sizeof(struct data_rsp_box)); + + rsp->ack = ack; + rsp->count = count; + +/* should be copy on dma duffer */ This comment really makes no sense to me.
Yes. It's pretty obvious, what I intent to do in this function. I will remove it.
Quoted 45 lines
Quoted 45 lines
(quoted diff) +2
-0+ memcpy(thor_tx_data_buf, rsp, sizeof(struct data_rsp_box)); + thor_tx_data(thor_tx_data_buf, sizeof(struct
data_rsp_box)); +drivers/usb/gadget/f_thor.c new file +6
-0+debug ("-DATA RSP: %d, %d\n" , ack, count); +} + +static int process_rqt_info (const struct rqt_box *rqt) +{ + ALLOC_CACHE_ALIGN_BUFFER(struct rsp_box, rsp,
sizeof(struct rsp_box));drivers/usb/gadget/f_thor.c new file +12
-0+memset (rsp,'\0' ,sizeof (struct rsp_box )); + + rsp->rsp = rqt->rqt; + rsp->rsp_data = rqt->rqt_data; + +switch (rqt->rqt_data) { +case RQT_INFO_VER_PROTOCOL : + rsp->int_data[0 ] =VER_PROTOCOL_MAJOR ; + rsp->int_data[1 ] =VER_PROTOCOL_MINOR ; +break ; +case RQT_INIT_VER_HW : + snprintf(rsp->str_data[0],
sizeof(rsp->str_data[0]),drivers/usb/gadget/f_thor.c new file +21
-0+ "%x", checkboard()); +break ; +case RQT_INIT_VER_BOOT : +sprintf (rsp->str_data[0 ],"%s" ,U_BOOT_VERSION ); +break ; +case RQT_INIT_VER_KERNEL : +sprintf (rsp->str_data[0 ],"%s" ,"k unknown" ); +break ; +case RQT_INIT_VER_PLATFORM : +sprintf (rsp->str_data[0 ],"%s" ,"p unknown" ); +break ; +case RQT_INIT_VER_CSC : +sprintf (rsp->str_data[0 ],"%s" ,"c unknown" ); +break ; +default : +return -EINVAL ; + } + +send_rsp (rsp); +return true; +}
Quoted 8 lines
Review
Quoted 6 lines
drivers/usb/gadget/f_thor.c new file +4
-0+ +static int process_rqt_cmd (const struct rqt_box *rqt) +{ + ALLOC_CACHE_ALIGN_BUFFER(struct rsp_box, rsp,
sizeof(struct rsp_box));(quoted diff) +1
-0+ memset(rsp, '\0', sizeof(struct rsp_box));memset(rsp, 0,
sizeof()... this '\0' is unneeded, fix globally.
Good point. I will correct this.
Quoted 10 lines
Quoted 10 lines
drivers/usb/gadget/f_thor.c new file +9
-0+ + rsp->rsp = rqt->rqt; + rsp->rsp_data = rqt->rqt_data; + +switch (rqt->rqt_data) { +case RQT_CMD_REBOOT : +debug ("TARGET RESET\n" ); +send_rsp (rsp); +g_dnl_unregister ();
Quoted 8 lines
drivers/usb/gadget/f_thor.c line 130
Quoted 6 lines
drivers/usb/gadget/f_thor.c new file +6
-0+dfu_free_entities (); +run_command ("reset" ,0 ); +break ; +case RQT_CMD_POWEROFF : +case RQT_CMD_EFSCLEAR : +send_rsp (rsp);This case fallthrough is intentional here ?
Yes. Thor protocol requires to receive response from device even when HOST PC ordered it to power off.
Also, on the target only reboot command is supported.
Quoted 12 lines
Quoted 9 lines
(quoted diff) +2
-0+ default: + printf("Command not supported -> cmd: %d\n",
rqt->rqt_data);drivers/usb/gadget/f_thor.c new file +5
-0+return -EINVAL ; + } + +return true; +}[...]
[...]
Quoted 12 lines
drivers/usb/gadget/f_thor.c line 402
Quoted 10 lines
+static struct
usb_cdc_call_mgmt_descriptorthor_downloader_cdc_call= {drivers/usb/gadget/f_thor.c new file +8
-0+ .bLength = sizeof(thor_downloader_cdc_call), + .bDescriptorType = 0x24, /* CS_INTERFACE */ + .bDescriptorSubType = 0x01, + .bmCapabilities = 0x00, + .bDataInterface = 0x01, +}; + +struct usb_cdc_acm_descriptor thor_downloader_cdc_abstract = {Why is this and the rest not static ?
They shall be static. I will fix that.
Quoted 35 lines
Quoted 23 lines
drivers/usb/gadget/f_thor.c new file +22
-0+ .bLength = sizeof(thor_downloader_cdc_abstract), + .bDescriptorType = 0x24, /* CS_INTERFACE */ + .bDescriptorSubType = 0x02, + .bmCapabilities = 0x00, +}; + +struct usb_cdc_union_desc thor_downloader_cdc_union = { + .bLength =sizeof (thor_downloader_cdc_union), + .bDescriptorType =0x24 ,/* CS_INTERFACE */ + .bDescriptorSubType =USB_CDC_UNION_TYPE , +}; + +static struct usb_endpoint_descriptor fs_int_desc = { + .bLength =USB_DT_ENDPOINT_SIZE , + .bDescriptorType =USB_DT_ENDPOINT , + + .bEndpointAddress =3 |USB_DIR_IN , + .bmAttributes =USB_ENDPOINT_XFER_INT , + .wMaxPacketSize =__constant_cpu_to_le16 (16 ), + + .bInterval =0x9 , +};[...]
drivers/usb/gadget/f_thor.c line 513
Quoted 7 lines
(quoted diff) +1
-1+/*------------------------------------------------------------------------ -*/ +static struct usb_request *alloc_ep_req(struct usb_ep *ep,unsigned length) +{
drivers/usb/gadget/f_thor.c new file +4
-0+struct usb_request *req; + + req =usb_ep_alloc_request (ep,0 ); +if (req) {if (!req)
Quoted 2 lines
return ...... rest of the code ...
Thanks for spotting. I fully agree.
Quoted 40 lines
Quoted 11 lines
(quoted diff) +2
-0+ req->length = length; + req->buf = memalign(CONFIG_SYS_CACHELINE_SIZE,length);
drivers/usb/gadget/f_thor.c new file +7
-0+if (!req->buf) { +usb_ep_free_request (ep, req); + req =NULL ; + } + } +return req; +}[...]
Quoted 26 lines
+static void
thor_rx_tx_complete(struct usb_ep *ep, struct usb_request *req)+{drivers/usb/gadget/f_thor.c new file +6
-0+struct thor_dev *dev = thor_func->dev; +int status = req->status; + +debug ("%s: ep_ptr:%p, req_ptr:%p\n" , __func__, ep, req); +switch (status) { +case 0 :/* normal completion? */
drivers/usb/gadget/f_thor.c new file +8
-0+if (ep == dev->out_ep) + dev->rxdata =1 ; +else + dev->txdata =1 ; + +break ; + +/* this endpoint is normally active while we're configured */
(quoted diff) +1
-0+ case -ECONNABORTED: /* hardware forced epreset */
drivers/usb/gadget/f_thor.c new file +6
-0+case -ECONNRESET :/* request dequeued */ +case -ESHUTDOWN :/* disconnect from host */ +/* Exeptional situation - print error message */ + +case -EOVERFLOW : +error ("ERROR:%d" , status);
Quoted 8 lines
drivers/usb/gadget/f_thor.c line 612
Quoted 6 lines
drivers/usb/gadget/f_thor.c new file +6
-0+default : +debug ("%s complete --> %d, %d/%d\n" , ep->name, + status, req->actual, req->length); +case -EREMOTEIO :/* short read */ +break ; + }You might want to fix the order of these cases here.
Ok. I will reorder it.
Quoted 35 lines
Quoted 20 lines
drivers/usb/gadget/f_thor.c new file +19
-0+} + +static struct usb_request *thor_start_ep (struct usb_ep *ep) +{ +struct usb_request *req; + + req =alloc_ep_req (ep, ep->maxpacket); +debug ("%s: ep:%p req:%p\n" , __func__, ep, req); + +if (!req) +return NULL ; + +memset (req->buf,0 , req->length); + req->complete = thor_rx_tx_complete; + +memset (req->buf,0x55 , req->length); + +return req; +}[...]
Quoted 13 lines
drivers/usb/gadget/f_thor.c new file +5
-0+int thor_init (void ) +{ +struct thor_dev *dev = thor_func->dev; + +/* Wait for a device enumeration and configuration settings */
drivers/usb/gadget/f_thor.c new file +7
-0+debug ("THOR enumeration/configuration setting....\n" ); +while (!dev->configuration_done) +usb_gadget_handle_interrupts (); + +thor_set_dma (thor_rx_data_buf,strlen (recv_key)); +/* detect the download request from Host PC */ +if (thor_rx_data () <0 ) {
Quoted 8 lines
Quoted 6 lines
drivers/usb/gadget/f_thor.c new file +5
-0+printf ("%s: Data not received!\n" , __func__); +return -1 ; + } + + if (strncmp(thor_rx_data_buf, recv_key, strlen(recv_key))== 0) {
Use
min()of upper bound on therecv_keylength and thisstrlen()
But the recv_key is defined as const char *recv_key = "THOR";
I will rewrite this as:
if (!strcmp(thor_rx_data_buf, "THOR"))
Quoted 36 lines
Quoted 13 lines
drivers/usb/gadget/f_thor.c new file +12
-0+puts ("Download request from the Host PC\n" ); +udelay (30 *1000 );/* 30 ms */ + +strncpy (thor_tx_data_buf, tx_key,strlen (tx_key)); +thor_tx_data (thor_tx_data_buf,strlen (tx_key)); + }else { +puts ("Wrong reply information\n" ); +return -1 ; + } + +return 0 ; +}[...]
Quoted 7 lines
drivers/usb/gadget/f_thor.c new file +7
-0+static int thor_eps_setup (struct usb_function *f) +{ +struct usb_composite_dev *cdev = f->config->cdev; +struct usb_gadget *gadget = cdev->gadget; +struct thor_dev *dev = thor_func->dev; +struct usb_endpoint_descriptor *d; +struct usb_request *req;drivers/usb/gadget/f_thor.c line 916
Quoted 10 lines
drivers/usb/gadget/f_thor.c new file +10
-0+struct usb_ep *ep; +int result; + + ep = dev->in_ep; + d =ep_desc (gadget, &hs_in_desc, &fs_in_desc); +debug ("(d)bEndpointAddress: 0x%x\n" , d->bEndpointAddress); + + result =usb_ep_enable (ep, d); + +if (result ==0 ) {if (result)
goto exit;
Quoted 1 line
... the rest ...
Yes, correct. I will change this.
Quoted 13 lines
Quoted 13 lines
drivers/usb/gadget/f_thor.c new file +12
-0+ ep->driver_data = cdev;/* claim */ + req =thor_start_ep (ep); +if (req !=NULL ) { + dev->in_req = req; + }else { +usb_ep_disable (ep); + result = -EIO ; + } + }else { + goto exit; + } + ep = dev->out_ep;
Quoted 8 lines
drivers/usb/gadget/f_thor.c line 934
Quoted 6 lines
drivers/usb/gadget/f_thor.c new file +6
-0+ d =ep_desc (gadget, &hs_out_desc, &fs_out_desc); +debug ("(d)bEndpointAddress: 0x%x\n" , d->bEndpointAddress); + + result =usb_ep_enable (ep, d); + +if (result ==0 ) {DTTO
Yes, this will be also changed.
Quoted 23 lines
Quoted 9 lines
drivers/usb/gadget/f_thor.c new file +8
-0+ ep->driver_data = cdev;/* claim */ + req =thor_start_ep (ep); +if (req !=NULL ) { + dev->out_req = req; + }else { +usb_ep_disable (ep); + result = -EIO ; + }drivers/usb/gadget/f_thor.c line 952
Quoted 10 lines
drivers/usb/gadget/f_thor.c new file +10
-0+ }else { + goto exit; + } +/* ACM control EP */ + ep = dev->int_ep; + ep->driver_data = cdev;/* claim */ + + exit: +return result; +}[...]
Best regards,
Marek Vasut
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v2 6/10 usb:g_dnl:f_thor: USB download function to support TIZEN's THOR protocol
Dear Lukasz Majewski,
Quoted 19 lines
Hi Marek,
Quoted 4 lines
Dear Lukasz Majewski,
[...]
Quoted 12 lines
Quoted 9 lines
drivers/usb/gadget/f_thor.c new file +7
-0+static struct f_thor *thor_func; +static inline struct f_thor *func_to_thor (struct usb_function *f) +{ + return container_of(f, struct f_thor, usb_function); +} + +DEFINE_CACHE_ALIGN_BUFFER(char, thor_tx_data_buf, sizeof(struct
rsp_box)); +DEFINE_CACHE_ALIGN_BUFFER(char,thor_rx_data_buf,sizeof(struct rqt_box));This should either be
uint8_tor unsigned char. A buffer shall not be (signed) char.
Quoted 6 lines
Yes. I agree. This buffer shall be unsigned char. I will correct that.
Quoted 1 line
Also, I suspect you want to use
DEFINE_CACHE_ALIGN_BUFFERhere, no ?I'm a bit confused.... I do use
DEFINE_CACHE_ALIGN_BUFFERfor those buffers.
OOPS!
Quoted 9 lines
Quoted 6 lines
drivers/usb/gadget/f_thor.c line 47
Quoted 4 lines
drivers/usb/gadget/f_thor.c new file +4
-0+/* ********************************************************** */ +/* THOR protocol - transmission handling */ +/* ********************************************************** */ +DEFINE_CACHE_ALIGN_BUFFER (char, f_name,F_NAME_BUF_SIZE );Ditto
I believe that buffer for storing file name (
f_name) shall be defined as char.
OK, good point.
[...]
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
drivers/usb/gadget/f_thor.c new file +9
-0+ + rsp->rsp = rqt->rqt; + rsp->rsp_data = rqt->rqt_data; + +switch (rqt->rqt_data) { +case RQT_CMD_REBOOT : +debug ("TARGET RESET\n" ); +send_rsp (rsp); +g_dnl_unregister ();Quoted 8 lines
drivers/usb/gadget/f_thor.c line 130
Quoted 6 lines
drivers/usb/gadget/f_thor.c new file +6
-0+dfu_free_entities (); +run_command ("reset" ,0 ); +break ; +case RQT_CMD_POWEROFF : +case RQT_CMD_EFSCLEAR : +send_rsp (rsp);This case fallthrough is intentional here ?
Quoted 4 lines
Yes. Thor protocol requires to receive response from device even when HOST PC ordered it to power off.
Also, on the target only reboot command is supported.
But this will fall through into the default: branch here.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
(quoted diff) +2
-0+ default: + printf("Command not supported -> cmd: %d\n",
rqt->rqt_data);drivers/usb/gadget/f_thor.c new file +5
-0+return -EINVAL ; + } + +return true; +}
[...]
PATCH 6/10 usb:g_dnl:f_thor: USB download function to support TIZEN's THOR protocol
Hi Marek,
Quoted 64 lines
Dear Lukasz Majewski,
Quoted 19 lines
Hi Marek,
Quoted 4 lines
Dear Lukasz Majewski,
[...]
Quoted 12 lines
Quoted 9 lines
(quoted diff) +2
-0+static struct f_thor *thor_func; +static inline struct f_thor *func_to_thor(struct usb_function*f) +{
drivers/usb/gadget/f_thor.c new file +4
-0+ return container_of(f, struct f_thor, usb_function); +} + +DEFINE_CACHE_ALIGN_BUFFER(char, thor_tx_data_buf, sizeof(struct
rsp_box)); +DEFINE_CACHE_ALIGN_BUFFER(char,thor_rx_data_buf,sizeof(struct rqt_box));This should either be
uint8_tor unsigned char. A buffer shall not be (signed) char.Quoted 8 lines
Yes. I agree. This buffer shall be unsigned char. I will correct that.
Quoted 2 lines
Also, I suspect you want to use
DEFINE_CACHE_ALIGN_BUFFERhere, no ?I'm a bit confused.... I do use
DEFINE_CACHE_ALIGN_BUFFERfor those buffers.OOPS!
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
+/* **********************************************************
*/ +/* THOR protocol - transmission
handling */ +/*
********************************************************** */ +DEFINE_CACHE_ALIGN_BUFFER(char,f_name,F_NAME_BUF_SIZE);Ditto
I believe that buffer for storing file name (
f_name) shall be defined as char.OK, good point.
[...]
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
drivers/usb/gadget/f_thor.c new file +5
-0+ + rsp->rsp = rqt->rqt; + rsp->rsp_data = rqt->rqt_data; + +switch (rqt->rqt_data) {drivers/usb/gadget/f_thor.c line 130
Quoted 10 lines
drivers/usb/gadget/f_thor.c new file +10
-0+case RQT_CMD_REBOOT : +debug ("TARGET RESET\n" ); +send_rsp (rsp); +g_dnl_unregister (); +dfu_free_entities (); +run_command ("reset" ,0 ); +break ; +case RQT_CMD_POWEROFF : +case RQT_CMD_EFSCLEAR : +send_rsp (rsp);This case fallthrough is intentional here ?
Quoted 6 lines
Quoted 4 lines
Yes. Thor protocol requires to receive response from device even when HOST PC ordered it to power off.
Also, on the target only reboot command is supported.
But this will fall through into the default: branch here.
From my perspective this looks like a proper behaviour.
We send response that we have received such request and display information that it is not supported.
Quoted 11 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
(quoted diff) +2
-0+ default: + printf("Command not supported -> cmd: %d\n",
rqt->rqt_data);drivers/usb/gadget/f_thor.c new file +5
-0+return -EINVAL ; + } + +return true; +}[...]
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH 7/10 usb:g_dnl: Support for TIZEN's THOR function at generic download code
In reply to Lukasz MajewskiSupport of "thor" function at generic download code (g_dnl.c).
--- drivers/usb/gadget/g_dnl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/usb/gadget/g_dnl.c +8 -2
@@ -16,6 +16,7 @@#include <g_dnl.h> #include <usb_mass_storage.h> #include <dfu.h> +#include <thor.h> #include "gadget_chips.h" #include "composite.c"
@@ -101,6 +102,8 @@ static int g_dnl_do_config(struct usb_configuration *c) ret =dfu_add (c); else if (!strcmp(s, "usb_dnl_ums")) ret =fsg_add (c); + else if (!strcmp(s, "usb_dnl_thor")) + ret =thor_add (c);return ret; }
@@ -191,8 +194,8 @@ static struct usb_composite_driver g_dnl_driver = {int g_dnl_register (const char *type) { -/* We only allow "dfu" atm, so 3 should be enough */ -static char name[sizeof (shortname) +3 ]; +/* The largest function name is 4 */ +static char name[sizeof (shortname) +4 ];int ret;if (!strcmp (type,"dfu" )) {
@@ -201,6 +204,9 @@ int g_dnl_register(const char *type) }else if (!strcmp (type,"ums" )) {strcpy (name, shortname);strcat (name, type); + }else if (!strcmp (type,"thor" )) { +strcpy (name, shortname); +strcat (name, type); }else {printf ("%s: unknown command: %s\n" , __func__, type);return -EINVAL ;
Signature · 1 line
1.7.10.4
PATCH 8/10 cmd:thor: Support for TIZEN's download (thordown) command
In reply to Lukasz MajewskiNew command - thordown - has been added to support downloading data via lthor TIZEN program.
It is similar to dfu command syntax and reuses its code for flashing data.
--- common/Makefile | 1 + common/cmd_thordown.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 common/cmd_thordown.c
common/Makefile +1 -0
@@ -168,6 +168,7 @@ COBJS-y += usb.o usb_hub.o COBJS-$(CONFIG_USB_STORAGE) += usb_storage.o endif COBJS-$(CONFIG_CMD_USB_MASS_STORAGE) += cmd_usb_mass_storage.o +COBJS-$(CONFIG_CMD_THOR_DOWNLOAD) += cmd_thordown.o COBJS-$(CONFIG_CMD_XIMG) += cmd_ximg.o COBJS-$(CONFIG_YAFFS2) += cmd_yaffs2.o COBJS-$(CONFIG_CMD_SPL) += cmd_spl.o
common/cmd_thordown.c new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH 9/10 samsung:common:thor: Define common Samsung code to handle THOR usb descriptor setup
In reply to Lukasz MajewskiSpecial, common to Samsung, function for altering usb descriptor's idVendor and idProduct has been added.
For compatibility reasons (Win vs Linux) the THOR idProduct must be different than the one for DFU/UMS.
--- board/samsung/common/Makefile | 1 + board/samsung/common/thor.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 board/samsung/common/thor.c
board/samsung/common/Makefile +1 -0
@@ -10,6 +10,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)libsamsung.o COBJS-$(CONFIG_SOFT_I2C_MULTI_BUS) += multi_i2c.o +COBJS-$(CONFIG_THOR_FUNCTION) += thor.o SRCS := $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(COBJS-y))
board/samsung/common/thor.c new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Copyright (C) 2013 Samsung Electronics +* Lukasz Majewski <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <linux/usb/ch9.h> + +int g_dnl_bind_fixup (struct usb_device_descriptor *dev,const char *name) +{ +if (!strcmp (name,"usb_dnl_thor" )) { +put_unaligned (CONFIG_G_DNL_THOR_VENDOR_NUM , &dev->idVendor); +put_unaligned (CONFIG_G_DNL_THOR_PRODUCT_NUM , &dev->idProduct); + }else { +put_unaligned (CONFIG_G_DNL_VENDOR_NUM , &dev->idVendor); +put_unaligned (CONFIG_G_DNL_PRODUCT_NUM , &dev->idProduct); + } +return 0 ; +}
Signature · 1 line
1.7.10.4
PATCH 10/10 trats: Update TRATS config to support TIZEN download
In reply to Lukasz MajewskiA set of environment variables needs to be updated to provide support for TIZEN download command (tizendown).
Since DFU is used as a flashing backend, it is also necessary to extent malloc pool size for DFU buffer allocation.
Moreover, for compatibility reasons (Win vs. Lin) new USB idProduct number for download gadget had to be added.
--- include/configs/trats.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
include/configs/trats.h +11 -2
@@ -50,7 +50,7 @@#define CONFIG_MACH_TYPE MACH_TYPE_TRATS/* Size of malloc() pool */ -#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (16 << 20)) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (80 << 20))/* select serial console configuration */ #define CONFIG_SERIAL2 /* use SERIAL 2 */
@@ -91,12 +91,20 @@/* USB Composite download gadget - g_dnl */ #define CONFIG_USBDOWNLOAD_GADGET + +/* TIZEN THOR downloader support */ +#define CONFIG_CMD_THOR_DOWNLOAD +#define CONFIG_THOR_FUNCTION + +#define CONFIG_SYS_DFU_DATA_BUF_SIZE (32 << 20)#define CONFIG_DFU_FUNCTION #define CONFIG_DFU_MMC /* USB Samsung's IDs */ #define CONFIG_G_DNL_VENDOR_NUM 0x04E8#define CONFIG_G_DNL_PRODUCT_NUM 0x6601 +#define CONFIG_G_DNL_THOR_VENDOR_NUM CONFIG_G_DNL_VENDOR_NUM +#define CONFIG_G_DNL_THOR_PRODUCT_NUM 0x685D#define CONFIG_G_DNL_MANUFACTURER "Samsung"#define CONFIG_BOOTDELAY 1
@@ -131,7 +139,8 @@#define CONFIG_DFU_ALT \ "u-boot mmc 80 400;" \ "uImage ext4 0 2;" \ - "exynos4210-trats.dtb ext4 0 2\0" + "exynos4210-trats.dtb ext4 0 2;" \ + ""PARTS_ROOT" part 0 5\0"#define CONFIG_ENV_OVERWRITE #define CONFIG_SYS_CONSOLE_INFO_QUIET
Signature · 1 line
1.7.10.4
PATCH v2 10/10 trats: Update TRATS config to support TIZEN download
Dear Lukasz Majewski,
Quoted 19 lines
A set of environment variables needs to be updated to provide support for TIZEN download command (tizendown).
Since DFU is used as a flashing backend, it is also necessary to extent malloc pool size for DFU buffer allocation.
Moreover, for compatibility reasons (Win vs. Lin) new USB idProduct number for download gadget had to be added.Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>--- include/configs/trats.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)include/configs/trats.h +0
-0
include/configs/trats.h line 53
Quoted 5 lines
include/configs/trats.h +1
-1@@ -50,7 +50,7 @@#define CONFIG_MACH_TYPE MACH_TYPE_TRATS/* Size of malloc() pool */ -#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (16 << 20)) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (80 << 20))
Use SZ_1M instead of that l-shift by 20.
include/configs/trats.h line 99
Quoted 13 lines
include/configs/trats.h +6
-0/* select serial console configuration */ #define CONFIG_SERIAL2 /* use SERIAL 2 */ @@ -91,12 +91,20 @@/* USB Composite download gadget - g_dnl */ #define CONFIG_USBDOWNLOAD_GADGET + +/* TIZEN THOR downloader support */ +#define CONFIG_CMD_THOR_DOWNLOAD +#define CONFIG_THOR_FUNCTION + +#define CONFIG_SYS_DFU_DATA_BUF_SIZE (32 << 20)
DTTO
Quoted 12 lines
include/configs/trats.h +2
-0#define CONFIG_DFU_FUNCTION #define CONFIG_DFU_MMC /* USB Samsung's IDs */ #define CONFIG_G_DNL_VENDOR_NUM 0x04E8#define CONFIG_G_DNL_PRODUCT_NUM 0x6601 +#define CONFIG_G_DNL_THOR_VENDOR_NUM CONFIG_G_DNL_VENDOR_NUM +#define CONFIG_G_DNL_THOR_PRODUCT_NUM 0x685D#define CONFIG_G_DNL_MANUFACTURER "Samsung"#define CONFIG_BOOTDELAY 1
include/configs/trats.h line 146
Quoted 9 lines
include/configs/trats.h +2
-1@@ -131,7 +139,8 @@#define CONFIG_DFU_ALT \ "u-boot mmc 80 400;" \ "uImage ext4 0 2;" \ - "exynos4210-trats.dtb ext4 0 2\0" + "exynos4210-trats.dtb ext4 0 2;" \ + ""PARTS_ROOT" part 0 5\0"#define CONFIG_ENV_OVERWRITE #define CONFIG_SYS_CONSOLE_INFO_QUIET
btw. I'm picking this patch before this set:
[PATCH v5] usb: new board-specific USB init interface
So you might want to wait until it's applied onto usb/next and then rebase and repost.
Best regards,
Marek Vasut
PATCH 10/10 trats: Update TRATS config to support TIZEN download
Hi Marek,
Quoted 23 lines
Dear Lukasz Majewski,
Quoted 21 lines
A set of environment variables needs to be updated to provide support for TIZEN download command (tizendown).
Since DFU is used as a flashing backend, it is also necessary to extent malloc pool size for DFU buffer allocation. Moreover, for compatibility reasons (Win vs. Lin) new USB idProduct number for download gadget had to be added.
Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>--- include/configs/trats.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)include/configs/trats.h +0
-0@@ -50,7 +50,7 @@#define CONFIG_MACH_TYPE MACH_TYPE_TRATS
Quoted 6 lines
Quoted 4 lines
include/configs/trats.h +0
-1/* Size of malloc() pool */ -#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE +(16 << 20)) +#define
CONFIG_SYS_MALLOC_LEN
(CONFIG_ENV_SIZE+ (80 << 20))Use
SZ_1Minstead of that l-shift by 20.
Ok, I will use it.
Quoted 41 lines
Quoted 5 lines
/* select serial console configuration */
#defineCONFIG_SERIAL2/* use SERIAL 2 */include/configs/trats.h line 99
Quoted 9 lines
include/configs/trats.h +6
-0@@ -91,12 +91,20 @@/* USB Composite download gadget - g_dnl */ #define CONFIG_USBDOWNLOAD_GADGET + +/* TIZEN THOR downloader support */ +#define CONFIG_CMD_THOR_DOWNLOAD +#define CONFIG_THOR_FUNCTION + +#define CONFIG_SYS_DFU_DATA_BUF_SIZE (32 << 20)DTTO
Quoted 12 lines
include/configs/trats.h +2
-0#define CONFIG_DFU_FUNCTION #define CONFIG_DFU_MMC /* USB Samsung's IDs */ #define CONFIG_G_DNL_VENDOR_NUM 0x04E8#define CONFIG_G_DNL_PRODUCT_NUM 0x6601 +#define CONFIG_G_DNL_THOR_VENDOR_NUM CONFIG_G_DNL_VENDOR_NUM +#define CONFIG_G_DNL_THOR_PRODUCT_NUM 0x685D#define CONFIG_G_DNL_MANUFACTURER "Samsung"#define CONFIG_BOOTDELAY 1include/configs/trats.h line 146
Quoted 9 lines
include/configs/trats.h +2
-1@@ -131,7 +139,8 @@#define CONFIG_DFU_ALT \ "u-boot mmc 80 400;" \ "uImage ext4 0 2;" \ - "exynos4210-trats.dtb ext4 0 2\0" + "exynos4210-trats.dtb ext4 0 2;" \ + ""PARTS_ROOT" part 0 5\0"#define CONFIG_ENV_OVERWRITE #define CONFIG_SYS_CONSOLE_INFO_QUIET btw. I'm picking this patch before this set:
Quoted 4 lines
[PATCH v5] usb: new board-specific USB init interface
So you might want to wait until it's applied onto usb/next and then rebase and repost.
I will do as you suggested. Thanks for review.
Quoted 3 lines
Best regards,
Marek Vasut
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
v2 cover usb: Support for TIZEN's THOR download protocol
In reply to Lukasz MajewskiThis patch series provide support for TIZEN's THOR download protocol.
Dedicated program for flashing TIZEN developer devices (TRATS, TRATS2) is called lthor (or thor for Windows) and can be found at:
git clone git://review.tizen.org/tools/lthor
or for git web:
https://review.tizen.org/git/?p=tools/lthor.git;a=summary
Presented composite USB function acts as a front end to perform correct USB communication with HOST PC.
To store the received data on the target, the DFU (Device Firmware Update) code for flashing has been reused.
This means, that the "dfu_alt_info" environment variable is used to provide information where a received file is stored.
This also means that dfu and thor can co-exists together. Thor protocol and its implementation has one advantage - it is much faster than DFU for large files transfers (especially rootfs images).
It applies on: u-boot-denx-usb/next
SHA1: 6928d26b84a5aa4a44706362234ab435bb15a6fb
Test HW: Exynos4210 (TRATS)
Lukasz Majewski (10):
usb:udc:s3c: Reduce dcache invalidate range for UDC receive buffer dfu:core: Find DFU alt setting number by passing its name dfu:core: Export dfu_{get|free}_buf functions
usb:g_dnl: Replace static usb_configuration structure with
dynamically allocated one
usb:g_dnl: Add name parameter to g_dnl_bind_fixup function usb:g_dnl:f_thor: USB download function to support TIZEN's THOR
protocol
usb:g_dnl: Support for TIZEN's THOR function in generic download code cmd:thor: Support for TIZEN's download command (thordown) samsung:common:thor: Define common Samsung code to handle THOR usb
descriptor setup
trats: Update TRATS config to support TIZEN download
board/samsung/common/Makefile | 1 + board/samsung/common/thor.c | 21 + board/siemens/common/factoryset.c | 2 +- common/Makefile | 1 + common/cmd_thordown.c | 72 +++ drivers/dfu/dfu.c | 16 +- drivers/usb/gadget/Makefile | 1 + drivers/usb/gadget/f_thor.c | 1003 +++++++++++++++++++++++++++++ drivers/usb/gadget/f_thor.h | 124 ++++ drivers/usb/gadget/g_dnl.c | 38 +- drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 3 +- include/configs/trats.h | 14 +- include/dfu.h | 3 + include/g_dnl.h | 2 +- include/thor.h | 27 + 15 files changed, 1309 insertions(+), 19 deletions(-) create mode 100644 board/samsung/common/thor.c create mode 100644 common/cmd_thordown.c create mode 100644 drivers/usb/gadget/f_thor.c create mode 100644 drivers/usb/gadget/f_thor.h create mode 100644 include/thor.h
Signature · 1 line
1.7.10.4
PATCH v2 1/10 usb:udc:s3c: Reduce dcache invalidate range for UDC receive buffer
The s3c udc driver sends data in a max packet size. Therefore the dcache invalidate range shall be equal to max packet, not the entire DMA_BUFFER_SIZE.
---
Changes for v2:
- ROUND the maxpacket value to invalidate data smaller than cache line size
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +2 -1
@@ -117,7 +117,8 @@ static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req)invalidate_dcache_range ((unsigned long ) ep->dev->dma_buf[ep_num], (unsigned long ) ep->dev->dma_buf[ep_num] - +DMA_BUFFER_SIZE ); + +ROUND (ep->ep.maxpacket, +CONFIG_SYS_CACHELINE_SIZE ));if (length ==0 ) pktcnt =1 ;
Signature · 1 line
1.7.10.4
PATCH v2 2/10 dfu:core: Find DFU alt setting number by passing its name
In reply to Lukasz MajewskiNew function - dfu_get_alt() - has been added to dfu core. If present, it returns alt setting's number corresponding to passed name.
---
Changes for v2:
- None
drivers/dfu/dfu.c | 12 ++++++++++++ include/dfu.h | 1 + 2 files changed, 13 insertions(+)
drivers/dfu/dfu.c +12 -0
@@ -440,3 +440,15 @@ struct dfu_entity *dfu_get_entity(int alt)return NULL ; } + +int dfu_get_alt (char *name) +{ +struct dfu_entity *dfu; + +list_for_each_entry (dfu, &dfu_list, list) { +if (!strncmp (dfu->name, name,strlen (dfu->name))) +return dfu->alt; + } + +return -ENODEV ; +}
include/dfu.h +1 -0
@@ -126,6 +126,7 @@ const char *dfu_get_layout(enum dfu_layout l);struct dfu_entity *dfu_get_entity (int alt);char *dfu_extract_token (char ** e,int *n);void dfu_trigger_reset (void ); +int dfu_get_alt (char *name);bool dfu_reset (void );int dfu_init_env_entities (char *interface,int dev);
Signature · 1 line
1.7.10.4
PATCH v2 3/10 dfu:core: Export dfu_{get|free}_buf functions
In reply to Lukasz MajewskiDefine the dfu_get_buf() and dfu_free_buf() as global functions. They are necessary for zero copy buffer management, when DFU backend is used for storing data.
---
Changes for v2:
- None
drivers/dfu/dfu.c | 4 ++-- include/dfu.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/dfu/dfu.c +2 -2
@@ -67,14 +67,14 @@ int dfu_init_env_entities(char *interface, int dev)static unsigned char *dfu_buf;static unsigned long dfu_buf_size =CONFIG_SYS_DFU_DATA_BUF_SIZE ; -static unsigned char *dfu_free_buf (void ) +unsigned char *dfu_free_buf (void ) {free (dfu_buf); dfu_buf =NULL ;return dfu_buf; } -static unsigned char *dfu_get_buf (void ) +unsigned char *dfu_get_buf (void ) {char *s;
include/dfu.h +2 -0
@@ -129,6 +129,8 @@ void dfu_trigger_reset(void);int dfu_get_alt (char *name);bool dfu_reset (void );int dfu_init_env_entities (char *interface,int dev); +unsigned char *dfu_get_buf (void ); +unsigned char *dfu_free_buf (void );int dfu_read (struct dfu_entity *de,void *buf,int size,int blk_seq_num);int dfu_write (struct dfu_entity *de,void *buf,int size,int blk_seq_num);
Signature · 1 line
1.7.10.4
PATCH v2 4/10 usb:g_dnl: Replace static usb_configuration structure with dynamically allocated one
In reply to Lukasz MajewskiWhen the usb_configuration structure is declared as static, it is very hard to assure, that relevant fields (as e.g. config->interfaces[]) are cleared out before new call to g_dnl related functions.
---
Changes for v2:
- None
drivers/usb/gadget/g_dnl.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/usb/gadget/g_dnl.c +16 -8
@@ -79,6 +79,8 @@ static int g_dnl_unbind(struct usb_composite_dev *cdev) {struct usb_gadget *gadget = cdev->gadget; +free (cdev->config); + cdev->config =NULL ;debug ("%s: calling usb_gadget_disconnect for " "controller '%s'\n" , shortname, gadget->name);usb_gadget_disconnect (gadget);
@@ -105,16 +107,22 @@ static int g_dnl_do_config(struct usb_configuration *c)static int g_dnl_config_register (struct usb_composite_dev *cdev) { -static struct usb_configuration config = { - .label ="usb_dnload" , - .bmAttributes =USB_CONFIG_ATT_ONE |USB_CONFIG_ATT_SELFPOWER , - .bConfigurationValue =CONFIGURATION_NUMBER , - .iConfiguration =STRING_USBDOWN , +struct usb_configuration *config; +const char *name ="usb_dnload" ; - .bind = g_dnl_do_config, - }; + config =memalign (CONFIG_SYS_CACHELINE_SIZE ,sizeof (*config)); +if (!config) +return -ENOMEM ; -return usb_add_config (cdev, &config); +memset (config,0 ,sizeof (*config)); + + config->label = name; + config->bmAttributes =USB_CONFIG_ATT_ONE |USB_CONFIG_ATT_SELFPOWER ; + config->bConfigurationValue =CONFIGURATION_NUMBER ; + config->iConfiguration =STRING_USBDOWN ; + config->bind = g_dnl_do_config; + +return usb_add_config (cdev, config); }__weak
Signature · 1 line
1.7.10.4
PATCH v2 5/10 usb:g_dnl: Add name parameter to g_dnl_bind_fixup function
In reply to Lukasz MajewskiNew parameter, namely *name has been added to g_dnl_bind_fixup(). It is necessary (for compatibility reasons) to assign new USB idProduct and idVendor for different usb functions.
---
Changes for v2:
- None
board/siemens/common/factoryset.c | 2 +- drivers/usb/gadget/g_dnl.c | 4 ++-- include/g_dnl.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
board/siemens/common/factoryset.c +1 -1
@@ -275,7 +275,7 @@ int factoryset_setenv(void)return ret; } -int g_dnl_bind_fixup (struct usb_device_descriptor *dev) +int g_dnl_bind_fixup (struct usb_device_descriptor *dev,const char *name) {put_unaligned (factory_dat.usb_vendor_id, &dev->idVendor);put_unaligned (factory_dat.usb_product_id, &dev->idProduct);
drivers/usb/gadget/g_dnl.c +2 -2
@@ -126,7 +126,7 @@ static int g_dnl_config_register(struct usb_composite_dev *cdev) }__weak -int g_dnl_bind_fixup (struct usb_device_descriptor *dev) +int g_dnl_bind_fixup (struct usb_device_descriptor *dev,const char *name) {return 0 ; }
@@ -153,7 +153,7 @@ static int g_dnl_bind(struct usb_composite_dev *cdev) g_dnl_string_defs[1 ].id = id; device_desc.iProduct = id; -g_dnl_bind_fixup (&device_desc); +g_dnl_bind_fixup (&device_desc, cdev->driver->name); ret =g_dnl_config_register (cdev);if (ret) goto error;
include/g_dnl.h +1 -1
@@ -10,7 +10,7 @@#include <linux/usb/ch9.h> #include <linux/usb/gadget.h> -int g_dnl_bind_fixup (struct usb_device_descriptor *); +int g_dnl_bind_fixup (struct usb_device_descriptor *,const char *);int g_dnl_register (const char *s);void g_dnl_unregister (void );
Signature · 1 line
1.7.10.4
PATCH v2 6/10 usb:g_dnl:f_thor: USB download function to support TIZEN's THOR protocol
In reply to Lukasz MajewskiImplementation of USB download function which supports THOR protocol.
---
Changes for v2:
- Change thor_{rx|tx}_data_buf to unsigned char
- Replace '\0' to 0 on memset calls
- Refactor switch() at thor_rx_tx_complete()
- Add missing static declaration
- Rewrite logic at alloc_ep_req() and thor_eps_setup()
- Add SZ_XM at f_thor.h thor packet size definition
- Remove *recv_key = "THOR" and *tx_key = "ROHT". Use "THOR" and "ROHT" directly
drivers/usb/gadget/Makefile | 1 + drivers/usb/gadget/f_thor.c | 1003 +++++++++++++++++++++++++++++++++++++++++++ drivers/usb/gadget/f_thor.h | 124 ++++++ include/thor.h | 27 ++ 4 files changed, 1155 insertions(+) create mode 100644 drivers/usb/gadget/f_thor.c create mode 100644 drivers/usb/gadget/f_thor.h create mode 100644 include/thor.h
drivers/usb/gadget/Makefile +1 -0
@@ -21,6 +21,7 @@ ifdef CONFIG_USB_GADGET COBJS-$(CONFIG_USB_GADGET_ATMEL_USBA) += atmel_usba_udc.o COBJS-$(CONFIG_USB_GADGET_S3C_UDC_OTG) += s3c_udc_otg.o COBJS-$(CONFIG_USB_GADGET_FOTG210) += fotg210.o +COBJS-$(CONFIG_THOR_FUNCTION) += f_thor.o COBJS-$(CONFIG_USBDOWNLOAD_GADGET) += g_dnl.o COBJS-$(CONFIG_DFU_FUNCTION) += f_dfu.o COBJS-$(CONFIG_USB_GADGET_MASS_STORAGE) += f_mass_storage.o
drivers/usb/gadget/f_thor.c new file +1003 -0
1,003 lines not on this page · raw message
drivers/usb/gadget/f_thor.h new file +124 -0
124 lines not on this page · raw message
include/thor.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* thor.h -- USB THOR Downloader protocol +* +* Copyright (C) 2013 Samsung Electronics +* Lukasz Majewski <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +* +*/ + +#ifndef __THOR_H_ +#define __THOR_H_ + +#include <linux/usb/composite.h> + +int thor_handle (void ); +int thor_init (void ); + +#ifdef CONFIG_THOR_FUNCTION +int thor_add (struct usb_configuration *c); +#else +int thor_add (struct usb_configuration *c) +{ +return 0 ; +} +#endif +#endif /* __THOR_H_ */
Signature · 1 line
1.7.10.4
PATCH v2 7/10 usb:g_dnl: Support for TIZEN's THOR function in generic download code
In reply to Lukasz MajewskiSupport of "thor" function in generic download code (g_dnl.c).
---
Changes for v2:
- None
drivers/usb/gadget/g_dnl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/usb/gadget/g_dnl.c +8 -2
@@ -16,6 +16,7 @@#include <g_dnl.h> #include <usb_mass_storage.h> #include <dfu.h> +#include <thor.h> #include "gadget_chips.h" #include "composite.c"
@@ -101,6 +102,8 @@ static int g_dnl_do_config(struct usb_configuration *c) ret =dfu_add (c); else if (!strcmp(s, "usb_dnl_ums")) ret =fsg_add (c); + else if (!strcmp(s, "usb_dnl_thor")) + ret =thor_add (c);return ret; }
@@ -191,8 +194,8 @@ static struct usb_composite_driver g_dnl_driver = {int g_dnl_register (const char *type) { -/* We only allow "dfu" atm, so 3 should be enough */ -static char name[sizeof (shortname) +3 ]; +/* The largest function name is 4 */ +static char name[sizeof (shortname) +4 ];int ret;if (!strcmp (type,"dfu" )) {
@@ -201,6 +204,9 @@ int g_dnl_register(const char *type) }else if (!strcmp (type,"ums" )) {strcpy (name, shortname);strcat (name, type); + }else if (!strcmp (type,"thor" )) { +strcpy (name, shortname); +strcat (name, type); }else {printf ("%s: unknown command: %s\n" , __func__, type);return -EINVAL ;
Signature · 1 line
1.7.10.4
PATCH v2 8/10 cmd:thor: Support for TIZEN's download command (thordown)
In reply to Lukasz MajewskiNew command - thordown - has been added to support downloading data via lthor TIZEN program.
It is similar to dfu command syntax and reuses its code for flashing data.
---
Changes for v2:
- Adjust according to new board_usb_init() function semantics.
- do_thor_down() written in a similar way to rewritten do_dfu() function
- Check error condition for board_usb_init()
common/Makefile | 1 + common/cmd_thordown.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 common/cmd_thordown.c
common/Makefile +1 -0
@@ -168,6 +168,7 @@ COBJS-y += usb.o usb_hub.o COBJS-$(CONFIG_USB_STORAGE) += usb_storage.o endif COBJS-$(CONFIG_CMD_USB_MASS_STORAGE) += cmd_usb_mass_storage.o +COBJS-$(CONFIG_CMD_THOR_DOWNLOAD) += cmd_thordown.o COBJS-$(CONFIG_CMD_XIMG) += cmd_ximg.o COBJS-$(CONFIG_YAFFS2) += cmd_yaffs2.o COBJS-$(CONFIG_CMD_SPL) += cmd_spl.o
common/cmd_thordown.c new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 9/10 samsung:common:thor: Define common Samsung code to handle THOR usb descriptor setup
In reply to Lukasz MajewskiSpecial, common to Samsung, function for altering usb descriptor's idVendor and idProduct has been added.
For compatibility reasons (Win vs Linux) the THOR idProduct must be different than the one for DFU/UMS.
---
Changes for v2:
- None
board/samsung/common/Makefile | 1 + board/samsung/common/thor.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 board/samsung/common/thor.c
board/samsung/common/Makefile +1 -0
@@ -10,6 +10,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)libsamsung.o COBJS-$(CONFIG_SOFT_I2C_MULTI_BUS) += multi_i2c.o +COBJS-$(CONFIG_THOR_FUNCTION) += thor.o SRCS := $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(COBJS-y))
board/samsung/common/thor.c new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Copyright (C) 2013 Samsung Electronics +* Lukasz Majewski <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <linux/usb/ch9.h> + +int g_dnl_bind_fixup (struct usb_device_descriptor *dev,const char *name) +{ +if (!strcmp (name,"usb_dnl_thor" )) { +put_unaligned (CONFIG_G_DNL_THOR_VENDOR_NUM , &dev->idVendor); +put_unaligned (CONFIG_G_DNL_THOR_PRODUCT_NUM , &dev->idProduct); + }else { +put_unaligned (CONFIG_G_DNL_VENDOR_NUM , &dev->idVendor); +put_unaligned (CONFIG_G_DNL_PRODUCT_NUM , &dev->idProduct); + } +return 0 ; +}
Signature · 1 line
1.7.10.4
PATCH v2 10/10 trats: Update TRATS config to support TIZEN download
In reply to Lukasz MajewskiA set of environment variables needs to be updated to provide support for TIZEN download command (tizendown).
Since DFU is used as a flashing backend, it is also necessary to extent malloc pool size for DFU buffer allocation.
Moreover, for compatibility reasons (Win vs. Lin) new USB idProduct number for download gadget had to be added.
---
Changes for v2:
- Replace (X << 20) with SZ_XM defines
include/configs/trats.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
include/configs/trats.h +12 -2
@@ -49,8 +49,9 @@#define MACH_TYPE_TRATS 3928#define CONFIG_MACH_TYPE MACH_TYPE_TRATS +#include <asm/sizes.h> /* Size of malloc() pool */ -#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (16 << 20)) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (80 * SZ_1M))/* select serial console configuration */ #define CONFIG_SERIAL2 /* use SERIAL 2 */
@@ -91,12 +92,20 @@/* USB Composite download gadget - g_dnl */ #define CONFIG_USBDOWNLOAD_GADGET + +/* TIZEN THOR downloader support */ +#define CONFIG_CMD_THOR_DOWNLOAD +#define CONFIG_THOR_FUNCTION + +#define CONFIG_SYS_DFU_DATA_BUF_SIZE SZ_32M#define CONFIG_DFU_FUNCTION #define CONFIG_DFU_MMC /* USB Samsung's IDs */ #define CONFIG_G_DNL_VENDOR_NUM 0x04E8#define CONFIG_G_DNL_PRODUCT_NUM 0x6601 +#define CONFIG_G_DNL_THOR_VENDOR_NUM CONFIG_G_DNL_VENDOR_NUM +#define CONFIG_G_DNL_THOR_PRODUCT_NUM 0x685D#define CONFIG_G_DNL_MANUFACTURER "Samsung"#define CONFIG_BOOTDELAY 1
@@ -131,7 +140,8 @@#define CONFIG_DFU_ALT \ "u-boot mmc 80 400;" \ "uImage ext4 0 2;" \ - "exynos4210-trats.dtb ext4 0 2\0" + "exynos4210-trats.dtb ext4 0 2;" \ + ""PARTS_ROOT" part 0 5\0"#define CONFIG_ENV_OVERWRITE #define CONFIG_SYS_CONSOLE_INFO_QUIET
Signature · 1 line
1.7.10.4
Marek Vasut
Appliedv2 cover usb: Support for TIZEN's THOR download protocol
In reply to Lukasz MajewskiDear Lukasz Majewski,
Quoted 20 lines
This patch series provide support for TIZEN's THOR download protocol.
Dedicated program for flashing TIZEN developer devices (TRATS, TRATS2) is called lthor (or thor for Windows) and can be found at:
git clone
git://review.tizen.org/tools/lthoror for git web:
https://review.tizen.org/git/?p=tools/lthor.git;a=summary
Presented composite USB function acts as a front end to perform correct USB communication with HOST PC.
To store the received data on the target, the DFU (Device Firmware Update) code for flashing has been reused.This means, that the "
dfu_alt_info" environment variable is used to provide information where a received file is stored.
Quoted 8 lines
This also means that dfu and thor can co-exists together. Thor protocol and its implementation has one advantage - it is much faster than DFU for large files transfers (especially rootfs images).
It applies on: u-boot-denx-usb/next
SHA1:6928d26b84a5aa4a44706362234ab435bb15a6fbTest HW: Exynos4210 (TRATS)
Applied all, thanks
Best regards,
Marek Vasut