Accessing the Piper Computer Card using a Mac (backing up level progress)


#1

So, I faced the “no audio” and “screen resolution” issues some days after updating.

I checked today in the forums and found a fix for the resolution problem.

I tried fixing the audio with this fix. I found it here

However, I opted to do the flashing of the card, but before pulling it out I did not save the progress file for the game. So, since I was going to flash it anyway I am posting this to access the file system, so you can copy the necessary files ~/piper/game/userData/playData/levelsCompleted.txt to your local machine, and then flash the card.

This assumes that you have already pulled out the card from the Raspberry. It also assumes that you have already installed Etcher.

Almost everything will be done in the Terminal app (in Applications > Utilities)):

  1. Plug the microSD card into a card reader connected to your Mac. The boot volume will be automatically mounted, but it doesn’t contain all the files from the Pi’s primary filesystem.
  2. Open a terminal window (on the spotlight search type “Terminal” or from finder: Applications > Utilities >Terminal
  3. Install Homebrew. by typing the following command in Terminal

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

  1. Once homebrew has been installed, you can use it to install the needed software to mount the filesystem.
    We need to install osxfuse and ext4fuse (find out more about the tools on the FUSE for macOS website):

brew cask install osxfuse
brew install ext4fuse

  1. Once installed, use Disk Utility on the command line to find the Raspberry Pi’s partition ID; run diskutil list to get output like below:

$ diskutil list
/dev/disk0 (internal):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme 500.3 GB disk0
1: EFI EFI 314.6 MB disk0s1
2: Apple_HFS Macintosh HD 499.3 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3

/dev/disk2 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *15.9 GB disk4
1: Windows_FAT_32 boot 66.1 MB disk4s1
2: Linux 15.9 GB disk4s2

You should be able to tell which drive is your Pi drive by the description (external, physical), the ‘Linux’ partition type, and the size of the disk (e.g. 15.9 GB for my 15.9 GB card). The ID is the disk4s2 in my case, in the IDENTIFIER column.

  1. Create a ‘mount point’—a folder on your Mac where you will ‘mount’ the Linux partition so you can read data from it:

sudo mkdir /Volumes/rpi

NOTE: sudo requires you to enter your Mac account’s admin password, since it performs actions with elevated privileges—enter your password when prompted. You can also create this folder using finder.

  1. Mount the drive using ext4fuse:

sudo ext4fuse /dev/disk2s2 /Volumes/rpi -o allow_other

The -o allow_other is required to make sure the mounted disk is readable by everyone (and not just the sudo/root user). If something is not right, see this issue: Unable to open ext4 mounted partition on El Captain.

  1. Now you’ll see the rpi volume mounted in the Finder. You can open it and read from it just like any other disk, card, or flash drive you connect to your Mac. Using Finder, navigate to:

~/home/piper/game/userData/playData/

Find the file named: levelsCompleted.txt

Copy this file to another folder in your MAC.

With this, you have correctly backed up level progress. Now go ahead and flash the card as per the instructions here.

UPDATE: I was going to add some info on setting up samba file share to copy the level progress file backed up here to the newly flashed card, however given that it takes a little bit more configuration, I preferred @Paul’s response belo, installing netatalk. It’s faster, easier and hassle free.

Bluetooth file sharing (instead of networking)
On your MAC, go to bluetooth icon, click on Open Bluetooth Preferences
On the pi, exit PIPER to desktop.
Click on bluetooth icon and Turn Bluetooth On
Click on Make Discoverable
On that same menu, select Devices or Setup New Devices
After some time it will find the name of your Mac. In my case it is “MacBook Pro”.
Right click on it and select Pair.
Follow the instructions.
You will now be able to send the desired file.


#2

If you want to transfer files to the Mac, before shutting off the Pi,

  1. exit Piper to the desktop
  2. open a terminal window
  3. type: sudo apt-get install netatalk
    and hit enter
  4. When that finishes, reboot the Pi.

You should now see the Pi show up on the Mac in the sidebar of a finder window. If you don’t, open the Finder Preferences, select the ‘Sidebar’ tab and make sure that under the ‘Shared’ topic, ‘Bonjour computers’ is checked.

  1. When you click on the device, you will have to click the ‘Connect As’ button (top right) and enter the user ID: Pi and the password: piper

I do this all the time to move files back and forth.


#3

Thanks for the netatalk tip, I usually set up samba, but in this particular case netatalk is much faster. Since only the home folder is to be accessed, it is perfect for copying files back to the card.