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

Initial release of USB gadget mode #6

Merged
merged 4 commits into from Apr 22, 2021
Merged

Conversation

stanoba
Copy link
Contributor

@stanoba stanoba commented Sep 9, 2020

This PR should cover issue #1

Main changes:

  • added new NETWORK_MODE='usb'
  • Raspberry is in USB gadget mode configured with static IP address 192.168.7.2
  • UUID is now generated from Raspberry's Serial number instead of MAC address
  • changed config files for USB gadget mode in GoodTFT drivers folder (not yet for Waveshare)
  • updated install.sh script
  • tested on Raspberry Pi Zero, Zero W and 4 (need to be done on other models)

Note: USB Gadget is compatible with Raspberry Pi 0, 0W, A, A+, and 4 only. (Pi B, B+, 2, 3, 3A+, and 3B+ lack the required pin for OTG)

@stanoba
Copy link
Contributor Author

stanoba commented Sep 9, 2020

Raspberry Pi Zero W + 3.5" TFT display. It has disabled WiFi and only one cable is attached:

LCD_img1
LCD_img2

@EnDeRWiGiN
Copy link

Any way I could help test this?

@stanoba
Copy link
Contributor Author

stanoba commented Sep 10, 2020

Any way I could help test this?

Hi @EnDeRWiGiN, I think yes, but you need to update your code on SD card.

Here are steps that you need to follow:

  1. Connect Raspberry Pi to internet (needed for installation).

  2. Rename folder mobro-raspberrypi to mobro-raspberrypi_old and display-drivers folder to display-drivers_old:

mv mobro-raspberrypi mobro-raspberrypi_old
mv display-drivers display-drivers_old
  1. Clone my mobro-raspberrypi fork and run installation script:
cd /home/modbros
git clone https://github.com/stanoba/mobro-raspberrypi.git
cd mobro-raspberrypi
chmod +x install.sh
sudo ./install.sh

Note: This step is better to do on RPI3 or RPI4 as Zero could be quite slow. After installation you can put SD card back to Zero.

  1. Re-connect raspberry to your computer via USB port (not PWR).

  2. Wait until boots, you should see new network interface in you computer.

  3. Set IP address and net-mask to your new interface e.g. 192.168.7.10/255.255.255.0

  4. Open http://192.168.7.2 in your browser and go through wizard.

  5. After reboot, everything should be working.

@EnDeRWiGiN
Copy link

Okay, so I followed your instruction and was able to do steps 1-3 smoothly. There was a problem once I tried to connect over USB. I was getting a "USB could not be deciphered" problem.

Knowing that it might be a config problem I checked the config.txt file and cmdline.txt. The config file was correct and had "dtoverlay=dwc2" but the cmdline.txt file did not have "modules-load=dwc2,g_ether" after rootwait. I added this and was able to proceed.

I was able to do steps 4-8 but afterward, the PI did not see the server even though I could go to the configurator and SSH into it.

I was able to set the network to private and ran the configuration multiple times but I could not get the Pi to see the modbros Client. I tried the static IP of the computer on that network adapter and the normal Network name but it could not find the client.

I ended up removing all the firewall rules and reinstalling modbros and I got it to work! (I have a feeling I messed up the firewall rules while tried to get other things working)

TLDR:

  • Add "modules-load=dwc2,g_ether" to cmdline.txt file

  • Make sure the new network interface has the PI's IP for the gateway. This way it is recognized as a valid network and you can set it to public or private.

  • Make sure the modbros application is configured properly with the firewall rules.

  • Enjoy! Thank you @stanoba

@Seraksab
Copy link
Member

Thanks for putting in the work to implement this feature @stanoba 👍

I'll have a look at all of it once i find time to do so.
But i I guess it will take a bit of time as I want to test it on multiple Pi models and make sure it doesn't interfere with normal network operation (wifi, ethernet) on the models that doesn't support OTG

Also we will need to update all of those Waveshare configuration files.. :/

@Ezero03
Copy link

Ezero03 commented Jan 31, 2021

Hi, every time I follow this guide I get the exact same log and Windows cant recognice my raspberry with conected USB, althoug modbros app finds it and it works through wifi, not USB.
Attached the installation log, so if there is any error, somebody can help me.

modbros_ssh_log.txt

@EnDeRWiGiN
Copy link

@Ezero03 Did you make sure the config.txt file and the cmdline.txt file had correct lines to enable the USB port to become a network adapter?

Did you try the items in my post:

Okay, so I followed your instruction and was able to do steps 1-3 smoothly. There was a problem once I tried to connect over USB. I was getting a "USB could not be deciphered" problem.

Knowing that it might be a config problem I checked the config.txt file and cmdline.txt. The config file was correct and had "dtoverlay=dwc2" but the cmdline.txt file did not have "modules-load=dwc2,g_ether" after rootwait. I added this and was able to proceed.

I was able to do steps 4-8 but afterward, the PI did not see the server even though I could go to the configurator and SSH into it.

I was able to set the network to private and ran the configuration multiple times but I could not get the Pi to see the modbros Client. I tried the static IP of the computer on that network adapter and the normal Network name but it could not find the client.

I ended up removing all the firewall rules and reinstalling modbros and I got it to work! (I have a feeling I messed up the firewall rules while tried to get other things working)

TLDR:

  • Add "modules-load=dwc2,g_ether" to cmdline.txt file
  • Make sure the new network interface has the PI's IP for the gateway. This way it is recognized as a valid network and you can set it to public or private.
  • Make sure the modbros application is configured properly with the firewall rules.
  • Enjoy! Thank you stanoba

@Seraksab Seraksab merged commit a4e8ab4 into ModBros:master Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

USB gadget mode enabled in the image to allow single wire connection to machine.
4 participants