17.07.2015 Views

Linux Distribution For Xilinx MicroBlaze - Eu.com

Linux Distribution For Xilinx MicroBlaze - Eu.com

Linux Distribution For Xilinx MicroBlaze - Eu.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.2.4 Debugging the application3.2.4.1 On the host system4 Connecting to the <strong>Xilinx</strong> EDK4.1 User permission troubleshootingGeneral InformationDefinitions and acronymsBSP systemBSP stands for "Board Support Package"The BSP system is the system where the BSP is installed ­ i.e., the <strong>MicroBlaze</strong>DTCDevice Tree Compiler: to <strong>com</strong>pile the hardware architecture in a form suitable for the <strong>Linux</strong> kernelEDKEmbedded Design Kit ­ i.e., the 'EDK and Platform Studio' for Microblaze provided by <strong>Xilinx</strong>EDK systemThe machine where the EDK is installedEvelin BSPThe <strong>Linux</strong> distribution made by Evidence and running on the <strong>MicroBlaze</strong>Evelin SDKSDK stands for "Software Development Kit"Evelin SDK is the development environment made by Evidence to <strong>com</strong>pile the Evelin BSP and to create applications. Itis installed inside the virtual machine.FDTFlat Device Tree; a <strong>com</strong>pact description of the hardware architecture (used by the <strong>Linux</strong> kernel to find the resources).The virtual machineThe Evelin SDK and the sources of Evelin BSP for <strong>Xilinx</strong> Microblaze are available as a virtual machine provided byEvidence. This virtual machine contains a Ubuntu 10.04 LTS 32­bits <strong>Linux</strong> 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 <strong>com</strong>mercial use). These two virtualmachine players are available for several systems (Windows, <strong>Linux</strong> and Mac OS included).The virtual machine contains:The development environment on host, called Evelin SDK:A Microblaze gcc cross­<strong>com</strong>piler (C, C++)Some fundamental libraries (e.g., libc, libstdc++)A Microblaze software debuggerSome additional Microblaze tools (to use with binary files)A DTC <strong>com</strong>pilerThe QEMU emulator for MicroblazeScratchbox2 for MicroblazeEclipse (with wizards to <strong>com</strong>pile/debug Microblaze code)The embedded <strong>Linux</strong> distribution for Microblaze, called Evelin BSP:The U­Boot bootloaderThe <strong>Linux</strong> kernel with driversThe root filesystem for the board with some unix daemonsAn integration systemA FPGA reference design


Note: due to license constraints, the virtual machine does not contain the <strong>Xilinx</strong> tools (which are needed to synthesize theFPGA design and to change the FPGA design).Note: the software has been tested using <strong>Xilinx</strong> EDK 12.1 and a Virtex 6 FPGA on a <strong>Xilinx</strong> ML605 board.AccountsThe account available on the virtual machine is the following:system nameuser nameYou can get 'root' permissions by using the sudo <strong>com</strong>mand.Location of main directoriesThe home directory of 'user'/home/userEvelin SDK/home/user/ev­edkEvelin BSP/home/user/ev­sdk/workspace/evelin­bspThe FPGA reference design/home/user/era_hw_reference_projectA Eclipse example/home/user/ev­sdk/workspace/microblaze_test_2evelinbspuseruser password userRunning <strong>Linux</strong> on Microblaze: Evelin BSPEvelin BSP is the name of the <strong>Linux</strong> distribution for the <strong>MicroBlaze</strong>. The distribution (AKA the "firmware") consists ofbootloader U­Boot, kernel image uImage and filesystem. The distribution is provided both as sources and as pre­<strong>com</strong>piledbinaries. This Section explains both ways of running the <strong>Linux</strong> distribution.Keep in mind that the U­Boot bootloader and the <strong>Linux</strong> kernel running on <strong>MicroBlaze</strong> 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­<strong>com</strong>piled <strong>Linux</strong> distributionGetting the <strong>Linux</strong> distributionThe pre­<strong>com</strong>piled binaries of the <strong>Linux</strong> distribution are available under the /home/user/Desktop/pre<strong>com</strong>piled_binariesdirectory of the virtual machine.Flashing and running the <strong>Linux</strong> distributionFollow the Evelin instructions (http://server.era­project.org:8080/wiki/images/1/12/Evelin­bsp­run.txt) :InstructionsabouthowtoflashdefaultimagesoftheEvelin<strong>Linux</strong>distributiononthe<strong>Xilinx</strong>Virtex6FPGA.1.Taketheimagesofthe<strong>Linux</strong>distribution(e.g.,thoseinsidethe/home/user/Desktop/pre<strong>com</strong>piled_binaries/directoryofthevmwareimage)andputthemonthemachinewhereyouhave<strong>Xilinx</strong>toolsinstalled2.Onthemachinewiththe<strong>Xilinx</strong>toolsinstalled:


2.1 Openaconsoleandtype:exportLD_PRELOAD=/opt/<strong>Xilinx</strong>/usb-driver/libusb-driver.socd/opt/<strong>Xilinx</strong>/13.1/ISE_DS../settings32.shxps2.2Selecttheproject2.3ClickonDeviceConfiguration->DownloadBitstreamWait"Done!"(Ifithasproblems,disconnectandreconnecttheUSBcablesandtryagain.)2.4ClickonDebug->Launch_XMDtorunthegdbconsole2.5Ona<strong>Linux</strong>console,launch"kermit-c"(ormini<strong>com</strong>,ifyouprefer)Note:theserialconsolemustbesetto96008N1-noflowcontrol2.6Onthegdbconsole(i.e.,xmd)type:cddowu-boot.bindow-dataxilinx.dtb0xb2000000dow-datauImage0xb3000000Onlythefirsttime,toflashthefilesystem:dow-datarootfs.jffs20xb8000000run2.7Onthe<strong>Linux</strong>consoleyouwillseeU-Bootbooting.Stopthebootbypressingakey,andtypeOnlythefirsttime,toflashthefilesystem:erasenor0,4cp.b0xb80000000x9c5600000x840000bootm0xb3000000-0xb20000002.8Oncethesystemisbooted,onlythefirsttime,runmdev-sThere are not passwords into the system; and there are no users except the root user (with password root).Customized <strong>Linux</strong> distributionConfiguring the <strong>Linux</strong> distributionRun a shell on the virtual machine, enter the evelib­bsp directory and type the <strong>com</strong>mand sb2 make menuconfig:user@evelinbsp:~$cdev-sdk/workspace/evelin-bsp/user@evelinbsp:~/ev-sdk/workspace/evelin-bsp$sb2makemenuconfigThe following screen will appear:


Configuration of the targetEnter the "Vendor/Productselection". The following screen will appear:Select:Vendor: MicroblazeProduct: GenericIn the hardware design field, you can insert the absolute path of the directory containing your specific <strong>Xilinx</strong> design (or leaveit as it is to use the default design).Busybox configurationIn the main menu, enter the "busybox configuration" menu. The following window will appear:


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 configurationIn the main menu, enter the "kernel configuration" menu. The following window will appear:


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).


Choosing xparameters.hIf 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 bitstreamIf 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:~$cdevelin-bsp/michael@panicking:~/evelin-bsp$makeupdate-hwdesignMakefile:31:includedotconfig"linux/linux-2.6.37-microblaze"make-C"/home/user/era_hw_reference_project"-fsystem.makeinit_brammake[1]:Enteringdirectory`/home/michael/era_hw_reference_project'****************************************************Creatingsystemnetlistforhardwarespecification..****************************************************platgen-pxc6vlx240tff1156-1-langvhdl -msg__xps/ise/xmsgprops.lstsystem.mhsRelease12.1-platgen<strong>Xilinx</strong>EDK12.1BuildEDK_MS1.53d......


............Runningpost_generate.Runningexecs_generate.make[1]:Leavingdirectory`/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 <strong>Linux</strong> distributionTo <strong>com</strong>pile the kernel, u­boot and to generate the rootfs type the <strong>com</strong>mand sb2 make.user@evelinbsp:~/ev-sdk/workspace/evelin-bsp$sb2makeMakefile:31:includedotconfig"linux/linux-2.6.37-microblaze"make[1]:Enteringdirectory`/home/user/ev-sdk/workspace/evelin-bsp/boot/u-boot/u-boot-microblaze'Generatinginclude/autoconf.mkGeneratinginclude/autoconf.mk.depmake[1]:Leavingdirectory`/home/user/ev-sdk/workspace/evelin-bsp/boot/u-boot/u-boot-microblaze'make[1]:Enteringdirectory`/home/user/ev-sdk/workspace/evelin-bsp/boot/u-boot/u-boot-microblaze'Configuringformicroblaze-genericboard...make[1]:Leavingdirectory`/home/user/ev-sdk/workspace/evelin-bsp/boot/u-boot/u-boot-microblaze'makeCROSS_COMPILE="ccache"-Cboot/u-boot/u-boot-microblazemake[1]:Enteringdirectory`/home/user/ev-sdk/workspace/evelin-bsp/boot/u-boot/u-boot-microblaze'Generatinginclude/autoconf.mkGeneratinginclude/autoconf.mk.dep..................UIMAGE arch/microblaze/boot/simpleImage.xilinx.ubImageName: <strong>Linux</strong>-2.6.37-00717-ga7ace98Created: SunMay2914:17:112011ImageType: <strong>MicroBlaze</strong><strong>Linux</strong>KernelImage(un<strong>com</strong>pressed)DataSize: 3018756Bytes=2948.00kB=2.88MBLoadAddress:b0000000EntryPoint: b0000000STRIP arch/microblaze/boot/simpleImage.xilinxKernel:arch/microblaze/boot/simpleImage.xilinxisready (#23)make[1]:Leavingdirectory`/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/uImagecplinux/linux-2.6.37-microblaze/arch/microblaze/boot/xilinx.dtb/home/user/ev-sdk/workspace/evelin-bsp/imagescplinux/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_linuxfakerootmkfs.jffs2-dnfsroot-b-e127-oimages/rootfs.jffs2touch/home/user/ev-sdk/workspace/evelin-bsp/images/.evelin_done_romfsuser@evelinbsp:~/ev-sdk/workspace/evelin-bsp$At the end of the <strong>com</strong>pilation, the directory ~/ev­sdk/workspace/evelin­bsp/images will contain the following files:1. uImage: the <strong>Linux</strong> 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 formU­Boot is configured to be loaded at address 0xb1000000; the <strong>Linux</strong> 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 <strong>Linux</strong> distributionFollow the Section (http://server.eraproject.org:8080/wiki/index.php/<strong>Linux</strong>_<strong>Distribution</strong>_<strong>For</strong>_<strong>Xilinx</strong>_<strong>MicroBlaze</strong>#Flashing_and_running_the_<strong>Linux</strong>_distribution).Advanced topicsManual tricking the u­boot/<strong>Linux</strong> configuration


Changes of xparameters.hThe configuration of u­boot and <strong>Linux</strong> 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 <strong>Linux</strong>. 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$rmimages/.evelin_done_linuxuser@evelinbsp:~/ev-sdk/workspace/evelin-bsp$sb2makelinuxMakefile:31:includedotconfig"linux/linux-2.6.37-microblaze"Startbuilding<strong>Linux</strong>...if[!-flinux/linux-2.6.37-microblaze/.config];then\echo"ERROR:<strong>Linux</strong>.configfilenotfound";\echo"Pleaserunmakemenuconfig";\exit1;\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$rmimages/.evelin_done_ubootuser@evelinbsp:~/ev-sdk/workspace/evelin-bsp$sb2makeu-boot........Note: the following pathnames are relative to the BSP installation path (usually /home/user/ev­sdk/workspace/evelib­bsp).U­Boot configuration fileThe 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)<strong>Linux</strong> kernel configuration fileThe 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 instructionCONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTRmust be 1 if the Microblaze cpu has the PCMP instuctionCONFIG_XILINX_MICROBLAZE0_USE_BARRELmust be 1 if the barrel can be usedCONFIG_XILINX_MICROBLAZE0_USE_DIVmust be 1 if the DIV instruction can be usedCONFIG_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 FPUCONFIG_XILINX_MICROBLAZE0_HW_VERthe hardware version (usually, for Virtex6, "8.10.a")CONFIG_XILINX_MICROBLAZE0_FAMILYthe Microblaze family (usually an empty string)


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 <strong>com</strong>plex directory layout).michael@panicking:~/evelin-bsp$sudomount-tauto/dev/sdf1/mntmichael@panicking:~/evelin-bsp$sudocpimages/booting.ace/mntmichael@panicking:~/evelin-bsp$sudoumount/mntInsert 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.TroubleshootingWhen something went wrong, a red led lights.Check the 'sace mode' dip switch bank: the 'SysAce mode' must be on. Your <strong>com</strong>pact 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 filesystemThe era_hw_reference_project contains RAM memory and Flash memory.Component Start address SizeRAM 0xb0000000 256 MBFlash 0x9c000000 32 MBWe use the 'xmd' tools to transfer all to the board (from the EDK system). The transfer can take a long time.michael@panicking:~$cdevelin-bsp/images/michael@panicking:~/evelin-bsp/images$xmd<strong>Xilinx</strong>MicroprocessorDebugger(XMD)Engine<strong>Xilinx</strong>EDK12.1BuildEDK_MS1.53dCopyright(c)1995-2009<strong>Xilinx</strong>,Inc. Allrightsreserved.XMD%connectmbmdmJTAGchainconfiguration--------------------------------------------------Device IDCode IRLength PartName1 0a001093 8 System_ACE_CF2 24250093 10 XC6VLX240T<strong>MicroBlaze</strong>ProcessorConfiguration:-------------------------------------Version............................7.30.aOptimization.......................PerformanceInterconnect.......................PLBv46MMUType...........................Full_MMUNoofPCBreakpoints...............1NoofReadAddr/DataWatchpoints...0NoofWriteAddr/DataWatchpoints..0InstructionCacheSupport..........onInstructionCacheBaseAddress.....0xb0000000InstructionCacheHighAddress.....0xbfffffffDataCacheSupport.................onDataCacheBaseAddress............0xb0000000DataCacheHighAddress............0xbfffffffExceptions Support................onFPU Support.......................offHardDividerSupport...............onHardMultiplierSupport............on-(Mul64)BarrelShifterSupport.............onMSRclr/setInstructionSupport....onCompareInstructionSupport........onPVRSupported......................onPVRConfigurationType.............FullDataCacheWrite-backSupport......offConnectedto"mb"target.id=0StartingGDBserverfor"mb"target(id=0)atTCPportno1234XMD%lsace booting.acerootfs.jffs2 u-boot.bin uImagexilinx.dtb xilinx.dtsXMD%dow-dataxilinx.dtb0xb2000000DownloadingDataFile--xilinx.dtbat0xb2000000XMD%dow-datauImage0xb3000000DownloadingDataFile--uImageat0xb3000000


XMD%dow-datarootfs.jffs20xb8000000DownloadingDataFile--rootfs.jffs2at0xb8000000XMD%stopXMD%rwrpc0xb1000000XMD%conRUNNING>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-cConnectingto/dev/ttyUSB0,speed9600Escapecharacter:Ctrl-\(ASCII28,FS):enabledTypetheescapecharacterfollowedbyCtogetback,orfollowedby?toseeotheroptions.----------------------------------------------------SDRAM:Icache:ONDcache:OFFU-BootStart:0xb1000000FLASH:32MiBUsingdefaultenvironmentNet: <strong>Xilinx</strong>_EmacliteMAC: 00:e0:0c:00:00:fdU-BOOTforevidence-mbHitanykeytostopautoboot: 0evidence-mb>'evidence­mb>' is the prompt of u­boot visible from a serial line console. U­Boot has been loaded from the SysACE <strong>com</strong>pactflash and now is running. Now we can transfer the system into the flash memory. First of all the flash must be partitioned.evidence-mb>mtdpartsdefaultevidence-mb>mtdpartsdevicenor0,#parts=5#:name size offset mask_flags0:u-boot 0x00100000 0x00000000 01:env 0x00040000 0x00100000 02:fdt 0x00020000 0x00140000 03:kernel 0x00400000 0x00160000 04:jffs2 0x01aa0000 0x00560000 0activepartition:nor0,0-(u-boot)0x00100000@0x00000000defaults: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>erasenor0,0EraseFlashPartitionnor0,0,bank0,0x9c000000-0x9c0fffff........doneErased8sectorsevidence-mb>cp.b0xb10000000x9c0000000xCE5BACopytoFlash....0doneevidence-mb>erasenor0,2EraseFlashPartitionnor0,2,bank0,0x9c140000-0x9c15ffff.doneErased1sectorsevidence-mb>cp.b0xb20000000x9c1400000x34ECCopytoFlash....0doneevidence-mb>erasenor0,3EraseFlashPartitionnor0,3,bank0,0x9c160000-0x9c55ffff................................doneErased32sectorsevidence-mb>cp.b0xb30000000x9c1600000x2E1044CopytoFlash....0doneevidence-mb>erasenor0,4EraseFlashPartitionnor0,4,bank0,0x9c560000-0x9dffffff


UDP-Litehashtableentries:256(order:0,4096bytes)NET:Registeredprotocolfamily1RPC:Registeredudptransportmodule.RPC:Registeredtcptransportmodule.RPC:RegisteredtcpNFSv4.1backchanneltransportmodule.SkippingunavailableRESETgpio-2(reset)GPIOpinisalreadyallocatedJFFS2version2.2.(NAND)(SUMMARY) ©2001-2006RedHat,Inc.msgmnihasbeensetto501BlocklayerSCSIgeneric(bsg)driverversion0.4loaded(major254)ioschedulernoopregisteredioschedulerdeadlineregisteredioschedulercfqregistered(default)Serial:8250/16550driver,4ports,IRQsharingdisabled84000000.serial:ttyUL0atMMIO0x84000000(irq=2)isauartliteconsole[ttyUL0]enabled9c000000.flash:Found1x16devicesat0x0in16-bitbank.ManufacturerID0x000089ChipID0x008919Intel/SharpExtendedQueryTableat0x010AIntel/SharpExtendedQueryTableat0x010AIntel/SharpExtendedQueryTableat0x010AIntel/SharpExtendedQueryTableat0x010AIntel/SharpExtendedQueryTableat0x010AUsingbufferwritemethodUsingauto-unlockonpower-up/resumecfi_cmdset_0001:Erasesuspendonwriteenablederaseregion0:offset=0x0,size=0x20000,blocks=255eraseregion1:offset=0x1fe0000,size=0x8000,blocks=45cmdlinepartpartitionsfoundonMTDdevice9c000000.flashCreating5MTDpartitionson"9c000000.flash":0x000000000000-0x000000100000:"u-boot"0x000000100000-0x000000140000:"env"0x000000140000-0x000000160000:"fdt"0x000000160000-0x000000560000:"kernel"0x000000560000-0x000002000000:"jffs2"of:xilinx_emaclite81000000.ethernet:DeviceTreeProbing<strong>Xilinx</strong>EmacliteMDIO:probedof:xilinx_emaclite81000000.ethernet:MACaddressisnow00:0a:35:ac:99:00of:xilinx_emaclite81000000.ethernet:<strong>Xilinx</strong>EmacLiteat0x81000000mappedto0xD2180000,irq=1DeviceTreeProbing'i2c'of:iic81660000.i2c:noIRQfound.of:iic:probeof81660000.i2cfailedwitherror-1DeviceTreeProbing'i2c'of:iic81640000.i2c:noIRQfound.of:iic:probeof81640000.i2cfailedwitherror-1DeviceTreeProbing'i2c'of:iic81620000.i2c:noIRQfound.of:iic:probeof81620000.i2cfailedwitherror-1DeviceTreeProbing'i2c'of:iic81600000.i2c:noIRQfound.of:iic:probeof81600000.i2cfailedwitherror-1TCPcubicregisteredNET:Registeredprotocolfamily1wVFS:Mountedroot(jffs2filesystem)ondevice31:4.Freeingunusedkernelmemory:96kfreedStartingrcS...++Creatingdevicepoints++Mountingfilesystem++Loadingsystemloggers++Startingnetworkudhcpc(v1.18.4)startedSendingdiscover...PHY:c000ba40:07-LinkisDownPHY:c000ba40:07-LinkisUp-100/FullSendingdiscover...Sendingselectfor192.168.97.187...Leaseof192.168.97.187obtained,leasetime345600addingdns192.168.97.1++Startingtelnetdaemon++StartingftpddaemonrcSComplete/bin/sh:can'taccesstty;jobcontrolturnedoff/#TroubleshootingSometimes 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 <strong>com</strong>mand must be hexadecimal.Booting


All the <strong>com</strong>ponents of the system are into the SysACE <strong>com</strong>pact 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.shmichael@panicking:~/evelin-bsp$kermit-cConnectingto/dev/ttyUSB0,speed9600Escapecharacter:Ctrl-\(ASCII28,FS):enabledTypetheescapecharacterfollowedbyCtogetback,orfollowedby?toseeotheroptions.----------------------------------------------------SDRAM:Icache:ONDcache:OFFU-BootStart:0xb1000000FLASH:32MiBUsingdefaultenvironmentNet: <strong>Xilinx</strong>_EmacliteMAC: 00:e0:0c:00:00:fdU-BOOTforevidence-mbHitanykeytostopautoboot: 0##BootingkernelfromLegacyImageat9c160000...ImageName: <strong>Linux</strong>-2.6.37-00717-ga7ace98ImageType: <strong>MicroBlaze</strong><strong>Linux</strong>KernelImage(un<strong>com</strong>pressed)DataSize: 3026948Bytes=2.9MiBLoadAddress:b0000000EntryPoint: b0000000VerifyingChecksum...OK##FlattenedDeviceTreeblobat9c140000Bootingusingthefdtblobat0x9c140000LoadingKernelImage...OKOKearly_printk_consoleisenabledat0x84000000Ramdiskaddr0x00000003,FDTat0x9c140000<strong>Linux</strong>version2.6.37-00717-ga7ace98(user@evelinbsp)(gccversion4.1.2)#27MonMay3008:51:54PDT2011setup_cpuinfo:initialising........................NET:Registeredprotocolfamily1wVFS:Mountedroot(jffs2filesystem)ondevice31:4.Freeingunusedkernelmemory:96kfreedStartingrcS...++Creatingdevicepoints++Mountingfilesystem++Loadingsystemloggers++Startingnetworkudhcpc(v1.18.4)startedSendingdiscover...PHY:c000ba40:07-LinkisDownPHY:c000ba40:07-LinkisUp-100/FullSendingdiscover...Sendingselectfor192.168.97.187...Leaseof192.168.97.187obtained,leasetime345600addingdns192.168.97.1++Startingtelnetdaemon++StartingftpddaemonrcSComplete/bin/sh:can'taccesstty;jobcontrolturnedoff/#Compiling applications for <strong>MicroBlaze</strong>: Evelin SDKEvelin SDK is the development environment made by Evidence. It to <strong>com</strong>pile the Evelin BSP <strong>Linux</strong> distribution, theSupervisor and other applications for the <strong>MicroBlaze</strong>. 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.


Writing an applicationThis example of application <strong>com</strong>putes the Fibonacci's sequence numbers.The source codeFirst of all, build the directory structure:user@evelinbsp:~$cdev-sdk/workspace/user@evelinbsp:~/ev-sdk/workspace$mkdirfibonacciuser@evelinbsp:~/ev-sdk/workspace$cdfibonacci/user@evelinbsp:~/ev-sdk/workspace/fibonacci$mkdirsrcThen, use an editor (vi, emacs, gedit, etc.) to write the src/fibonacci.c file:/**MadeusingEvelinSDkforMicroblaze*EvidenceSrl --- */#include#include#includestaticvoidfibonacci(intx,inty){if(x>10000)return;printf("%i",x);fibonacci(y,x+y);}intmain(){constchar*s="MadeusingEvelinSDK";intn;n=puts(s);fflush(stdout);fibonacci(0,1);printf("\n");return0;}Finally, write the Makefile:#MadeusingEvelinSDkforMicroblaze#EvidenceSrlCC=gccCFLAGS=-ansi-Wall-g2SRC=src/fibonacci.cOBJ=src/fibonacci.o.PHONY:allcleanall:fibonacciclean:-rm$(OBJ)-rmfibonaccifibonacci:$(OBJ)gcc-ofibonacci$(OBJ)Note: the Makefile will use gcc to <strong>com</strong>pile the applicationCompiling the applicationWe use the scratchbox2 tool to build the application using the <strong>com</strong>mand sb2 make:user@evelinbsp:~/ev-sdk/workspace/fibonacci$sb2makegcc-ansi-Wall-g2 -c-osrc/fibonacci.osrc/fibonacci.cgcc-ofibonaccisrc/fibonacci.ouser@evelinbsp:~/ev-sdk/workspace/fibonacci$


The file fibonacci is generated.Note: scratchbox2 automatically handles all the cross <strong>com</strong>pilation issuesRunning the applicationOn the host systemThe file fibonacci has been <strong>com</strong>piled 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:Nosuchfileordirectoryuser@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./fibonacciMadeusingEvelinSDK011235813213455891442333776109871597258441816765user@evelinbsp:~/ev-sdk/workspace/fibonacci$On the MicroblazeFirst, 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$ftpmbboardConnectedtombboard.priv.mgsi.eu.220OperationsuccessfulName(mbboard:user):230OperationsuccessfulRemotesystemtypeisUNIX.Usingbinarymodetotransferfiles.ftp>putfibonaccilocal:fibonacciremote:fibonacci200Operationsuccessful150Oktosenddata226Operationsuccessful9357bytessentin0.00secs(19525.0kB/s)ftp>exit221Operationsuccessfuluser@evelinbsp:~/ev-sdk/workspace/fibonacci$telnetmbboardTrying192.168.97.187...Connectedtombboard.priv.mgsi.eu.Escapecharacteris'^]'./#chmod+xfibonacci/#./fibonacciMadeusingEvelinSDK011235813213455891442333776109871597258441816765/#exitConnectionclosedbyforeignhost.user@evelinbsp:~/ev-sdk/workspace/fibonacci$Debugging the applicationWorkaround: 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)orto link your application statically (using the ­static gcc flag); you should clean the project and rebuild the application.On the host system


Start the application to be debugged through sb2 with an emulator that accepts remote gdb <strong>com</strong>mands from a TCP/IPconnection on port 1234 of localhost:user@evelinbsp:~/ev-sdk/workspace/first_microblaze_test$sb2qemu-microblaze-g1234./mainNote: the evelinbsp prompt does not appear, the application is waiting for gdb <strong>com</strong>mands.Then, use a another terminal to start the debugger:user@evelinbsp:~/ev-sdk/workspace/first_microblaze_test$mb-linux-gdbGNUgdb(GDB)7.2Copyright(C)2010FreeSoftwareFoundation,Inc.LicenseGPLv3+:GNUGPLversion3orlaterThisisfreesoftware:youarefreetochangeandredistributeit.ThereisNOWARRANTY,totheextentpermittedbylaw. Type"showcopying"and"showwarranty"fordetails.ThisGDBwasconfiguredas"--host=i686-pc-linux-gnu--target=microblaze-unknown-linux-gnu".<strong>For</strong>bugreportinginstructions,pleasesee:.(gdb)Note: the prompt of gdb is '(gdb) ',Select the target to be run and load the symbols:(gdb)targetremotelocalhost:1234Remotedebuggingusinglocalhost:1234[NewRemotetarget][SwitchingtoRemotetarget]0x10000100in??()(gdb)file./mainAprogramisbeingdebuggedalready.Areyousureyouwanttochangethefile?(yorn)yReadingsymbolsfrom/home/user/ev-sdk/workspace/first_microblaze_test/main...done.(gdb)Start debugging your program. <strong>For</strong> example, you can set a breakpoint at line 16 of the main source file:(gdb)list3 * byEvidenceSrl --- 4 */56 #include7 #include8910 intmain()11 {12 constchar*s="MadeusingEvelinSDK";(gdb)list13 intn;1415 n=puts(s);16 fflush(stdout);1718 printf("Helloworld!\n");1920 return0;2122 }(gdb)break16Breakpoint1at0x1000028c:filesrc/main.c,line16.(gdb)infobreakNum Type DispEnbAddress What1 breakpoint keepy 0x1000028cinmainatsrc/main.c:16(gdb)You can run the application and see the values of some variables:(gdb)contContinuing.Breakpoint1,main()atsrc/main.c:16


16 fflush(stdout);(gdb)printn$1=22(gdb)prints$2=0x10072f28"MadeusingEvelinSDK"(gdb)Note that the output of the program is shown into the other terminaluser@evelinbsp:~/ev-sdk/workspace/first_microblaze_test$sb2qemu-microblaze-g1234./mainMadeusingEvelinSDKContinue to debug until the end:(gdb)contContinuing.Programexitednormally.(gdb)The <strong>com</strong>plete output of the programuser@evelinbsp:~/ev-sdk/workspace/first_microblaze_test$sb2qemu-microblaze-g1234./mainMadeusingEvelinSDKHelloworld!user@evelinbsp:~/ev-sdk/workspace/first_microblaze_test$Using EclipseYou can start Eclipse clicking the Evelin SDK Eclipse icon or using the <strong>com</strong>mand '/home/user/ev­sdk/bin/scratchbox/bin/evsdk­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 projectCreating a project for Microblaze is a simple task: click on File/New/New Scratchbox2 project


A wizard appears; type the name of your project and press next:Then choose your target cpu, select to generate a source code sample and press finish:


Your project has been created, a source sample has been created and has been built:Modifying the sourcesYou can edit the source code:If you save your changes the project will be automatically rebuilt.Running the applicationOn the host systemTo run the application, select Run/Run configurations...


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.


On the <strong>MicroBlaze</strong>You must use the same steps explainend in #On the <strong>MicroBlaze</strong>.The project directory is located in /home/user/ev­sdk/workspace/first_microblaze_testDebugging the applicationOn the host systemTo 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:


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. <strong>For</strong> 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 <strong>com</strong>mands.


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 <strong>Xilinx</strong> EDKIn some cases you may need to use some tools provided by the <strong>Xilinx</strong> 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 <strong>Xilinx</strong>2. Install the EDK on a different <strong>Linux</strong> system and connect it to the virtual machine.


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-bspevelinbsp:/home/user/era_hw_reference_project/home/michael/evelin-bspnfsdefaults00/home/michael/era_hw_reference_projectnfsdefaults00User permission troubleshootingIf 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 user3. change the uid of the user 'user' into the BSP system to match the uid of the EDK system using the <strong>com</strong>and sudousermod ­g NEW_GID ­u NEW_UIDRetrieved from "http://server.era­project.org:8080/wiki/index.php/<strong>Linux</strong>_<strong>Distribution</strong>_<strong>For</strong>_<strong>Xilinx</strong>_<strong>MicroBlaze</strong>"This page was last modified on 4 July 2013, at 07:38.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!