Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem setting up the bulk configuration using Jetson nano and M350 #229

Open
DPCW19 opened this issue Dec 5, 2024 · 23 comments
Open

Problem setting up the bulk configuration using Jetson nano and M350 #229

DPCW19 opened this issue Dec 5, 2024 · 23 comments

Comments

@DPCW19
Copy link

DPCW19 commented Dec 5, 2024

Hello,
I am trying to get the video feedback from my M350 dji drone using the e-port. I've followed the dji documentation without success. I am only able to get the telemetry using the serial port. I tried to set up the bulk port using the 2. Enable Jetson Nano's USB bulk function from the dji documentation and the README from the startup_bulk script. I did change the path /home/dji/Desktop/startup_bulk/startup_bulk /dev/usb-ffs/bulk1 & from l4-usb-device-mode-start.sh and l4-usb-device-mode.sh with my user.

When I run the command after reboot:
ps -aux | grep startup_bulk
I only get the following output:
my_user 12171 0.0 0.0 8944 2052 pts/6 S+ 09:45 0:00 grep startup_bulk

I also tried to add changes made by another user facing the same issue but with another drone : #179, but nothing has changed.

Thank you for your assistance.

@dji-dev
Copy link
Contributor

dji-dev commented Dec 6, 2024

Agent comment from Leon in Zendesk ticket #123724:

Hello, is there any error when you run the script l4-usb-device-mode-start.sh manually? From the phenomenon, your script did not successfully generate the BULK node.

°°°

@DPCW19
Copy link
Author

DPCW19 commented Dec 6, 2024

Hello,

Thanks for your feedback !

I've achieved to make the service nv-l4t-usb-device-mode.service work by removing the line cp -r /proc/device-tree/chosen/plugin-manager "${mntpoint}/version/plugin-manager" from the script nv-l4-usb-device-mode-start.sh.

The /dev/usb-ffs/ folder is created but I cannot see the usb device using lsusb after that.

My nv-l4-usb-device-mode-start.sh file:

#!/bin/bash

# Copyright (c) 2017-2020, NVIDIA CORPORATION.  All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#  * Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#  * Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#  * Neither the name of NVIDIA CORPORATION nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

set -ex

# Ensure the script runs as root
if [ "$(id -u)" -ne 0 ]; then
    echo "This script must be run as root"
    exit 1
fi

# Load required modules
sudo modprobe configfs
sudo modprobe libcomposite
sudo modprobe usb_f_fs

# Mount configfs if not already mounted
if ! mountpoint -q /sys/kernel/config; then
    sudo mount -t configfs none /sys/kernel/config
fi

script_dir="$(cd "$(dirname "$0")" && pwd)"
. "${script_dir}/nv-l4t-usb-device-mode-config.sh"

# Wait for any modules to load and initialize
for attempt in $(seq 60); do
    udc_dev_t210=700d0000.xudc
    if [ -e "/sys/class/udc/${udc_dev_t210}" ]; then
        udc_dev="${udc_dev_t210}"
        break
    fi
    udc_dev_t186=3550000.usb
    if [ -e "/sys/class/udc/${udc_dev_t186}" ]; then
        udc_dev="${udc_dev_t186}"
        break
    fi
    sleep 1
done
if [ "${udc_dev}" == "" ]; then
    echo No known UDC device found
    exit 1
fi

macs_file="${script_dir}/mac-addresses"
if [ -f "${macs_file}" ]; then
    . "${macs_file}"
else
    # Generate unique data
    if [ -f /proc/device-tree/serial-number ]; then
        random="$(md5sum /proc/device-tree/serial-number|cut -c1-12)"
    else
        random="$(echo "no-serial"|md5sum|cut -c1-12)"
    fi
    # Extract 6 bytes
    b1="$(echo "${random}"|cut -c1-2)"
    b2="$(echo "${random}"|cut -c3-4)"
    b3="$(echo "${random}"|cut -c5-6)"
    b4="$(echo "${random}"|cut -c7-8)"
    b5="$(echo "${random}"|cut -c9-10)"
    b6="$(echo "${random}"|cut -c11-12)"
    # Clear broadcast/multicast, set locally administered bits
    b1="$(printf "%02x" "$(("0x${b1}" & 0xfe | 0x02))")"
    # Set 4 LSBs to unique value per interface
    b6_rndis_h="$(printf "%02x" "$(("0x${b6}" & 0xfc | 0x00))")"
    b6_rndis_d="$(printf "%02x" "$(("0x${b6}" & 0xfc | 0x01))")"
    b6_ecm_h="$(printf "%02x" "$(("0x${b6}" & 0xfc | 0x02))")"
    b6_ecm_d="$(printf "%02x" "$(("0x${b6}" & 0xfc | 0x03))")"
    # Construct complete MAC per interface
    mac_rndis_h="${b1}:${b2}:${b3}:${b4}:${b5}:${b6_rndis_h}"
    mac_rndis_d="${b1}:${b2}:${b3}:${b4}:${b5}:${b6_rndis_d}"
    mac_ecm_h="${b1}:${b2}:${b3}:${b4}:${b5}:${b6_ecm_h}"
    mac_ecm_d="${b1}:${b2}:${b3}:${b4}:${b5}:${b6_ecm_d}"
    # Save values for next boot
    echo "mac_rndis_h=${mac_rndis_h}" > "${macs_file}"
    echo "mac_rndis_d=${mac_rndis_d}" >> "${macs_file}"
    echo "mac_ecm_h=${mac_ecm_h}" >> "${macs_file}"
    echo "mac_ecm_d=${mac_ecm_d}" >> "${macs_file}"
fi

mkdir -p /sys/kernel/config/usb_gadget/l4t
cd /sys/kernel/config/usb_gadget/l4t

# If this script is modified outside NVIDIA, the idVendor and idProduct values
# MUST be replaced with appropriate vendor-specific values.
echo 0x0955 > idVendor
echo 0x7020 > idProduct
# BCD value. Each nibble should be 0..9. 0x1234 represents version 12.3.4.
echo 0x0002 > bcdDevice

# Informs Windows that this device is a composite device, i.e. it implements
# multiple separate protocols/devices.
echo 0xEF > bDeviceClass
echo 0x02 > bDeviceSubClass
echo 0x01 > bDeviceProtocol

mkdir -p strings/0x409
if [ -f /proc/device-tree/serial-number ]; then
    serialnumber="$(cat /proc/device-tree/serial-number|tr -d '\000')"
else
    serialnumber=no-serial
fi
echo "${serialnumber}" > strings/0x409/serialnumber
# If this script is modified outside NVIDIA, the manufacturer and product values
# MUST be replaced with appropriate vendor-specific values.
echo "NVIDIA" > strings/0x409/manufacturer
echo "Linux for Tegra" > strings/0x409/product

cfg=configs/c.1
mkdir -p "${cfg}"
cfg_str=""

# Note: RNDIS must be the first function in the configuration, or Windows'
# RNDIS support will not operate correctly.
if [ ${enable_rndis} -eq 1 ]; then
    cfg_str="${cfg_str}+RNDIS"
    func=functions/rndis.usb0
    mkdir -p "${func}"
    echo "${mac_rndis_h}" > "${func}/host_addr"
    echo "${mac_rndis_d}" > "${func}/dev_addr"
    ln -sf "${func}" "${cfg}"

    # Informs Windows that this device is compatible with the built-in RNDIS
    # driver. This allows automatic driver installation without any need for
    # a .inf file or manual driver selection.
    echo 1 > os_desc/use
    echo 0xcd > os_desc/b_vendor_code
    echo MSFT100 > os_desc/qw_sign
    echo RNDIS > "${func}/os_desc/interface.rndis/compatible_id"
    echo 5162001 > "${func}/os_desc/interface.rndis/sub_compatible_id"
    ln -sf "${cfg}" os_desc
fi

# If two USB configs are created, and the second contains RNDIS and ACM, then
# Windows will ignore at the ACM function in that config. Consequently, this
# script creates only a single USB config.
if [ ${enable_acm} -eq 1 ]; then
    cfg_str="${cfg_str}+ACM"
    func=functions/acm.GS0
    mkdir -p "${func}"
    ln -sf "${func}" "${cfg}"
fi

# Copy system version information into the exposed filesystem image,
# so that any system that's attached to the USB port can identify this device.
# Do this even if $enable_ums!=1, since $fs_img is locally mounted too.
mntpoint="/mnt/l4t-devmode-$$"
rm -rf "${mntpoint}"
mkdir -p "${mntpoint}"
mount -o loop "${fs_img}" "${mntpoint}"
rm -rf "${mntpoint}/version"
mkdir -p "${mntpoint}/version"
if [ -f /etc/nv_tegra_release ]; then
    cp /etc/nv_tegra_release "${mntpoint}/version"
fi
if dpkg -s nvidia-l4t-core > /dev/null 2>&1; then
    dpkg -s nvidia-l4t-core > "${mntpoint}/version/nvidia-l4t-core.dpkg-s.txt"
fi
cp -r /proc/device-tree/chosen/plugin-manager "${mntpoint}/version/plugin-manager"
umount "${mntpoint}"
rm -rf "${mntpoint}"

if [ ${enable_ums} -eq 1 ]; then
    cfg_str="${cfg_str}+UMS"
    func=functions/mass_storage.0
    mkdir -p "${func}"
    ln -sf "${func}" "${cfg}"
    # Prevent users from corrupting the disk image; make it read-only
    echo 1 > "${func}/lun.0/ro"
    echo "${fs_img}" > "${func}/lun.0/file"
fi

if [ ${enable_ecm} -eq 1 ]; then
    cfg_str="${cfg_str}+${ecm_ncm_name}"
    func=functions/${ecm_ncm}.usb0
    mkdir -p "${func}"
    echo "${mac_ecm_h}" > "${func}/host_addr"
    echo "${mac_ecm_d}" > "${func}/dev_addr"
    ln -sf "${func}" "${cfg}"
fi

enable_bulk=1
if [ ${enable_bulk} -eq 1 ]; then
    mkdir -p /dev/usb-ffs
    
    cfg_str="${cfg_str}+BULK1" 
    mkdir -p /dev/usb-ffs/bulk1
    func=functions/ffs.bulk1
    mkdir -p "${func}"
    ln -sf "${func}" "${cfg}"
    mount -o mode=0777 -o uid=2000 -o gid=2000 -t functionfs bulk1 /dev/usb-ffs/bulk1
    /home/my_user/Desktop/startup_bulk/startup_bulk /dev/usb-ffs/bulk1 &
    sleep 3


    cfg_str="${cfg_str}+BULK2" 
    mkdir -p /dev/usb-ffs/bulk2
    func=functions/ffs.bulk2
    mkdir -p "${func}"
    ln -sf "${func}" "${cfg}"
    mount -o mode=0777 -o uid=2000 -o gid=2000 -t functionfs bulk2 /dev/usb-ffs/bulk2
    /home/my_user/Desktop/startup_bulk/startup_bulk /dev/usb-ffs/bulk2 &
    sleep 3
fi


mkdir -p "${cfg}/strings/0x409"
# :1 in the variable expansion strips the first character from the value. This
# removes the unwanted leading + sign. This simplifies the logic to construct
# $cfg_str above; it can always add a leading delimiter rather than only doing
# so unless the string is previously empty.
echo "$(echo "$cfg_str" | cut -c2-)" > "${cfg}/strings/0x409/configuration"

# Create and configure the network bridge before setting the UDC device. This
# ensures that no matter how quickly udev events (which run -runtime-start.sh)
# are triggered after setting the UDC device below, the bridge device is
# guaranteed to exist, so -runtime-start.sh is guaranteed to be able to
# configure it.
#
# Set the device to "down" initially; if/when -runtime-start.sh runs in response
# to cable presence, the interface will be set to "up".
/sbin/brctl addbr l4tbr0
/sbin/ifconfig l4tbr0 down

echo "${udc_dev}" > UDC

# Ethernet devices require additional configuration. This must happen after the
# UDC device is assigned, since that triggers the creation of the Tegra-side
# Ethernet interfaces.
#
# This script always assigns any-and-all Ethernet devices to an Ethernet
# bridge, and assigns the static IP to that bridge. This allows the script to
# more easily handle the potentially variable set of Ethernet devices.
#
# If your custom use-case requires separate IP addresses per interface, or
# only ever has one interface active, you may modify this script to skip
# bridge creation, and assign IP address(es) directly to the interface(s).

if [ ${enable_rndis} -eq 1 ]; then
    /sbin/brctl addif l4tbr0 "$(cat functions/rndis.usb0/ifname)"
    /sbin/ifconfig "$(cat functions/rndis.usb0/ifname)" up
fi

if [ ${enable_ecm} -eq 1 ]; then
    /sbin/brctl addif l4tbr0 "$(cat functions/${ecm_ncm}.usb0/ifname)"
    /sbin/ifconfig "$(cat functions/${ecm_ncm}.usb0/ifname)" up
fi

cd - # Out of /sys/kernel/config/usb_gadget

# Create a local disk device that exposes the same filesystem image that's
# exported over USB. This will allow local users to see the files too.
/sbin/losetup -f -r "${fs_img}"

exit 0

@dji-dev
Copy link
Contributor

dji-dev commented Dec 9, 2024

Agent comment from Leon in Zendesk ticket #123724:

Hello, thank you for your patience. We remember that the Jetson Nano device actually has a l4-usb-device-mode-start.sh file. You can check the /opt/nvidia* directory to see if there is a script file with the same name. You can copy it directly to the end of your script and start it up following your script (note that the path needs to be modified).

enable_bulk=1if [${enable_bulk}-eq1]; thenmkdir-p /dev/usb-ffs    cfg_str="${cfg_str}+BULK1"mkdir-p /dev/usb-ffs/bulk1func=functions/ffs.bulk1mkdir-p"${func}"ln-sf"${func}""${cfg}"mount -omode=0777-ouid=2000-ogid=2000-t functionfs bulk1 /dev/usb-ffs/bulk1/home/kyle/work/DJI/startup_bulk/startup_bulk /dev/usb-ffs/bulk1 &sleep3cfg_str="${cfg_str}+BULK2"mkdir-p /dev/usb-ffs/bulk2func=functions/ffs.bulk2mkdir-p"${func}"ln-sf"${func}""${cfg}"mount -omode=0777-ouid=2000-ogid=2000-t functionfs bulk2 /dev/usb-ffs/bulk2/home/kyle/work/DJI/startup_bulk/startup_bulk /dev/usb-ffs/bulk2 &sleep3fimkdir -p "${cfg}/strings/0x409" echo "${cfg_str:1}" > "${cfg}/strings/0x409/configuration" udevadm settle -t 5 || : ls /sys/class/udc > UDC /sbin/brctl addbr pi4br0 /sbin/ifconfig pi4br0 ${net_ip} netmask ${net_mask} up if [${enable_rndis} -eq 1]; then /sbin/brctl addif pi4br0 usb0 /sbin/ifconfig usb0 down /sbin/ifconfig usb0 up fi


°°°

@DPCW19
Copy link
Author

DPCW19 commented Dec 9, 2024

Hello,
as suggested in the tutorial, i put the psdk-usb-config.sh into /opt/nvidia/l4t-usb-device-mode-start.sh

/* Using PSDK's bulk configuration file */
sudo cp startup_bulk/psdk-usb-configure.sh  /opt/nvidia/l4t-usb-device-mode-start.sh

But what you suggested is half way done in the file already.

Besides, when i run the script manually, i have an error :
l4t-usb-device-mode-start.sh: 32: .: cannot open /opt/nvidia/nv-l4t-usb-device-mode-config.sh: No such file
So I moved it in:
/opt/nvidia/l4t-usb-device-mode/
But I still get errors :

l4t-usb-device-mode-start.sh: 48: [: 3550000.usb: unexpected operator
mkdir: cannot create directory ‘/sys/kernel/config/usb_gadget’: Operation not permitted

This what the l4t-usb-device-mode-start.sh looks like:

#!/bin/bash

set -e

script_dir="$(cd "$(dirname "$0")" && pwd)"
. "${script_dir}/nv-l4t-usb-device-mode-config.sh"

# Wait for any modules to load and initialize
for attempt in $(seq 60); do
    udc_dev_t210=700d0000.xudc
    if [ -e "/sys/class/udc/${udc_dev_t210}" ]; then
        udc_dev="${udc_dev_t210}"
        break
    fi
    udc_dev_t186=3550000.usb
    if [ -e "/sys/class/udc/${udc_dev_t186}" ]; then
        udc_dev="${udc_dev_t186}"
        break
    fi
    sleep 1
done
if [ "${udc_dev}" == "" ]; then
    echo No known UDC device found
    exit 1
fi

macs_file="${script_dir}/mac-addresses"
if [ -f "${macs_file}" ]; then
    . "${macs_file}"
else
    # Generate unique data
    if [ -f /proc/device-tree/serial-number ]; then
        random="$(md5sum /proc/device-tree/serial-number|cut -c1-12)"
    else
        random="$(echo "no-serial"|md5sum|cut -c1-12)"
    fi
    # Extract 6 bytes
    b1="$(echo "${random}"|cut -c1-2)"
    b2="$(echo "${random}"|cut -c3-4)"
    b3="$(echo "${random}"|cut -c5-6)"
    b4="$(echo "${random}"|cut -c7-8)"
    b5="$(echo "${random}"|cut -c9-10)"
    b6="$(echo "${random}"|cut -c11-12)"
    # Clear broadcast/multicast, set locally administered bits
    b1="$(printf "%02x" "$(("0x${b1}" & 0xfe | 0x02))")"
    # Set 4 LSBs to unique value per interface
    b6_rndis_h="$(printf "%02x" "$(("0x${b6}" & 0xfc | 0x00))")"
    b6_rndis_d="$(printf "%02x" "$(("0x${b6}" & 0xfc | 0x01))")"
    b6_ecm_h="$(printf "%02x" "$(("0x${b6}" & 0xfc | 0x02))")"
    b6_ecm_d="$(printf "%02x" "$(("0x${b6}" & 0xfc | 0x03))")"
    # Construct complete MAC per interface
    mac_rndis_h="${b1}:${b2}:${b3}:${b4}:${b5}:${b6_rndis_h}"
    mac_rndis_d="${b1}:${b2}:${b3}:${b4}:${b5}:${b6_rndis_d}"
    mac_ecm_h="${b1}:${b2}:${b3}:${b4}:${b5}:${b6_ecm_h}"
    mac_ecm_d="${b1}:${b2}:${b3}:${b4}:${b5}:${b6_ecm_d}"
    # Save values for next boot
    echo "mac_rndis_h=${mac_rndis_h}" > "${macs_file}"
    echo "mac_rndis_d=${mac_rndis_d}" >> "${macs_file}"
    echo "mac_ecm_h=${mac_ecm_h}" >> "${macs_file}"
    echo "mac_ecm_d=${mac_ecm_d}" >> "${macs_file}"
fi

mkdir -p /sys/kernel/config/usb_gadget/l4t
cd /sys/kernel/config/usb_gadget/l4t

# If this script is modified outside NVIDIA, the idVendor and idProduct values
# MUST be replaced with appropriate vendor-specific values.
echo 0x0955 > idVendor
echo 0x7020 > idProduct
# BCD value. Each nibble should be 0..9. 0x1234 represents version 12.3.4.
echo 0x0002 > bcdDevice

# Informs Windows that this device is a composite device, i.e. it implements
# multiple separate protocols/devices.
echo 0xEF > bDeviceClass
echo 0x02 > bDeviceSubClass
echo 0x01 > bDeviceProtocol

mkdir -p strings/0x409
if [ -f /proc/device-tree/serial-number ]; then
    serialnumber="$(cat /proc/device-tree/serial-number|tr -d '\000')"
else
    serialnumber=no-serial
fi
echo "${serialnumber}" > strings/0x409/serialnumber
# If this script is modified outside NVIDIA, the manufacturer and product values
# MUST be replaced with appropriate vendor-specific values.
echo "NVIDIA" > strings/0x409/manufacturer
echo "Linux for Tegra" > strings/0x409/product

cfg=configs/c.1
mkdir -p "${cfg}"
cfg_str=""

# Note: RNDIS must be the first function in the configuration, or Windows'
# RNDIS support will not operate correctly.
if [ ${enable_rndis} -eq 1 ]; then
    cfg_str="${cfg_str}+RNDIS"
    func=functions/rndis.usb0
    mkdir -p "${func}"
    echo "${mac_rndis_h}" > "${func}/host_addr"
    echo "${mac_rndis_d}" > "${func}/dev_addr"
    ln -sf "${func}" "${cfg}"

    # Informs Windows that this device is compatible with the built-in RNDIS
    # driver. This allows automatic driver installation without any need for
    # a .inf file or manual driver selection.
    echo 1 > os_desc/use
    echo 0xcd > os_desc/b_vendor_code
    echo MSFT100 > os_desc/qw_sign
    echo RNDIS > "${func}/os_desc/interface.rndis/compatible_id"
    echo 5162001 > "${func}/os_desc/interface.rndis/sub_compatible_id"
    ln -sf "${cfg}" os_desc
fi

# If two USB configs are created, and the second contains RNDIS and ACM, then
# Windows will ignore at the ACM function in that config. Consequently, this
# script creates only a single USB config.
if [ ${enable_acm} -eq 1 ]; then
    cfg_str="${cfg_str}+ACM"
    func=functions/acm.GS0
    mkdir -p "${func}"
    ln -sf "${func}" "${cfg}"
fi

# Copy system version information into the exposed filesystem image,
# so that any system that's attached to the USB port can identify this device.
# Do this even if $enable_ums!=1, since $fs_img is locally mounted too.
mntpoint="/mnt/l4t-devmode-$$"
rm -rf "${mntpoint}"
mkdir -p "${mntpoint}"
mount -o loop "${fs_img}" "${mntpoint}"
rm -rf "${mntpoint}/version"
mkdir -p "${mntpoint}/version"
if [ -f /etc/nv_tegra_release ]; then
    cp /etc/nv_tegra_release "${mntpoint}/version"
fi
if dpkg -s nvidia-l4t-core > /dev/null 2>&1; then
    dpkg -s nvidia-l4t-core > "${mntpoint}/version/nvidia-l4t-core.dpkg-s.txt"
fi
cp -r /proc/device-tree/chosen/plugin-manager "${mntpoint}/version/plugin-manager"
umount "${mntpoint}"
rm -rf "${mntpoint}"

if [ ${enable_ums} -eq 1 ]; then
    cfg_str="${cfg_str}+UMS"
    func=functions/mass_storage.0
    mkdir -p "${func}"
    ln -sf "${func}" "${cfg}"
    # Prevent users from corrupting the disk image; make it read-only
    echo 1 > "${func}/lun.0/ro"
    echo "${fs_img}" > "${func}/lun.0/file"
fi

if [ ${enable_ecm} -eq 1 ]; then
    cfg_str="${cfg_str}+${ecm_ncm_name}"
    func=functions/${ecm_ncm}.usb0
    mkdir -p "${func}"
    echo "${mac_ecm_h}" > "${func}/host_addr"
    echo "${mac_ecm_d}" > "${func}/dev_addr"
    ln -sf "${func}" "${cfg}"
fi

enable_bulk=1 
if [${enable_bulk}-eq1]; then
    mkdir-p /dev/usb-ffs
    cfg_str="${cfg_str}+BULK1"
    mkdir-p /dev/usb-ffs/bulk1
    func=functions/ffs.bulk1
    mkdir-p"${func}"
    ln-sf"${func}""${cfg}"
    mount -o mode=0777 -o uid=2000 -o gid=2000 -t functionfs bulk1 /dev/usb-ffs/bulk1 
    /home/my_user/Desktop/startup_bulk/startup_bulk /dev/usb-ffs/bulk1 &
    sleep3
    
    cfg_str="${cfg_str}+BULK2"
    mkdir-p /dev/usb-ffs/bulk2
    func=functions/ffs.bulk2
    mkdir-p"${func}"
    ln-sf"${func}""${cfg}"
    mount -o mode=0777 -o uid=2000 -o gid=2000 -t functionfs bulk2 /dev/usb-ffs/bulk2
    /home/my_user/Desktop/startup_bulk/startup_bulk /dev/usb-ffs/bulk2 &
    sleep3
fi




mkdir -p "${cfg}/strings/0x409"
# # :1 in the variable expansion strips the first character from the value. This
# # removes the unwanted leading + sign. This simplifies the logic to construct
# # $cfg_str above; it can always add a leading delimiter rather than only doing
# # so unless the string is previously empty.
echo "${cfg_str:1}" > "${cfg}/strings/0x409/configuration"

# DJI SUGESTIONS
udevadm settle -t 5 || :
ls /sys/class/udc > UDC
#

# # Create and configure the network bridge before setting the UDC device. This
# # ensures that no matter how quickly udev events (which run -runtime-start.sh)
# # are triggered after setting the UDC device below, the bridge device is
# # guaranteed to exist, so -runtime-start.sh is guaranteed to be able to
# # configure it.
# #
# # Set the device to "down" initially; if/when -runtime-start.sh runs in response
# # to cable presence, the interface will be set to "up".
/sbin/brctl addbr l4tbr0
/sbin/ifconfig l4tbr0 down

# DJI SUGESTIONS
/sbin/brctl addbr pi4br0
/sbin/ifconfig pi4br0 ${net_ip} netmask ${net_mask} up
if [${enable_rndis} -eq 1]; then
    /sbin/brctl addif pi4br0 usb0
    /sbin/ifconfig usb0 down
    /sbin/ifconfig usb0 up
fi
#

echo "${udc_dev}" > UDC

# # Ethernet devices require additional configuration. This must happen after the
# # UDC device is assigned, since that triggers the creation of the Tegra-side
# # Ethernet interfaces.
# #
# # This script always assigns any-and-all Ethernet devices to an Ethernet
# # bridge, and assigns the static IP to that bridge. This allows the script to
# # more easily handle the potentially variable set of Ethernet devices.
# #
# # If your custom use-case requires separate IP addresses per interface, or
# # only ever has one interface active, you may modify this script to skip
# # bridge creation, and assign IP address(es) directly to the interface(s).

if [ ${enable_rndis} -eq 1 ]; then
    /sbin/brctl addif l4tbr0 "$(cat functions/rndis.usb0/ifname)"
    /sbin/ifconfig "$(cat functions/rndis.usb0/ifname)" up
fi

if [ ${enable_ecm} -eq 1 ]; then
    /sbin/brctl addif l4tbr0 "$(cat functions/${ecm_ncm}.usb0/ifname)"
    /sbin/ifconfig "$(cat functions/${ecm_ncm}.usb0/ifname)" up
fi

cd - # Out of /sys/kernel/config/usb_gadget

# # Create a local disk device that exposes the same filesystem image that's
# # exported over USB. This will allow local users to see the files too.
/sbin/losetup -f -r "${fs_img}"

exit 0

@dji-dev
Copy link
Contributor

dji-dev commented Dec 10, 2024

Agent comment from Leon in Zendesk ticket #123724:

Hello, if you have modified the /opt/nvidia/l4t-usb-device-mode-start.sh file, you can directly restart the device without manually running the script, because some configuration statements will rely on permissions or resource usage, running during the device startup initialization phase can avoid many errors. You only need to pay attention to whether the corresponding services are running normally after startup (including the l4t-usb-device-mode-start.sh service, which can be viewed using systemctrl status **).

°°°

@DPCW19
Copy link
Author

DPCW19 commented Dec 10, 2024

Hello,
I tried a lot of things, and I wanted to start clean so I flashed the OS back again into my jetson nano with Jetpack 6.1.

I don't have any file l4t-usb-device-mode-start.sh in /opt/nvidia/ now.
I have the same setup as before (#229 (comment)) and I can't fix it.
The error:

nv-l4t-usb-device-mode-start.sh[839]: cp: cannot stat '/proc/device-tree/chosen/plugin-manager/': No such file or directory

@dji-dev
Copy link
Contributor

dji-dev commented Dec 11, 2024

Agent comment from Leon in Zendesk ticket #123724:

Hello, this error message indicates that the system cannot find the /proc/device-tree/chosen/plugin-manager/ directory when executing the cp command. You can confirm whether the path does not exist. You can use the ls /proc/device-tree/chosen/plugin-manager/ command to confirm. If the path exists, you need to pay attention to permissions when running. It is recommended to run with sudo.
In addition, we noticed that the purpose of this sentence is to copy the plugin manager information and has little effect on the configuration of bulk. You can directly comment it out and skip it.

°°°

@DPCW19
Copy link
Author

DPCW19 commented Dec 11, 2024

Hello,

Thanks for the support !

Indeed, nv-l4t-usb-device-mode.service is active when removing the cp command. But notihng appears using lsusb. However, I can see changes with ip a command:
Without usb connected :
without_usb

With usb connected :
with_usb

Using psdk_wrapper ros2, I can start the service start_percepetion, but I dont get anything in the camera stream topic. I don't think that the perception is really up.

@DPCW19 DPCW19 closed this as completed Dec 11, 2024
@DPCW19 DPCW19 reopened this Dec 11, 2024
@dji-dev
Copy link
Contributor

dji-dev commented Dec 11, 2024

Agent comment from Leon in Zendesk ticket #123724:

Hello, you can directly check the ps -ef|grep "startup" command to see if two BULK nodes are pulled up? Normally, you will get the following command:

rsp@CUBE:~/workspace/E-Port/3.9.2/Payload-SDK-release-v3.9.2/build/bin$ ps -ef | grep "startup"root 678 1 0 17:42 ? 00:00:00 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startupsroot 689 1 0 17:42 ? 00:00:00 /opt/startup_bulk/build/startup_bulk /dev/usb-ffs/bulk1root 729 1 0 17:42 ? 00:00:00 /opt/startup_bulk/build/startup_bulk /dev/usb-ffs/bulk2rsp 14853 1254 0 18:21 pts/0 00:00:00 grep --color=auto startup


°°°

@DPCW19
Copy link
Author

DPCW19 commented Dec 11, 2024

Hello,
Yes I do have /dev/usb-ffs/bulk1 and bulk2
ps -ef

@dji-dev
Copy link
Contributor

dji-dev commented Dec 12, 2024

Agent comment from Leon in Zendesk ticket #123724:

Hello, if you have these two nodes, please configure the link as DJI_USE_UART_AND_USB_BULK_DEVICE in dji_sdk_config.h, and then refer to the configuration of this article: https://sdk-forum.dji.net/hc/zh-cn/articles/38622108040857-Linux%E5%B9%B3%E5%8F%B0%E9%85%8D%E7%BD%AEBULK

°°°

@DPCW19
Copy link
Author

DPCW19 commented Dec 12, 2024

Hello,

I already configured the dji_sdk_config.h, but I have some updates.

Now when I run the sample code from PSDK, I can go deeper into camera stream functions:

stream-file

But then, nothing appear, I don't get anything else. I tried diffrent options and none of them output an image.
It's still better than before, because I don't get an USB bulk config error.

Does it implies that usb bulk is configured properly ?

@dji-dev
Copy link
Contributor

dji-dev commented Dec 12, 2024

Agent comment from Leon in Zendesk ticket #123724:

Hello, have you installed LIBUSB correctly? And your opencv version, ffmpeg version, these will affect the implementation of this function. In addition, you can directly use the liveview function to verify, in fact, the effect is the same, that is, refer to the DjiTest_LiveviewRunSample function,

°°°

@DPCW19
Copy link
Author

DPCW19 commented Dec 13, 2024

Hello,

Yes everything is installed correctly.
The only difference between the documentation and my setup is that I have an USB-C connector on the Jetson side, not a micro-USB. Do you think that this could be problematic ?

@dji-dev
Copy link
Contributor

dji-dev commented Dec 13, 2024

Agent comment from Leon in Zendesk ticket #123724:

Hello, could you upload the relevant hardware diagram so that we can better confirm for you that there may be confusion in the master-slave relationship of USB devices?

°°°

@DPCW19
Copy link
Author

DPCW19 commented Dec 13, 2024

Hello,

This is the only modification I have.
The E-Port is set to host.
USB-C to USB-A cable

@dji-dev
Copy link
Contributor

dji-dev commented Dec 16, 2024

Agent comment from Leon in Zendesk ticket #123724:

Hello, we recommend that you use a TypeC to A cable and an OTG cable to connect. This will force your device to connect to the drone as a slave device, so there will be no problem with the master-slave relationship.

°°°

@DPCW19
Copy link
Author

DPCW19 commented Dec 16, 2024

Hello,

Thanks for the feedback.

I am already using a TypeC to A cable and an OTG cable.

Is it normal that I cannot see any ports using lsusb ?

@dji-dev
Copy link
Contributor

dji-dev commented Dec 16, 2024

Agent comment from Leon in Zendesk ticket #123724:

Hello, this is normal. lsusb enumerates the USB slave devices you are currently connected to. When your device is connected as a slave device, you cannot see the aircraft connected, unless your device is the host and the aircraft is the slave device.

°°°

@DPCW19
Copy link
Author

DPCW19 commented Dec 17, 2024

Hello,

Thanks for your help.

This is what I get when I run./dji_sdk_demo_linux_cxx

image

Do you see anything that prevents me from getting the perception, or fpv stream ?

@dji-dev
Copy link
Contributor

dji-dev commented Dec 17, 2024

Agent comment from Leon in Zendesk ticket #123724:

Hello, it is normal so far. The PTZ function is not supported because your PSDK program is running on EXTENSION PORT. It is only supported when running on Payload Port. This error is as expected.

°°°

@DPCW19
Copy link
Author

DPCW19 commented Dec 17, 2024

Hello,

Do you have another idea where to look ?

@dji-dev
Copy link
Contributor

dji-dev commented Dec 18, 2024

Agent comment from Leon in Zendesk ticket #123724:

Hello, we recommend that you check the version of opencv and ffmpeg. We are using: ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers, opencv-4.9.0

°°°

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants