From 7f6730650498bf502c1a0398f71be9c26d6ebd61 Mon Sep 17 00:00:00 2001 From: Sakib Ahmed Sumdany Date: Mon, 8 Jul 2024 02:59:10 +0200 Subject: [PATCH 1/4] add g_ether in cmdline.txt in my Windows 11, pi was showing up as 'CDC ECM' and 'RNDIS' under "other devices" So ensure that the modules are always loaded on boot, regardless of any issues with script execution. This makes the configuration more robust and less dependent on external scripts. --- rpi4-usb.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rpi4-usb.sh b/rpi4-usb.sh index 0f3bf74..177d3a6 100755 --- a/rpi4-usb.sh +++ b/rpi4-usb.sh @@ -136,14 +136,14 @@ fi # enable dwc2 overlay teeconfirm "dtoverlay=dwc2" $CONFIG_FILE -if ! $(grep -q modules-load=dwc2 $CMDLINE_FILE) ; then +if ! $(grep -q modules-load=dwc2,g_ether $CMDLINE_FILE) ; then echo - echo "Add the line modules-load=dwc2 to $CMDLINE_FILE" + echo "Add the line modules-load=dwc2,g_ether to $CMDLINE_FILE" if ! confirm ; then exit fi if $DO_MODIFY ; then - sudo sed -i '${s/$/ modules-load=dwc2/}' $CMDLINE_FILE + sudo sed -i '${s/$/ modules-load=dwc2,g_ether/}' $CMDLINE_FILE fi fi From 1c627c97c38ac44b65c3c2d60245b540da18e249 Mon Sep 17 00:00:00 2001 From: Sakib Ahmed Sumdany Date: Mon, 8 Jul 2024 03:05:14 +0200 Subject: [PATCH 2/4] Update remove.sh --- remove.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/remove.sh b/remove.sh index 26bb65b..9a4fa08 100755 --- a/remove.sh +++ b/remove.sh @@ -77,14 +77,14 @@ fi -if $(grep -q modules-load=dwc2 $CMDLINE_FILE) ; then +if $(grep -q modules-load=dwc2,g_ether $CMDLINE_FILE) ; then echo - echo "remove line modules-load=dwc2 from $CMDLINE_FILE" + echo "remove line modules-load=dwc2,g_ether from $CMDLINE_FILE" if ! confirm ; then exit fi cat $CMDLINE_FILE - sudo sed -i '${s/ modules-load=dwc2//}' $CMDLINE_FILE + sudo sed -i '${s/ modules-load=dwc2,g_ether//}' $CMDLINE_FILE cat $CMDLINE_FILE fi From 973e04470c11b0d32b1c1dda4cb59ff3f90592a8 Mon Sep 17 00:00:00 2001 From: Sakib Ahmed Sumdany Date: Mon, 8 Jul 2024 04:02:24 +0200 Subject: [PATCH 3/4] fixed dtoverlay=dwc2 multy instances in config file --- rpi4-usb.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rpi4-usb.sh b/rpi4-usb.sh index 177d3a6..9918a3b 100755 --- a/rpi4-usb.sh +++ b/rpi4-usb.sh @@ -135,7 +135,9 @@ fi # enable dwc2 overlay -teeconfirm "dtoverlay=dwc2" $CONFIG_FILE +# teeconfirm "dtoverlay=dwc2" $CONFIG_FILE #cant use `teeconfirm` function, config file has multiple `dtoverlay=dwc2` +sudo sed -i '$ a\dtoverlay=dwc2' $CONFIG_FILE + if ! $(grep -q modules-load=dwc2,g_ether $CMDLINE_FILE) ; then echo echo "Add the line modules-load=dwc2,g_ether to $CMDLINE_FILE" From 0f994252d16276a423f5cccd5762764d808711d0 Mon Sep 17 00:00:00 2001 From: Sakib Ahmed Sumdany Date: Mon, 8 Jul 2024 04:08:52 +0200 Subject: [PATCH 4/4] Update README.md replace existing file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 50e7fdf..c3bbc11 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ on the shoulders of giants. ## Usage ```shell -wget https://raw.githubusercontent.com/kmpm/rpi-usb-gadget/master/rpi4-usb.sh +curl -O https://raw.githubusercontent.com/kmpm/rpi-usb-gadget/master/rpi4-usb.sh bash rpi4-usb.sh ``` If you answer no to any of the questions the script will exit