diff --git a/arch/arm/src/stm32f7/stm32_otghost.c b/arch/arm/src/stm32f7/stm32_otghost.c index 20e308849b4..dd9992420dd 100644 --- a/arch/arm/src/stm32f7/stm32_otghost.c +++ b/arch/arm/src/stm32f7/stm32_otghost.c @@ -2200,6 +2200,7 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, size_t xfrlen; ssize_t xfrd; int ret; + bool zlp; /* Loop until the transfer completes (i.e., buflen is decremented to zero) * or a fatal error occurs (any error other than a simple NAK) @@ -2208,8 +2209,9 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, chan = &priv->chan[chidx]; start = clock_systimer(); xfrd = 0; + zlp = (buflen == 0); - while (buflen > 0) + while (buflen > 0 || zlp) { /* Transfer one packet at a time. The hardware is capable of queueing * multiple OUT packets, but I just haven't figured out how to handle @@ -2286,6 +2288,7 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, buffer += xfrlen; buflen -= xfrlen; xfrd += chan->xfrd; + zlp = false; } } diff --git a/arch/arm/src/stm32h7/stm32_otghost.c b/arch/arm/src/stm32h7/stm32_otghost.c index 3f20583560c..d7851eea0f6 100644 --- a/arch/arm/src/stm32h7/stm32_otghost.c +++ b/arch/arm/src/stm32h7/stm32_otghost.c @@ -2205,6 +2205,7 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, size_t xfrlen; ssize_t xfrd; int ret; + bool zlp; /* Loop until the transfer completes (i.e., buflen is decremented to zero) * or a fatal error occurs (any error other than a simple NAK) @@ -2213,8 +2214,9 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, chan = &priv->chan[chidx]; start = clock_systimer(); xfrd = 0; + zlp = (buflen == 0); - while (buflen > 0) + while (buflen > 0 || zlp) { /* Transfer one packet at a time. The hardware is capable of queueing * multiple OUT packets, but I just haven't figured out how to handle @@ -2291,6 +2293,7 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, buffer += xfrlen; buflen -= xfrlen; xfrd += chan->xfrd; + zlp = false; } } diff --git a/arch/arm/src/stm32l4/stm32l4_otgfshost.c b/arch/arm/src/stm32l4/stm32l4_otgfshost.c index 25fb2071868..719a44085c7 100644 --- a/arch/arm/src/stm32l4/stm32l4_otgfshost.c +++ b/arch/arm/src/stm32l4/stm32l4_otgfshost.c @@ -2205,6 +2205,7 @@ static ssize_t stm32l4_out_transfer(FAR struct stm32l4_usbhost_s *priv, size_t xfrlen; ssize_t xfrd; int ret; + bool zlp; /* Loop until the transfer completes (i.e., buflen is decremented to zero) * or a fatal error occurs (any error other than a simple NAK) @@ -2213,8 +2214,9 @@ static ssize_t stm32l4_out_transfer(FAR struct stm32l4_usbhost_s *priv, chan = &priv->chan[chidx]; start = clock_systimer(); xfrd = 0; + zlp = (buflen == 0); - while (buflen > 0) + while (buflen > 0 || zlp) { /* Transfer one packet at a time. The hardware is capable of queueing * multiple OUT packets, but I just haven't figured out how to handle @@ -2291,6 +2293,7 @@ static ssize_t stm32l4_out_transfer(FAR struct stm32l4_usbhost_s *priv, buffer += xfrlen; buflen -= xfrlen; xfrd += chan->xfrd; + zlp = false; } }