USB Debugger use DBG_CTRL for automated testing

Hi

On the Verdin Development Board there is USB converter FT4232HL that allows to control the DBG_CTRL signals (CTRL_RESET_MICO#, CTRL_RECOVERY_MICO#, …)

This allows to easy bring the board to Recovery Mode and we can flash the U-Boot over USB-Recovery.

Do you have script or sample-code that shows how to control those signals from a Linux (Ubuntu-20.04) over USB?

Best Regards
Stefan

On the Verdin Evaluation board, the CTRL_RESET_MICO# signal is connected to the ADBUS5 pin of the FT4232HL chip, and the CTRL_RECOVERY_MICO# is connected to the ADBUS7 pin.
When the FT4232HL is connected to a Linux (Ubuntu) machine, it is configured by default as an ASYNC Serial. In this mode, ADBUS5 is treated as DSR and ADBUS7 is treated as RI (Ring Indicator).
Unfortunately, manipulating the DSR and RI lines on a UART directly from a Linux shell is not straightforward. Such low-level hardware operations typically require a programming language like C, which provides functions to control the UART directly using ioctl. Another approach is to switch the FT4232HL into Bit Bang mode and manipulate the ADBUS5 and ADBUS7 lines using the FT_SetBitMode() function. However, this approach also necessitates the development of a special program.

Hi Alex
Thanks for the reply. I did some tests with ioctl (TIOCMBIC, TIOCMBIS) could manipulate RTS and DTR but not RI and DSR. I will continue with the tests and also try Bit Bang mode and keep you updated.
Best Regards
Stefan

I have found now a good and easy solution with python pylibftdi.

For installation see pylibftdi installation

pip3 install pylibftdi
sudo apt-get install libftdi1-dev

With the command pylibftdi.examples.list_devices you can discover your device and its id.

python3 -m pylibftdi.examples.list_devices
Toradex AG:Verdin DB v1.1E:11079014

The simple python script brings then the SOM to recovery mode.
Replace the your_device_id with the discovered id.

#!/usr/bin/python3

from pylibftdi import Driver, BitBangDevice, INTERFACE_A
import time

def main(device_id):
    dev = BitBangDevice(device_id, interface_select=INTERFACE_A)
     
    print("Start send to Recovery Mode")
    dev.direction = 0xA0
    dev.port = 0xA0
    time.sleep(0.1)
    dev.port = 0x20  # reset=False, recovery=True
    time.sleep(0.1)
    dev.port = 0x00  # reset=True, recovery=True
    time.sleep(0.1)
    dev.port = 0x20  # reset=False, recovery=True
    time.sleep(10.0) # wait 10sec
    dev.port = 0xA0  # reset=False, recovery=False)
    dev.direction = 0x00
    print("Recovery Mode now")

if __name__ == "__main__":
    # device_id discover with  python3 -m pylibftdi.examples.list_devices
    your_device_id="11079014"  
    main(your_device_id)