Академический Документы
Профессиональный Документы
Культура Документы
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
The most basic skill required for developing with embedded Linux is working in the cross-compilation environment: compiling the kernel, libraries and applications and downloading the resulting images onto the embedded target. The purpose of this lab is to familiarize you with this process. This lab will load the MicroBlaze processor Linux system in QEMU. QEMU is a generic and open-source machine emulator, integrated into PetaLinux SDK. In this lab, you will use QEMU to run the Linux built for the MicroBlaze processor system. It can achieve near native performance by executing the guest code directly on the host CPU. This lab will prepare you for the most basic task of working with embedded Linuxhow to build and boot the operating system and applications. Small embedded Linux targets, such as the MicroBlaze processor, are usually developed in a cross-compilation environment. This means that the kernel and applications are compiled on a development machine (in this case, a Linux PC), and then downloaded onto the target. The PetaLinux distribution contains a number of tools and a configuration architecture that automates much of this process. In this lab, you will learn how to use these tools and how to download the resulting embedded Linux image onto the hardware platform.
Objectives
After completing this lab, you will be able to: Explore the Linux configuration menus, including how to configure a default Linux kernel and user environment Build the MicroBlaze processor Linux kernel and applications Boot the resulting system image in QEMU Download the resulting system image to the development board
Typographic Conventions
Commands to be executed on the development (desktop) workstation look like the following:
Preparation
Before we can build and boot an image we need to set up the environment variables Start by opening a new terminal. Change directories to the main petalinux directory:
[host] $ cd ~/petalinux-v2.1-final-full
HINT: Bash will auto complete names for you. Simply start typing the name and push tab. If it doesnt auto complete it either means that the name doesnt exist in that directory, or there are multiple options. Push tab again to list the other options. HINT: The tilde symbol (~) is a shortcut to your home directory. In this case it is exactly the same as typing /home/student. You can see this by typing pwd, which will print your current working directory. List and examine the contents of this directory:
[host] $ ls
Notice the Shell script settings.sh. Running this script will add the petalinux directories to the PATH and allow us to run the petalinux tools. (Note: this needs to be done every time you open a new terminal window.)
Warning: Be extremely gentle with the Micro USB ports. They are fragile!
Step 1
[host] $ make
This may take a few minutes. During this time, the following are occurring: o Cross-compiling and linking the Linux kernel (linux-2.6.x/*) o Cross-compiling and linking the default user libs and applications (lib/* and user/*) o Building a local copy of the MicroBlaze Linux root file system (romfs/*) o Assembling the kernel and root file system into a single downloadable binary image file (images/*) o Copying the image files in from images/ to /tftpboot. The compilation log is saved in the build.log file. The console shows the compilation progress.
For example:
[host] $ make [INFO ] Building ucfront tool [INFO ] Building kernel [INFO ] Building kernel modules [00:04] /
1-1-2. Once compilation completes, look in the images subdirectory by executing:
total 147288 9472 image.elf 9468 image-s.bin 9472 image-s.elf 28360 image.srec 28380 image-s.srec 9468 image.ub 9464 linux.bin 32808 pflash.bin 6836 rootfs.cpio 572 System.map 244 u-boot.bin 832 u-boot.elf 244 u-boot-s.bin 244 u-boot-s.elf 712 u-boot.srec 712 u-boot-s.srec
You can see the various components that constitute the final image linux.bin and rootfs.cpio. 1-1-3. Examine the contents of the /tftpboot directory by executing:
[host] $ ls /tftpboot
All the image files in the ~/petalinux-v2.1-final-full/software/petalinux-dist/images directory have a copy in /tftpboot, because as part of the build process, the image files have also been copied there. The development machine has been configured as a TFTP (trivial FTP) server, allowing the board to pull new kernel images directly over the network. You will use this capability in the next exercise.
Step 2
2-1. As mentioned earlier, you can run Linux for the MicroBlaze processor system on QEMU. Load the MicroBlaze processor Linux on QEMU.
2-1-1. Run the following command to load the latest built Linux in QEMU:
Linux version 2.6.31.12 (petalinux@petalinux) (gcc version 4.1.2) #4 Thu Nov 4 05:47:07 UTC 2010
2-1-2. When prompted, login as root, using password root (no quotes) If you miss out some of the boot log, you can login as root with password root, then enter reboot to soft reboot the board.
# reboot
2-1-2. Exit QEMU by pressing <Ctrl-A> then press <X>.
2-2-3. In the New iMPACT Project window, select the create new project (.ipf) option, and click Ok.
2-2-4. In the Auto Assign Configuration File Query Dialog window click Yes. 2-2-5. In the welcome to iMPACT window select Configure devices using Boundary-Scan (JTAG) and click Ok.
2-2-6. In the Auto Assign Configuration Files Query Dialog window click Ok. Browse to the impact_petalinux directory, and select the download.bit file and click Open. 2-2-7. In the Attach SPI or BPI PROM window click No. 2-2-8. In the Device Programming Properties Device 1 Programming Properties window click Ok. 2-2-9. Right click on the green square labelled XC6SLX45 download.bit. This square represents the FPGA, and the file you have assigned to download to it. Click Program. After a few seconds a blue bar saying Programming Succeeded will appear.
By default, the petalinux-jtag-boot command will use the latest built Linux image in the PetaLinux tree. Use -help argument so see more details of all the options of the tool. The petalinux-jtag-boot uses Xilinx JTAG to load the image. It will take a few minutes. Be patient until it finishes.
2-3-3. Watch the booting messages on the kermit window. A message similar to the following is displayed when the image is built.
## Booting kernel from Legacy Image at 48002000 ... Image Name: PetaLinux Kernel 2.6-MMU Image Type: MicroBlaze Linux Kernel Image (uncompressed) Data Size: 9801732 Bytes = 9.4 MB Load Address: 48000000 Entry Point: 48000000 Verifying Checksum ... OK Loading Kernel Image ... OK OK ## Transferring control to Linux (at address 48000000), 0x48000000 ramdisk 0x00000000, FDT 0x00000000... Ramdisk addr 0x00000003, Compiled-in FDT at 0xc01fb610 Linux version 2.6.31.12 (petalinux@petalinux) (gcc version 4.1.2) #4 Thu Nov 22 05:47:07 UTC 2010
setup_cpuinfo: initialising 2-3-3 Do not turn off the board, and continue on to Lab 2.