[go: up one dir, main page]

Skip to content

Commit

Permalink
New scripts:
Browse files Browse the repository at this point in the history
- to build EEM module
- to install only EEM feature on RPI Zero or ZeroW

RPI usb0 interface config relies now on dhcpcd service (allows avahi to work)
  • Loading branch information
bousqi committed Feb 6, 2019
1 parent 87894b9 commit 9effc92
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 15 deletions.
22 changes: 22 additions & 0 deletions build_eem.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# check rpi-source
if [ -z "$(which rpi-source)" ]; then
sudo apt install bc
wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update
fi

# around 150 Mo
rpi-source --nomake
cd /lib/modules/$(uname -r)/source

# enabling USB EEM module in config
sed -i "s/# CONFIG_USB_ETH_EEM is not set/CONFIG_USB_ETH_EEM=y/" .config

# building module
make drivers/usb/gadget/function/usb_f_eem.ko
# installing module
sudo mv drivers/usb/gadget/function/usb_f_eem.ko /lib/modules/$(uname -r)/kernel/drivers/usb/gadget/function/
sudo depmod
cd -

7 changes: 4 additions & 3 deletions install_psakey.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ systemctl restart apache2

echo "Installing USB gadget script..."
# Installing as a system service to enable it on boot
cp resources/myusbgadget /usr/bin/myusbgadget
chmod +x /usr/bin/myusbgadget
cp resources/myusbgadget /usr/local/bin/myusbgadget
chmod +x /usr/local/bin/myusbgadget
cp resources/myusbgadget.service /usr/lib/systemd/system/
systemctl enable myusbgadget

echo "Installing network related files..."
# USB gadget configuration file
cp resources/usb0 /etc/network/interfaces.d/
cat resources/dhcpcd.conf >> /etc/dhcpcd.conf
#cp resources/usb0 /etc/network/interfaces.d/

echo "Setting up the read-only filesystem..."
# We need to setup filesystems as readonly because the RPi will be shut down without notice
Expand Down
39 changes: 39 additions & 0 deletions install_usbgadget.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

if [ "`whoami`" != "root" ];
then
echo "This script needs to be run as root. Please use sudo."
exit 1
fi

if [ "`grep ^dtoverlay=dwc2 /boot/config.txt`" = "" ]; then
echo dtoverlay=dwc2 >> /boot/config.txt
fi

echo "Installing USB gadget script..."
# Installing as a system service to enable it on boot
mkdir /usr/lib/systemd/system
cp resources/myusbgadget /usr/local/bin/myusbgadget
chmod +x /usr/local/bin/myusbgadget
cp resources/myusbgadget.service /usr/lib/systemd/system/
systemctl enable myusbgadget

echo "Installing network related files..."
# USB gadget configuration file
cat resources/dhcpcd.conf >> /etc/dhcpcd.conf
#cp resources/usb0 /etc/network/interfaces.d/

echo "Setting up the read-only filesystem..."
# We need to setup filesystems as readonly because the RPi will be shut down without notice
cp /etc/fstab /etc/fstab.bak
sed 's/^\(PARTUUID.*defaults\)/\1,ro/' < /etc/fstab.bak > /etc/fstab
# Add some folders as tmpfs (logs, tmp...)
cat resources/fstab.tmp >> /etc/fstab
# this remount script can be called to mount root filesystem as read-write again
cp resources/remount /usr/sbin/remount
chmod +x /usr/sbin/remount
mv /etc/resolv.conf /tmp/resolv.conf
ln -s /tmp/resolv.conf /etc/resolv.conf

echo "Installation is done! You can reboot to apply the configuration,"
echo "then plug the key into your car's USB port and navigate to the Internet application."
3 changes: 3 additions & 0 deletions resources/dhcpcd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

interface usb0
static ip_address=192.168.0.2/24
2 changes: 1 addition & 1 deletion resources/myusbgadget.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Before=networking.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/myusbgadget
ExecStart=/usr/local/bin/myusbgadget

[Install]
WantedBy=sysinit.target
11 changes: 0 additions & 11 deletions resources/usb0

This file was deleted.

0 comments on commit 9effc92

Please sign in to comment.