Вы находитесь на странице: 1из 4

Lab 3: A First Look at PetaLinux

Acknowledgements
This module is derived from the Xilinx University Program course: Embedded Linux on Xilinx Micorblaze given at Simon Fraser University in April 2011. Many thanks to Xilinx, and PetaLogix for allowing us to use and modify their material.

Introduction
Embedded Linux is the use of a Linux operation system in embedded systems. Unlike desktop and server versions of Linux, embedded versions of Linux are designed for devices with relatively limited resources. The MicroBlaze processor is a soft processor core designed for Xilinx FPGAs; it supports embedded Linux. In most labs of this workshop, you will run embedded Linux on the MicroBlaze processor, using the PetaLinux SDK from PetaLogix. This first lab is a basic introduction to embedded Linux and the development boards that you are using for the workshop. The basic activities covered here will be used repeatedly through the later lab sessions, so be sure to ask your instructor if you have any questions or concerns.

Objectives
After completing this lab, you will be able to: Power on the development board used in the workshop Log in to the MicroBlaze processor Linux system Make comparisons between the embedded Linux and desktop Linux environments

Typographic Conventions
Commands to be executed on the development (desktop) workstation look like the following:

[host]$ command and parameters


Commands to be executed on the MicroBlaze processor Linux target look like the following:

# run my Linux application

Before You Start


Before you start, ensure that the: Power switch is in the 'on' position JTAG cable is connecting the development board to the PC Serial cable is connecting the development board to the PC Power cable for the development board is connected Ethernet port on the development board is connected to the 10/100 Ethernet

Initializing the Workshop Environment


This lab is intended to be done after lab 1. Do not power off your board between labs. If you do you will need to reprogram the FPGA and re-download the kernel image. Start this lab after logging into Petalinux.

Exploring
It is interesting to scroll the terminal up and review the bootup log existing Linux users will recognize much of the output (as they should, its the same operating system!) Spend the next 15 minutes exploring! Most of the usual Linux commands are available:

ls, vi, cat,gpio-demo


Executing:

# ls /bin
will list the applications currently installed. Try the gpio-demo to test the GPIOs. Use

# ls /sys/class/gpio
to see the GPIOs available in the system. The GPIOs are presented as gpiochip<ID> in the directory. Have a look at file /sys/class/gpio/gpiochipN/label:

# cat /sys/class/gpio/gpiochipN/label
The GPIO label file contains the GPIO label; and the label contains the GPIO's physical address information. The GPIO label format is /plb@0/gpio@<PYHSICAL_ADDRESS>. For example:

~ # cat /sys/class/gpio/gpiochip240/label /plb@0/gpio@81420000


In your Altys system, there are these GPIOs on the board: 8 LEDs (8 channels), 5 Buttons (5 channels), and 8 Switches (8 channels). The gpiochip<ID> to GPIOs mapping is:

gpiochip235 for 5Push Buttons; gpiochip240for 8 LEDs; gpiochip248for 8DIP Switches;


Running the following command will output 1 to 8-bit LEDs:

# gpio-demo -g 240 -o 1
Running the following command will print the value of 8 DIP Switches:

# gpio-demo -g 248 -i
Another interesting place to explore is the /proc directory. This is a virtual directory that provides a window into the kernel. For example, the file /proc/cpuinfo contains details about the CPU. /proc/interrupts gives interrupt statistics, and so on. For example:

~ # cat /proc/cpuinfo CPU-Family:MicroBlaze FPGA-Arch:spartan6 CPU-Ver:8.00.a

CPU-MHz:75.00 BogoMips:36.99 HW: Shift:yes MSR:yes PCMP:yes DIV:yes MMU:3 MUL:v2 FPU:v1 Exc:ill zero fpu Icache:32kBline length:32B Dcache:32kBline length:32B write-back HW-Debug:yes PVR-USR1:00 PVR-USR2:00000000 ~ #
The contents of /proc/cpuinfo shows the processor information such as the its version, frequency, FPGA architecture, and its hardware configuration. Your /proc/cpuinfo may be different than above, depending on the configuration of the processor.

/proc/interrupts shows the interrupts information of the system.


For example:

~ # cat /proc/interrupts CPU0 0: 4 level Xilinx INTC xilinx_dma_tx_int 1: 2 level Xilinx INTC xilinx_dma_rx_int 2: 3251 edge Xilinx INTC timer 3: 8655 level Xilinx INTC xilinx_spi 4: 0 level Xilinx INTC eth0 5: 371 level Xilinx INTC serial ~ #
Your results could be different. The /proc/interrupts tells you what are the interrupts in your system, their type, and how many interrupts have happened. /dev contains entries for various devices in the system. /dev/console is the main console you could try copying a file to /dev/console. For example:

~ # cp /etc/inetd.conf /dev/console telnet stream tcp nowait root telnetd telnetd -i ftp stream tcp nowait root ftpd ftpd -w /var/ftp/ \
Another thing to note is the standard Linux directory structure: /bin, /dev, /tmp, /var, and so on. Open up another terminal window on the desktop machine and browse around, see how similar they are. /proc is also there in the desktop Linux box try comparing some of the numbers in /proc/cpuinfo. Close kermit console by pressing <Ctrl - \> then pressing <C>. Type exit in the kermit console to shut down kermit.

C-Kermit> exit

Conclusion
The purpose of this lab was to introduce you to the embedded Linux target and demonstrate its heritage in the desktop Linux genealogy. This is one of the immediate benefits of embedded Linux. As an application and user environment, it has tremendous commonality with standard desktop Linux platforms. Although brief, this introduction should have prepared you with some basic experience in powering on, logging into, and navigating around the embedded Linux target. These basic capabilities will be expanded upon in subsequent lab sessions.

Вам также может понравиться