Skip to content

config: boards: pocketbeagle2: Enable better USB Gadget #8382

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ayush1325
Copy link
Member

Description

Enable Multifunction Composite Gadget for PocketBeagle 2. This allows ssh over USB with zero configuration by the user.

Currently, enabling ttyGS0 causes armbian-first-run to not work, so had to disable it. Will work on finding a solution for it.

setup-usbgadget-network-multi.sh uses setup-usbgadget-network.sh as a base but exposes a Multifunction Composite Gadget instead of just NCM.

How Has This Been Tested?

  • Tested on PocketBeagle 2 rev A0.

Checklist:

Please delete options that are not relevant.

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

- Use configfs API to setup Multifunction Composite Gadget
- This is already done on all BeagleBoard debian images.
- Allows ssh and serial over USB without any user setup.

Signed-off-by: Ayush Singh <[email protected]>
@Ayush1325 Ayush1325 requested review from Grippy98 and a team as code owners July 15, 2025 15:01
Copy link
Contributor

coderabbitai bot commented Jul 15, 2025

Walkthrough

The changes introduce USB gadget networking support for the PocketBeagle 2 board. The configuration file for the board is updated to remove the secondary serial console and add two new functions: one to install USB gadget network scripts and services during firmware preparation, and another to enable and configure the necessary systemd service and DHCP server within the target environment. A new shell script is added to set up the USB gadget network interface using configfs, configure device descriptors, activate the network and serial functions, and assign IP addresses with a DHCP server.

Possibly related PRs

Suggested labels

08, Needs review, size/medium, Hardware

Suggested reviewers

  • Grippy98
  • igorpecovnik
  • TheSnowfield
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added size/medium PR with more then 50 and less then 250 lines 08 Milestone: Third quarter release Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... BSP Board Support Packages labels Jul 15, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (3)
config/boards/pocketbeagle2.conf (2)

13-16: Temporary removal of ttyGS0 - Track the underlying issue

The removal of ttyGS0 from both SERIALCON and SRC_CMDLINE is consistent with the PR objectives. Since this is a temporary workaround for the armbian-first-run failure, consider adding a TODO comment to track this issue.

Would you like me to create a tracking issue for investigating and resolving the ttyGS0/armbian-first-run conflict?


37-50: Improve service configuration reliability

The function correctly handles the Armbian repository manipulation and service configuration. Consider these improvements:

Use a heredoc for better readability and maintainability:

-	echo -e "[Service]\nEnvironment=\"unudhcpd_host_ip=192.168.7.2\"\nEnvironment=\"unudhcpd_client_ip=192.168.7.3\"" > "${SDCARD}"/etc/systemd/system/usbgadget-rndis.service.d/override.conf
+	cat > "${SDCARD}"/etc/systemd/system/usbgadget-rndis.service.d/override.conf <<-EOF
+	[Service]
+	Environment="unudhcpd_host_ip=192.168.7.2"
+	Environment="unudhcpd_client_ip=192.168.7.3"
+	EOF

Also consider adding error handling for the systemctl enable command.

packages/bsp/usb-gadget-network/setup-usbgadget-network-multi.sh (1)

58-58: Fix typo in error message

-		echo "  Couldn't write configration name"
+		echo "  Couldn't write configuration name"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8155cc5 and 8d57c7a.

📒 Files selected for processing (2)
  • config/boards/pocketbeagle2.conf (1 hunks)
  • packages/bsp/usb-gadget-network/setup-usbgadget-network-multi.sh (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
packages/bsp/usb-gadget-network/setup-usbgadget-network-multi.sh (2)
Learnt from: djurny
PR: armbian/build#8235
File: packages/bsp/mvebu/helios4/helios4-wol.service:0-0
Timestamp: 2025-05-29T01:52:21.381Z
Learning: When implementing systemd services that need to iterate over network interfaces, the pattern `/bin/ls -1 /sys/class/net/ | /bin/grep -E "^(eth|en[do])[0-9]+" | /bin/xargs -n1 -I{} /sbin/ethtool -s "{}" wol g` is more robust than using shell variables, as it avoids systemd variable resolution issues that can cause service failures.
Learnt from: EvilOlaf
PR: armbian/build#8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: Armbian build framework extensions are NOT designed to run standalone but are called by the supervisor. The framework provides environment variables like USERPATCHES_PATH and SDCARD, and commands are executed with protection via run_host_command_logged and chroot_sdcard functions that use bash -e -o pipefail.
config/boards/pocketbeagle2.conf (10)
Learnt from: EvilOlaf
PR: armbian/build#0
File: :0-0
Timestamp: 2025-06-16T03:24:00.458Z
Learning: In Armbian board configuration files (.csc), the standard pattern is to have only one line as a comment describing the board hardware specifications. This single-line description typically includes the SoC model, core count, RAM options, and key features like connectivity options, storage interfaces, and special features.
Learnt from: EvilOlaf
PR: armbian/build#8330
File: config/sources/families/sun55iw3.conf:32-36
Timestamp: 2025-06-25T03:40:52.109Z
Learning: In Armbian build system configuration files like config/sources/families/*.conf, when KERNELSOURCE is not explicitly declared in a case branch, the system falls back to a default KERNELSOURCE value, so missing KERNELSOURCE declarations are not critical issues.
Learnt from: EvilOlaf
PR: armbian/build#8330
File: config/sources/families/sun55iw3.conf:32-36
Timestamp: 2025-06-25T03:42:09.086Z
Learning: In Armbian build system configuration files like config/sources/families/*.conf, KERNELSOURCE is explicitly declared when using unofficial or 3rd party kernel repositories (like the "dev" branch using https://github.com/apritzel/linux), but can be omitted when using the standard mainline kernel (like the "edge" branch) since it will fall back to the default mainline source.
Learnt from: Grippy98
PR: armbian/build#8152
File: lib/functions/configuration/interactive.sh:209-266
Timestamp: 2025-05-05T12:35:07.143Z
Learning: For the interactive kernel selection in Armbian, KERNEL_MAJOR_MINOR and KERNEL_DESCRIPTION are parsed from family.conf but deliberately not set as environment variables to avoid potential interference with other parts of the build system.
Learnt from: rpardini
PR: armbian/build#8044
File: patch/u-boot/v2025.04/cmd-fileenv-read-string-from-file-into-env.patch:76-86
Timestamp: 2025-03-31T22:20:48.475Z
Learning: For the Armbian build project, maintaining consistency with existing patches across U-Boot versions (such as between 2025.01 and 2025.04) is prioritized over refactoring individual patches for code improvements.
Learnt from: rpardini
PR: armbian/build#8044
File: patch/u-boot/v2025.04/cmd-fileenv-read-string-from-file-into-env.patch:73-75
Timestamp: 2025-03-31T22:20:41.849Z
Learning: When porting patches between U-Boot versions (like from 2025.01 to 2025.04), rpardini prefers to maintain patches as-is rather than introducing refactoring changes, even when potential improvements are identified. This approach prioritizes consistency and reduces the risk of introducing new issues.
Learnt from: EvilOlaf
PR: armbian/build#8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: Armbian build framework extensions are NOT designed to run standalone but are called by the supervisor. The framework provides environment variables like USERPATCHES_PATH and SDCARD, and commands are executed with protection via run_host_command_logged and chroot_sdcard functions that use bash -e -o pipefail.
Learnt from: libiunc
PR: armbian/build#8033
File: config/kernel/linux-starfive2-vendor.config:43-43
Timestamp: 2025-03-31T12:57:13.880Z
Learning: For StarFive2 platform kernel configurations, maintain alignment with vendor-provided configurations rather than modifying security settings like SECCOMP. This ensures hardware compatibility as intended by the manufacturer.
Learnt from: djurny
PR: armbian/build#8272
File: config/bootscripts/boot-mvebu.cmd:182-186
Timestamp: 2025-06-04T23:45:38.860Z
Learning: In config/bootscripts/boot-mvebu.cmd, the `fdtfile` variable is mandatory for booting and is pre-set by U-Boot, but can be overridden via armbianEnv.txt. If `fdtfile` is empty, the subsequent device tree file search logic will eventually fail and trigger the critical error "Cannot find DT!" with proper error handling.
Learnt from: Grippy98
PR: armbian/build#8202
File: config/desktop/trixie/environments/gnome/armbian/create_desktop_package.sh:2-3
Timestamp: 2025-05-16T15:34:34.672Z
Learning: The shell scripts in the Armbian build system's desktop configuration files, such as config/desktop/trixie/environments/gnome/armbian/create_desktop_package.sh, rely on environment variables like $SRC and $destination that are expected to be set externally before the script is executed.

Comment on lines +21 to +35
function post_family_tweaks_bsp__pocketbeagle2_firmware() {
display_alert "Setup USB Gadget for ${BOARD}" "${RELEASE}" "warn"

# USB Gadget Network service
mkdir -p $destination/usr/local/bin/
mkdir -p $destination/usr/lib/systemd/system/
mkdir -p $destination/etc/initramfs-tools/scripts/init-bottom/
install -Dm655 $SRC/packages/bsp/usb-gadget-network/setup-usbgadget-network-multi.sh $destination/usr/local/bin/setup-usbgadget-network.sh
install -Dm655 $SRC/packages/bsp/usb-gadget-network/remove-usbgadget-network.sh $destination/usr/local/bin/
install -Dm644 $SRC/packages/bsp/usb-gadget-network/usbgadget-rndis.service $destination/usr/lib/systemd/system/
install -Dm655 $SRC/packages/bsp/usb-gadget-network/usb-gadget-initramfs-hook $destination/etc/initramfs-tools/hooks/usb-gadget
install -Dm655 $SRC/packages/bsp/usb-gadget-network/usb-gadget-initramfs-premount $destination/etc/initramfs-tools/scripts/init-premount/usb-gadget
install -Dm655 $SRC/packages/bsp/usb-gadget-network/dropbear $destination/etc/initramfs-tools/scripts/init-premount/
install -Dm655 $SRC/packages/bsp/usb-gadget-network/kill-dropbear $destination/etc/initramfs-tools/scripts/init-bottom/
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling and clarify file renaming

The function implementation looks good but could benefit from:

  1. Error handling for the install commands
  2. Clarification on why setup-usbgadget-network-multi.sh is renamed to setup-usbgadget-network.sh during installation

Consider adding error checking:

 function post_family_tweaks_bsp__pocketbeagle2_firmware() {
 	display_alert "Setup USB Gadget for ${BOARD}" "${RELEASE}" "warn"
 
 	# USB Gadget Network service
 	mkdir -p $destination/usr/local/bin/
 	mkdir -p $destination/usr/lib/systemd/system/
 	mkdir -p $destination/etc/initramfs-tools/scripts/init-bottom/
-	install -Dm655 $SRC/packages/bsp/usb-gadget-network/setup-usbgadget-network-multi.sh $destination/usr/local/bin/setup-usbgadget-network.sh
+	install -Dm655 $SRC/packages/bsp/usb-gadget-network/setup-usbgadget-network-multi.sh $destination/usr/local/bin/setup-usbgadget-network.sh || exit_with_error "Failed to install USB gadget setup script"

Also, consider keeping the original filename to avoid confusion, or add a comment explaining the renaming rationale.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In config/boards/pocketbeagle2.conf around lines 21 to 35, the install commands
lack error handling and the renaming of setup-usbgadget-network-multi.sh to
setup-usbgadget-network.sh is unclear. Add error checking after each install
command to verify success and handle failures appropriately. Either keep the
original filename during installation to avoid confusion or add a comment
explaining why the file is renamed.

Comment on lines +1 to +8
#!/bin/bash

deviceinfo_name="USB Gadget Network"
deviceinfo_manufacturer="Armbian"
#deviceinfo_usb_idVendor=
#deviceinfo_usb_idProduct=
#deviceinfo_usb_serialnumber=

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling and safety flags

For a system configuration script that modifies kernel interfaces, consider adding safety flags to catch errors early.

 #!/bin/bash
+set -euo pipefail
 
 deviceinfo_name="USB Gadget Network"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/bin/bash
deviceinfo_name="USB Gadget Network"
deviceinfo_manufacturer="Armbian"
#deviceinfo_usb_idVendor=
#deviceinfo_usb_idProduct=
#deviceinfo_usb_serialnumber=
#!/bin/bash
set -euo pipefail
deviceinfo_name="USB Gadget Network"
deviceinfo_manufacturer="Armbian"
#deviceinfo_usb_idVendor=
#deviceinfo_usb_idProduct=
#deviceinfo_usb_serialnumber=
🤖 Prompt for AI Agents
In packages/bsp/usb-gadget-network/setup-usbgadget-network-multi.sh at the
beginning (lines 1 to 8), add safety flags such as 'set -euo pipefail' to ensure
the script exits immediately on errors, treats unset variables as errors, and
fails on pipeline errors. This will improve error handling and make the script
safer when modifying kernel interfaces.

Comment on lines +113 to +114
setup_usb_network_configfs
set_usbgadget_ipaddress
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for function execution

The script should handle failures properly:

-setup_usb_network_configfs
-set_usbgadget_ipaddress
+if setup_usb_network_configfs; then
+    set_usbgadget_ipaddress
+else
+    echo "Failed to setup USB network configfs"
+    exit 1
+fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
setup_usb_network_configfs
set_usbgadget_ipaddress
# Replace the final calls in setup-usbgadget-network-multi.sh:
if setup_usb_network_configfs; then
set_usbgadget_ipaddress
else
echo "Failed to setup USB network configfs" >&2
exit 1
fi
🤖 Prompt for AI Agents
In packages/bsp/usb-gadget-network/setup-usbgadget-network-multi.sh at lines 113
to 114, the calls to setup_usb_network_configfs and set_usbgadget_ipaddress lack
error handling. Add checks after each function call to verify if it succeeded,
and if not, output an error message and exit the script with a non-zero status
to properly handle failures.

Comment on lines +95 to +98
ip a add "${host_ip}/255.255.0.0" dev usb0 2> /dev/null && ip link set usb0 up && INTERFACE=usb0
if [ -z $INTERFACE ]; then
ip a add "${host_ip}/255.255.0.0" dev eth0 2> /dev/null && eth0 && INTERFACE=eth0
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix syntax error and reconsider eth0 fallback

Critical issues in the interface selection logic:

Line 97 has a syntax error - && eth0 && should be && ip link set eth0 up &&:

 	if [ -z $INTERFACE ]; then
-		ip a add "${host_ip}/255.255.0.0" dev eth0 2> /dev/null && eth0 && INTERFACE=eth0
+		ip a add "${host_ip}/16" dev eth0 2> /dev/null && ip link set eth0 up && INTERFACE=eth0
 	fi

Also:

  1. Use CIDR notation /16 instead of /255.255.0.0
  2. Consider if falling back to eth0 is appropriate for a USB gadget network setup - this could interfere with the main network interface
🤖 Prompt for AI Agents
In packages/bsp/usb-gadget-network/setup-usbgadget-network-multi.sh around lines
95 to 98, fix the syntax error by replacing '&& eth0 &&' with '&& ip link set
eth0 up &&' to correctly bring up the eth0 interface. Change the netmask from
the dotted format '/255.255.0.0' to CIDR notation '/16' for both interfaces.
Additionally, review whether falling back to eth0 is appropriate in this USB
gadget network context and remove or adjust this fallback if it risks
interfering with the main network interface.

Comment on lines +30 to +82
echo " Setting up an USB gadget through configfs"
# Create an usb gadet configuration
mkdir $CONFIGFS/g1 || echo " Couldn't create $CONFIGFS/g1"
echo "$usb_idVendor" > "$CONFIGFS/g1/idVendor"
echo "$usb_idProduct" > "$CONFIGFS/g1/idProduct"
echo 0x0404 > "$CONFIGFS/g1/bcdDevice"
echo 0x0200 > "$CONFIGFS/g1/bcdUSB"

# Create english (0x409) strings
mkdir $CONFIGFS/g1/strings/0x409 || echo " Couldn't create $CONFIGFS/g1/strings/0x409"

# shellcheck disable=SC2154
echo "$deviceinfo_manufacturer" > "$CONFIGFS/g1/strings/0x409/manufacturer"
echo "$usb_serialnumber" > "$CONFIGFS/g1/strings/0x409/serialnumber"
# shellcheck disable=SC2154
echo "$deviceinfo_name" > "$CONFIGFS/g1/strings/0x409/product"

# Create network function.
mkdir $CONFIGFS/g1/functions/"$usb_network_function" ||
echo " Couldn't create $CONFIGFS/g1/functions/$usb_network_function"

# Create configuration instance for the gadget
mkdir $CONFIGFS/g1/configs/c.1 ||
echo " Couldn't create $CONFIGFS/g1/configs/c.1"
echo 250 > $CONFIGFS/g1/configs/c.1/MaxPower
mkdir $CONFIGFS/g1/configs/c.1/strings/0x409 ||
echo " Couldn't create $CONFIGFS/g1/configs/c.1/strings/0x409"
echo "NCM Configuration" > $CONFIGFS/g1/configs/c.1/strings/0x409/configuration ||
echo " Couldn't write configration name"

# Link the network instance to the configuration
ln -s $CONFIGFS/g1/functions/"$usb_network_function" $CONFIGFS/g1/configs/c.1 ||
echo " Couldn't symlink $usb_network_function"

# Enable ACM if first-run is done.
# Enabling it when armbian first-run executes seems to cause some kind of reset which kind of
# concludes the config without any actual configuration.
mkdir -p $CONFIGFS/g1/functions/"$usb_serial_function" ||
echo " Couldn't create $CONFIGFS/g1/functions/$usb_serial_function"
ln -s $CONFIGFS/g1/functions/"$usb_serial_function" $CONFIGFS/g1/configs/c.1 ||
echo " Couldn't symlink $usb_serial_function"

# Check if there's an USB Device Controller
if [ -z "$(ls /sys/class/udc)" ]; then
echo " No USB Device Controller available"
return
fi

# Link the gadget instance to an USB Device Controller. This activates the gadget.
# See also: https://github.com/postmarketOS/pmbootstrap/issues/338
# shellcheck disable=SC2005
echo "$(ls /sys/class/udc)" > $CONFIGFS/g1/UDC || echo " Couldn't write UDC"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Improve error handling and simplify UDC assignment

Several improvements needed for reliability:

  1. Add proper error handling instead of just echoing errors:
-	mkdir $CONFIGFS/g1 || echo "  Couldn't create $CONFIGFS/g1"
+	mkdir $CONFIGFS/g1 || { echo "  Couldn't create $CONFIGFS/g1"; return 1; }
  1. Simplify the UDC assignment on line 81:
-	echo "$(ls /sys/class/udc)" > $CONFIGFS/g1/UDC || echo "  Couldn't write UDC"
+	ls /sys/class/udc | head -1 > $CONFIGFS/g1/UDC || echo "  Couldn't write UDC"
  1. Add safety check for UDC directory:
 	# Check if there's an USB Device Controller
-	if [ -z "$(ls /sys/class/udc)" ]; then
+	if [ ! -d /sys/class/udc ] || [ -z "$(ls /sys/class/udc 2>/dev/null)" ]; then
 		echo "  No USB Device Controller available"
 		return
 	fi
🤖 Prompt for AI Agents
In packages/bsp/usb-gadget-network/setup-usbgadget-network-multi.sh from lines
30 to 82, improve error handling by replacing simple echo error messages with
proper checks that exit or handle failures gracefully after mkdir or echo
commands fail. Simplify the UDC assignment by directly redirecting the output of
ls /sys/class/udc to the UDC file without using echo and command substitution.
Add a safety check before assigning UDC to ensure the directory /sys/class/udc
exists and contains at least one device, preventing errors if no USB Device
Controller is present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
08 Milestone: Third quarter release BSP Board Support Packages Hardware Hardware related like kernel, U-Boot, ... Needs review Seeking for review size/medium PR with more then 50 and less then 250 lines
Development

Successfully merging this pull request may close these issues.

1 participant