ECE472/572 (UCLX) Assignment 2 - version for RaspberryPi
Prepare for the lab
Answer these questions while doing this lab – they will help you understand the procedure and better prepare for the tests.
- What happens if running sudo su is skipped? What does the sudo su command do? What does each of these two commands do when run separately?
- The man command and help switch are very important for command line work. Try sfdisk -h and man sfdisk to see the difference. The info command is similar to man. Try it too. Having trouble exiting a man or info screen? Press 'q'. What is the -l switch do for sfdisk?
- What is the difference between the mkfs.vfat and mkfs.ext2 commands? What do the -n and -L switches do respectively?
- What does the apt-get command do?
- Find the commands and their options as necessary for the following command line tasks:
- Change directory to the root folder
- Change directory to the folder XYZ in your current directory
- Change directory to your home directory
- Check what directory you are in
- List files in the current directory without too many details
- List files in the current directory with all details
- List all files in the current directory including hidden files
- What does -F do when used with command than lists files?
- Delete a file in the current directory
- Delete an empty folder
- Delete a non-empty folder with its contents
This lab assignment task has been reviewed by Mr. Christopher Noe, class of
2018, Mr. Joseph Groe, class of 2017
and by Ms. Kate Palmer, class of 2015.
This installation assumes that you are running a Linux, or preferably Debian Linux such as Ubuntu booted from a HD or a Virtual Machine. It may be possible to do it while running from a Live CD but the amount of data to be saved temporarily on a RAM disk
will be prohibitive with less than 8GB of RAM.
- This exercise is based on documentation posted at
. It puts emphasis on performing steps manually one by one rather than running
automated scripts for the sake of learning media partitioning and formatting
- script hw2rp.txt
- sudo apt-get install wget
- ls -l /dev/*
- Insert a 4GB or larger up to 32GB SD card. (4GB, 8GB and 16GB cards were
- ls -l /dev/sd*
- Check for a new disk device name. It will be in the format of /dev/sdx .
- Use that name in the reminder of this instruction by substituting x to form correct name. For example:/dev/sdb
- Some systems (different than Ubuntu) use different naming systems for SD cards, such as /dev/mmcblk0 or /dev/mmc/blk0
- If you use N-in-one card reader that reads multiple memory cards it may show up as several (up to four) devices even if you do not insert the SD card into it. Therefore, it is highly recommended that novice users use a single purpose SD card reader. Running sudo mount and inspecting for additional lines after the SD card was inserted may be of help if the SD card was already formatted.
- sudo mount
- df -h
- sudo umount /dev/sdx?
should unmount /dev/sdx1 and /dev/sdx2,
and produce an error message for /dev/sdx as the latter was never mounted.
- Do not proceed with this media name if the command above produced an error indicating that the media unmounting failed because the media is in use. You might be trying to format your hard drive instead of the SD card!
- Inspect what kind of partition system was already present on your SD
sudo sfdisk -l /dev/sdx
- mkdir rpi
- cd rpi
Note that as of January 2018 this will result in downloading the image that
is also available at
- ls -l
- mv raspbian_latest raspbian.zip
- Extract the compressed file using unzip to pipe, and read from that pipe by dd run as root that writes data sector by sector to Sd card "hard drive":
unzip -p raspbian.zip | sudo dd bs=4M
- Try this: open another terminal and occasionally type:
sudo pkill -USR1 -n -x dd
and then inspect
the original terminal window. We are copying almost
4GB of data.
- Inspect what kind of partition system was written to your SD card:
sudo sfdisk -l /dev/sdx
- Adjust the UART settings
Note: this step can be performed when you prepare the
system for the older Raspberry Pi but it does not have any effect on it.
- Remove the SD card and insert it again.
Note: instead of removing
and reinserting the SD card you can mount the SD card manually by
clicking on its icon that showed up on the desktop.
- ls -l /media/youruserid
- gedit /media/youruserid/boot/config.txt
- Add the following line at the end of the configuration file
- In case of RaspberryPi version 3B we use wired UART and not
Add the following line at the end of the configuration
- Save the file and close gedit.
- sudo umount /dev/sdx?
- Remove the SD card and insert it into your RaspberryPi. Make sure that
the SD card reader LED stopped flashing before ejecting the
card. Otherwise, you may have to restart the process from the step where you
copy the image file to the SD card using dd.
- Connect the RaspberryPi to your 4-pin USB to serial adapter
connected as instructed.
- Within a minute the board shall come "alive", it's LED shall start pulsing, your computer shall detect four USB devices including USB to serial, and mass storage device
- Run a HyperTerminal (from Windows or Linux)
On windows you may use an open source software called PUTTY from
- Connect to the RaspberryPi. The connection parameters are
115000 bits per second, 8-bit, no parity, 1 stop bit
- Try to login as one of the follwoing
- User: root, no password
- User: pi, password
- Set the password using passwd command. Set the password to
ee00 or if that is too short set it
If you have problems with
password being to short use sudo and set the password as root instead of
as the user.
- Enable ssh server to allow for remote login using SSH
choose: interfacing options / ssh / enable / yes
- Check if you are connected to Ethernet
- verify that the RJ45 connector is active (LED on the connector lights up)
- check what is your IP address using ifconfig
- Ignore the 127.0.0.1 address as it is a local address of the board for testing purposes (Local Loopback).
- If the IP address starts with 10..... that
means that the Ethernet port is initialized but DHCP client for IP v.4 was not run.
- If you are running a home router with network address translation firewall the address should most likely start with
- if you are connected do attempt to update the board contents. Since you are using the most recent image very little updates should be available.
Note: some distributions may not have
Try dpkg, apt-get,
aptitude instead of opkg.
sudo apt-get update
sudo apt-get upgrade
- More packages that may be useful one day:
sudo apt-get install binutils bzip2 gettext git libtool make patch sed wget
sudo apt-get install gcc g++ libgcc-dev task-native-sdk
sudo apt-get install fakeroot
sudo apt-get install kernel-module-ftdi-sio
Comment: It is not our intention to develop software directly on the board. The industry does use cross-compiling technology for embedded system development. However, this board is powerful enough to allow for local compilation of simple programs directly on the board. It is possible to do all further lab work except #5, #6 (system speed and SD card speed and size limit), and #13 (not applicable) directly on this board.
- just in case run sync
- Connect to the board using SSH:
ssh 123.456.789.012 -l root
Note: Adjust user name accordingly. Typing exit will log you out back to the local terminal window.
This will end the script session. Submit the file
hw2rp.txt if requested.
Take a photographs (phone camera is OK) of the board and a HyperTerminal
window showing that you connected to it.
Type uname -a
in the console to show which version of system is running. make sure that the
outcome of uname command is legible in the screen shot
or the photograph. ZIP files together if you are submitting multiple files.
Only if requested: Drop the file with the information collected
during the exercise as instructed in the corresponding assignment drop box on Sakai.
Peoria area students only: label your SD card with your name or use an envelope
and hand it to the instructor by the end of the lecture the day the lab is due.
Your disk will be returned after grading.