27
Linux Distribution For Xilinx MicroBlaze From ERA PROJECT This page contains the instruction about how to install and use the Linux distribution for Xilinx Microblaze by Evidence Srl (www.evidence.eu.com). Contents 1 General Information 1.1 Definitions and acronyms 1.2 The virtual machine 1.2.1 Accounts 1.2.2 Location of main directories 2 Running Linux on Microblaze: Evelin BSP 2.1 Using precompiled Linux distribution 2.1.1 Getting the Linux distribution 2.1.2 Flashing and running the Linux distribution 2.2 Customized Linux distribution 2.2.1 Configuring the Linux distribution 2.2.1.1 Configuration of the target 2.2.1.2 Busybox configuration 2.2.1.3 Kernel configuration 2.2.1.4 Choosing xparameters.h 2.2.2 Updating the bitstream 2.2.3 Compiling the Linux distribution 2.2.4 Flashing and running the Linux distribution 2.3 Advanced topics 2.3.1 Manual tricking the uboot/Linux configuration 2.3.1.1 Changes of xparameters.h 2.3.1.2 UBoot configuration file 2.3.1.3 Linux kernel configuration file 2.3.2 Boot from Compact Flash 2.3.2.1 Generating SysACE booting file 2.3.2.2 Filling the compact flash 2.3.2.2.1 Troubleshooting 2.3.2.3 Flashing the kernel and the root filesystem 2.3.2.4 First test boot 2.3.2.5 Troubleshooting 2.3.2.6 Booting 3 Compiling applications for MicroBlaze: Evelin SDK 3.1 Writing an application 3.1.1 The source code 3.1.2 Compiling the application 3.1.3 Running the application 3.1.3.1 On the host system 3.1.3.2 On the Microblaze 3.1.4 Debugging the application 3.1.4.1 On the host system 3.2 Using Eclipse 3.2.1 Creating the project 3.2.2 Modifying the sources 3.2.3 Running the application 3.2.3.1 On the host system 3.2.3.2 On the MicroBlaze 3.2.4 Debugging the application

Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

Embed Size (px)

Citation preview

Page 1: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

Linux Distribution For Xilinx MicroBlazeFrom ERA PROJECT

This page contains the instruction about how to install and use the Linux distribution for Xilinx Microblaze by Evidence Srl(www.evidence.eu.com).

Contents

1 General Information1.1 Definitions and acronyms1.2 The virtual machine

1.2.1 Accounts1.2.2 Location of main directories

2 Running Linux on Microblaze: Evelin BSP2.1 Using pre­compiled Linux distribution

2.1.1 Getting the Linux distribution2.1.2 Flashing and running the Linux distribution

2.2 Customized Linux distribution2.2.1 Configuring the Linux distribution

2.2.1.1 Configuration of the target2.2.1.2 Busybox configuration2.2.1.3 Kernel configuration2.2.1.4 Choosing xparameters.h

2.2.2 Updating the bitstream2.2.3 Compiling the Linux distribution2.2.4 Flashing and running the Linux distribution

2.3 Advanced topics2.3.1 Manual tricking the u­boot/Linux configuration

2.3.1.1 Changes of xparameters.h2.3.1.2 U­Boot configuration file2.3.1.3 Linux kernel configuration file

2.3.2 Boot from Compact Flash2.3.2.1 Generating SysACE booting file2.3.2.2 Filling the compact flash

2.3.2.2.1 Troubleshooting2.3.2.3 Flashing the kernel and the root filesystem2.3.2.4 First test boot2.3.2.5 Troubleshooting2.3.2.6 Booting

3 Compiling applications for MicroBlaze: Evelin SDK3.1 Writing an application

3.1.1 The source code3.1.2 Compiling the application3.1.3 Running the application

3.1.3.1 On the host system

3.1.3.2 On the Microblaze3.1.4 Debugging the application

3.1.4.1 On the host system3.2 Using Eclipse

3.2.1 Creating the project3.2.2 Modifying the sources3.2.3 Running the application

3.2.3.1 On the host system3.2.3.2 On the MicroBlaze

3.2.4 Debugging the application

Page 2: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

3.2.4 Debugging the application3.2.4.1 On the host system

4 Connecting to the Xilinx EDK4.1 User permission troubleshooting

General InformationDefinitions and acronyms

BSP systemBSP stands for "Board Support Package"The BSP system is the system where the BSP is installed ­ i.e., the MicroBlaze

DTCDevice Tree Compiler: to compile the hardware architecture in a form suitable for the Linux kernel

EDKEmbedded Design Kit ­ i.e., the 'EDK and Platform Studio' for Microblaze provided by Xilinx

EDK systemThe machine where the EDK is installed

Evelin BSPThe Linux distribution made by Evidence and running on the MicroBlaze

Evelin SDKSDK stands for "Software Development Kit"Evelin SDK is the development environment made by Evidence to compile the Evelin BSP and to create applications. Itis installed inside the virtual machine.

FDTFlat Device Tree; a compact description of the hardware architecture (used by the Linux kernel to find the resources).

The virtual machine

The Evelin SDK and the sources of Evelin BSP for Xilinx Microblaze are available as a virtual machine provided byEvidence. This virtual machine contains a Ubuntu 10.04 LTS 32­bits Linux distribution.

The current version of the virtual machine can be downloaded at the following URL:

DOWNLOAD (http://server.era­project.org:8080/evelin/evelin­microblaze­0.9.6.7z)

Note: the virtual machine can be run using VirtualBox (free) or VMPlayer (free for not commercial use). These two virtualmachine players are available for several systems (Windows, Linux and Mac OS included).

The virtual machine contains:

The development environment on host, called Evelin SDK:A Microblaze gcc cross­compiler (C, C++)Some fundamental libraries (e.g., libc, libstdc++)A Microblaze software debuggerSome additional Microblaze tools (to use with binary files)A DTC compilerThe QEMU emulator for MicroblazeScratchbox2 for MicroblazeEclipse (with wizards to compile/debug Microblaze code)

The embedded Linux distribution for Microblaze, called Evelin BSP:The U­Boot bootloaderThe Linux kernel with driversThe root filesystem for the board with some unix daemonsAn integration systemA FPGA reference design

Page 3: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

Note: due to license constraints, the virtual machine does not contain the Xilinx tools (which are needed to synthesize theFPGA design and to change the FPGA design).

Note: the software has been tested using Xilinx EDK 12.1 and a Virtex 6 FPGA on a Xilinx ML605 board.

Accounts

The account available on the virtual machine is the following:

system name evelinbspuser name useruser password user

You can get 'root' permissions by using the sudo command.

Location of main directories

The home directory of 'user'/home/user

Evelin SDK/home/user/ev­edk

Evelin BSP/home/user/ev­sdk/workspace/evelin­bsp

The FPGA reference design/home/user/era_hw_reference_project

A Eclipse example/home/user/ev­sdk/workspace/microblaze_test_2

Running Linux on Microblaze: Evelin BSPEvelin BSP is the name of the Linux distribution for the MicroBlaze. The distribution (AKA the "firmware") consists ofbootloader U­Boot, kernel image uImage and filesystem. The distribution is provided both as sources and as pre­compiledbinaries. This Section explains both ways of running the Linux distribution.

Keep in mind that the U­Boot bootloader and the Linux kernel running on MicroBlaze must be aligned with the hardwaredesign synthetized on the FPGA. Therefore, if you change the hardware design, you will likely have also to configure, buildand flash a new firmware on the platform.

Using pre­compiled Linux distribution

Getting the Linux distribution

The pre­compiled binaries of the Linux distribution are available under the /home/user/Desktop/precompiled_binariesdirectory of the virtual machine.

Flashing and running the Linux distribution

Follow the Evelin instructions (http://server.era­project.org:8080/wiki/images/1/12/Evelin­bsp­run.txt) :

Instructions about how to flash default images of the Evelin Linux distributionon the Xilinx Virtex6 FPGA.

1. Take the images of the Linux distribution (e.g., those inside the /home/user/Desktop/precompiled_binaries/ directory of the vmware image) and put them on the machine where you have Xilinx tools installed

2. On the machine with the Xilinx tools installed:

Page 4: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

2.1 Open a console and type:

export LD_PRELOAD=/opt/Xilinx/usb-driver/libusb-driver.so

cd /opt/Xilinx/13.1/ISE_DS

. ./settings32.sh

xps

2.2 Select the project

2.3 Click on Device Configuration -> Download Bitstream

Wait "Done!"

(If it has problems, disconnect and reconnect the USB cables and try again.)

2.4 Click on Debug -> Launch_XMD to run the gdb console

2.5 On a Linux console, launch "kermit -c" (or minicom, if you prefer)

Note: the serial console must be set to 9600 8N1 - no flow control 2.6 On the gdb console (i.e., xmd) type:

cd <directory containing images>

dow u-boot.bin

dow -data xilinx.dtb 0xb2000000

dow -data uImage 0xb3000000

Only the first time, to flash the filesystem: dow -data rootfs.jffs2 0xb8000000

run

2.7 On the Linux console you will see U-Boot booting. Stop the boot by pressing a key, and type

Only the first time, to flash the filesystem: erase nor0,4 cp.b 0xb8000000 0x9c560000 0x840000

bootm 0xb3000000 - 0xb2000000

2.8 Once the system is booted, only the first time, run

mdev -s

There are not passwords into the system; and there are no users except the root user (with password root).

Customized Linux distribution

Configuring the Linux distribution

Run a shell on the virtual machine, enter the evelib­bsp directory and type the command sb2 make menuconfig:

user@evelinbsp:~$ cd ev-sdk/workspace/evelin-bsp/user@evelinbsp:~/ev-sdk/workspace/evelin-bsp$ sb2 make menuconfig

The following screen will appear:

Page 5: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

Configuration of the target

Enter the "Vendor/Productselection". The following screen will appear:

Select:

Vendor: MicroblazeProduct: Generic

In the hardware design field, you can insert the absolute path of the directory containing your specific Xilinx design (or leaveit as it is to use the default design).

Busybox configuration

In the main menu, enter the "busybox configuration" menu. The following window will appear:

Page 6: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

This menu allows to choose between a default busybox configuration and a custom busybox configuration. In case a customconfiguration is chosen, the busybox menu configuration will be automatically launched when exiting from the menù, and thefollowing menù will appear:

Kernel configuration

In the main menu, enter the "kernel configuration" menu. The following window will appear:

Page 7: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

This menu allows to choose between a default kernel configuration or a custom kernel configuration. In case a customconfiguration is chosen, the kernel menù configuration will be automatically launched when exiting from the menù, and thefollowing menù will appear:

Remember however that the 'Platform options' are overriden with values from the hardware design (so, it is useless modifythem).

Page 8: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

Choosing xparameters.h

If your FPGA design contains more xparameters.h files you are prompted to choose one:

Note that, in case you want don't want to add further xparameters files, the one used to build the default images is the secondfile in the list.

Updating the bitstream

If you modify the hardware design you must update the microblaze bitstream and the hardware architecture through the EDKsystem.

In the directory containing the hw design type make update­hwdesign.

michael@panicking:~$ cd evelin-bsp/michael@panicking:~/evelin-bsp$ make update-hwdesignMakefile:31: include dot config "linux/linux-2.6.37-microblaze"make -C "/home/user/era_hw_reference_project" -f system.make init_brammake[1]: Entering directory /home/michael/era_hw_reference_project'****************************************************Creating system netlist for hardware specification..****************************************************platgen -p xc6vlx240tff1156-1 -lang vhdl -msg __xps/ise/xmsgprops.lst system.mhs

Release 12.1 - platgen Xilinx EDK 12.1 Build EDK_MS1.53d......

Page 9: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

......

......Running post_generate.Running execs_generate.make[1]: Leaving directory /home/michael/era_hw_reference_project'michael@panicking:~/evelin-bsp$

Note: if you change the resources used by the RS232 uart you must change the linux boot parameters in the same way; thechosen section of the .dts file must contain a line similar to linux,stdout­path = "/plb@0/serial@84000000"; this line tells thekernel the location of the serial port used by the console. You can use the EDK to make the modification.

Compiling the Linux distribution

To compile the kernel, u­boot and to generate the rootfs type the command sb2 make.

user@evelinbsp:~/ev-sdk/workspace/evelin-bsp$ sb2 makeMakefile:31: include dot config "linux/linux-2.6.37-microblaze"make[1]: Entering directory /home/user/ev-sdk/workspace/evelin-bsp/boot/u-boot/u-boot-microblaze'Generating include/autoconf.mkGenerating include/autoconf.mk.depmake[1]: Leaving directory /home/user/ev-sdk/workspace/evelin-bsp/boot/u-boot/u-boot-microblaze'make[1]: Entering directory /home/user/ev-sdk/workspace/evelin-bsp/boot/u-boot/u-boot-microblaze'Configuring for microblaze-generic board...make[1]: Leaving directory /home/user/ev-sdk/workspace/evelin-bsp/boot/u-boot/u-boot-microblaze'make CROSS_COMPILE="ccache " -C boot/u-boot/u-boot-microblazemake[1]: Entering directory /home/user/ev-sdk/workspace/evelin-bsp/boot/u-boot/u-boot-microblaze'Generating include/autoconf.mkGenerating include/autoconf.mk.dep.................. UIMAGE arch/microblaze/boot/simpleImage.xilinx.ubImage Name: Linux-2.6.37-00717-ga7ace98Created: Sun May 29 14:17:11 2011Image Type: MicroBlaze Linux Kernel Image (uncompressed)Data Size: 3018756 Bytes = 2948.00 kB = 2.88 MBLoad Address: b0000000Entry Point: b0000000 STRIP arch/microblaze/boot/simpleImage.xilinxKernel: arch/microblaze/boot/simpleImage.xilinx is ready (#23)make[1]: Leaving directory /home/user/ev-sdk/workspace/evelin-bsp/linux/linux-2.6.37-microblaze'cp /home/user/ev-sdk/workspace/evelin-bsp/linux/linux-2.6.37-microblaze/arch/microblaze/boot/simpleImage.xilinx.ub /home/user/ev-sdk/workspace/evelin-bsp/images/uImagecp linux/linux-2.6.37-microblaze/arch/microblaze/boot/xilinx.dtb /home/user/ev-sdk/workspace/evelin-bsp/imagescp linux/linux-2.6.37-microblaze/xilinx.dts /home/user/ev-sdk/workspace/evelin-bsp/imagestouch /home/user/ev-sdk/workspace/evelin-bsp/images/.evelin_done_linuxfakeroot mkfs.jffs2 -d nfsroot -b -e 127 -o images/rootfs.jffs2touch /home/user/ev-sdk/workspace/evelin-bsp/images/.evelin_done_romfs user@evelinbsp:~/ev-sdk/workspace/evelin-bsp$

At the end of the compilation, the directory ~/ev­sdk/workspace/evelin­bsp/images will contain the following files:

1. uImage: the Linux kernel2. u­boot.bin: the u­boot boot loader3. rootfs.jffs2: the root filesystem (a JFFS2 filesystem)4. xilinx.dtb: the FDT in a binary form5. xilinx.dts: the FDT in a readable form

U­Boot is configured to be loaded at address 0xb1000000; the Linux kernel at address 0xb0000000 (the start of the RAMsynthesized into the hardware design); the rootfs usually resides on the 4th partition of the board flash memory.

Flashing and running the Linux distribution

Follow the Section (http://server.era­project.org:8080/wiki/index.php/Linux_Distribution_For_Xilinx_MicroBlaze#Flashing_and_running_the_Linux_distribution).

Advanced topics

Manual tricking the u­boot/Linux configuration

Page 10: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

Changes of xparameters.h

The configuration of u­boot and Linux is changed automatically to reflect the change that arevmade in the hardware design.The file xparameters.h is used to make this changes visible for Linux. However, if needed you can manually change theconfiguration.

Note: if you change the hardware design (and generate a new xparameters.h) your manually modification are lost (i.e.overwritten) when you rebuild the system.

After you have modified the configuration file you can rebuild the kernel using:

user@evelinbsp:~/ev-sdk/workspace/evelin-bsp$ rm images/.evelin_done_linuxuser@evelinbsp:~/ev-sdk/workspace/evelin-bsp$ sb2 make linuxMakefile:31: include dot config "linux/linux-2.6.37-microblaze"Start building Linux...if [ ! -f linux/linux-2.6.37-microblaze/.config ]; then \ echo "ERROR: Linux .config file not found"; \ echo "Please run make menuconfig"; \ exit 1; \ fi[ -d /home/user/ev-sdk/workspace/evelin-bsp/images ] || mkdir /home/user/ev-sdk/workspace/evelin-bsp/images........

and for u­boot:

user@evelinbsp:~/ev-sdk/workspace/evelin-bsp$ rm images/.evelin_done_ubootuser@evelinbsp:~/ev-sdk/workspace/evelin-bsp$ sb2 make u-boot........

Note: the following pathnames are relative to the BSP installation path (usually /home/user/ev­sdk/workspace/evelib­bsp).

U­Boot configuration file

The file boot/u­boot/u­boot­microblaze/board/xilinx/microblaze­generic/config.mk contains:

CONFIG_SYS_TEXT_BASEthe address where the u­boot must be load (usually 0xB1000000)

Linux kernel configuration file

The file linux/linux­2.6.37­microblaze/.config contains:

CONFIG_KERNEL_BASE_ADDRthe address where the linux kernel must be load (usually 0XB0000000)

CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTRmust be 1 if the Microblaze cpu has the MSR instruction

CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTRmust be 1 if the Microblaze cpu has the PCMP instuction

CONFIG_XILINX_MICROBLAZE0_USE_BARRELmust be 1 if the barrel can be used

CONFIG_XILINX_MICROBLAZE0_USE_DIVmust be 1 if the DIV instruction can be used

CONFIG_XILINX_MICROBLAZE0_USE_HW_MULis the type of hardware used for the MUL/DIV instructions (see Microblaze documentation)

CONFIG_XILINX_MICROBLAZE0_USE_FPUmust be 1 if is present a FPU

CONFIG_XILINX_MICROBLAZE0_HW_VERthe hardware version (usually, for Virtex6, "8.10.a")

CONFIG_XILINX_MICROBLAZE0_FAMILYthe Microblaze family (usually an empty string)

Page 11: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

Boot from Compact Flash

Generating SysACE booting file

We use the SysACE compact flash to load the bitstream and U­Boot onto the board. An ACE file must be generated.

On the EDK system type make generate­ace

michael@panicking:~/evelin-bsp$ make generate-aceMakefile:31: include dot config "linux/linux-2.6.37-microblaze"mkdir images/acemkdir: cannot create directory images/ace': File existsmake: [generate-ace] Error 1 (ignored)cd images/ace; xmd -tcl genace.tcl -board ml605 -jprog \ -hw ~/era_project_mgtest2/implementation/system.bit \ -elf ../u-boot.bin \ -target mdm \ -ace booting.aceXilinx Microprocessor Debugger (XMD) EngineXilinx EDK 12.1 Build EDK_MS1.53dCopyright (c) 1995-2009 Xilinx, Inc. All rights reserved.Executing xmd script : /opt/Xilinx/12.1/ISE_DS/EDK/data/xmd/genace.tcl...............Converting SVF file 'booting.svf' to SystemACE file 'booting.ace'Executing 'impact -batch svf2ace.scr'

SystemACE file 'booting.ace' created successfully

The directory ~/ev­sdk/workspace/evelin­bsp/images contains:

booting.ace: the ACE file

Filling the compact flash

The Compact Flash must be partitioned, formatted and filled. The first two operation should be executed only the first time.The last operation should be executed whenever the hardware bitstream or U­Boot are changed.

Partitioning: the first partition is the SysACE partition.

michael@panicking:~/evelin-bsp$ sudo fdisk /dev/sdfGNU Fdisk 1.2.4Copyright (C) 1998 - 2006 Free Software Foundation, Inc.This program is free software, covered by the GNU General Public License.

This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.

Using /dev/sdfCommand (m for help): p

Disk /dev/sdf: 512 MB, 512483328 bytes16 heads, 63 sectors/track, 993 cylindersUnits = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System /dev/sdf1 * 1 993 500440 6 FAT16Command (m for help): w Information: Don't forget to update /etc/fstab, if necessary.

Writing all changes to /dev/sdf.

Note: this is only an example. Use the correct device and the correct commands.

Formatting: The first partition must be formatted using FAT16 with 0 hidden sectors, 1 reserved sector, 2 FAT, with morethan 1 sector for cluster and without alignment.

michael@panicking:~/evelin-bsp$ sudo mkdosfs -F 16 -f 2 -h 0 -R 1 -s 64 -a -v /dev/sdf1

Page 12: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

Copying the file: never put more than one ACE file into a directory; the ACE file of the root directory in loaded during theboot (unless using a more complex directory layout).

michael@panicking:~/evelin-bsp$ sudo mount -t auto /dev/sdf1 /mntmichael@panicking:~/evelin-bsp$ sudo cp images/booting.ace /mntmichael@panicking:~/evelin-bsp$ sudo umount /mnt

Insert the Compact Flash into your board and switch it on. A green led (labelled 'system ace status led') will blink for a shorttime. The bitstream, that contains the hardware design, has been loaded into the FPGA.

Troubleshooting

When something went wrong, a red led lights.

Check the 'sace mode' dip switch bank: the 'SysAce mode' must be on. Your compact flash must not exceed 2GB. Only thefirst partition is used and there must be a FAT16 filesystem with more than 1 block for cluster.

Flashing the kernel and the root filesystem

The era_hw_reference_project contains RAM memory and Flash memory.

Component Start address SizeRAM 0xb0000000 256 MBFlash 0x9c000000 32 MB

We use the 'xmd' tools to transfer all to the board (from the EDK system). The transfer can take a long time.

michael@panicking:~$ cd evelin-bsp/images/michael@panicking:~/evelin-bsp/images$ xmdXilinx Microprocessor Debugger (XMD) EngineXilinx EDK 12.1 Build EDK_MS1.53dCopyright (c) 1995-2009 Xilinx, Inc. All rights reserved.

XMD% connect mb mdm

JTAG chain configuration--------------------------------------------------Device ID Code IR Length Part Name 1 0a001093 8 System_ACE_CF 2 24250093 10 XC6VLX240T

MicroBlaze Processor Configuration :-------------------------------------Version............................7.30.aOptimization.......................PerformanceInterconnect.......................PLBv46MMU Type...........................Full_MMUNo of PC Breakpoints...............1No of Read Addr/Data Watchpoints...0No of Write Addr/Data Watchpoints..0Instruction Cache Support..........onInstruction Cache Base Address.....0xb0000000Instruction Cache High Address.....0xbfffffffData Cache Support.................onData Cache Base Address............0xb0000000Data Cache High Address............0xbfffffffExceptions Support................onFPU Support.......................offHard Divider Support...............onHard Multiplier Support............on - (Mul64)Barrel Shifter Support.............onMSR clr/set Instruction Support....onCompare Instruction Support........onPVR Supported......................onPVR Configuration Type.............FullData Cache Write-back Support......off

Connected to "mb" target. id = 0Starting GDB server for "mb" target (id = 0) at TCP port no 1234XMD% lsace booting.ace rootfs.jffs2 u-boot.bin uImage xilinx.dtb xilinx.dtsXMD% dow -data xilinx.dtb 0xb2000000Downloading Data File -- xilinx.dtb at 0xb2000000

XMD% dow -data uImage 0xb3000000Downloading Data File -- uImage at 0xb3000000

Page 13: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

XMD% dow -data rootfs.jffs2 0xb8000000Downloading Data File -- rootfs.jffs2 at 0xb8000000

XMD% stopXMD% rwr pc 0xb1000000XMD% con

RUNNING> XMD%

U­Boot is not dowloaded to the RAM because it is already loaded by the SysACE.

If you have a terminal emulator connected to the board you should see the system running.

You must stop the autoboot pressing a key because the board flash is empty.

michael@panicking:~$ kermit -cConnecting to /dev/ttyUSB0, speed 9600 Escape character: Ctrl-\ (ASCII 28, FS): enabledType the escape character followed by C to get back,or followed by ? to see other options.----------------------------------------------------SDRAM : Icache:ON Dcache:OFF U-Boot Start:0xb1000000FLASH: 32 MiBUsing default environment

Net: Xilinx_EmacliteMAC: 00:e0:0c:00:00:fdU-BOOT for evidence-mb

Hit any key to stop autoboot: 0 evidence-mb>

'evidence­mb>' is the prompt of u­boot visible from a serial line console. U­Boot has been loaded from the SysACE compactflash and now is running. Now we can transfer the system into the flash memory. First of all the flash must be partitioned.

evidence-mb> mtdparts defaultevidence-mb> mtdparts

device nor0 <ml401-0>, # parts = 5 #: name size offset mask_flags 0: u-boot 0x00100000 0x00000000 0 1: env 0x00040000 0x00100000 0 2: fdt 0x00020000 0x00140000 0 3: kernel 0x00400000 0x00160000 0 4: jffs2 0x01aa0000 0x00560000 0

active partition: nor0,0 - (u-boot) 0x00100000 @ 0x00000000

defaults:mtdids : nor0=ml401-0mtdparts: mtdparts=ml401-0:1m(u-boot),256k(env),128k(fdt),4m(kernel),-(jffs2)evidence-mb>

Then, we can transfer the system into the flash.

evidence-mb> erase nor0,0Erase Flash Partition nor0,0, bank 0, 0x9c000000 - 0x9c0fffff ........ doneErased 8 sectorsevidence-mb> cp.b 0xb1000000 0x9c000000 0xCE5BACopy to Flash... .0doneevidence-mb> erase nor0,2 Erase Flash Partition nor0,2, bank 0, 0x9c140000 - 0x9c15ffff . doneErased 1 sectorsevidence-mb> cp.b 0xb2000000 0x9c140000 0x34EC Copy to Flash... .0doneevidence-mb> erase nor0,3Erase Flash Partition nor0,3, bank 0, 0x9c160000 - 0x9c55ffff ................................ doneErased 32 sectorsevidence-mb> cp.b 0xb3000000 0x9c160000 0x2E1044Copy to Flash... .0doneevidence-mb> erase nor0,4Erase Flash Partition nor0,4, bank 0, 0x9c560000 - 0x9dffffff

Page 14: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

.........................................................................................

.........................................................................................

...................................... doneErased 216 sectorsevidence-mb> cp.b 0xb8000000 0x9c560000 0x640000Copy to Flash... .0doneevidence-mb> setenv partition nor0,4evidence-mb> lsScanning JFFS2 FS: ..... done. -rw-r--r-- 1612 Wed May 18 19:44:11 2011 .ash_history drwxr-xr-x 0 Tue May 17 19:34:45 2011 bin drwxrwxrwx 0 Wed May 18 18:55:48 2011 dev drwxr-xr-x 0 Wed May 18 17:40:42 2011 etc lrwxrwxrwx 11 Tue May 17 16:01:09 2011 init -> bin/busybox drwxr-xr-x 0 Tue May 17 20:25:51 2011 lib -rwxr-xr-x 10009 Wed May 18 19:34:51 2011 main drwxrwxrwx 0 Tue May 17 16:01:09 2011 mnt drwxrwxrwx 0 Tue May 17 16:01:09 2011 proc drwxr-xr-x 0 Wed May 18 19:01:35 2011 root drwxr-xr-x 0 Tue May 17 19:34:47 2011 sbin drwxrwxrwx 0 Tue May 17 16:01:09 2011 sys drwxrwxrwx 0 Tue May 17 16:01:09 2011 tmp drwxr-xr-x 0 Tue May 17 19:34:51 2011 usr drwxrwxrwx 0 Wed May 18 19:09:39 2011 varevidence-mb>

First test boot

We can try to boot the linux kernel for the first time using the command bootm 0x9c160000 ­ 0x9c140000 or the commandboot from the u­boot prompt.

evidence-mb> bootm 0x9c160000 - 0x9c140000## Booting kernel from Legacy Image at 9c160000 ... Image Name: Linux-2.6.37-00717-ga7ace98 Image Type: MicroBlaze Linux Kernel Image (uncompressed) Data Size: 3026948 Bytes = 2.9 MiB Load Address: b0000000 Entry Point: b0000000 Verifying Checksum ... OK## Flattened Device Tree blob at 9c140000 Booting using the fdt blob at 0x9c140000 Loading Kernel Image ... OKOKearly_printk_console is enabled at 0x84000000Ramdisk addr 0x00000003, FDT at 0x9c140000 Linux version 2.6.37-00717-ga7ace98 (user@evelinbsp) (gcc version 4.1.2) #27 Mon May 30 08:51:54 PDT 2011setup_cpuinfo: initialisingsetup_cpuinfo: Using full CPU PVR supportcache: wt_msr_noirqsetup_memory: max_mapnr: 0x10000setup_memory: min_low_pfn: 0xb0000setup_memory: max_low_pfn: 0xc0000On node 0 totalpages: 65536free_area_init_node: node 0, pgdat c02c81b4, node_mem_map c02f8000 Normal zone: 512 pages used for memmap Normal zone: 0 pages reserved Normal zone: 65024 pages, LIFO batch:15pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768pcpu-alloc: [0] 0 Built 1 zonelists in Zone order, mobility grouping on. Total pages: 65024Kernel command line: console=ttyUL0 root=/dev/mtdblock4 rw rootfstype=jffs2 mtdparts=9c000000.flash:1m(u-boot),256k(env),128k(fdt),4m(kernel),-(jffs2)PID hash table entries: 1024 (order: 0, 4096 bytes)Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)Memory: 256552k/262144k availableNR_IRQS:32xlnx,xps-intc-1.00.a #0 at 0xd0000000, num_irq=4, edge=0x7xlnx,xps-timer-1.00.a #0 at 0xd0004000, irq=0microblaze_timer_set_mode: shutdownmicroblaze_timer_set_mode: periodicCalibrating delay loop... 49.15 BogoMIPS (lpj=98304)pid_max: default: 32768 minimum: 301Mount-cache hash table entries: 512NET: Registered protocol family 16bio: create slab <bio-0> at 0XGpio: /plb@0/gpio@81460000: registeredXGpio: /plb@0/gpio@81440000: registeredXGpio: /plb@0/gpio@81420000: registeredXGpio: /plb@0/gpio@81400000: registeredSwitching to clocksource microblaze_clocksourcemicroblaze_timer_set_mode: oneshotNET: Registered protocol family 2IP route cache hash table entries: 2048 (order: 1, 8192 bytes)TCP established hash table entries: 8192 (order: 4, 65536 bytes)TCP bind hash table entries: 8192 (order: 3, 32768 bytes)TCP: Hash tables configured (established 8192 bind 8192)TCP reno registeredUDP hash table entries: 256 (order: 0, 4096 bytes)

Page 15: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)NET: Registered protocol family 1RPC: Registered udp transport module.RPC: Registered tcp transport module.RPC: Registered tcp NFSv4.1 backchannel transport module.Skipping unavailable RESET gpio -2 (reset)GPIO pin is already allocatedJFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.msgmni has been set to 501Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)io scheduler noop registeredio scheduler deadline registeredio scheduler cfq registered (default)Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled84000000.serial: ttyUL0 at MMIO 0x84000000 (irq = 2) is a uartliteconsole [ttyUL0] enabled9c000000.flash: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x000089 Chip ID 0x008919Intel/Sharp Extended Query Table at 0x010AIntel/Sharp Extended Query Table at 0x010AIntel/Sharp Extended Query Table at 0x010AIntel/Sharp Extended Query Table at 0x010AIntel/Sharp Extended Query Table at 0x010AUsing buffer write methodUsing auto-unlock on power-up/resumecfi_cmdset_0001: Erase suspend on write enablederase region 0: offset=0x0,size=0x20000,blocks=255erase region 1: offset=0x1fe0000,size=0x8000,blocks=45 cmdlinepart partitions found on MTD device 9c000000.flashCreating 5 MTD partitions on "9c000000.flash":0x000000000000-0x000000100000 : "u-boot"0x000000100000-0x000000140000 : "env"0x000000140000-0x000000160000 : "fdt"0x000000160000-0x000000560000 : "kernel"0x000000560000-0x000002000000 : "jffs2"of:xilinx_emaclite 81000000.ethernet: Device Tree ProbingXilinx Emaclite MDIO: probedof:xilinx_emaclite 81000000.ethernet: MAC address is now 00:0a:35:ac:99:00of:xilinx_emaclite 81000000.ethernet: Xilinx EmacLite at 0x81000000 mapped to 0xD2180000, irq=1Device Tree Probing 'i2c'of:iic 81660000.i2c: no IRQ found.of:iic: probe of 81660000.i2c failed with error -1Device Tree Probing 'i2c'of:iic 81640000.i2c: no IRQ found.of:iic: probe of 81640000.i2c failed with error -1Device Tree Probing 'i2c'of:iic 81620000.i2c: no IRQ found.of:iic: probe of 81620000.i2c failed with error -1Device Tree Probing 'i2c'of:iic 81600000.i2c: no IRQ found.of:iic: probe of 81600000.i2c failed with error -1TCP cubic registeredNET: Registered protocol family 1wVFS: Mounted root (jffs2 filesystem) on device 31:4.Freeing unused kernel memory: 96k freedStarting rcS...++ Creating device points++ Mounting filesystem++ Loading system loggers++ Starting networkudhcpc (v1.18.4) startedSending discover...PHY: c000ba40:07 - Link is DownPHY: c000ba40:07 - Link is Up - 100/FullSending discover...Sending select for 192.168.97.187...Lease of 192.168.97.187 obtained, lease time 345600adding dns 192.168.97.1++ Starting telnet daemon++ Starting ftpd daemonrcS Complete/bin/sh: can't access tty; job control turned off/ #

Troubleshooting

Sometimes the JTAG cable seems to not work ('ERROR: Failed to Open JTAG Cable'). Usually, it is sufficient to plug outand then plug in the USB connector.

Note: the numbers of the cp.b command must be hexadecimal.

Booting

Page 16: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

All the components of the system are into the SysACE compact flash or into the board memory flash. There is a little bug thatprevents the board to auto boot. You must use a script to run the u­boot from the board:

1. switch on the board2. run the "run_u­boot.sh" script (the script is located into the evelin­bsp directory)

Note: the script needs to use the JTAG cable so you must not have another program using it and you must run the script fromthe EDK system. You can see all the booting process from the serial console. You have 3 seconds to stop the u­bootautomatic boot (if you want or need).

michael@panicking:~/evelin-bsp$ ./run_u-boot.sh michael@panicking:~/evelin-bsp$ kermit -cConnecting to /dev/ttyUSB0, speed 9600 Escape character: Ctrl-\ (ASCII 28, FS): enabledType the escape character followed by C to get back,or followed by ? to see other options.----------------------------------------------------SDRAM : Icache:ON Dcache:OFF U-Boot Start:0xb1000000FLASH: 32 MiBUsing default environment

Net: Xilinx_EmacliteMAC: 00:e0:0c:00:00:fdU-BOOT for evidence-mb

Hit any key to stop autoboot: 0 ## Booting kernel from Legacy Image at 9c160000 ... Image Name: Linux-2.6.37-00717-ga7ace98 Image Type: MicroBlaze Linux Kernel Image (uncompressed) Data Size: 3026948 Bytes = 2.9 MiB Load Address: b0000000 Entry Point: b0000000 Verifying Checksum ... OK## Flattened Device Tree blob at 9c140000 Booting using the fdt blob at 0x9c140000 Loading Kernel Image ... OKOKearly_printk_console is enabled at 0x84000000Ramdisk addr 0x00000003, FDT at 0x9c140000 Linux version 2.6.37-00717-ga7ace98 (user@evelinbsp) (gcc version 4.1.2) #27 Mon May 30 08:51:54 PDT 2011setup_cpuinfo: initialising........................NET: Registered protocol family 1wVFS: Mounted root (jffs2 filesystem) on device 31:4.Freeing unused kernel memory: 96k freedStarting rcS...++ Creating device points++ Mounting filesystem++ Loading system loggers++ Starting networkudhcpc (v1.18.4) startedSending discover...PHY: c000ba40:07 - Link is DownPHY: c000ba40:07 - Link is Up - 100/FullSending discover...Sending select for 192.168.97.187...Lease of 192.168.97.187 obtained, lease time 345600adding dns 192.168.97.1++ Starting telnet daemon++ Starting ftpd daemonrcS Complete/bin/sh: can't access tty; job control turned off/ #

Compiling applications for MicroBlaze: Evelin SDKEvelin SDK is the development environment made by Evidence. It to compile the Evelin BSP Linux distribution, theSupervisor and other applications for the MicroBlaze. This development environment is already installed inside the virtualmachine provided by Evidence.

This section contains two examples showing how to write an application with the integrated development environment(Eclipse) and without.

Page 17: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

Writing an application

This example of application computes the Fibonacci's sequence numbers.

The source code

First of all, build the directory structure:

user@evelinbsp:~$ cd ev-sdk/workspace/user@evelinbsp:~/ev-sdk/workspace$ mkdir fibonacciuser@evelinbsp:~/ev-sdk/workspace$ cd fibonacci/user@evelinbsp:~/ev-sdk/workspace/fibonacci$ mkdir src

Then, use an editor (vi, emacs, gedit, etc.) to write the src/fibonacci.c file:

/* * Made using Evelin SDk for Microblaze * Evidence Srl --- <[email protected]> */

#include <stdio.h>#include <stdlib.h>#include <strings.h>

static void fibonacci(int x, int y) if (x>10000) return; printf("%i ",x); fibonacci(y,x+y);

int main() const char* s = "Made using Evelin SDK"; int n; n = puts(s); fflush(stdout); fibonacci(0,1); printf("\n"); return 0;

Finally, write the Makefile:

# Made using Evelin SDk for Microblaze# Evidence Srl <[email protected]>

CC=gccCFLAGS=-ansi -Wall -g2SRC=src/fibonacci.cOBJ=src/fibonacci.o

.PHONY: all clean

all: fibonacci

clean: -rm $(OBJ) -rm fibonacci

fibonacci: $(OBJ) gcc -o fibonacci $(OBJ)

Note: the Makefile will use gcc to compile the application

Compiling the application

We use the scratchbox2 tool to build the application using the command sb2 make:

user@evelinbsp:~/ev-sdk/workspace/fibonacci$ sb2 makegcc -ansi -Wall -g2 -c -o src/fibonacci.o src/fibonacci.cgcc -o fibonacci src/fibonacci.ouser@evelinbsp:~/ev-sdk/workspace/fibonacci$

Page 18: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

The file fibonacci is generated.

Note: scratchbox2 automatically handles all the cross compilation issues

Running the application

On the host system

The file fibonacci has been compiled for Microblaze architecture so if we try to execute it we have an error.

user@evelinbsp:~/ev-sdk/workspace/fibonacci$ ./fibonacci/lib/ld.so.1: No such file or directoryuser@evelinbsp:~/ev-sdk/workspace/fibonacci$

But, thanks to the target emulation provided by Scratchbox2 and Qemu, it can be run on scratchbox2:

user@evelinbsp:~/ev-sdk/workspace/fibonacci$ sb2 ./fibonacciMade using Evelin SDK0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 user@evelinbsp:~/ev-sdk/workspace/fibonacci$

On the Microblaze

First, switch on the board and start the start­up script (as described in #Booting). Then, transfer the executable using ftp andstart the application using a telnet client:

user@evelinbsp:~/ev-sdk/workspace/fibonacci$ ftp mbboardConnected to mbboard.priv.mgsi.eu.220 Operation successfulName (mbboard:user): 230 Operation successfulRemote system type is UNIX.Using binary mode to transfer files.ftp> put fibonaccilocal: fibonacci remote: fibonacci200 Operation successful150 Ok to send data226 Operation successful9357 bytes sent in 0.00 secs (19525.0 kB/s)ftp> exit221 Operation successfuluser@evelinbsp:~/ev-sdk/workspace/fibonacci$ telnet mbboardTrying 192.168.97.187...Connected to mbboard.priv.mgsi.eu.Escape character is ']'.

/ # chmod +x fibonacci/ # ./fibonacciMade using Evelin SDK0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 / # exitConnection closed by foreign host.user@evelinbsp:~/ev-sdk/workspace/fibonacci$

Debugging the application

Workaround: if you obtain a segmentation fault during debugging you can try :

to remove the /etc/ld.so.cache file (with sudo rm /etc/ld.so.cache)

or

to link your application statically (using the ­static gcc flag); you should clean the project and rebuild the application.

On the host system

Page 19: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

Start the application to be debugged through sb2 with an emulator that accepts remote gdb commands from a TCP/IPconnection on port 1234 of localhost:

user@evelinbsp:~/ev-sdk/workspace/first_microblaze_test$ sb2 qemu-microblaze -g 1234 ./main

Note: the evelinbsp prompt does not appear, the application is waiting for gdb commands.

Then, use a another terminal to start the debugger:

user@evelinbsp:~/ev-sdk/workspace/first_microblaze_test$ mb-linux-gdbGNU gdb (GDB) 7.2Copyright (C) 2010 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law. Type "show copying"and "show warranty" for details.This GDB was configured as "--host=i686-pc-linux-gnu --target=microblaze-unknown-linux-gnu".For bug reporting instructions, please see:<http://www.gnu.org/software/gdb/bugs/>.(gdb)

Note: the prompt of gdb is '(gdb) ',

Select the target to be run and load the symbols:

(gdb) target remote localhost:1234Remote debugging using localhost:1234[New Remote target][Switching to Remote target]0x10000100 in ?? ()(gdb) file ./mainA program is being debugged already.Are you sure you want to change the file? (y or n) yReading symbols from /home/user/ev-sdk/workspace/first_microblaze_test/main...done.(gdb)

Start debugging your program. For example, you can set a breakpoint at line 16 of the main source file:

(gdb) list3 * by Evidence Srl --- <[email protected]>4 */5 6 #include <stdio.h>7 #include <stdlib.h>8 9 10 int main()11 12 const char* s = "Made using Evelin SDK";(gdb) list13 int n;14 15 n = puts(s);16 fflush(stdout);17 18 printf("Hello world!\n");19 20 return 0;21 22 (gdb) break 16Breakpoint 1 at 0x1000028c: file src/main.c, line 16.(gdb) info breakNum Type Disp Enb Address What1 breakpoint keep y 0x1000028c in main at src/main.c:16(gdb)

You can run the application and see the values of some variables:

(gdb) contContinuing.

Breakpoint 1, main () at src/main.c:16

Page 20: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

16 fflush(stdout);(gdb) print n$1 = 22(gdb) print s$2 = 0x10072f28 "Made using Evelin SDK"(gdb)

Note that the output of the program is shown into the other terminal

user@evelinbsp:~/ev-sdk/workspace/first_microblaze_test$ sb2 qemu-microblaze -g 1234 ./main Made using Evelin SDK

Continue to debug until the end:

(gdb) contContinuing.

Program exited normally.(gdb)

The complete output of the program

user@evelinbsp:~/ev-sdk/workspace/first_microblaze_test$ sb2 qemu-microblaze -g 1234 ./main Made using Evelin SDKHello world!user@evelinbsp:~/ev-sdk/workspace/first_microblaze_test$

Using Eclipse

You can start Eclipse clicking the Evelin SDK Eclipse icon or using the command '/home/user/ev­sdk/bin/scratchbox/bin/ev­sdk­eclipse'.

Note: this section does not explain all the features of the Eclipse IDE; it is only a small example of some features.

This is the main screen of Eclipse:

Creating the project

Creating a project for Microblaze is a simple task: click on File/New/New Scratchbox2 project

Page 22: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

Your project has been created, a source sample has been created and has been built:

Modifying the sources

You can edit the source code:

If you save your changes the project will be automatically rebuilt.

Running the application

On the host system

To run the application, select Run/Run configurations...

Page 23: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

You must select or create a configuration for a scratchbox2 application:

When you press enter the application is started. Note: it is a Microblaze native application run through the QEmu emulator.

Page 24: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

On the MicroBlaze

You must use the same steps explainend in #On the MicroBlaze.

The project directory is located in /home/user/ev­sdk/workspace/first_microblaze_test

Debugging the application

On the host system

To debug the application you must select Run/Debug configurations...:

A wizard will appear. You must ensure to select a Scratchbox2 application and that the Debuger tab has the values shownbelow:

Page 25: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

Now you can start the debugger by clicking the Debug button. Eclipse will switch to a new perspective (a visual container ofwindows). The application is started and run until the main() function is reached.

To set a breakpoint you must go to the line of the source window and press CTRL­ALT­B. For example we set a breakpoint tothe line 16 and then we continue the execution of the application pressing F8.

Note: In Eclipse you can use keyboard shortcut or the menu system to execute commands.

Page 26: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

You can see into the Variables window the values of the two variable of the main() function. To resume the application presskey F8.

The application is terminated. The Console window shows the output of the program.

Connecting to the Xilinx EDKIn some cases you may need to use some tools provided by the Xilinx EDK environment. These tools cannot be distributedinside the virtual machine because they are subject to licensing by Xlinix. Therefore, you have two possible solutions:

1. Install the EDK inside the evelinbsp system using your own license purchased by Xilinx2. Install the EDK on a different Linux system and connect it to the virtual machine.

Page 27: Linux Distribution For Xilinx MicroBlazesoftware.evidence.eu.com/evelin/microblaze/manual-evelin... · Customized Linux distribution Configuring the Linux distribution ... UIMAGE

We will show how to use the second method. The setup needs to be done only once. To use this method you must setup thesystem of the EDK to access the evelinbsp system. In the following example the system containing the EDK is calledpanicking (the user is called michael).

Evelinbsp exports, through the NFS filesystem, the directory /home/user/ev­sdk/workspace/evelin­bsp and/home/user/era_hw_reference_project. You must import them into the EDK system and create a link for the 'user' into yourhome, as shown in the following example:

michael@panicking:~$ mkdir evelin­bsp michael@panicking:~$ mkdir era_hw_reference_project michael@panicking:~$sudo su [sudo] password for michael: root@panicking:/home/michael# vi /etc/fstab root@panicking:/home/michael# mount ­aroot@panicking:/home# cd .. root@panicking:/home# ln ­s michael user root@panicking:/home# exit michael@panicking:~$These are the lines that must be added to the /etc/fstab file:

evelinbsp:/home/user/ev-sdk/workspace/evelin-bsp /home/michael/evelin-bsp nfs defaults 0 0evelinbsp:/home/user/era_hw_reference_project /home/michael/era_hw_reference_project nfs defaults 0 0

User permission troubleshooting

If you are in trouble accessing files of evelinbsp from your EDK system you can try to modify the pid and gid of evelinbsp(the BSP system):

1. find the pid and gid of your user into the EDK system (from files /etc/passwd and /etc/group)2. change the gid of the group 'user' into the BSP system to match the gid of the EDK system using sudo groupmod ­gNEW_GID user

3. change the uid of the user 'user' into the BSP system to match the uid of the EDK system using the comand sudousermod ­g NEW_GID ­u NEW_UID

Retrieved from "http://server.era­project.org:8080/wiki/index.php/Linux_Distribution_For_Xilinx_MicroBlaze"

This page was last modified on 4 July 2013, at 07:38.