New Horizons









Welcome to my blog

My name is Sven Andersson and I
work as a consultant in embedded
system design, implemented in ASIC
and FPGA.
In my spare time I write this blog
and I hope it will inspire others to
learn more about this fantastic field.
I live in Stockholm Sweden and have
my own company

Contact

You are welcome to contact me
and ask questions or make comments
about my blog.



Content

New Horizons
What's new
Starting a blog
Writing a blog
Using an RSS reader

Zynq Design From Scratch
Started February 2014
1 Introduction
Changes and updates
2 Zynq-7000 All Programmable SoC
3 ZedBoard and other boards
4 Computer platform and VirtualBox
5 Installing Ubuntu
6 Fixing Ubuntu
7 Installing Vivado
8 Starting Vivado
9 Using Vivado
10 Lab 1. Create a Zynq project
11 Lab 1. Build a hardware platform
12 Lab 1. Create a software application
13 Lab 1. Connect to ZedBoard
14 Lab 1. Run a software application
15 Lab 1. Benchmarking ARM Cortex-A9
16 Lab 2. Adding a GPIO peripheral
17 Lab 2. Create a custom HDL module
18 Lab 2. Connect package pins and implement
19 Lab 2. Create a software application and configure the PL
20 Lab 2. Debugging a software application
21 Running Linux from SD card
22 Installing PetaLinux
23 Booting PetaLinux
24 Connect to ZedBoad via ethernet
25 Rebuilding the PetaLinux kernel image
26 Running a DHCP server on the host
27 Running a TFTP server on the host
28 PetaLinux boot via U-boot
29 PetaLinux application development
30 Fixing the host computer
31 Running NFS servers
32 VirtualBox seamless mode
33 Mounting guest file system using sshfs
34 PetaLinux. Setting up a web server
35 PetaLinux. Using cgi scripts
36 PetaLinux. Web enabled application
37 Convert from VirtualBox to VMware
38 Running Linaro Ubuntu on ZedBoard
39 Running Android on ZedBoard
40 Lab2. Booting from SD card and SPI flash
41 Lab2. PetaLinux board bringup
42 Lab2. Writing userspace IO device driver
43 Lab2. Hardware debugging
44 MicroZed quick start
45 Installing Vivado 2014.1
46 Lab3. Adding push buttons to our Zynq system
47 Lab3. Adding an interrupt service routine
48 Installing Ubuntu 14.04
49 Installing Vivado and Petalinux 2014.2
50 Using Vivado 2014.2
51 Upgrading to Ubuntu 14.04
52 Using Petalinux 2014.2
53 Booting from SD card and SPI flash
54 Booting Petalinux 2014.2 from SD card
55 Booting Petalinux 2014.2 from SPI flash
56 Installing Vivado 2014.3

Chipotle Verification System
Introduction

EE Times Retrospective Series
It all started more than 40 years ago
My first job as an electrical engineer
The Memory (R)evolution
The Microprocessor (R)evolution

Four soft-core processors
Started January 2012
Introduction
Table of contents
Leon3
MicroBlaze
OpenRISC 1200
Nios II

Using the Spartan-6 LX9 MicroBoard
Started August 2011
Introduction
Table of contents
Problems, fixes and solutions

FPGA Design From Scratch
Started December 2006
Introduction
Table of contents
Index
Acronyms and abbreviations

Actel FPGA design
Designing with an Actel FPGA. Part 1
Designing with an Actel FPGA. Part 2
Designing with an Actel FPGA. Part 3
Designing with an Actel FPGA. Part 4
Designing with an Actel FPGA. Part 5

CAD
A hardware designer's best friend
Zoo Design Platform

Linux
Installing Cobra Command Tool
A processor benchmark

Mac
Porting a Unix program to Mac OS X
Fixing a HyperTerminal in Mac OS X
A dream come true

Bicycling
Stockholm by bike

Running
The New York City Marathon

Skiing/Skating
Kittelfjall Lappland

Tour skating in Sweden and around the world
Top
Introduction
SSSK
Wild skating
Tour day
Safety equipment
A look at the equipment you need
Skate maintenance
Links
Books, photos, films and videos
Weather forecasts

Travel
38000 feet above see level
A trip to Spain
Florida the sunshine state

Photo Albums
Seaside Florida
Ronda Spain
Sevilla Spain
Cordoba Spain
Alhambra Spain
Kittelfjäll Lapland
Landsort Art Walk
Skating on thin ice

Books
100 Power Tips for FPGA Designers

Favorites
Adventures in ASIC
ChipHit
Computer History Museum
DeepChip
Design & Reuse
Dilbert
d9 Tech Blog
EDA Cafe
EDA DesignLine
Eli's tech Blog
Embedded.com
EmbeddedRelated.com
FPGA Arcade
FPGA Blog
FPGA Central
FPGA CPU News
FPGA developer
FPGA Journal
FPGA World
Lesley Shannon Courses
Mac 2 Ubuntu
Programmable Logic DesignLine
OpenCores
Simplehelp
SOCcentral
World of ASIC



If you want to be updated on this weblog Enter your email here:



rss feed



 
Wednesday, September 05, 2007
FPGA design from scratch. Part 43
Installing a Linux OS

It has been a long and bumpy ride but now we start to see the
light in the tunnel. So keep up, stay onboard, we will soon reach the final destination. We are ready for the real challenge, installing a Linux OS in our embedded system.

Why using a Linux OS

Linux use in future embedded, mobile, and real-time projects will grow 278 percent over that in past projects, suggests a recent survey by Venture Development Corp. (VDC). Meanwhile, proprietary commercial embedded operating systems are holding steady, gaining customers from do-it-yourself OS users, but losing them just as fast to Linux, the analyst firm reports.

Embedded Linux OS

The MicroBlaze procssor has one drawback, it doesn't include a
Memory Management Unit (MMU). To overcome this limitation, development started early to come up with a Linux kernel that could be used on a MMU-less processor. This work lead to to the introduction of uClinux. Most of the work done in the uClinux was been incorporated into the Linux kernel development and the 2.6 Linux kernel is the first stable release with mainline support for processors, such as MicroBlaze, that do not have an MMU eliminating the need to apply and forward-port uClinux patches.

uClinux

The original uClinux was a derivative of Linux 2.0 kernel intended for microcontrollers without MMUs. However, the Linux/Microcontroller Project has grown both in brand recognition and coverage of processor architectures. Today's uClinux as an operating system includes Linux kernel releases for 2.0 2.4 and 2.6 as well as a collection of user applications, libraries and tool chains.

Finding a Linux OS

This table shows some of the Linux OSes that runs on a MicroBlaze processor.

 Distribution  Vendor  Information
 uClinux  OpenSource  
 PetaLinux  PetaLogix
 BlueCat Linux ME  LinuxWorks  Available ?
     

Third Party Real Time Operating Systems (RTOS) Support

This
table and this
table shows RTOS supporting PowerPC and MicroBlaze.


Application notes

You can find a number of
application notes from Xilinx describing how to install an RTOS on a MicroBlaze processor.
  • Getting Started with uClinux on the MicroBlaze Processor (XAPP730)
  • Getting Started with the Nucleus PLUS RTOS and EDGE Tools on the MicroBlaze Processor (XAAP1016)

Choosing a Linux OS

We will use PetaLinux from
PetaLogix. PetaLogix is an embedded Linux solution provider founded by Dr John Williams, architect and maintainer of the port of the uClinux operating system to the Xilinx MicroBlaze soft processor.

PetaLinux

PetaLogix has released PetaLinux v0.20, including Linux kernel 2.6.20 support for the Xilinx MicroBlaze soft-CPU architecture. PetaLinux is available as a free download from
http://developer.petalogix.com, along with complete documentation, getting started guides and reference designs. Pre-built demo packages for the Xilinx ML401, Spartan3E-500 and Spartan3E-1600 allow a instant preview of the capabilities of Embedded Linux on the MicroBlaze.

The "uClinux microblaze port" mailing list

John Williams has setup a mailing list where you can ask all kind of questions about uClinux and the port to MicroBlaze.

Embedded Linux developer forum

uCdot is  the place to find more information about embedded Linux.

PetaLinux system requirements

The minimum system requirements to build a PetaLinux ready hardware platform are:
  • MicroBlaze soft core processor
  • Timer
  • Interrupt Controller
  • Standard input and output devices
  • External memory controller
  • RAM (DDR-SDRAM)
  • ROM (Flash) optional
  • Microprocessor Debug Module (for image download)
PetaLinux installation procedure

Let's read the
installation guide.

Download

We will start by downloading petalinux-v0.20-rc3.tar.gz. The gzipped tar file is 317MB.

Select an installation directory

Create: mkdir /home/svenand/linux and goto the installation directory: cd /home/svenand/linux and move the tar file to this directory: mv /home/svenand/Desktop/
petalinux-v0.20-rc3.tar.gz .

Unpacking

Unzip and unpack the file using the following command: tar zxvf petalinux-v0.20-rc3.tar.gz



After unpacking the following directory structure has been generated. The total size is 1.77GB

Environment setup

To set up our PetaLinux environment, change to the PetaLinux root directory and run the set up script. This script updates our path to point to the bundled gcc toolchain, and sets the $PETALINUX environment variable to point to the PetaLinux root.

-> cd petalinux-v0.20-rc3
-> source settings.sh (bash and sh)
-> source setting.csh (csh and tcsh)

We will add the following lines to .bashrc to make sure the script will always be run:
cd
/home/svenand/linux/petalinux-v0.20-rc3
source /home/svenand/linux/petalinux-v0.20-rc3/settings.sh
cd
/home/svenand


Configure and build our Linux kernel

After we have everything setup it is time to configure and build our Linux kernel. Let's follow the
PetaLinux Platform from Scratch tutorial.

Selecting a platform

Selecting a platform is the initial step in the build of a kernel for our target. A platform configuration is essentially a collection of kernel configurations that are associated with that particular platform. This process allows the user to configure for a target platform without having to go through all the configurations associated with that platform.

Create a New Vendor Platform variant

We will use the petalinux-new-platform script to create a new vendor and platform combination for our system.

-> cd $PETALINUX/software/petalinux-dist
-> petalinux-new-platform -v Xilinx -p ML403 -k 2.6

The ML403 board has been added to the Xilinx directory.




PetaLinux kernel configuration

To start the configuration program execute the following commands:
-> cd software/petalinux-dist
-> make xconfig



Vendor/Product Selection





We select vendor Xilinx and the ML403 platform.


Kernel/Library/Defaults selection



We will use the default settings and click Save and Exit. The configuration setup is stored in the file $PETALINUX/software/petalinux-dist/.config. Later on we will change the configuration to match the hardware in our system.

Hardware modification

MicroBlaze

Instruction cache : Enabled
Data cache : Enabled

RS232 UART

Baudrate : 115200
Interrupt : Enable

Debug module

Enable the UART Interface on OPB: Disable
Interrupt : Enable

For more information about the hadware setup read the
PetaLinux Platform from Scratch tutorial.

Auto configuration

PetaLinux AutoConfig framework allows the hardware configurations to be propagated to the bootloader and Linux kernel configurations. A few simple parameters in the EDK project's MSS (MicroProcessor Software Specification) file are all that is required to automatically configure the kernel and bootloader for our specific hardware platform.

Briefly, the steps are:

  1. Create a new linux platform.
  2. Create a EDK hardware project
  3. Edit the MSS file to specifiy the PetaLinux autoconfiguration BSP tools (see below)
  4. Use XPS to build the hardware project and generate libraries and BSPs
  5. Use the petalinux-copy-autoconfig helpder script to propagate the system settings from your hardware project, across to your new Linux platform
  6. Rebuild PetaLinux, to get your fully configured bootloader, Linux kernel and root filesystem image, ready for download.
Editing the MSS file

See the PetaLinux User Guide
AutoConfig. Let' take a look in the ETC_system.mss file. This is what the OS part looks like:

BEGIN OS
 PARAMETER OS_NAME = standalone
 PARAMETER OS_VER = 1.00.a
 PARAMETER PROC_INSTANCE = microblaze_0
 PARAMETER STDIN = RS232_Uart
 PARAMETER STDOUT = RS232_Uart
END


We will change it like this:

BEGIN OS
 PARAMETER OS_NAME = petalinux
 PARAMETER OS_VER = 1.00.b
 PARAMETER PROC_INSTANCE = microblaze_0
 PARAMETER STDIN = RS232_Uart
 PARAMETER STDOUT = RS232_Uart
 PARAMETER MAIN_MEMORY = DDR_SDRAM_64Mx32
 PARAMETER MAIN_MEMORY_BANK = 0
END

Generate netlist and libraries

Let's start Xilinx Platform Studio and generate a new netlist and libraries and BSPs.
--> xps ETC_system.xmp &

The following error stops us from loading our project.

ERROR:MDT - Can not find MLD for the os petalinux 1.00.b
INFO:MDT - Directories Searched :
  - /home/svenand/root/projects/ETC/xps/bsp/petalinux_v1_00_b/data
  - /home/svenand/cad/edk91i/sw/ThirdParty/bsp/petalinux_v1_00_b/data
  - /home/svenand/cad/edk91i/sw/XilinxProcessorIPLib/bsp/petalinux_v1_00_b/data
  - /home/svenand/cad/edk91i/sw/lib/bsp/petalinux_v1_00_b/data

To fix this problem we have to find the petalinux .mld file and copy it to the XPS project directory. The .mld file can be found here: $PETALINUX/hardware/edk_user_repository/PetaLogix/bsp/petalinux_v1_00_b/data. We will make a link to the bsp directory from our EDK project directory.

-> cd $EDK_PROJECT
-> ln -s bsp
$PETALINUX/hardware/edk_user_repository/PetaLogix/bsp



We use the menu command Hardware->Generate Netlist to generate a new netlist. No configuration files are generated during the netlist generation. We then generate the libraries using the menu command Software->Generate Libraries and BSPs. This process will create the following directory structure.



Here we find the auto-config.in (Linux 2.4.x) and the Kconfig.auto (Linux 2.6.x) configuration files.


Copying the AutoConfig file

To copy the configuration file across to our currently selected PetaLinux platform, we use the petalinux-copy-autoconfig command as follows: petalinux-copy-autoconfig ETC_system.xmp

==>petalinux-copy-autoconfig ETC_system.xmp                                                               

INFO: Attempting vendor/platform auto-detect
INFO: Auto-detected Xilinx/ML403 combination.
Auto-config file successfully updated for Xilinx ML403

The script will automatically detect which platform and which Linux kernel we have specified by reading the.config file and copy the right configuration file to the right place.



Platform reconfiguration

Next we have to reconfigure the platform settings of our custom platform into PetaLinux. This step requires us to run through the following configuration options.

More to be added.

Changing the default shell

In Ubuntu 7.04 the default shell (/bin/sh) is defined as /bin/dash instead of /bin/bash. The build process script relays on the bash shell to function. To change the default shell to bash execute the following commands:

--> sudo rm -f /bin/sh
--> sudo ln -s /bin/bash /bin/sh

To change back to dash execute the following commands:

--> sudo rm -f /bin/sh
--> sudo ln -s /bin/dash /bin/sh

Adding the /tftpboot directory

When working with network-enabled embedded Linux systems, it is often convenient to update Linux images and other files over the TCP/IP network.
The directory /tftpboot is commonly used as a transfer directory for this purpose. The PetaLinux tools can optionally copy Linux and bootloader files into this (or another) directory automatically.
To create the /tftpboot directory, you must have root access.

-> sudo mkdir /tftpboot
-> sudo chmod -R 777 /tftpboot

Installing zlib1g-dev

We need zlib to be able to build the Linux kernel: sudo apt-get install zlib1g-dev

Build the 2.6 kernel and user applications

The build process
entails the following tasks.
  • Build the Linux Kernel
  • Build GNU tools
  • Build the Root Filesystem
  • Build the U-Boot bootloader

To start the build process for the newly added platform, in the $PETALINUX/software/petalinux-dist directory execute the following commands.

-> cd $PETALINUX/software/petalinux-dist

1. Build the project dependencies.
-> yes "" │ make oldconfig dep

2. Build images.
-> make all

The logfile

.......

Image Name:   PetaLinux Kernel 2.6
Created:      Sun Sep 30 17:36:28 2007
Image Type:   MicroBlaze Linux Kernel Image (uncompressed)
Data Size:    3289251 Bytes = 3212.16 kB = 3.14 MB
Load Address: 0x44000000
Entry Point:  0x44000000
# Run mkimage to build u-boot autoscr script
/home/svenand/linux/petalinux-v0.20-rc3/software/petalinux-dist/u-boot/tools/mkimage -A microblaze -O linux -T script -C none
    -a 0 -e 0 -n "PetaLinux Autoscr Script" 
    -d /home/svenand/linux/petalinux-v0.20-rc3/software/petalinux-dist/u-boot/board/petalogix/microblaze-auto/ub.config /home/svenand/linux/petalinux-v0.20-rc3/software/petalinux-dist/images/ub.config.img
Image Name:   PetaLinux Autoscr Script
Created:      Sun Sep 30 17:36:29 2007
Image Type:   MicroBlaze Linux Script (uncompressed)
Data Size:    1412 Bytes = 1.38 kB = 0.00 MB
Load Address: 0x00000000
Entry Point:  0x00000000
Contents:
   Image 0:     1404 Bytes =    1 kB = 0 MB
# Copy image files into /tftpboot, if requested
if [ "y" == 'y' ] ; then
        cp /home/svenand/linux/petalinux-v0.20-rc3/software/petalinux-dist/images/* "/tftpboot";
    fi
make[2]: Leaving directory `/home/svenand/linux/petalinux-v0.20-rc3/software/petalinux-dist/vendors/Xilinx/ML401'
make[1]: Leaving directory `/home/svenand/linux/petalinux-v0.20-rc3/software/petalinux-dist/vendors'
==>   

Congratulations to all of us. We made it!!!!

Output images


Once the build process is completed, all the images are located in both the $PETALINUX/software/petalinux-dist/images and the /tftpboot directory.


tftpboot directory content





Image Name
Description File Size
Linux Kernel
   
image.bin The Linux kernel and root filesystem image in binary format
3.1 MB
image.elf The Linux kernel and root filesystem image in ELF format 3.4 MB
image.srec The Linux kernel and root filesystem image in SREC format
9.3 MB
image.ub The Linux kernel and root filesystem image in U-Boot format 3.1 MB
linux.bin  ?? 1.9 MB
romfs.img The ROMFS image in binary format
1.2 MB 
 U-Boot    
 u-boot.bin The U-Boot image in binary format
119 KB
 u-boot.srec The U-Boot image in SREC format 358 KB
 u-boot-s.bin The relocatable U-Boot image in binary format 119 KB 
 u-boot-s.elf The relocatable U-Boot image in ELF format 120 KB 
 u-boot-s.rec The relocatable U-Boot image in SREC format 358 KB
 ub.config.img U-Boot platform configuration script in binary format
1.4 KB



Top  Next   Previous




Posted at 07:20 by

Faycel
March 12, 2010   06:24 AM PST
 
Hello. First, I would like to thank you for sharing your knowledge on this blog. It's been great help for me. My current project is to port linux to a microblaze. This work has been documented on your blog. However, petalinux is no longer free. Do you know any other links where I could still get a free download of the package? Thanks again.
Aindrik
March 8, 2010   02:05 PM PST
 
This blog page has been arguably the most useful documentation of working with Xilinx FPGA boards and Petalogix Petalinux. I cant thank you enough for sharing your knowledge with us through your blog.

Looking forward to other such great posts from you.

--Aindrik Dutta
Eko
September 19, 2007   04:29 AM PDT
 
Hello I just saw on Xilinx's site 2 Appnotes : 1 showing how to install uClinux (PetaLinux) and the other Linux,
Please let me know if there are more choices : Montavista Linux & Windriver.
Keep going very nice, step by step blog. I'm trying to put a MB on Spartan3A starterkit, hope there will be a port of uCLinux on this board.
 

Leave a Comment:

Name


Homepage (optional)


Comments




Previous Entry Home Next Entry