Simply copying bytes from one UART to the other will not work.
If the sending side (PC serial adapter) is just by 0.1% faster than the MCU, it will start dropping bytes after the 1000th byte. The frequency accuracy of the STM32F107 internal clock is given as -1.1% to +1.8% at room temperature in the datasheet, so it might as well happen earlier, and the other two participants might not be perfectly accurate either.
Dropping bytes in the middle of a firmware update to an otherwise inaccessible part is not going to be funny.
You need circular (FIFO) buffers both ways
The size of the buffer is determined by the size of the data packets, and the sum of the frequency inaccuracies in the participating devices. E.g. if there is 64 kB data in one block, and both devices have +/- 2% frequency accuracy, then you'd need at least 65536*0.04 ~ 2622 bytes buffer.
Do this in an endless loop,
- check for
RXNE
in USART1->SR
- if set, read the data from
USART1->DR
and put it at the head of the buffer (complain loudly if the buffer is full)
- check for
TXE
in UART5->SR`
- if set, AND the buffer is not empty, write the byte at the tail of the buffer into
UART5->DR
- do the same for the other direction