cis 191: linux and unix class 9 april 1, 2015 hardware, project, and devices
TRANSCRIPT
CIS 191: Linux and Unix
Class 9April 1, 2015
Hardware, Project, and Devices
Outline
Final Project Overview
Amazingly Short Hardware Brief
rm –rf /
Part Handout
Raspberry PI
• For the final project, you’ll be working with a raspberry pi project to make something cool using your unix skills
• There are plenty of projects out there that can run on pis• We’ll be giving you the pis, and you already have access
to the internet
Raspberry PI
• For the final project, you’ll be working with a raspberry pi project to make something cool using your unix skills
• There are plenty of projects out there that can run on pis• We’ll be giving you the pis, and you already have access
to the internet• We just want you to make something cool• And sufficiently difficult…
Due Date
• The final project will be due on our last day of class, which is April 29th.
• So you have 4 weeks– Which should honestly be more than enough time to make
something great
Raspberry PIs are…
• A full multipurpose computer on a chip• Strong enough to run an Xbox media center emulation!• fully equipped with general purpose I/O pins
– We’ll go over how to use these a bit next week
• unable to handle anything more than 5 volts– so don’t try to output more than that or you’ll break it– In fact, don’t try to output more than 3.3V
• really cool
Running the raspberry pi
• You’ll have to load up an image• We’re not going to force you to use any in particular
– The official distribution is “raspbian”, which should also be fine• It’s also a derivative of debian, after all• This means apt-get is a-go
Raspberry PI project ideas…
• Let’s just look at youtube!
Outline
Final Project Overview
Amazingly Short Hardware Brief
rm –rf /
Part Handout
Ohm’s Law
V = IR
http://www.electrical4u.com/wp-content/uploads/2013/03/ohm-law-2.jpg
Vary Resistance
• You can vary resistance to modify the behavior of a circuit
• For example, in this fart detector project linked to on piazza, the circuit is modified to the ambient gas environment using a resistor ladder– This prevents false fart positives
Breadboards
http://www.mikroe.com/img/development-tools/compontents/breadboard-400/breadboard_400.png
How to strip a wire
• https://www.youtube.com/watch?v=TZFTKbT4XFs
Color Coding your Circuit
• Red should come from source• Black should go to ground• Inner colors aren’t important
Polarized Parts
• Current can flow from the anode (the + terminal) to the cathode (the – terminal).
• BUT NOT THE OTHER WAY AROUND!
• Damage the parts and (maybe) even yourself
• See this sparkfun link to learn more
Polarized LED
How to make a basic LED circuit
https://www.youtube.com/watch?v=k9jcHB9tWko
Raspberry Pi GPIO
• GPIO on the Raspberry Pi can be controlled pretty easily• To write to output, you can either write to a few files
through the terminal, use the gpio utility, or use a python interface.
• To read from the input, you can use the gpio utility or use the python interface.– Note that this can be a little iffy… they are digital input pins after
all– Anyone see how this might be a problem? How to work around
it?
Outline
Amazingly Short Hardware Brief
A Little More About /dev
rm –rf /
Part Handout
Remember /dev?
• /dev contains system device files• Linux systems accomplish tons of magic by treating
devices as special files– And by pretending that certain non-device objects are files…– Linux employs devices to provide lightweight “system services”
• The contents of /dev have odd permissions if you check with ls -l
Device Files are “Pseudofiles”
• When you read from or write to a device “file”, the operating system silently intercepts your request and feeds it to a driver
• The driver knows how to interact with the device• Drivers are typically written in C
– Can anyone tell me why that might be?
Device File Permissions
• If you took the liberty of running ls –l on the files, you might see something like this
• The “b” means that this is a “block” device• You could also see a “c”, which would mean it is a
“character” device• The size field has been replaced by a csv field where
– The first value represents the major device number– The second value represents the minor device number
Types of Devices
• Character Devices– Denoted by “c” character at start of permissions– Provide direct, unbuffered access to the hardware– Examples: Serial ports, keyboards, sound cards, modems
• Block Devices– Denoted by “b” character at start of permissions– Provide buffered access to the hardware– Always allowed to read/write any sized block– Buffered => We don’t know when the data will be written
• Pseudo Devices– Fake devices that are useful
Some Pseudo Devices
• /dev/null– Accepts all data written to it and does nothing– http://devnull-as-a-service.com/
• /dev/full– Always full; returns a continuous stream of NULL bytes when
read and returns “disk full” error when written to
• /dev/zero– Produces endless string of zero bits when read
• /dev/random and /dev/urandom– Contains a stream of random bytes
Hard Disk Partitions
• Each computer may have several hard drives attached, and each hard drive can be divided into several partitions– Windows assigns each partition its own drive letter (like C:)– Linux allows you to specify where the data on a given partition
should appear in the filesystem
• Every hard drive is assigned a name in /dev– Like /dev/sda for the first drive, or /dev/sdb for the second– Naming starts at sd followed by a letter
• The nth partition of the drive sdb is sdb(n)– So sdb3 is the third partition on the second hard disk
Mounting and Unmounting
• To use a partition, you can use the mount command– The usage is mount device location– For example, mount /dev/sda2 /media/windows
• The mounted filesystems and devices are tracked in /etc/mtab. You’ll probably need to be root to access it.
• umount unmounts a directory– Note the absence of the ‘n’ in umount
fstab
• Non-changing filesystem information is written in /etc/fstab– According to the man page, “it is the duty of the system
administrator to properly create and maintain this file”– At boot, fstab tells the system which filesystems should be
loaded– Afterwards, fstab is used (by mount/umount) to describe how to
mount and unmount filesystems
• fstab entries contain the filesystem location, the mount point, the file system type, options, and information about core dumping and checking the filesystem
Outline
Amazingly Short Hardware Brief
A Little More About /dev
rm –rf /
Project Help
https://www.youtube.com/watch?v=D4fzInlyYQo
https://www.youtube.com/watch?v=I1KrsEBzJO8
Outline
Amazingly Short Hardware Brief
A Little More About /dev
rm –rf /
Part Handout