How to get eCos running on the Xilinx ML403 evaluation board (c) 2006/05/10 Enno Lübbers University of Paderborn Department of Computer Science Computer Engineering Group This mini-HOWTO aims at setting up the Xilinx ML403 evaluation platform so that an eCos application (in this case, the eCos bootloader, RedBoot) can be executed on it and use most of the board's peripherals. It utilizes a reference design provided by Xilinx and a patch to eCos published by Mind NV. My thanks go to Mind NV, Belgium, for publishing the first patch. DISCLAIMER: Use this HOWTO at your own risk. This is work in progress. I will not take any responsibility for whatever might happen to your board, yourself or anything else in general. That being said, any comments, suggestions or corrections to this HOWTO are most welcome. REQUIREMENTS ============ What you will need: - a Xilinx Virtex-4 ML403 Embedded Platform (http://www.xilinx.com/ml403), which is an evaluation board consisting of a Virtex-4 FX FPGA with an embedded PowerPC405 CPU core and numerous peripherals (UART, Ethernet, VGA etc.). You'll also need a suitable programming device, such as the Xilinx Parallel IV or Platform USB cable. - Xilinx EDK8.1.01i (later service packs might work as well), which in turn requires ISE8.1. - The "ML403 EDK Embedded PowerPC Reference Design" for 8.1 from Xilinx: http://www.xilinx.com/products/boards/ml403/files/\ ml403_emb_ref_ppc_81.zip I'll assume you unzipped this file to $REFDESIGN, so you'll have a directory structure like $REFDESIGN +- projects/ | +- ml403_emb_ref_ppc/ | +- ... +- sw/ +- ... - eCos release 2.0 (from ecos.sourceware.org), which includes the graphical configuration tool and the GNU toolchain for PPC. Detailed instructions for downloading and installing can be found under http://ecos.sourceware.org/getstart.html under the heading "eCos". When using the ecos-install.tcl (which you should), be sure to get the GCC PowerPC toolchain as well. NOTE: It is recommended to configure and build eCos under Linux. I used a separate Linux box for this purpose, while my Xilinx tools ran on Windows. - an anonymous CVS checkout of the ecos sources. The patch mentioned later in this document was created against the ecos CVS repository as of 3th May 2006. To get a current snapshot, follow the instructions on http://ecos.sourceware.org/anoncvs.html For the remainder of this howto, I will assume that you checked out into the directory $ECOS, i.e. the directory structure looks something like $ECOS/ +- ecos/ +- packages/ +- ... - the patch from http://www.upb.de/cs/ag-platzner/people/luebbers/stuff/ecos/ This patch was created by trying to apply the patch from Mind NV (http://mind.be/virtex/ecos/ml403/) to current ecos CVS sources and resolving the conflicts. Note that this patch is neither endorsed by Mind NV nor an official eCos patch, meaning it might break some eCos functionality, especially when used for a platform other than the Xilinx ML403. Because I occasionally check it against a current version of the eCos anonymous CVS repository, it may contain a few unneccessary patches like empty lines. - the file "xparameters_translation.h" from http://www.upb.de/cs/ag-platzner/people/luebbers/stuff/ecos/ CREATING THE HARDWARE DESIGN ============================ The patch includes support for most peripheral components included in the Xilinx "ML403 EDK Embedded PowerPC Reference Design". So all we need to do is synthesize the design with EDK and load it onto the FPGA. To do this, follow these quick instructions. - start EDK8.1 - open the project file $REFDESIGN/projects/ml403_emb_ref_ppc/system.xmp - click on the "Applications" tab and make sure that only the "Default: ppc405_0_bootloop" is selected to initialize the BRAMs, and all other projects are inactive (you can right-click them to change settings) - choose "Hardware->Generate Bitstream" from the menu - take a coffee break - make sure that only warnings occured, and no errors, i.e. that the bitstream was created successfully - choose "Software->Generate Libraries and BSPs" from the menu - choose "Device Configuration->Update Bitstream" from the menu Now you've got a FPGA configuration bitstream containing the soft peripherals for ethernet, UART, AC97, SysACE etc. and a bootloop program that will keep the processor busy after you program the FPGA. You can use the iMPACT tool or EDK for downloading the configuration to the ML403 board. Make sure the board is connected via JTAG to your host PC running EDK, and choose "Device Configuration->Download Bitstream" from the menu. If the INIT LED on the board turns on, you're all set. PATCHING ECOS ============= This is straightforward. Just change into your $ECOS directory and execute $> patch -p1 < $PATH_TO_ECOS_ML403_PATCH/ecos-ml403.patch where $PATH_TO_ECOS_ML403_PATCH is - you guessed it - the path to the ecos-ml403 patch. COMPILING REDBOOT ================= In this section we will create a RedBoot image to load onto the ML403 board which is now configured with Xilinx' reference design. After this, you will find creating "standard" eCos applications quite similar. Refer to the eCos book at http://ecos.sourceware.org/docs.html for more details. I assume that you have already installed the ecos-2.0 distribution as outlined in the REQUIREMENTS section. Now, - create a project directory (e.g. ml403-redboot) somewhere. I'll call that directory $PROJECT - copy the ppc405_0-directory from the (compiled) Xilinx ml403 reference design ($REFDESIGN/projects/ml403_emb_ref_ppc/ppc405_0) to a new folder in your project directory (e.g. $PROJECT/bsp) - copy the xparameters_translation.h you downloaded to the $PROJECTS/bsp/ ppc405_0/include/ directory - set the environment variable $HW_DESIGN to your $PROJECT/bsp directory and launch the configtool: $> export HW_DESIGN=/bsp/; \ $PATH_TO_YOUR_ECOS-2.0_INSTALLATION/ecos/tools/bin/configtool - choose "Build->Repository..." from the menu and select the patched CVS sources (e.g. $ECOS/ecos) - choose "Build->Templates..." from the menu and select the "XILINX VIRTEX4 PowerPC 405" hardware as well as the "redboot" package template. The configuration tool will complain about unresoved dependencies - just accept the proposed solutions. This will setup eCos for our architecture - choose "File->Import..." from the menue and import $ECOS/ecos/packages/ hal/powerpc/virtex4/current/misc/redboot_ROMRAM.ecm. This sets some useful options for building the redboot image. - now you can enable or disable specific eCos/RedBoot components. For example, it would be useful to have UART and ethernet support in RedBoot, so select the appropriate options in the configuration tree under "eCos HAL/PowerPC architecture/XILINX VIRTEX4 (PowerPC 405) board". Some of the options are labeled "Should be set in BSP"; you can see which driver is meant by looking at the Macro name in the upper right window. Other options you might want to look at include the RedBoot networking support under "Redboot ROM monitor", especially the DHCP and IP address settings. - save the project as something like "ml403-redboot.ecc" in your $PROJECT directory. - now copy the libxil.a library, which includes all Xilinx-specific code like the ethernet or SystemACE drivers, from $PROJECT/bsp/ppc405_0/lib to $PROJECT/ml403-redboot_install/lib - edit the linker script $PROJECT/ml403_redboot_install/lib/target.ld, adding libxil.a to the list of libraries in the GROUP section. This will instruct the linker to look in libxil.a for the Xilinx code - back in the configtool, you can now press F7 or select "Build->Library" from the menu to build the ecos library and the redboot image - the finished redboot binary will be in your $PROJECT/ ml403-redboot_install/bin/ directory under the filename "redboot.elf". Copy this file to $REFDESIGN/projects/ml403_emb_ref_ppc/ppc405_0/code/. DOWNLOADING THE REDBOOT IMAGE ============================= You can upload this redboor.elf (or any other executable) to your board through JTAG, using the Xilinx Microprocessor Debugger (XMD). Either choose "Debug->Launch XMD..." from the EDK's menu, or change to your $REFDESIGN/ projects/ml403_emb_ref_ppc/ directory and type $> xmd -xmp system.xmp -opt etc/xmd_ppc405_0.opt This will open the XMD and connect to the PowerPC on the FPGA. The XMD allows you to read and modify register and memory contents, debug programs on the PPC, and, most importantly, load ELF executables into memory. Connect a crossed serial cable (a "nullmodem" cable) between your host PC and the ML403 board. Start a terminal program (such as minicom or Hyperterminal) and set the connection to 9600 8N1 (or whatever you specified while configuring eCos). Now type XMD% dow ppc405_0/code/redboot.elf into the XMD window, and, after the image has been loaded, XMD% run If you see some activity on the serial console, eventually resulting in a "RedBoot>" prompt, rejoice! You now have eCos/RedBoot running on the ML403. CREATING AN ACE FILE ==================== The SystemACE controller on the ML403 is able to both configure the FPGA _and_ load an executable into RAM on power-up. The configuration bitstream and the executable file can be loaded from an .ace file on a compact flash card. To create an .ace file (e.g. from our download.bit amd redboot.elf), change into your $REFDESIGN/projects/ml403_emb_ref_ppc/ directory and type $> xmd -tcl genace.tcl -jprog -board ml403 \ -hw implementation/download.bit -elf ppc405_0/code/redboot.elf \ -ace redboot.ace If you run into an error like "Executable redboot.elf does not contain start address", try Xilinx Answer Record #23192 at http://www.xilinx.com/xlnx/xil_ans_display.jsp?getPagePath=23192 which tells you to change line 378 of %XILIND_EDK%\data\xmd\genace.tcl from calling mb-objdump to calling powerpc-eabi-objdump. It might also help to set your $PATH correctly before issuing the above xmd command. The resulting redboot.ace file can be copied onto the ML403 compact flash card into the directory /ml403/myace. Be sure to rename the existing system_my_ace.ace into system_my_ace.ace.bak, so that there is only one file with an .ace extension in that directory. Plug the CF card back into the ML403, set the configuration DIP switches to "110111" and apply power to the board. Alternatively, you can set the DIP switches to "000111" and choose "My ACE File" from the menu. You should now be able to see the RedBoot prompt on the serial line.