From 664e47b1c05358cc7c074aed2d936b82a1ec7762 Mon Sep 17 00:00:00 2001 From: Stephen Gordon Date: Tue, 23 Oct 2018 07:47:23 -0400 Subject: [PATCH 1/6] Create the TeslaCam directory as part of the SD card setup --- windows_archive/setup-teslausb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/windows_archive/setup-teslausb b/windows_archive/setup-teslausb index 5910eab..b9da36e 100644 --- a/windows_archive/setup-teslausb +++ b/windows_archive/setup-teslausb @@ -103,6 +103,12 @@ function create_usb_drive_backing_files () { /tmp/create-backingfiles.sh "$campercent" "$BACKINGFILES_MOUNTPOINT" } +function create_teslacam_directory () { + mount /mnt/cam + mkdir /mnt/cam/TeslaCam + umount /mnt/cam +} + function configure_archive () { echo "Configuring the archive..." mkdir /mnt/archive @@ -216,6 +222,8 @@ echo "" >> /etc/fstab create_usb_drive_backing_files +create_teslacam_directory + configure_archive configure_rc_local From 7eaead43aef881286ca2c8848058861805841b3f Mon Sep 17 00:00:00 2001 From: Stephen Gordon Date: Tue, 23 Oct 2018 09:13:25 -0400 Subject: [PATCH 2/6] Remove instructions about manually creating the TeslaCam directory --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index c672958..e963075 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,6 @@ After reboot, the Pi hostname will become `teslausb`, so future `ssh` sessions w ### Get the Pi set up for your Tesla. If you set up the Pi with a keyboard and a monitor disconnect it and connect it to a PC. If you're using a cable be sure to use the port labeled "USB" on the circuitboard. 1. Wait for the Pi to show up on the PC as a USB drive. -1. Create a directory named TeslaCam at the root of the drive labeled CAM. 1. Copy any music you'd like to the drive labeled MUSIC. 1. Eject the drives. 1. Unplug the Pi from the PC. From b71d7d77d6641df75c4e3babe6dc12cd8708161c Mon Sep 17 00:00:00 2001 From: Stephen Gordon Date: Tue, 23 Oct 2018 09:39:18 -0400 Subject: [PATCH 3/6] More changes to the readme instructions. Connecting the Pi to a PC after setup-teslausb is run is only required when adding music to the Pi --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e963075..2771d94 100644 --- a/README.md +++ b/README.md @@ -106,12 +106,14 @@ Now that you have Wifi up and running, it's time to set up the USB storage and s ``` 1. Run this command: ``` - reboot + shutdown -h now ``` -After reboot, the Pi hostname will become `teslausb`, so future `ssh` sessions will be `ssh pi@teslausb.local`. +On the next boot, the Pi hostname will become `teslausb`, so future `ssh` sessions will be `ssh pi@teslausb.local`. -### Get the Pi set up for your Tesla. +Your Pi is now ready to be plugged into your Tesla. If you want to add music to the Pi, follow the instructions in the next section. + +### (Optional) Add music to the Pi If you set up the Pi with a keyboard and a monitor disconnect it and connect it to a PC. If you're using a cable be sure to use the port labeled "USB" on the circuitboard. 1. Wait for the Pi to show up on the PC as a USB drive. 1. Copy any music you'd like to the drive labeled MUSIC. From cc89acefce2286862c2e8e24f2c4e6370c7ea5c4 Mon Sep 17 00:00:00 2001 From: cimryan Date: Tue, 23 Oct 2018 16:40:41 -0700 Subject: [PATCH 4/6] Halt is preferred. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2771d94..0b941a4 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ Now that you have Wifi up and running, it's time to set up the USB storage and s ``` 1. Run this command: ``` - shutdown -h now + halt ``` On the next boot, the Pi hostname will become `teslausb`, so future `ssh` sessions will be `ssh pi@teslausb.local`. From 5b75897c7d480df27ef266272c99e63efd499695 Mon Sep 17 00:00:00 2001 From: cimryan Date: Tue, 23 Oct 2018 18:18:35 -0700 Subject: [PATCH 5/6] Move creation of the TeslaCam directory to create-backingfiles.sh The create-backingfiles.sh file already contains the responsibility for defining the mount points, which this step needs. --- windows_archive/create-backingfiles.sh | 8 ++++++++ windows_archive/setup-teslausb | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/windows_archive/create-backingfiles.sh b/windows_archive/create-backingfiles.sh index a406df4..69f19b4 100644 --- a/windows_archive/create-backingfiles.sh +++ b/windows_archive/create-backingfiles.sh @@ -21,6 +21,12 @@ function add_drive () { echo "$filename $mountpoint vfat noauto,users,umask=000 0 0" >> /etc/fstab } +function create_teslacam_directory () { + mount /mnt/cam + mkdir /mnt/cam/TeslaCam + umount /mnt/cam +} + FREE_1K_BLOCKS="$(df --output=avail --block-size=1K /backingfiles/ | tail -n 1)" CAM_DISK_SIZE="$(( $FREE_1K_BLOCKS * $CAM_PERCENT / 100 ))" @@ -36,3 +42,5 @@ then else echo "options g_mass_storage file=$CAM_DISK_FILE_NAME removable=1 ro=0 stall=0 iSerialNumber=123456" > "$G_MASS_STORAGE_CONF_FILE_NAME" fi + +create_teslacam_directory diff --git a/windows_archive/setup-teslausb b/windows_archive/setup-teslausb index 3fe1526..c50b31b 100644 --- a/windows_archive/setup-teslausb +++ b/windows_archive/setup-teslausb @@ -139,12 +139,6 @@ function create_usb_drive_backing_files () { /tmp/create-backingfiles.sh "$campercent" "$BACKINGFILES_MOUNTPOINT" } -function create_teslacam_directory () { - mount /mnt/cam - mkdir /mnt/cam/TeslaCam - umount /mnt/cam -} - function configure_archive () { local archive_server_ip_address="$1" @@ -276,8 +270,6 @@ echo "" >> /etc/fstab create_usb_drive_backing_files -create_teslacam_directory - configure_archive "$ARCHIVE_SERVER_IP_ADDRESS" configure_rc_local From a7a9110160505b167f5ef4e601d9efc114942871 Mon Sep 17 00:00:00 2001 From: cimryan Date: Tue, 23 Oct 2018 18:29:26 -0700 Subject: [PATCH 6/6] Just three phases to setting up the Pi, now. --- README.md | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0b941a4..6f3c49e 100644 --- a/README.md +++ b/README.md @@ -58,11 +58,10 @@ Get the IP address of the archive machine. You'll need this later, so write it d ### TODO Other hosting solutions ## Set up the Raspberry Pi -There are four phases to setting up the Pi: +There are three phases to setting up the Pi: 1. Get the OS onto the micro sd card. 1. Get a shell on the Pi. 1. Set up the USB storage functionality. -1. Get the Pi set up for your Tesla. ### Get the OS onto the micro SD card @@ -73,13 +72,17 @@ There are four phases to setting up the Pi: ### Get a shell on the Pi If you used a Windows computer to flash the OS onto the MicroSD card, follow these [Instructions](GetShellWithoutMonitorOnWindows.md). + If you used a Mac or a Linux computer, follow these [Instructions](GetShellWithoutMonitorOnLinux.md). ### Set up the USB storage functionality Now that you have Wifi up and running, it's time to set up the USB storage and scripts that will manage the dashcam and (optionally) music storage. -1. SSH to the Pi and run `sudo -i` +1. SSH to the Pi and run + ``` + sudo -i + ``` 1. Try to ping your archive server from the Pi. In this example the server is named `nautilus`. ``` ping -c 3 nautilus @@ -108,29 +111,30 @@ Now that you have Wifi up and running, it's time to set up the USB storage and s ``` halt ``` +1. Disconnect the Pi from the computer. On the next boot, the Pi hostname will become `teslausb`, so future `ssh` sessions will be `ssh pi@teslausb.local`. -Your Pi is now ready to be plugged into your Tesla. If you want to add music to the Pi, follow the instructions in the next section. +Your Pi is now ready to be plugged into your Tesla. If you want to add music to the Pi, follow the instructions in the next section. -### (Optional) Add music to the Pi -If you set up the Pi with a keyboard and a monitor disconnect it and connect it to a PC. If you're using a cable be sure to use the port labeled "USB" on the circuitboard. -1. Wait for the Pi to show up on the PC as a USB drive. +## (Optional) Add music to the Pi +Connect the Pi to a computer. If you're using a cable be sure to use the port labeled "USB" on the circuitboard. +1. Wait for the Pi to show up on the computer as a USB drive. 1. Copy any music you'd like to the drive labeled MUSIC. 1. Eject the drives. 1. Unplug the Pi from the PC. 1. Plug the Pi into your Tesla. ## Making changes to the system after setup -The setup process configures the Pi with read-only file systems for the operating system but with read-write access through the USB - interface. This means that you'll be able to record dashcam video and add and remove music files but you won't be able to make changes - to files on / or on /boot. This is to protect against corruption of the operating system when the Tesla cuts power to the Pi. +The setup process configures the Pi with read-only file systems for the operating system but with read-write +access through the USB interface. This means that you'll be able to record dashcam video and add and remove +music files but you won't be able to make changes to files on / or on /boot. This is to protect against +corruption of the operating system when the Tesla cuts power to the Pi. To make changes to the system partitions: ``` ssh pi@teslausb. sudo -i -mount / -o remount,rw -mount /boot -o remount,rw +/root/bin/remountfs_rw ``` Then make whatever changes you need to. The next time the system boots the partitions will once again be read-only.