Jetson/L4T/peripheral/

= CAN =

Internal Loopback test

 * Connections


 * Setup

1. Configure pinmux for CAN bus through Jetson IO 1-1. Run Jetson-IO $ sudo /opt/nvidia/jetson-io/jetson-io.py 1-2. Enable can0 and can1 Configure Jetson 40pin Header -> Configure header pins manually -> Enable can0/can1 as following -> Back -> Save pin changes -> Save and reboot to reconfigure pins -> Enter [*] can0          (29,31) [*] can1          (33,37)
 * Steps to verify

1-3. Check pinmux register $ sudo busybox devmem 0x0c303018 //can0_din - 0xC454 $ sudo busybox devmem 0x0c303010 //can0_dout - 0xC400 $ sudo busybox devmem 0x0c303008 //can1_din - 0xC454 $ sudo busybox devmem 0x0c303000 //can1_dout - 0xC400

2. Enable CAN 2-1. Load kernel modules $ sudo modprobe can => can: controller area network core $ sudo modprobe can_raw => can: raw protocol $ sudo modprobe mttcan => net canX: mttcan device registered (regs=00000000b6e0395a, irq=51)

2-2. Setup interface $ sudo ip link set can0 up type can bitrate 500000 dbitrate 1000000 berr-reporting on fd on $ sudo ip link set can1 up type can bitrate 500000 dbitrate 1000000 berr-reporting on fd on

2-3. Check can interface $ ifconfig can0: flags=193 mtu 72 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10  (UNSPEC) RX packets 0 bytes 0 (0.0 B)        RX errors 0  dropped 0  overruns 0  frame 0 TX packets 0 bytes 0 (0.0 B)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 device interrupt 51 can1: flags=193 mtu 72 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10  (UNSPEC) RX packets 0 bytes 0 (0.0 B)        RX errors 0  dropped 0  overruns 0  frame 0 TX packets 0 bytes 0 (0.0 B)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 device interrupt 52

3. Test

3-1. Run candump for all interface in background $ candump -x any &

3-2. Run cansend from can0-TX, and you will see it receive the same data from can1-RX $ cansend can0 123#abcdabcd can1 RX - -  123   [4]  AB CD AB CD  can0  TX - -  123   [4]  AB CD AB CD

MCP2515 Verification

 * Connections


 * Setup

SPI: spi1: spi@3210000 spi3: spi@3230000
 * Mapping

Interrupt: PIN29 -> GPIO01 -> PQ.05 PIN33 -> GPIO13 -> PH.00


 * Steps to verify

'''Step1. Add configuration in device tree for MCP2515'''

'''Step2. Configure pinmux for CAN bus through Jetson-IO'''

2-1 Run Jetson-IO $ sudo /opt/nvidia/jetson-io/jetson-io.py

2-2 Enable spi1 and spi3

Configure Jetson 40pin Header -> Configure header pins manually -> Enable spi1/spi3 as following -> Back -> Save pin changes -> Save and reboot to reconfigure pins -> Enter [*] spi1          (19,21,23,24,26) [*] spi3          (13,16,18,22,37)

'''Step3. Enable can0/can1 and test'''

$ sudo ip link set can0 up type can bitrate 500000 $ sudo ip link set can1 up type can bitrate 500000 $ candump -x any & $ cangen can0

= SPI =

Loopback test
'''Step 1. Connect MOSI and MISO of SPI1'''

MOSI(PIN19 of 40-pin GPIO header) MISO(PIN21 of 40-pin GPIO header)

'''Step 2. Remove GPIO usage of SPI pins'''

2-1. Check flash log to know which dtb you are using (ex. tegra210-p3448-0000-p3449-0000-b00.dtb)

2-2. Remove GPIO usage in that device tree

2-2-1. Method 1 - Remove from source

2-2-2. Method 2 - Remove from decompiled dtb

2-2-2-1 Find you dtb in Linux_for_Tegra/kernel/dtb/tegra210-p3448-0000-p3449-0000-b00.dtb

2-2-2-2 Dissemble the dtb to dts $ dtc -I dtb -O dts -o temp.dts tegra210-p3448-0000-p3449-0000-b00.dtb

2-2-2-3 Modify the following line

2-2-2-4 Assemble the dts back to dtb dtc -I dts -O dtb -o tegra210-p3448-0000-p3449-0000-b00.dtb temp.dts

2-2-2-5 Flash the board

'''Step 3. Running Jetson-IO to enable SPI1'''

3-1. Run Jetson IO $ sudo /opt/nvidia/jetson-io/jetson-io.py

3-2. Configure SPI1 Configure Jetson 40pin Header => Configure header pins manually => Select "spi1 (19,21,23,24,26)" => Back -> Save pin changes => Save and reboot to reconfigure pins

3-3. Check pinmux for SPI if the same as following $ sudo cat /sys/kernel/debug/tegra_pinctrl_reg | grep -i spi Bank: 1 Reg: 0x70003050 Val: 0x0000e044 -> spi1_mosi_pc0 Bank: 1 Reg: 0x70003054 Val: 0x0000e044 -> spi1_miso_pc1 Bank: 1 Reg: 0x70003058 Val: 0x0000e044 -> spi1_sck_pc2 Bank: 1 Reg: 0x7000305c Val: 0x0000e048 -> spi1_cs0_pc3 Bank: 1 Reg: 0x70003060 Val: 0x0000e048 -> spi1_cs1_pc4 Bank: 1 Reg: 0x70003064 Val: 0x00006044 -> spi2_mosi_pb4 Bank: 1 Reg: 0x70003068 Val: 0x00006044 -> spi2_miso_pb5 Bank: 1 Reg: 0x7000306c Val: 0x00006044 -> spi2_sck_pb6 Bank: 1 Reg: 0x70003070 Val: 0x00006048 -> spi2_cs0_pb7 Bank: 1 Reg: 0x70003074 Val: 0x00006048 -> spi2_cs1_pdd0

'''Step 4. Probe SPI driver'''

$ sudo modprobe spidev

'''Step 5. Download/build this test file'''

5-1 Download $ wget https://raw.githubusercontent.com/torvalds/linux/v4.9/tools/spi/spidev_test.c

5-2 Build on the board $ gcc -o spidev_test spidev_test.c

'''Step 6. Run the command and check if the result is expected'''

$ sudo ./spidev_test -D /dev/spidev0.0 -v -p "HelloWorld123456789abcdef" Or $ sudo ./spidev_test -D /dev/spidev0.0 -s 10000000 -v

= I2C =

Commands
$ sudo i2cdump -y 0 0x50
 * Module

$ sudo i2cdump -y 0 0x56
 * Carrier board

$ i2cdetect -y 0
 * Check I2C bus 0

= Flash =

Image-Based OTA with layout change

 * Device: Xavier NX devkit - eMMC


 * Version: R32.7.4 -> R35.4.1

[Host]

1. Setup environment variable $ export BASE_BSP=${HOME}/workspace/nvidia_sdk/JetPack_4.6.4_Linux_JETSON_XAVIER_NX_TARGETS/Linux_for_Tegra $ export TARGET_BSP=${HOME}/workspace/nvidia_sdk/JetPack_5.1.2_Linux_JETSON_XAVIER_NX_TARGETS/Linux_for_Tegra

2. Extract OTA tool $ cd ${TARGET_BSP}/../ $ wget https://developer.nvidia.com/downloads/embedded/l4t/r35_release_v4.1/release/ota_tools_r35.4.1_aarch64.tbz2 $ sudo tar xpf ota_tools_r35.4.1_aarch64.tbz2



3. Generate recovery image and recovery dtb $ cd ${TARGET_BSP} $ sudo ./tools/ota_tools/version_upgrade/build_base_recovery_image.sh jetson-xavier-nx-devkit-emmc R32-7 ${BASE_BSP} ${BASE_BSP}/rootfs ${TARGET_BSP}



4. Generate OTA package

$ sudo -E ./tools/ota_tools/version_upgrade/l4t_generate_ota_package.sh jetson-xavier-nx-devkit-emmc R32-7

..



 (or Update NVMe) $ sudo -E ./tools/ota_tools/version_upgrade/l4t_generate_ota_package.sh --external-device nvme0n1 -S 118GiB jetson-xavier-nx-devkit-emmc R32-7

5. Put OTA package into target $ scp ${TARGET_BSP}/bootloader/jetson-xavier-nx-devkit-emmc/ota_payload_package.tar.gz nvidia@ :~/



[Target]

1. Setup OTA tool $ cd ${HOME} $ mkdir ota-tool $ export WORKDIR=${HOME}/ota-tool $ wget https://developer.nvidia.com/downloads/embedded/l4t/r35_release_v4.1/release/ota_tools_r35.4.1_aarch64.tbz2 $ sudo tar xpf ota_tools_r35.4.1_aarch64.tbz2 -C ${WORKDIR}/.

2. Place OTA package $ sudo mkdir /ota $ sudo mv ${HOME}/ota_payload_package.tar.gz /ota/



3. Unpack the OTA payload package and prepare to start OTA $ cd ${WORKDIR}/Linux_for_Tegra/tools/ota_tools/version_upgrade $ sudo ./nv_ota_start.sh /ota/ota_payload_package.tar.gz



..



4. Reboot to start OTA update $ sudo reboot



..



PXE boot
[Host]

1. DHCP server

1-1. Install $ sudo apt install isc-dhcp-server

1-2. Configuration modify /etc/default/isc-dhcp-server, XXX is the network interface connected to target

INTERFACESv4="XXX" INTERFACESv6="" DHCPDARGS="XXX"

1-3. Add pxe details in dhcp conf file (/etc/dhcp/dhcpd.conf), if XXX interface shows 192.168.0.1

1-4. Restart and check DHCP server $ sudo ifconfig enx00e04c360130 192.168.0.1 $ sudo systemctl restart isc-dhcp-server $ sudo systemctl status isc-dhcp-server

2. Setup TFTP Server

2-1. Install $ sudo apt install -y tftpd-hpa

2-2. Configuration modify /etc/default/tftpd-hpa, OOO is the username of your host PC

TFTP_USERNAME="OOO" TFTP_DIRECTORY="/tftp" TFTP_ADDRESS=":69" TFTP_OPTIONS="--secure"

2-3. Restart and check TFTP server $ sudo apt purge xinetd $ sudo systemctl restart tftpd-hpa $ sudo systemctl status tftpd-hpa.service

3. Restart host PC

4. Setup NFS $ export MYROOTFS=${HOME}/workspace/nvidia_sdk/JetPack_5.1.2_Linux_JETSON_AGX_ORIN_TARGETS/Linux_for_Tegra/rootfs $ echo "$MYROOTFS *(rw,sync,insecure,no_subtree_check,no_root_squash)" | sudo tee --append /etc/exports > /dev/null

5. OS setup

5-1. Create directory $ sudo mkdir /tftp $ sudo mkdir /tftp/grub $ sudo mkdir /tftp/efi

5-2. Copy files (kernel image, initrd, efi) $ sudo cp $MYROOTFS/boot/Image /tftp/ $ sudo cp $MYROOTFS/boot/initrd.img /tftp/ (https://ubuntu.pkgs.org/20.04/ubuntu-main-arm64/grub-efi-arm64-signed_1.142+2.04-1ubuntu26_arm64.deb.html) $ sudo cp grubnetaa64.efi.signed /tftp/efi/

5-3. Create grub.cfg $ sudo touch /tftp/grub/grub.cfg

modify grub.cfg as following:

[Target]

1. Reboot

2. Press ESC to enter UEFI menu

3. Select PXE as boot device