Book Image

Raspberry Pi Zero Cookbook

Book Image

Raspberry Pi Zero Cookbook

Overview of this book

The Raspberry Pi Zero, one of the most inexpensive, fully-functional computers available, is a powerful and revolutionary product developed by the Raspberry Pi Foundation. The Raspberry Pi Zero opens up a new world for the makers out there. This book will give you expertise with the Raspberry Pi Zero, providing all the necessary recipes that will get you up and running. In this book, you will learn how to prepare your own circuits rather than buying the expensive add–ons available in the market. We start by showing you how to set up and manage the Pi Zero and then move on to configuring the hardware, running it with Linux, and programming it with Python scripts. Later, we integrate the Raspberry Pi Zero with sensors, motors, and other hardware. You will also get hands-on with interesting projects in media centers, IoT, and more.
Table of Contents (17 chapters)
Raspberry Pi Zero Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Using OS X to validate a Raspbian image and write it to an SD card


If you are a Mac user, the process will be a little different from the Windows recipe, but still not too difficult. To do it, we'll leverage OS X's built-in *nix system tools.

Note

Mac OS X used to have a lot of options for easy GUI image writers, but many of them were not updated over time. After Yosemite 10.10.5, the Raspberry Pi community recommends using command-line tools. Fortunately, it is a pretty easy process.

How to do it...

The process for validating and copying a NOOBs installation on OS X is fairly straightforward:

  1. Open a Terminal window in OS X.

  2. Next, run shasum against the downloaded ZIP file to validate the signature:

    $ shasum ~/Downloads/2016-05-27-raspbian-jessie.zip 
    64c7ed611929ea5178fbb69b5a5f29cc9cc7c157
        /Users/ed/Downloads/2016-05-27-raspbian-jessie.zip
    

    The Raspbian Jessie download and SHA-1 signature

  3. If the return value matches the SHA-1 signature provided on the Raspberry Pi downloads page, your file is good and can be unzipped:

    Note

    As the downloads change, the SHA-1 will change too, so you'll likely be comparing a different number to your shasum output.

    $ unzip ~/Downloads/2016-05-27-raspbian-jessie.zip 
    Archive:  /Users/ed.snajder/Downloads/2016-05-27-
        raspbian-jessie.zip
    inflating: 2016-05-27-raspbian-jessie.img  
    

  4. Next, look at the filesystem before inserting the SD card:

    $ df -h
    Filesystem      Size   Used  Avail Capacity  iused 
        ifree %iused  Mounted on
    /dev/disk1     232Gi  216Gi   16Gi    94% 56751574 
        4163032   93%   /
    devfs          205Ki  205Ki    0Bi   100%      710 
        0  100%   /dev
    map -hosts       0Bi    0Bi    0Bi   100%        0 
        0  100%   /net
    map auto_home    0Bi    0Bi    0Bi   100%        0  
        0  100%   /home
    map -fstab       0Bi    0Bi    0Bi   100%        0  
        0  100%   /Network/Servers
    

  5. Then, insert the SD card and run the command again:

    $ df -h
    Filesystem      Size   Used  Avail Capacity  iused 
        ifree %iused  Mounted on
    /dev/disk1     232Gi  216Gi   16Gi    94% 56751576 
        4163030   93%   /
    devfs          211Ki  211Ki    0Bi   100%      730 
        0  100%   /dev
    map -hosts       0Bi    0Bi    0Bi   100%        0  
        0  100%   /net
    map auto_home    0Bi    0Bi    0Bi   100%        0 
        0  100%   /home
    map -fstab       0Bi    0Bi    0Bi   100%        0 
        0  100%   /Network/Servers
    
    /dev/disk2s6    63Mi   20Mi   43Mi    32%      512 
          0  100%   /Volumes/boot
    
    
    /dev/disk2s1   1.1Gi  1.0Gi   92Mi    92%        0 
          0  100%   /Volumes/RECOVERY
    
    

  6. As you can see, /dev/disk2s6 and /dev/disk2s1 were added. This creates two partitions on disk2 - most SD cards will only have one, but however many there are mounted, you need to unmount them with diskutil:

    $ sudo diskutil unmount /dev/disk2s1
    Password:
    Volume RECOVERY on disk2s1 unmounted
    $ sudo diskutil unmount /dev/disk2s6
    Volume boot on disk2s6 unmounted
    

    Note

    Very important: Running dd on the wrong device will be disastrous - use with extreme caution!

  7. There is a critical difference now from typical Linux drives and dd use. Let's say you had the aforementioned configuration and see that the SD card disk is disk2. For the dd command, you will change this to rdisk2:

    $ sudo dd bs=1m if=./2016-05-27-raspbian-jessie.img 
        of=/dev/rdisk2
    
    3833+0 records in
    3833+0 records out
    4019191808 bytes transferred in 377.097088 secs (10658241 bytes/sec)
    

    Note

    The dd command can take a while to run, and doesn't provide any output while it is, so you can get that feeling it might be stuck. Be patient, depending on the speed of your SD Card it could take several minutes to copy. Newer versions of dd (on Ubuntu 16.04 and newer) include the status=progress flag, which will indicate copying progress.

  8. Finally, eject the disk, and you are ready to go!

    $ sudo diskutil eject /dev/rdisk2
    Disk /dev/rdisk2 ejected