Skip to content

Instantly share code, notes, and snippets.

@ozgurgulsuna
Last active October 26, 2022 08:41
Show Gist options
  • Save ozgurgulsuna/147c038bfef78b497d9571bfbd17f729 to your computer and use it in GitHub Desktop.
Save ozgurgulsuna/147c038bfef78b497d9571bfbd17f729 to your computer and use it in GitHub Desktop.
Texas Instruments, TM4C123G, LaunchPad, Linux, USB/IP, USB Redirection, RDP.

Remote Program TM4C123
Ozgur Gulsuna

Middle East Technical University 2022

EE 447 Microprocessors lectures are arriving and in order to program the TI TM4C123G at anywhere I need to install Windows on my linux laptop. I really did not wanted to do that. The solution is remotely create a connection to a windows machine with usb redirecting.

This gist consist of installing required drivers on linux for Texas Instruments Tiva™ C Series TM4C123G and initializing USB/IP protocol to forward the usb connection of the micro-controller to the windows machine. Finally using RDP connection to program the launchpad remotely.

note that I could not get usb redirection feature of the RDP client (xfreerdp), maybe I could work on it.

Linux Drivers

Now we can install drivers of the debugger of the TM4C123G on linux. All Boards need a udev rule to be able to program as a regular user (not root). To install these udev rules, follow the steps below:

  1. Download the udev rules: TI udev rules

  2. Open a terminal and execute the following command:

sudo mv /71-ti-permissions.rules /etc/udev/rules.d/
  1. If your Linux distribution supports the service command you can active the new rules with sudo service udev restart. If your Linux distribution does not support this command or if you are not able to upload to the LaunchPad with Energia, then restart your computer to activate the rules.

If your board is pulled in, unplug it and plug it back in. Not needed if you rebooted your computer. Double check the usb cable for data transfer !

Now it is accessible via lsusb:

 Bus 001 Device 016: ID 1cbe:00fd Luminary Micro Inc. In-Circuit Debug Interface
 ̶B̶u̶s̶ ̶0̶0̶2̶ ̶D̶e̶v̶i̶c̶e̶ ̶0̶0̶1̶:̶ ̶I̶D̶ ̶1̶d̶6̶b̶:̶0̶0̶0̶3̶ ̶L̶i̶n̶u̶x̶ ̶F̶o̶u̶n̶d̶a̶t̶i̶o̶n̶ ̶3̶.̶0̶ ̶r̶o̶o̶t̶ ̶h̶u̶b̶
 ̶B̶u̶s̶ ̶0̶0̶1̶ ̶D̶e̶v̶i̶c̶e̶ ̶0̶0̶4̶:̶ ̶I̶D̶ ̶8̶0̶8̶7̶:̶0̶a̶2̶a̶ ̶I̶n̶t̶e̶l̶ ̶C̶o̶r̶p̶.̶ ̶B̶l̶u̶e̶t̶o̶o̶t̶h̶ ̶w̶i̶r̶e̶l̶e̶s̶s̶ ̶i̶n̶t̶e̶r̶f̶a̶c̶e̶
 ̶B̶u̶s̶ ̶0̶0̶1̶ ̶D̶e̶v̶i̶c̶e̶ ̶0̶0̶3̶:̶ ̶I̶D̶ ̶0̶4̶0̶8̶:̶5̶1̶e̶9̶ ̶Q̶u̶a̶n̶t̶a̶ ̶C̶o̶m̶p̶u̶t̶e̶r̶,̶ ̶I̶n̶c̶.̶ ̶H̶P̶ ̶W̶i̶d̶e̶ ̶V̶i̶s̶i̶o̶n̶ ̶H̶D̶ ̶C̶a̶m̶e̶r̶a̶
 ̶B̶u̶s̶ ̶0̶0̶1̶ ̶D̶e̶v̶i̶c̶e̶ ̶0̶1̶3̶:̶ ̶I̶D̶ ̶0̶4̶5̶e̶:̶0̶7̶f̶d̶ ̶M̶i̶c̶r̶o̶s̶o̶f̶t̶ ̶C̶o̶r̶p̶.̶ ̶N̶a̶n̶o̶ ̶T̶r̶a̶n̶s̶c̶e̶i̶v̶e̶r̶ ̶1̶.̶1̶
 ̶B̶u̶s̶ ̶0̶0̶1̶ ̶D̶e̶v̶i̶c̶e̶ ̶0̶0̶1̶:̶ ̶I̶D̶ ̶1̶d̶6̶b̶:̶0̶0̶0̶2̶ ̶L̶i̶n̶u̶x̶ ̶F̶o̶u̶n̶d̶a̶t̶i̶o̶n̶ ̶2̶.̶0̶ ̶r̶o̶o̶t̶ ̶h̶u̶b̶

and its port can be found under /dev/, named /dev/ttyACM0.

see Energia for more information.

Remote Desktop Protocol (RDP)

First we need to create a connection to the windows machine. We will use RDP, and the client on linux is freerdp.

to install it:

 sudo pacman -S freerdp 

the common command is:

 xfreerdp /u:<USERNAME> /p:<PASSWORD> /v:<IP> /w:1980 /h:1000 

for whom might be insterested in redirection in rdp, some basic commands are here:

sudo chmod -R 777 /dev/bus/usb/ to grant permissions for non root users to access usb ports.

xfreerdp /u:<USERNAME> /p:<PASSWORD> /v:<IP> /w:1980 /h:1000 /drives to share drives of the linux machine

xfreerdp /u:<USERNAME> /p:<PASSWORD> /v:<IP> /w:1980 /h:1000 /serial:COM4,/dev/ttyUSB0 to share serial port

xfreerdp /u:<USERNAME> /p:<PASSWORD> /v:<IP> /w:1980 /h:1000 /dvc:urbdrc,id,dev:054c:0268 to share usb port

See www.freerdp.com for more information. Also Manual can be reached here.

USB Redirecting using USB/IP

SB/IP Project aims to develop a general USB device sharing system over IP network. To share USB devices between computers with their full functionality, USB/IP encapsulates "USB I/O messages" into TCP/IP payloads and transmits them between computers.

Linux side

Installing the client

sudo pacman -S usbip

Activate the module.

sudo modprobe usbip_host

Start the module on boot. (reference)

sudo nano /etc/modules-load.d/usbip_host.conf
----------------------------------------------

# Load usbip_host at boot
usbip_host

Now check the busid of the device using

lsusb 
-----------------
 Bus 001 Device 016: ID 1cbe:00fd Luminary Micro Inc. In-Circuit Debug Interface
 ̶B̶u̶s̶ ̶0̶0̶2̶ ̶D̶e̶v̶i̶c̶e̶ ̶0̶0̶1̶:̶ ̶I̶D̶ ̶1̶d̶6̶b̶:̶0̶0̶0̶3̶ ̶L̶i̶n̶u̶x̶ ̶F̶o̶u̶n̶d̶a̶t̶i̶o̶n̶ ̶3̶.̶0̶ ̶r̶o̶o̶t̶ ̶h̶u̶b̶
 ̶B̶u̶s̶ ̶0̶0̶1̶ ̶D̶e̶v̶i̶c̶e̶ ̶0̶0̶4̶:̶ ̶I̶D̶ ̶8̶0̶8̶7̶:̶0̶a̶2̶a̶ ̶I̶n̶t̶e̶l̶ ̶C̶o̶r̶p̶.̶ ̶B̶l̶u̶e̶t̶o̶o̶t̶h̶ ̶w̶i̶r̶e̶l̶e̶s̶s̶ ̶i̶n̶t̶e̶r̶f̶a̶c̶e̶
 ̶B̶u̶s̶ ̶0̶0̶1̶ ̶D̶e̶v̶i̶c̶e̶ ̶0̶0̶3̶:̶ ̶I̶D̶ ̶0̶4̶0̶8̶:̶5̶1̶e̶9̶ ̶Q̶u̶a̶n̶t̶a̶ ̶C̶o̶m̶p̶u̶t̶e̶r̶,̶ ̶I̶n̶c̶.̶ ̶H̶P̶ ̶W̶i̶d̶e̶ ̶V̶i̶s̶i̶o̶n̶ ̶H̶D̶ ̶C̶a̶m̶e̶r̶a̶
 ̶B̶u̶s̶ ̶0̶0̶1̶ ̶D̶e̶v̶i̶c̶e̶ ̶0̶1̶3̶:̶ ̶I̶D̶ ̶0̶4̶5̶e̶:̶0̶7̶f̶d̶ ̶M̶i̶c̶r̶o̶s̶o̶f̶t̶ ̶C̶o̶r̶p̶.̶ ̶N̶a̶n̶o̶ ̶T̶r̶a̶n̶s̶c̶e̶i̶v̶e̶r̶ ̶1̶.̶1̶
 ̶B̶u̶s̶ ̶0̶0̶1̶ ̶D̶e̶v̶i̶c̶e̶ ̶0̶0̶1̶:̶ ̶I̶D̶ ̶1̶d̶6̶b̶:̶0̶0̶0̶2̶ ̶L̶i̶n̶u̶x̶ ̶F̶o̶u̶n̶d̶a̶t̶i̶o̶n̶ ̶2̶.̶0̶ ̶r̶o̶o̶t̶ ̶h̶u̶b̶

Corresponding port on usbip is listed using:

usbip list -p -l
-----------------
busid=1-3#usbid=1cbe:00fd#
̶b̶u̶s̶i̶d̶=̶1̶-̶2̶#̶u̶s̶b̶i̶d̶=̶0̶4̶5̶e̶:̶0̶7̶f̶d̶#̶
̶b̶u̶s̶i̶d̶=̶1̶-̶4̶#̶u̶s̶b̶i̶d̶=̶0̶4̶0̶8̶:̶5̶1̶e̶9̶#̶
̶b̶u̶s̶i̶d̶=̶1̶-̶7̶#̶u̶s̶b̶i̶d̶=̶8̶0̶8̶7̶:̶0̶a̶2̶a̶#̶

Then we can bind the selected usb device to the port

sudo usbip bind --busid=1-3
----------------------------
usbip: info: bind device on busid 1-3: complete

And start the daemon using:

sudo usbipd

check the IP address of the linux machine using:

ip addr

Continue with windows machine.

Windows side

  • Install USB/IP test certificate
    • Install driver/usbip_test.pfx (password: usbip)
    • Certificate should be installed into
      1. "Trusted Root Certification Authority" in "Local Computer" (not current user) and
      2. "Trusted Publishers" in "Local Computer" (not current user)
  • Enable test signing by opening PowerShell as administrator.
    • > bcdedit.exe /set TESTSIGNING ON
    • reboot the system to apply
  • Copy usbip.exe, usbipd.exe, usb.ids, usbip_stub.sys, usbip_stub.inx into a folder in target machine
    • You can find usbip.exe, usbipd.exe, usbip_stub.sys in the output folder after build or on release page.
    • userspace/usb.ids
    • driver/stub/usbip_stub.inx
  • Install the usbip by again in PowerShell as administrator.
    • ./usbip.exe install
  • Find USB Device ID
    • You can get id from usbip listing
      • ./usbip.exe list -r <Linux-IP>
    • Bus id is always 1. So output from usbip.exe listing is shown as:
 ./usbip.exe list -r <Linux-IP>
Exportable USB devices
======================
 - 144.122.248.124
        1-3: Luminary Micro Inc. : In-Circuit Debug Interface (1cbe:00fd)
           : /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3
           : Miscellaneous Device / ? / Interface Association (ef/02/01)
  • Finally attach the device using:
 ./usbip.exe attach -r 144.122.248.124 -b 1-3

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment