cimryan / teslausb

Steps and scripts for turning a Raspberry Pi into a useful USB drive for a Tesla
MIT License
580 stars 492 forks source link

Fix image creation for Tesla firmware 2019.5.x #125

Closed marcone closed 4 years ago

marcone commented 5 years ago

As of firmware 2019.5.x, Tesla expects a partitioned device for storing dashcam recordings. While this is not required for the music drive, this change modifies both camera and music images to use a partition table with a single primary partition formatted as FAT32, instead of formatting the entire device/file..

rtanaka commented 5 years ago

@cimryan - can you please review this pull request?

ghost commented 5 years ago

I pointed the setup config to @therealmarcone's branch and tested this out as well as manually adding his changes from PR https://github.com/cimryan/teslausb/pull/126. Worked well for me. Model 3 on 2019.5.15.

AngusThermo-Pyle commented 5 years ago

This PR does get filesystems that work on newer firmware, however it breaks the fsck /mnt/cam, which needs to be fsck /dev/loop0 style which means that as soon as the filesystem is powered off abruptly, which Tesla likes to do with USB ports, it never recovers. Testing now with the /dev/loop0 /dev/loop1 fsck.

marcone commented 5 years ago

Why does it break the fsck? Since the filesystem is mounted on /mnt/cam with the correct offset, "fsck /mnt/cam" should just work, no? (not near a pi right now, can't check)

AngusThermo-Pyle commented 5 years ago

fsck from util-linux 2.29.2 fsck.fat 4.1 (2017-01-24) Logical sector size is zero.

I'd assume that this is because of the partitioning. fsck /dev/loop0 works fine. I've modified my archiveloop to use /dev/loop for now, but there should be a way to get the /dev/loop address from the mountpoint in order to avoid hardcoding.

Incidentally, this may be the solution to the reports of filesystems becoming randomly inaccessible over time. I was seeing the cam icon and music drive vanishing randomly during the day and tracked it down to the fsck failure. I also rsync my music from a music archive when the clips are copied, so my install is already a bit custom.

marcone commented 5 years ago

Added a change that looks up the loopback used for the mountpoint being checked, then runs fsck on that instead.