Sunday, December 13, 2015

Setting Up Raspberry Pi

Preface

Cool, I've tried Arduino, BeagleBone, and STM boards before, but this would be my first experience in coding on Raspberry Pi, which quite famous and cheap as well. In this post, I would write down my steps for setting up Raspbian, a Linux distribution designed for Raspberry Pi. Although there are already tons of tutorial regarding to this, I will include some troubleshooting as well.

Equipments

  1. Raspberry Pi Model B
  2. HDMI Cable
  3. Monitor supports HDMI
  4. MicroSD Card (at least 8G)
  5. USB Keyboard / USB Mouse
  6. USB wireless adapter - Edimax EW-7811UN
  7. USB Cable (A type to Micro)

Steps

Build OS Image on SD Card

Normally, this step should be easy, only one or two commands are needed to get a SD with our OS in it. However, I found a problem while doing this step this time - my SD card is in read-only mode. Usually, this is cause by the physical lock switch on the card; however, no matter I switch it on or off, it's always locked. By applying the commands I noted in the last post, we can learn its details:
> diskutil info disk2
   Device Identifier:        disk2
   Device Node:              /dev/disk2
   Whole:                    Yes
   Part of Whole:            disk2
   Device / Media Name:      SD Card Reader
   Volume Name:              Not applicable (no file system)
   Mounted:                  Not applicable (no file system)
   File System:              None
   Content (IOContent):      FDisk_partition_scheme
   OS Can Be Installed:      No
   Media Type:               Generic
   Protocol:                 USB
   SMART Status:             Not Supported
   Total Size:               15.9 GB (15931539456 Bytes) (exactly 31116288 512-Byte-Units)
   Volume Free Space:        Not applicable (no file system)
   Device Block Size:        512 Bytes
   Read-Only Media:          Yes
   Read-Only Volume:         Not applicable (no file system)
   Device Location:          Internal
   Removable Media:          Yes
   Media Removal:            Software-Activated
   Virtual:                  No
   OS 9 Drivers:             No
   Low Level Format:         Not supported

And, whenever I tried to format or write onto the card, I got:

> sudo -s -- 'dd bs=1m if=/dev/zero of=/dev/disk2'
Password:
dd: /dev/disk2: Permission denied

After several trials and Googling, I found the problem is caused by the adaptor that adapts the small Micro SD back to the normal size where its switch isn't functioning well. Funny discussion regarding to this issue can be found online, such as "it worked when it was about 75% towards the unlocked position, but you might need to fiddle with it a bit". No matter how I place the switch lock, it never works.

So, I then brought a small Micro SD Card Reader, which costs around USD2.5, and it fixes all the problem nicely.

> diskutil info disk3
   Device Identifier:        disk3
   Device Node:              /dev/disk3
   Whole:                    Yes
   Part of Whole:            disk3
   Device / Media Name:      STORAGE DEVICE
   Volume Name:              Not applicable (no file system)
   Mounted:                  Not applicable (no file system)
   File System:              None
   Content (IOContent):      FDisk_partition_scheme
   OS Can Be Installed:      No
   Media Type:               Generic
   Protocol:                 USB
   SMART Status:             Not Supported
   Total Size:               15.9 GB (15931539456 Bytes) (exactly 31116288 512-Byte-Units)
   Volume Free Space:        Not applicable (no file system)
   Device Block Size:        512 Bytes
   Read-Only Media:          No
   Read-Only Volume:         Not applicable (no file system)
   Device Location:          External
   Removable Media:          Yes
   Media Removal:            Software-Activated
   Virtual:                  No
   OS 9 Drivers:             No
   Low Level Format:         Not supported
~
> diskutil unmountDisk /dev/disk3
Unmount of all volumes on disk3 was successful
~
> sudo -s -- 'dd bs=1m if=/Users/heron/Desktop/2015-11-21-raspbian-jessie-lite.img | pv | dd of=/dev/disk3'
I am using pv in the middle instead of barely using dd is because that dd doesn't show the process bar, which is hard for me to know how long will it take, and how much is done.

Power Up

Basically, the followings would be easy and we are already about to finish. Plug in the cables as below, and it will power up right after the micro USB is plugged in.


From the photo, one can see that I have:
  • 1 Micro USB for power
  • 1 HDMI for display
  • 2 Logitech Unifying Receiver for keyboard and mouse
  • 1 USB wireless adapter for Wifi
  • 1 USB microphone (for application purpose)

Keyboard Layout Issue

Everything should be set so far, and if you're using NOOBS system installer, it will do rest of the jobs. The only thing is you have to do is to select your settings or system you wish to install.

However, there's one issue I found when I just setup Raspbian, the operating system designed for Raspberry Pi based on Debian. It's using different keyboard layout which is a general one that I used to. So, to fix the problem, we have to fire up keyboard-configuration and pick the right setting. Steps are in this link. The settings will start to affect only after reboot.

Reference

No comments:

Post a Comment