diff --git a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c
index 519407b77..4de13ce6c 100644
--- a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c
+++ b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c
@@ -433,10 +433,11 @@ static void otg_epout_handler(USBDriver *usbp, usbep_t ep) {
osp = usbp->epc[ep]->out_state;
/* A short packet always terminates a transaction.*/
- if (((osp->rxcnt % usbp->epc[ep]->out_maxsize) == 0) &&
+ if ((ep == 0) &&
+ ((osp->rxcnt % usbp->epc[ep]->out_maxsize) == 0) &&
(osp->rxsize < osp->totsize)) {
- /* In case the transaction covered only part of the total transfer
- then another transaction is immediately started in order to
+ /* For EP 0 only, in case the transaction covered only part of the total
+ transfer then another transaction is immediately started in order to
cover the remaining.*/
osp->rxsize = osp->totsize - osp->rxsize;
osp->rxcnt = 0;
diff --git a/readme.txt b/readme.txt
index 443552bec..4a43833b6 100644
--- a/readme.txt
+++ b/readme.txt
@@ -157,6 +157,8 @@
- RT: Merged RT4.
- NIL: Merged NIL2.
- NIL: Added STM32F7 demo.
+- HAL: Fixed transaction end problem with STM32 OTGv1 driver (bug #832)
+ (backported to 16.1.8).
- HAL: Removed unused file in STM32 TIM driver (bug #831).
- HAL: Fixed wrong comment in STM32F7 mcuconf (bug #830)(backported to 16.1.8).
- RT: Fixed race condition in chBMReset() (bug #828)(backported to 16.1.8).
diff --git a/testhal/STM32/STM32F7xx/USB_CDC/debug/STM32F7xx-USB_CDC (OpenOCD, Flash and Run).launch b/testhal/STM32/STM32F7xx/USB_CDC/debug/STM32F7xx-USB_CDC (OpenOCD, Flash and Run).launch
index 815648669..c0990b8c7 100644
--- a/testhal/STM32/STM32F7xx/USB_CDC/debug/STM32F7xx-USB_CDC (OpenOCD, Flash and Run).launch
+++ b/testhal/STM32/STM32F7xx/USB_CDC/debug/STM32F7xx-USB_CDC (OpenOCD, Flash and Run).launch
@@ -1,52 +1,52 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+