[Cryptech Tech] USB interface

Peter Stuge peter at stuge.se
Sat Jun 6 02:43:34 UTC 2020


Hi,

Peter Stuge wrote:
> Peter Stuge wrote:
> > I suggest:
> > 
> > 1. Move forward with SAMD11 replacing FTDI
> > 2. Add CTS+RTS to the UART interface
> 
> I discovered that CTS+RTS are actually already connected to the USER FTDI
> in the rev03 schematic, but not to the MGMT FTDI. So at least some of the
> routing already exists!
> 
> Paul, do you know if the STM32 USER UART init code enables nCTS+nRTS use?

I thought that the answer is yes, since:

commit 3109973fe239e60f4ec223ce95ef1609ea329e7c
Author: Fredrik Thulin <fredrik at thulin.net>
Date:   Wed May 18 14:44:01 2016 +0200

    A little more robust file transfer

...

diff --git a/stm-init.c b/stm-init.c
index ab1905b..4421b21 100644
@@ -122,7 +122,7 @@ static void MX_USART2_UART_Init(void)
   huart_user.Init.StopBits = UART_STOPBITS_1;
   huart_user.Init.Parity = UART_PARITY_NONE;
   huart_user.Init.Mode = UART_MODE_TX_RX;
-  huart_user.Init.HwFlowCtl = UART_HWCONTROL_NONE;
+  huart_user.Init.HwFlowCtl = UART_HWCONTROL_RTS_CTS;
   huart_user.Init.OverSampling = UART_OVERSAMPLING_16;
 
   if (HAL_UART_Init(&huart_user) != HAL_OK) {


...but the answer is really no, hardware flow control has never worked
on the Alpha. If anyone has experienced communication issues then this
might well be why. A patch is attached.


> In a couple of days I'll check if wiring them to my SAMD11 daughterboard2
> does anything.

I've done this now. It turned out to be complicated, so it took a while.

The daughterboard2 I use for SAMD11 firmware testing and development covered
most of the FTDI chip so I soldered wires to the STM32 pins, which was fiddly,
and then I had to desolder the FTDI chip, because it seems to drive RTS even
when held in reset! >:( Then I observed that STM32 ignored CTS, guessed that
initialization was incorrect, and learned the horrible HAL way to fix that.

The good news is that a SAMD11 firmware using hardware flow control and
interrupts, no DMA, sends RPC_GET_VERSION to STM32 and receives the
response correctly every time, once the STM32 init code has been fixed.

So the SAMD11 USB interface I propose has been tested, and is reliable.


Kind regards

//Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-stm-uart.c-Program-CTS-and-RTS-pins-as-alternate-fun.patch
Type: text/x-diff
Size: 1514 bytes
Desc: not available
URL: <https://lists.cryptech.is/archives/tech/attachments/20200606/35a4fca7/attachment.patch>


More information about the Tech mailing list