System-on-Programmable-Chip is an emerging trend in the embedded world.
Here’s what I did to bring-up Petalinux on Xilinx Spartan-6 devkit SP605/SP601.
Petalinux is an embedded Linux distribution for Xilinx FPGA’s MicroBlaze softcore. Since SDK v1.3, the current release as of early 2011, Petalinux supports PowerPC440 hardcore.
Once you have the right hardware and software tools, such as devkit (SP605 or SP601), Xilinx ISE (12.4, 12.3 is fine), Petalinux SDK (v1.3) and a Linux host (a Xubuntu 10.4 VM on Macbook), it is surprising easy to bring-up Linux on FPGA. The idea is the same if you have a different hardware and software combination.
1. Install Xilinx ISE 12.4 for Linux. Petalinux SDK depends on Xilinx design suite to run.
I installed ISE (Embedded Edition) to a CIFS network share, which is a Journaled HFS+ external portable USB2 hard drive connected to Macbook (it is worth for another article to cover the topic, may be some other time). If ISE is installed on a virtual disk, it takes about 12G space for ISE, EDK, PlanAhead, LabTools and SDK (not all are necessary for our purpose).
Here’s how ISE 12.4 is setup.
Xilinx JTAG Platform Cable drive needs to be installed too. I installed CP210x USB/UART driver on Macbook host.
2. Install Petalinux SDK 1.3
The SDK should be installed on a Linux file system, because of some Linux specific symbolic links. I installed it to my Xubuntu’s second ext4 virtual disk.
Here’s how Xilinx and Petalinux (/media/users) are mounted:
Here’s how SDK is setup. I installed it to /software/target/ because of the specific need for the projects I am working on.
3. Treakin Ubuntu
The following first two changes are needed for SDK under Ubuntu.
4. Design hardware
PetaLogix’s Board Bringup Guide is extremely useful, but not all that clear. To bring up Linux, it needs UART, system timer, DDR and MicroBlaze hardware, Ethernet and Flash are optional. UART, system timer and Ethernet must be interrupt driven.
Create a folder, say sopc, under $PETALINUX/hardware/user-platforms.
Launch Xilinx Platform Studio (enter $xps &) and choose Base System Builder wizard.
Create New XPS Project by specifying project file name, say sopc.xmp under $PETALINUX/hardware/user-platforms/sopc, and search path at $PETALINUX/hardware/edk_user_repository.
Keep “PLB system” as the default interconnect type, and move BSB wizard forward to “Board Select”. Choose “Spartan-6 SP605 Evaluation Platform” as the “Board Name”.
Move BSB wizard forward by using all default selections till “Peripheral Configuration”. Add xps_timer, check “Use Interrupt” option and choose “Two timers are present” for “Configuration Mode”.
Check “Use Interrupt” option for Ethernet_MAC.
For RS232_Uart, select 115200 for “Baud Rate”, and check “Use Interrupt” option.
Move to “Cache Configuration”, and check both “Instruction Cache” and “Data Cache”.
Move the wizard to the end to finish BSB, and go back to XPS. In “System Assembly View” tab, double click MicroBlaze instance to launch “MicroBlaze Configuration Wizard”. Select “Linux with MMU” configuration, and then “OK” button to finish the wizard.
Select “Software Platform Settings” from XPS “Software” menu. For “Software Platform” tab, select “petalinux” as “OS” under “OS & Library Settings” section.
For “OS and Lib Configuration” tab, make the selections for peripheral as highlighted in the following screenshot. If FLASH is used in the design, make sure its value is properly set.
Now the hardware design is done, time to build bitstream by selecting “Generate Bitstream” from “Hardware” menu.
Before doing that, and if FLASH is used, make sure FLASH’s base address must be after DDR3. It can be changed and verified from XPS “System Assembly View” tab under “Address”.
In my environment, it takes about 22 minutes to finish the build process. The generated bit file is located at: $PETALINUX/hardware/user-platforms/sopc/implementation/sopc.bit. It will be used to configure Spartan-6 FPGA on SP605 later.
5. Design software
petalinux-new-platform -c <cpu-arch> -v <VENDOR> -p <PLATFORM>
Architecture configuration, Linux kernel configuration, and DTS file, etc., are generated at: $PETALINUX/software/petalinux-dist/vendors/tcao/sopc.
petalinux-copy-autoconfig -v <VENDOR> -p <PLATFORM> PROJECT_FILE
FPGA configuration files and drivers are copied to proper folders in $PETALINUX/software/petalinux-dist/linux-2.6.x.
petalinux-config-kernel
petalinux-config-apps
cd $PETALINUX/software/petalinux-dist
make
It takes about 21 minutes to build the kernel. Kernel image is at:
$PETALINUX/software/petalinux-dist/images/image.elf.
6. Upload configuration and application
Now comes the fun part to configure FPGA and unload Linux kernel. Connect JTAG USB and USB/UART cables to the host, power on SP605 or SP601 board. I forward the JTAG USB connection to VM, and keep USB/UART connection to host (baud rate is 115200).
Navigate to the hardware project folder and launch XMD:
$xmd
XMD% fpga -f xxx.bit
Within XMD, connect to Microblaze core, upload the Linux image and boot Linux:
XMD% connect mb mdm
XMD% dow xxx.elf
XMD% run
From serial console, login as root.
August 12, 2011 at 10:43 pm |
Interesting. More interesting will be seeing real-world applications using this combination of xilinx (spartan 6?) and petalinux.
Thanks for the post, helfull indeed.
August 12, 2011 at 10:59 pm |
The solution is being used for commercial equipments in mass production.
January 22, 2014 at 3:12 pm |
Thanks.
Helpful solutions.