Resurrecting a BrickLens

A unfortunate Linux kernel update has recently wreaked havoc on many DeepLens cameras. While some lucky users have been able to revert this update, many of them (myself included) have found themselves the proud owner of, well… a BrickLens :D

Not quite, but working on it.
Not quite, but working on it.

Here’s a detailed procedure to perform a full system restore on DeepLens. It builds upon the official troubleshooting guide.
 
DISCLAMER: THIS WILL ERASE ALL EXISTING CONTENT ON THE CAMERA.

Hardware shopping list

  • A USB key (2GB minimum),
  • A micro-SD card (16GB minimum),
  • An adapter to connect the microSD card to your computer (micro-SD to SD, micro-SD to USB, card reader),
  • An external monitor, with an HDMI to micro-HDMI cable,
  • A USB keyboard (no mouse needed, both USB ports on DeepLens will be occupied anyway).

Software shopping list

You’ll also need the ability to format the micro-SD card with NTFS:

  • Windows users: natively supported
  • Linux users: mkfs.ntfs (8)
  • Mac users: no native support, best option is to use Paragon NTFS (Free 10-day evaluation period, then $19.95)

Procedure

On your computer:

  • Use Etcher to burn the Ubuntu ISO image on the USB key.
  • Format the micro-SD card in NTFS format and name the volume Storage (with a capital S).
  • Extract the DeepLens system image at the root of the micro-SD card.
  • Eject the USB key and the micro-SD card safely.

On DeepLens:

  • Connect the keyboard and micro-HDMI cable.
  • Connect the USB key.
  • Insert the micro-SD card.
  • Connect the power adapter.
  • Power on the camera and keep pressing the ESC key.
  • When the BIOS menu appears, select ‘Boot Menu’ and boot from the USB key (not the DeepLens volume).
  • When the Ubuntu menu appears, select ‘Try Ubuntu without installing’.
  • The Ubuntu desktop will open (no password needed).
  • Using ALT-F1, open a Terminal and go to /media/ubuntu/Storage.

The flashing.py Python script uses dd to perform a raw copy the system image (image.bin) to the DeepLens internal storage (partition 2 on /dev/mmcblk1 aka /dev/mmcblk1p2). It then resizes the partition to the correct size.
 
A word of warning: there’s no error management in the script. To avoid messing up your filesystem and having to flash it again, I would suggest commenting out the filesystem commands.

sudo umount /dev/mmcblk1p2
sudo parted /dev/mmcblk1 resizepart2 15758
sudo fsck -fy /dev/mmcblk1p2
sudo resize2fs /dev/mmcblk1p2

Once you’ve run the modified script and flashed the image, you could run the filesystem commands one by one, carefully checking that each one has completed successfully before running the next.
 
If you think I’m just old-fashioned and paranoid, just go ahead and run the script as-is.

python flashing.py

The whole process takes about 15 minutes. Once it’s complete, you can shut DeepLens down.

sudo shutdown -h now

Disconnect the USB key and remove the micro-SD card. Store them somewhere safe, chances are you’ll need them again ;)
 
Your DeepLens is now operational. Power it on and follow the setup instructions in the AWS documentation.
 
One last thing: unless you really enjoyed running this procedure, may I suggest that you disable automatic updates, either at registration time or by running:

sudo apt-get remove unattended-upgrades

Have fun with DeepLens!
 
Questions and comments welcome on Twitter.


Obvious choice…