Lab4 Embedded Linux. Introduction

Similar documents
1. Conventions in this tutorial Introduction Check and change configuration settings as needed Start Digi ESP...

Pengwyn Documentation

Assignment 1: Build Environment

LTC Data Converter Board For The Arrow SoCKit Linux Application User s Guide

Labs instructions for Enabling BeagleBone with TI SDK 5.x

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

ELE409 SPRING2018 LAB0

MVAPICH MPI and Open MPI

Linux Systems Administration Getting Started with Linux

Exercise 1: Basic Tools

Access Server: User's and Developer's Guide <<< Previous Next >>>

Unix/Linux Operating System. Introduction to Computational Statistics STAT 598G, Fall 2011

Lab 1: Accessing the Linux Operating System Spring 2009

Parallel Programming Pre-Assignment. Setting up the Software Environment

First Steps. DNP/SK18 Embedded Linux Starter Kit

Unix. Examples: OS X and Ubuntu

LECTURE 7. Readings: - SSH: The Definitive Guide; D.J. Barret et al.; O Reilly Lecture outline: - SSH. Marco Spaziani Brunella, Manuel Campo

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

LAN Setup Reflection. Ask yourself some questions: o Does your VM have the correct IP? o Are you able to ping some locations, internal and external?

Systems Programming/ C and UNIX

Download, Install and Setup the Linux Development Workload Create a New Linux Project Configure a Linux Project Configure a Linux CMake Project

Z-Stack Linux Gateway Quick Start Guide Version 1.0

IoT with Intel Galileo Gerardo Carmona. makerobots.tk

CENG393 Computer Networks Labwork 1

Bitnami Re:dash for Huawei Enterprise Cloud

Development Environment Embedded Linux Primer Ch 1&2

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

LinX Software Suite v3 Getting Started

Laboratory 1 Semester 1 11/12

Spring 2017 Gabriel Kuri

Lab #9: Basic Linux Networking

This guide is used as an entry point into the Petalinux tool. This demo shows the following:

Cryptography Application : SSH. Cyber Security & Network Security March, 2017 Dhaka, Bangladesh

PROJECT INFRASTRUCTURE AND BASH INTRODUCTION MARKUS PILMAN<

LAN Setup Reflection

Cryptography - SSH. Network Security Workshop May 2017 Phnom Penh, Cambodia

Problem Set 1: Unix Commands 1

What is Secure. Authenticated I know who I am talking to. Our communication is Encrypted

Bitnami Piwik for Huawei Enterprise Cloud

Cryptography - SSH. Network Security Workshop. 3-5 October 2017 Port Moresby, Papua New Guinea

CS 642 Homework #4. Due Date: 11:59 p.m. on Tuesday, May 1, Warning!

CS197U: A Hands on Introduction to Unix

Linux Kung Fu. Stephen James UBNetDef, Spring 2017

MB/ Starter Kit: First Steps

Bitnami Dolibarr for Huawei Enterprise Cloud

Eclipse development with GNU Toolchain

Cloud Computing II. Exercises

CSCI 201 Lab 1 Environment Setup

Comodo Dome Data Protection Software Version 3.8

EX L-8 User Guide

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

FX SERIES. Programmer s Guide. Embedded SDK. MN000540A01 Rev. A

CS155: Computer Security Spring Project #1

CS Fundamentals of Programming II Fall Very Basic UNIX

Build your own Lightweight Webserver - Hands-on I - Information Network I. Marius Georgescu. Internet Engineering Laboratory. 17 Apr

Saint Louis University. Intro to Linux and C. CSCI 2400/ ECE 3217: Computer Architecture. Instructors: David Ferry

The TinyHPC Cluster. Mukarram Ahmad. Abstract

Introduction of Linux

ssh and handson Matsuzaki maz Yoshinobu 1

Docker task in HPC Pack

Bitnami ez Publish for Huawei Enterprise Cloud

Siemens PLM Software. HEEDS MDO Setting up a Windows-to- Linux Compute Resource.

Introduction to Linux

No More Passwords (with SSH)

Bitnami OSQA for Huawei Enterprise Cloud

GIGABYTE. Software Reference Guide for MP30 (APM) Platform R01. Document Version:

Lab 6: OS Security for the Internet of Things

EAN-Network Configuration

Bitnami Tiny Tiny RSS for Huawei Enterprise Cloud

HOW TO SECURELY CONFIGURE A LINUX HOST TO RUN CONTAINERS

Embedded Linux Systems. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

The Balabit s Privileged Session Management 5 F5 Azure Reference Guide

Blackfin cross development with GNU Toolchain and Eclipse

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Commands are in black

Lab 14 - Introduction to the PABLO Payload Autonomy Computer

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

OPENSTACK CLOUD RUNNING IN A VIRTUAL MACHINE. In Preferences, add 3 Host-only Ethernet Adapters with the following IP Addresses:

Appliance Guide. Version 1.0

Programming Project 1: Introduction to the BLITZ Tools

System Manager Unit (SMU) Hardware Reference

CENG 334 Computer Networks. Laboratory I Linux Tutorial

CS 460 Linux Tutorial

Secure SHell Explained!

Itron Riva Dev Software Development Getting Started Guide

Setting up a Chaincoin Masternode

EE516: Embedded Software Project 1. Setting Up Environment for Projects

SETTING UP SSH FOR YOUR PARALLELLA: A TUTORIAL FOR STUDENTS

SSH. What is Safely 6/19/ June 2018 PacNOG 22, Honiara, Solomon Islands Supported by:

Gyrfalcon 2.0 User's Guide

These instructions describe the system requirements and process for installing and initial configuration of jbase on Linux operating systems.

Matrix 500 Quick Installation Guide

Application Note: Demo programs for PremierWave EN and PremierWave XN

Bitnami ProcessMaker Community Edition for Huawei Enterprise Cloud

DNP/2110 Linux Starter Kit: First Steps

Hands-on Exercise Hadoop

Create Test Environment

StampA5D3x/PortuxA5/PanelA5. Quickstart Guide

Installing and Upgrading Cisco Network Registrar Virtual Appliance

Lab 6: OS Security for the Internet of Things

Transcription:

Introduction Lab4 Embedded Linux In this lab we will run Embedded Linux on the Arcom board. This allows us to use operating system services (such as inter-task communication) and use existing software (e.g., network stack, web server, etc.) to rapidly create a powerful embedded system. Prepare yourself by reading through the lab instructions and chapter 10, 12 and 13 (page 242 247) in the course textbook. More detailed information can be found in the Arcom Embedded Linux Technical Manual. You should also download and extract the lab4.tar.gz file from the course web page. Deliverables for all assignments Show your solutions to the lab assistant. The program sources should be well documented and you must be able to explain how the program works. Also, both students should submit the written answers and program source code by attaching them to an e-mail to the lab assistent with cc to the course leader. Please write your name(s) and e-mail address(es) in all documents/program sources that you submit. Write your name and personal number in the e-mail. Note: You do not have to demonstrate assignment 1 3 for the lab assistant. Assignment 1 Getting Started with Embedded Linux Start the Arcom board and boot into Linux mode (do not press reset during startup). When the startup-phase is completed you should see the following text in the cutecom terminal. <...text removed...> Arcom Embedded Linux v4i2b (ttys0) viper login: Next, login with user root and password arcom 1. You should now have a command prompt as shown in figure 1. Try some Linux commands, e.g. ls -l /, df, ps, uname -a, and uptime. It behaves more or less as a standard Linux system (running on a PC) doesn t it? Note: Typically, an embedded system has limited system resources compared to a PC. Thus, the standard Linux utilities is often replaced with size-optimized versions (e.g., via www.busybox.net). This means that these utilities generally have fewer options than their full-featured counterpart. Assignment 2 Setup Network Communication The first step is to connect the network cable, Ethernet LED cable, and Ethernet breakout adapter as shown on page 11 in the VIPER / VIPER-Lite Entry Level Embedded Linux Development Kit, Quickstart Manual. Observe that you must separate the processor board and the I/O board to connect the network cable (requires a screwdriver). You must be very careful when re-assembling the boards since it is easy to bend (destroy) the pins connecting the two boards. Contact the lab assistant if you need help. Login as root on the Arcom board (using cutecom) and use the ifconfig command to tempo- 1 You can also login as a normal user with username arcom and password arcom. Programming Embedded Systems, Spring 2009 Lab4 Page 1 of 9

Figure 1: Linux command prompt. rary 2 configure the network as follows: root@viper root# ifconfig eth0 192.168.0.100 netmask 255.255.255.0 up This command sets the IP address of the Arcom board to 192.168.0.100 and the netmask to 255.255.255.0. Verify that you can reach the Arcom board over the network interface by using the ping command on the PC (Press Ctrl+C to terminate the program): $ ping 192.168.0.100 PING 192.168.0.100 (192.168.0.100) 56(84) bytes of data. 64 bytes from 196.168.0.100: icmp_seq=1 ttl=254 time=0.898 ms... The next step is to make the network configuration permanent by modifying the /etc/network/interfaces configuration file on the Arcom board. Copy the lab4/network/interfaces file (from lab4.tar.gz) to the Arcom board with the following commands: $ cd lab4/network $ scp interfaces root@192.168.0.100:/etc/network/interfaces Answer yes to continue when scp 3 prints a warning that the authenticity of host 192.168.0.100 2 The configuration will be lost when you restart the Arcom board. 3 scp (Secure Copy) is a program to copy files between network-connected computers. It is a part of the OpenSSH (www.openssh.com) connectivity toolset. Programming Embedded Systems, Spring 2009 Lab4 Page 2 of 9

can t be established. Enter arcom when prompted for the password. Finally, verify that everything works by restarting the board and open a new SSH 4 connection once Linux start-up phase has completed. That is, wait for the login prompt in cutecom and open a SSH connection by writing the following command in a terminal window (on the PC): $ ssh root@192.168.0.100 Optional: Setup SSH Public Key Authentication It soon becomes a tedious task to write the password every time you want to access the Arcom board. One approach to avoid this is to setup SSH public key authentication. Start by generating private and public keys with the following commands on your PC: $ mkdir $HOME/.ssh # Not needed if it already exists $ chmod 700 $HOME/.ssh $ ssh-keygen -f $HOME/.ssh/arcom -t rsa Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Press Enter when prompted for passphrase. NB: You should only use these keys with the Arcom board since we don t protect them with a password 5. Next, copy the public key to the root account on the Arcom board with the following command: $ scp $HOME/.ssh/arcom.pub root@192.168.0.100:/root Login to the Arcom board (using ssh root@192.168.0.100) and use the following commands to setup the server: root@viper root# mkdir $HOME/.ssh # Not needed if it already exists root@viper root# chmod 700 $HOME/.ssh root@viper root# cat arcom.pub >> $HOME/.ssh/authorized_keys root@viper root# chmod 600 $HOME/.ssh/authorized_keys root@viper root# rm arcom.pub Next, verify that everything works by logging out (from the Arcom board) and re-connect to the Arcom board using ssh -i $HOME/.ssh/arcom root@192.168.0.100. This time you should get a command shell directly (without having to write the password). Finally, create the file $HOME/.ssh/config (on your PC) with the following contents: IdentityFile ~/.ssh/arcom to avoid having to specify the identity file every time you connect. Now, it should be sufficient to write ssh root@192.168.0.100 to connect to the Arcom board. Assignment 3 Your First Embedded Linux Program Start by creating a simple test program (e.g., hello_world.c) as shown below. here. Listing 1: hello world.c 4 SSH (Secure Shell) allows you to log in to a remote computer. 5 It is better to use passwords and let the ssh-agent manage the keys, but we use the quick-and-dirty approach Programming Embedded Systems, Spring 2009 Lab4 Page 3 of 9

#include <stdio. h> int main (void) { p r intf ( Hello, World! \n ) ; return ( 0 ); } To build this program, you must use a cross compiler that is configured to generate binaries for the ARM Linux target (arm-linux-gcc). This cross compiler is installed in /opt/arcom directory on the computers in the lab room 6. Thus, you should add the following lines to your $HOME/.bashrc file: Listing 2:.bashrc snippet export PATH=$PATH:/ opt/arcom/bin export MANPATH=$MANPATH:/ opt/ arcom/man Start a new terminal window and verify the settings with the following command: $ arm-linux-gcc -v Reading specs from... Next, compile (and link) the program using the arm-linux-gcc program: $ arm-linux-gcc -g -Wall -o hello_world hello_world.c Use scp (secure copy) to download the program to the Arcom board using the following command: $ scp hello_world root@192.168.0.100:/tmp Password: arcom Next, open a ssh connection to the Arcom board and execute the program using the following commands: $ ssh root@192.168.0.100 # <-- executed on the PC Password: arcom root@viper root# cd /tmp # <-- executed on the Arcom board root@viper tmp#./hello_world # <-- executed on the Arcom board Finally, let s try out the arm-linux-insight debugger. Use the existing ssh connection to start gdbserver with the following command: gdbserver host:1000 hello_world where host:1000 means that we are listening for a TCP connection on port 1000 and hello_world is the program that we want to debug. Start arm-linux-insight on the PC and load the hello_world program via File->Open. Next, open File->Target Settings and specify the following parameters: Target: Remote/TCP Hostname: 192.168.0.100 Port: 1000 Deselect "Download Program" under "More Options" 6 See Appendix A for information on how to install this compiler on your own computer. Programming Embedded Systems, Spring 2009 Lab4 Page 4 of 9

Now it only remains to setup the breakpoints and hit the Run button. Assignment 4a Blinking LED in Linux The operating system (usually) controls all hardware resources so we are not allowed to modify the GPIO registers directly as we did in lab 1 3. Instead, we will use the libdevmem 7 library available in Arcom Embedded Linux. The API for libdevmem is described in the /opt/arcom/arm-linux/include/libdevmem.h file. Look at the lab4/led/led.c file (available in lab4.tar.gz) for an example on how to use the libdevmem library. When compiling this example, you must tell the linker to look for object files to include in the libdevmem library by adding -ldevmem to the compilation command, that is: $ arm-linux-gcc -Wall -g -o led led.c -ldevmem NB: The course textbook uses the mmap system call instead of the libdevmem. You can use either mmap or libdevmem in these assignments, but we recommend libdevmem since it is easier to use. Your assignment is to port the light switch assignment from lab1 to Linux. That is, button SW0 SW2 should turn on/off the corresponding LED and button SW3 should change the state of all LEDs. Assignment 4b Blinking LED Using POSIX Threads One important feature provided by an operating system is multitasking. This enables several tasks to share the processor under the control of an operating system. Tasks 8 often make the design and implementation of embedded software easier by enabling us to divide a large program into smaller pieces. We will use the POSIX thread library to manage the tasks in this assignment. See lab4/pthread/pthread_example.c for an example on how to create and use threads. When compiling this example, you must add the libthread library to the compilation command, that is: $ arm-linux-gcc -Wall -o pthread_example pthread_example.c -lpthread Your assignment is to create a multitasking (multithreaded) application that toggles the three LEDs at different speeds. You should assign one LED per task so you will get three tasks in total. Optional: How would you implement this assignment in a single program? Discuss advantages and drawbacks of using multiple tasks. Optional: What are the advantages and drawbacks of using POSIX threads compared to normal processes? Assignment 4c Blinking LED Using Communicating Tasks In this assignment 9 you should create a light switch using two communicating tasks. The first task (producertask) should monitor the buttons (SW0 SW3), and once a button is pressed, 7 See Arcom Embedded Linux Technical Manual, page 47 48 for more information 8 Sometimes called threads 9 This is an extended version of the textbook example in chapter 12. Programming Embedded Systems, Spring 2009 Lab4 Page 5 of 9

the producer sends a message to the second task (consumertask). The consumer task receives the message and turns on/off the LEDs according to the specification in assignment 4a. Assignment 5 Controlling LEDs Using CGI Scripts In this assignment you should use the web server and CGI 10 scripts on the Arcom board to turn on/off the LEDs. First, you must configure the web server 11 on the Arcom board. Copy the lab4/thttpd/thttpd.conf file to the Arcom board with the following commands: $ cd lab4/thhtpd $ scp thttpd.conf root@192.168.1.100:/etc/thttpd.conf You should also create the cgi-bin directory on the Arcom board (if it does not exist) by opening a SSH connection to the board and write the following command: root@viper root# mkdir /var/www/cgi-bin Next, restart the web-server by writing the following command: root@viper root# /etc/init.d/thttpd restart Open a web browser on the PC (e.g., Firefox) and write 192.168.0.100 in the URL (address) bar. You should now see the web page shown in figure 2. Figure 2: Default web page on the Arcom board. Note: The html file for this web page is stored at /var/www/index.html on the Arcom board. The next step is to create an example web page that calls a CGI application. Look at lab4/cgi/hello.html and lab4/cgi/hello.c for an example on how to create and use CGI 10 CGI Common Gateway Interface, is a protocol for interfacing external application software with a web server. 11 The Arcom board comes with the thttpd web server. Programming Embedded Systems, Spring 2009 Lab4 Page 6 of 9

scripts. Compile the hello.c file (the source code for our CGI application) with the following command: $ arm-linux-gcc -Wall -o hello hello.c Upload hello.html and hello to the web server with the following commands: $ scp hello root@192.168.0.100:/var/www/cgi-bin $ scp hello.html root@192.168.0.100:/var/www Verify that the CGI application works by opening 192.168.0.100/hello.html in a web browser and press the Run button. If everything works you should see the text string Hello, World! in your web-browser. Your assignment is to create an application that allows you to turn on/off the LEDs using a web-browser. There are no special requirements on the design of the web interface, but you must be able to turn on/off the individual LEDs on the board from the web page. Assignment 6 Serial Driver in Linux In this assignment you will extend the POSIX serial driver from lab 2 to include both reading and writing capabilities. Furthermore, you should create an API (Application Programming Interface) so that applications can utilize this driver to communicate over the serial port. You are free to design the API, but it must include capabilities to initiate, read, and write to the serial port. NB: You should connect a VT100 terminal emulator to the middle connector (out of the five available connectors) on the serial port to test your driver. Then use/dev/ttys1 to communicate over this port. Assignment 7 Mini-Project You should either implement the Code Lock assignment or propose a mini-project yourself. Code Lock Your assignment is to design and implement a code lock system for a device (e.g., a door). The code lock system consists of three main parts: 1. A graphical user interface on the VT100 terminal emulator where the user enters login name and password to open the device. The device should either lock down automatically when some time has elapsed or be locked explicitly by the user. 2. The current status of the device should be indicated using the LEDs on the VIPER I/O board (e.g., green=open, red=locked). 3. A web interface (using CGI scripts) where the system administrator can see the current status of the lock (open/locked) and the number of failed login attempts. The application should be divided into three tasks where the first task manages the user interface, the second task turns on/off the LEDs, and the third task handles user authentication. The third task should also communicate with the other tasks and create a log file with current lock status and number of failed login attempts. The application should store a list of valid users and the corresponding passwords in a text file on the Arcom board (you do not have to encrypt 12 the passwords). Optional: Add functionality 12 You can use the crypt function to encrypt the passwords if you like. Programming Embedded Systems, Spring 2009 Lab4 Page 7 of 9

to add and remove users via the web interface. The CGI script should read the log file produced by the application and present the information on a web page. Custom Mini-Project NB: You must discuss your project ideas with the lab assistant before you start to work on the design and implementation. General project requirements: The application should have a web interface where you can display results from and/or setup some parameters to the application. You should use the VT100 terminal emulator as a user interface (both input and output). You can use the LEDs, buttons, and buzzer on the VIPER I/O board if you like. The application should be divided into (at least) two communicating tasks, where one manages the user interface and the other performs some processing. Programming Embedded Systems, Spring 2009 Lab4 Page 8 of 9

Appendix A: Software Installation Notes This appendix shows how to install the Arcom Embedded Linux (AEL) cross compiler on your own computer (the software is already installed in the lab rooms). You can find more information in the Programming Embedded Systems book, appendix E. You can install the AEL cross compiler either from the CD provided in the development kit or by extracting the arcom-tools.tar.bz2 file from the course web-page. NB: You cannot use cygwin in this lab this cross compiler only works in a Linux environment! Install from CD Insert the CD labeled Development Kit CD into the CD-ROM drive and execute the install script by: $ su # (or sudo sh) to start a root shell # perl /cdrom/install If you want to use the arm-linux-insight debugger, you must install it separately by executing the build_arm-linux-insight.sh script available on the course web-page. Install from arcom-tools.tar.bz2 Download the arcom-tools.tar.bz2 from the course web-page and use the following commands to extract the toolchain: $ su # (or sudo sh) to start a root shell # cd /opt # tar xvjf arcom-tools.tar.bz2 Note: This archive contains the arm-linux-insight debugger. Programming Embedded Systems, Spring 2009 Lab4 Page 9 of 9