NVIDIA Jetson TX2 - ISU-MAVRIC/Old-MAVRIC-Systems GitHub Wiki

Internal System Diagram

Useful Links

Notes about HATs

GPS HAT (UART)

The Serial port on the HAT /dev/ttyS0 is the kernel serial console. This makes it inaccessible for user applications (GPS). It's permissions are rwx-w---- meaning we can write to it, but not read (the kernel intercepts all data for the console function). As such, we will have to use GPS through the port on J17 (/dev/ttyTHS2). This header does not provide power, so 3.3-5V will need to be supplied from another pin. We may want to use a protoboard with the UART lines running to J17 as an extra cable.

Linux modifications and startup scripts

Automatic startup with rc.local

Most rover functions would not automatically launch at boot by themselves. Fortunately, Linux provides an easy way to automatically run scripts as the boot sequence finishes. The file /etc/rc.local is left empty for user scripts to be added, and will be run by Linux right before the boot sequence ends. The scripts that have been added to rc.local are as follows:

home/mavric/catkin_ws/src/mavric/launch/startup.bash

This bash script reads an environment variable (which we have exported manually) to decide what type of computing board is booting. It is able to select between Arm RPi, Drive RPi, Master RPi, and Jetson boards. Once it decides on a board, it runs that board's ROS launch script to automatically start the appropriate set of ROS nodes.

TODO CAN bringup

This bash script automatically configures the can0 interface to control Talon SRX motor controllers over CAN.

Renaming devices with udev rules

The Jetson kernel assigns the can0 and can1 interface names to its native CAN interfaces. Unfortunately, these native interfaces do not have enough bandwidth to control all the Talon SRXs necessary for the rover to function. Instead of disabling native CAN in the Jetson kernel, udev rules are used to remap the native CAN interfaces and free up can0 for a high-bandwidth CANable USB-to-CAN adapter.

The Jetson TX2 stores its udev rules in the /etc/udev/rules.d directory. MAVRIC's custom udev rules are located in the file 99-mavric-devices.rules; the 99 means they will run last and override any prior rules. 99-mavric-devices.rules contains 4 rules, which will be explained below.

i2c removal

Any kernel I2C drivers starting with i2c- will be removed from the list of devices. This is necessary for the I2C bus to work, though it has been forgotten why.

Remap native CAN interfaces

As mentioned above, the Jetson kernel assigns the can0 and can1 interface names to its native CAN interfaces. MAVRIC needs to use a CANable USB-to-CAN adapter on can0 because the Phoenix Tuner software made by Cross the Road Electronics is only compatible with can0. This is the software used to test Talon SRXs and update their firmware, so maintaining compatibility is critical. Instead of dropping native CAN, udev rules are added to map can1->can2 and can0->can1. This mapping is made based on the kernel's original name for the interface, which is why a can0 interface can be added afterward.

Add CANable on can0

Finally, a udev rule is used to map a CANable USB-to-CAN to the can0 interface. This mapping is made based on the USB serial number of the CANable, which means that any other CANable device will not enumerate as can0! If a new CANable is used, this udev rule will need to be modified to list the serial number of the new CANAble device.

CANable baudrate setup and "ip up"

To start the canable, we need to initialize it's baudrate and start it up. This is done with the following commands:

sudo ip link set can0 type can bitrate 1000000

sudo ip link set up can0

These commands are stored in a folder in the mavric home directory under the folder startupScripts. This folder contains the file can_up.sh. This file contains the two commands and is started by a custom systemd service stored in /etc/systemd/system/can_up.service.

Jetson tips

Network interfaces such as can0, eth0, are listed at /sys/class/net instead of /dev.

You can use udevadm info /path/to/dev/or/interface to list udev properties of a device or interface. For example, the KERNEL=can0 attribute is used to remap the native can0 interface to can1.

After editing udev rules, you will need to restart the Jetson or run the command sudo udevadm control --reload-rules && sudo systemctl restart systemd-udevd && sudo udevadm trigger. Restarting the Jetson is more reliable, so do that if you can.

MAVRIC has udev rules at /etc/udev/rules.d/99-mavric-devices.rules.

MAVRIC also has startup scripts listed in /etc/rc.local.

For reasons unknown, the native can1 driver (remapped to can2) does not seem to work. You should not need to use it anyway.

Sometimes the Phoenix Tuner program doesn't connect to the Jetson properly. If CAN devices don't seem to be showing up in the tuner, do the following:

  • Click "Run Temporary Diagnostic Server" and input the Jetson's login credentials. The install will fail. This step is important because it gets you logged in to the Jetson so the next step can succeed.
  • Click "Install Phoenix Diagnostics". The install will probably succeed. If it doesn't, click "Uninstall Phoenix Diagnostics" and do this step again.
  • If the install succeeded but the server isn't running, use the "Force Stop" and "Force Start" buttons to bring the server down and up again.

The Phoenix Tuner program ships with some stock firmware files for various FRC devices, including the Talon SRX. These firmware files are installed on Windows computers at C:\Users\Public\Public Documents\FRC\