Download a Linux distribution for Xilinx’ Microblaze

This post was written by eli on September 18, 2011
Posted Under: Linux,Microblaze

If you want to get to it, just go to the Xillybus mini-distro for Microblaze’s page.

This distribution is a software kit, which allows you to run a functional Linux system on the SP605 or ML605 hardware evaluation kit (for Spartan-6 and Virtex-6, respectively). All components necessary to build it will be available for download at no cost (partly from Xilinx’ site). The distribution is not a demo kit; it’s a kickstart for a real-life application.

The steps to reaching a functional system include installing pieces of software, and perform specific and rather trivial operations as described in detail. No prior knowledge on either FPGA nor Linux is necessary. Your computer may run either Windows or Linux for running this through.

This distribution will allow you to

  • Run a Linux system which is ready for working with, including a DHCP client, telnet, ftp, a small web server, mounting of NFS as well as Windows (SMB) shares. The CompactFlash card will also serve as the local disk which can be written to.
  • Easily compile your own user-space applications in with “make” and gcc (a ready-to-go cross-compilation environment will be available for download as well). Compilation is possibly dynamic against libraries which are part of the distro.
  • Easily develop your own Linux-reachable peripherals on the FPGA using the Xillybus IP core, and transport data between the FPGA and Linux user space applications with minimal effort.

Required hardware

  • A Xilinx SP605 evaluation kit or ML605 ditto.
  • A Sandisk CompactFlash card, with at least 512 MB. Let me emphasize this: Make it a Sandisk card, and not anything else. You may get away with using other cards for a one-off loading with data and multiple reads, but the Linux system is going to use this storage as its hard disk. Anything else than Sandisk, including the card which comes with the evaluation kit itself, is most likely to have reliability problems, which will give you a very wrong impression regarding the Linux system’s stability. Believe me, I’ve tried quite a few. Also, try to make the card not bigger than 8 GB, as the SysACE chip’s support of larger cards is questionable.
  • A CompactFlash to USB adapter. There is no special requirements here, as long as your operating system recognizes it, and it’s reliable. Which holds true even for those cheap universal card readers available on Ebay.

As mentioned above, this is in the Xillybus mini-distro for Microblaze’s page.

Required hardware

Before starting, please make sure you have the following equipment:

  • A Xilinx SP605 evaluation kit (hardware).
  • A Sandisk CompactFlash card, with at least 512 MB. Let me emphasize this: Make it a Sandisk card, and not anything else. You may get away with using other cards for a one-off loading with data and multiple reads, but the Linux system is going to use this storage as its hard disk. Anything else than Sandisk, including the card which comes with the evaluation kit itself, is most likely to have reliability problems, which will give you a very wrong impression regarding the Linux system’s stability. Believe me, I’ve tried quite a few. Also, try to make the card not bigger than 8 GB, as the SysACE chip’s support of larger cards is questionable.
  • A CompactFlash to USB adapter. There is no special requirements here, as long as your operating system recognizes it, and it’s reliable. Which holds true even for those cheap universal card readers available on Ebay.

Files to download

  • The CompactFlash image
  • The FPGA bundle

Downloading and installing the Xilinx EDK

Unless you already have Xilinx’ ISE Design suite with version 13.2 or above, you’ll need to download the installation image. If you don’t have the Embedded version, you’ll need to acquire a license.

The magnitude of the downloaded file is 4-5 GB, so kick this off as soon as possible. To do so:

  • Navigate to Xilinx website at http://www.xilinx.com/, and register as a new user if you don’t have an account on the site. You’ll need to provide a valid password, as well as other details about yourself. Xilinx allows access to file downloads only to registered users.
  • Once logged in, navigate yourself to the page for download the ISE design suite (possibly this page). It’s best to download version 13.2, since the Xillybus bundle was successfully built with it. But it’s most likely OK to use newer versions. There is no need to request the Embedded suite at this point, since the same chunk is downloaded for all versions. The feature set is determined by the license, which is acquired later on. The software is available for Windows as well as Linux.
  • Once downloaded, install the software, following the instructions. This takes around an hour, and eats up some 15 GB of your disk. On Windows installations, it’s possible and common to divert from the default installation path in favor of one which doesn’t contain white spaces, and possibly on a non-C: partition. Installing on a network drive is not recommended, as it will slow down operation significantly.
  • The installation wizard will suggest acquiring a license. Choose a 30-day evaluation of the Embedded Edition of the ISE Design Suite. Follow the wizard’s instructions, which may vary, depending on your computer’s configuration. Note that license issues can be handled after the software is completely installed. On Windows, go to Start > Programs > Xilinx ISE Design Suite 13.2 > Accessories > Manage Xilinx Licenses.

Compiling applications

September 13th, 2011

C and C++ programs can be compiled easily to run on the Microblaze Linux platform. The binaries are dynamically linked against libraries, which are part of the mini-distro. This includes the well-known basic libraries such as glibc and libm, as well as libcrypt, libpthread, libresolv and several others (just list the files in the distro’s /lib for all of them).

To get started immediately, just download the application cross-compilation tarball. Open it anywhere on a Linux computer’s file hierarchy (no superuser access is necessary) and you’re ready to go right away. There is no “installation” necessary.

This package runs on 32-bit Linux as well as 64-bit. A suitable cross compiler for Windows is currently not available.

The cross compilation package has three subdirectories: gnutools, example1 and example2. The gnutools subdirectory contains the GNU cross compiler, libraries and utilities. There is no need to look under the hood here.

The two other subdirectories each consist of a Makefile and a sample file to compile. Just change directory to either of them, and type “make” at shell prompt to compile an executable which runs on the platform under Linux.

These are templates for compiling real applications. We’ll look at the Makefile in the example1 subdirectory:

GNUPREFIX=../gnutools/microblazeel-unknown-linux-gnu/bin/microblazeel-unknown-linux-gnu-

CC=$(GNUPREFIX)gcc
AR=$(GNUPREFIX)ar
AS=$(GNUPREFIX)as
CXX=$(GNUPREFIX)g++
LD=$(GNUPREFIX)ld
STRIP=$(GNUPREFIX)strip

CFLAGS=-Wall -I. -O3

APPLICATION=hello

OBJECTS=#somefile.o somefile2.o etc

all: $(APPLICATION)

$(APPLICATION): $(OBJECTS) $(APPLICATION).o
	$(CC) $(CFLAGS) $(OBJECTS) $(APPLICATION).o -o $(APPLICATION)

clean:
	rm -f *~ $(APPLICATION) *.o

The first line sets the internal variable GNUPREFIX. It’s given as a relative path to the gnutools directory. This is done to make the bundle run out of the box, but it’s also possible to decide on a certain absolute path for the gnutools, and then set GNUPREFIX accordingly.

The CC, AR, AS, CXX, LD and STRIP variables are set so that GNU Make calls the cross compiler rather than the native compiler.

CFLAGS are the flags given to gcc on compilation. In particular, library dependencies go here. For example and as shown in the example2 subdirectory, if mathematical functions such as sin() are used, the “-lm” flag should be added here.

APPLICATION is the name of the final executable. It’s set here to “hello” so a C source file hello.c is expected to have the main() function.

OBJECTS is a space-delimited list of object targets: If the applications is divided into several source files, each should be listed here with the “.c” suffix replaced by “.o”.

The rest of the Makefile sets the targets, so that “make” and “make clean” work properly.

So all in all, this Makefile can be used to compile a fullblown software application targeted for the platform.

File system

September 10th, 2011

File system structure

The file system should look familiar to anyone who is at home with Linux/UNIX systems. Since embedded systems tend to get shut off accidentally, an effort has been made to keep essential files in filesystems mounted read-only. This goes for the root filesystem as well as the small FAT16 from which the System ACE chip reads the initial boot data. While these can be remounted for read-write, this should be avoided. Instead, a special partition has been set up for allowing write access. Files which are normally altered in the root filesystems have been replaced by symbolic links, as detailed below.

Users who have chosen a non-Sandisk CompactFlash should be advised that mounting a filesystem for write carries a significant chance of making it unmountable in the future, as repeated writes to system blocks may push a low-end flash device beyond its reliability.

The CompactFlash has been assigned three partitions:

  • Primary partition 1 (/dev/xsa1, 47MB). Configured as FAT16, and is intended to hold the xillybus.ace file, from which the System ACE chip configures the FPGA. Mounted read-only by default as /mnt/fat16 (or /rw/system/mnt/fat16, to be accurate).
  • Primary partition 2 (/dev/xsa2, 205MB). This ext2 partition is used as the root filesystem, and is mounted read-only by default.
  • Primary partition 3 (/dev/xsa3, 91MB). This ext2 partition is used for anything that needs to be written into the CompactFlash under normal operation. It’s mounted read-write by default at /rw.

The following files in the root filesystem are symbolic links:

  • /mnt to /rw/system/mnt — This allows creation of subdirectories on /mnt, and mounting /mnt/something. Unmounting is somewhat trickier, because the system knows the mount point by its full path, so for unmounting the full name, e.g. /rw/system/mnt/something must be used. Or the name of the device file, when applicable.
  • .ash_history to /rw/system/.ash_history
  • /etc/httpd.conf to /rw/system/httpd.conf
  • /etc/resolv.conf to /rw/system/resolv.conf — This allows the DHCP client to set up the DNS server list, despite the root file system being unmounted.

When necessary to write to the root partition, it can be remounted for read-write as follows:

# mount -o remount,rw /

And for the FAT16 partition:

# mount -o remount,rw /dev/xsa3

It’s recommended to remount them back as read-only as soon as possible after finishing whatever was needed to be done with them. For example, to remount the root partition back to read-only, go

# mount -o remount,ro /

And he FAT16 partition:

# mount -o remount,ro /dev/xsa3

Shutting down the system

Before powering down the card, the Linux system should be shut down properly, or problems may occur on the next reboot. The command for doing this is “halt”:

# halt

This runs a small script, which attempts to remount all partitions on the CompactFlash as read-only before running shutting down. If some process in the system has a file open for write, this will fail. In this case, use “ps” to track down the process, and possibly kill it (or kill -9) so that the filesystem can be released.

Execution environment

The Linux distribution has the basic set of libraries for dynamic linking, so basic applications can run on the platform just like on any Linux machine.

Even so, the lightweight busybox suite supplies all UNIX command-line utilities. Please consult busybox’ command summary to get a summary of the commands and their usage. Note that the installed version of busybox is v1.17.1, so the web site may reflect newer version (with possibly unsupported utilities). Type “busybox” at command prompt on the platform to get a full list of commands.

Custom rc file

When booting up, the script checks for the existence of an executable file at /rw/system/userrc. If such file exists, it’s run as the last stage of the boot process. This file can be used to e.g. set up networking automatically.

The file is run “as is”. If it’s a script, it must have a #! (shebang) header. It can also be an executable binary. Either way, don’t forget to set the executable flag for it, or it will be ignored.

For example, to make the platform available on the LAN with a constant address 10.12.14.16, /rw/system/userrc should read:

#!/bin/sh  

ifconfig eth0 10.12.14.16 netmask 255.0.0.0

and made executable:

/ # chmod a+x /rw/system/userrc

Note that the platform can also get an address with DHCP. See the section about networking.

Setting up network

September 8th, 2011

Networking

Connecting the card to a LAN is recommended. The Linux machine boots up with servers supporting telnet, ftp and CGI-enabled http (meaning that the card can be accessed with a web browser). On top of this, it’s possible to mount shared folders from both Linux and Windows machines. This is very convenient when developing applications, as there’s no need to copy the files back and forth from and to a fullblown computer to the embedded platform.

Please note that by enabling networking on the card, you expose it to complete control by anyone who can access it. Anyone with access to its network interface can gain superuser access to it without supplying any credentials whatsoever. This is usually not a concern when the card is run on an internal LAN, since the latter is usually behind a firewall preventing requests from the outer world. Nevertheless, it’s important to realize that the card comes with zero networking security (even though it’s possibly to take security measures on this platform).

Setting up Ethernet with DHCP

If there’s a DHCP server available, simply type “dhcp” at shell prompt. When successful, it typically looks like this:

/ # dhcp
udhcpc (v1.17.1) started
Sending discover...
PHY: c0729a0c:07 - Link is Up - 100/Full
Sending discover...
Sending select for 10.12.14.16...
Lease of 10.12.14.16 obtained, lease time 21600
deleting routers
route: SIOCDELRT: No such process
adding dns 10.0.0.1
adding dns 10.0.0.2
/ # eth0: no IPv6 routers present

If the DHCP server offers addresses to DNS servers, they will be used as well.

Setting up Ethernet manually

The network can be set up manually with an ifconfig command as well. For example, to assign the card an IP address of 10.12.14.16 with net mask 255.0.0.0:

/ # ifconfig eth0 10.12.14.16 netmask 255.0.0.0

To access computers beyond the LAN, a gateway must be specified. Note that by adding this gateway, the card becomes accessible to attackers from the whole internet, which it wouldn’t be otherwise (because it couldn’t establish a connection beyond the LAN).

Having that said, if the gateway is at 10.11.12.13, it’s declared with

/ # route add default gw 10.11.12.13

The gateway address must be within the previously given net mask, of course.

To set up DNS servers, edit /etc/resolv.conf as appropriate.

telnet, ftp and web server

Once the network is set up as shown above, connect to the platform with telnet and ftp as usual. No username or password are required for the telnet connections, and neither are they necessary for ftp. The connecting ftp application may prompt the user for these, but they are ignored by the platform; just supply anything you like.

To access the platform as a web server, simply open your browser and type e.g. http://10.11.12.13/ on the address bar. The IP should be adjusted to the one assigned to the platform, of course.

The platform can also contact servers with wget (possibly download web pages as well as data from ftp servers). ftpget and ftpput are simple ftp clients. Anyhow, it’s usually easier let the platform be the server as modern full-blown computers generally don’t have these services, as they’re problematic in terms of security.

When more than a single occasional file transfer is necessary, it’s wiser to mount a share, as described next.

Accessing shared folders over the network

The Linux kernel is configured to support network filesystem shares. Both UNIX/Linux NFS as well as Window’s SMB are supported, so files may be read and written to both UNIX and Windows computers.

Connection to a windows computer at 10.11.12.13, with the share name “mydisk”, Windows user name “theuser” and password “thepass” goes

# mount -o user=theuser,password=thepass //10.11.12.13/mydisk /mnt/try

(assuming that /mnt/try exists).

To mount an NFS share:

# mount 10.11.12.13:/thedir -o nolock,proto=tcp /mnt/try

The nolock option is crucial here. Without it, the mount simply hangs. But without the proto=tcp part, there’s a good chance that the NFS connection will hang sooner or later. In short use both.

Accessing files on the CompactFlash

Remounting / for read/write

/ # mount -o remount,rw /

Flow outline of docs

September 8th, 2011

General flow

Make the documentation page list out the recommended flow for reading

Microblaze docs

As follows:

  • Equipment: Sandisk CF, USB adapter
  • Using the Flash image to load the flash (Windows and Linux, Windows recommended)
  • Building the FPGA subsystem (downloading ISE, picking the project, creating bitfile and ACE)
  • Storing the ACE file in the Compact Flash
  • Booting: What to expect. Connecting Hyperterminal
  • The license: Use as is with no restriction, changes in FPGA using Xillybus for evaluation or licensed.
  • Setting up network (with DHCP and without)
  • Accessing files: NFS mount, SMB mount, files on CF (FAT and extra partition), remounting root as rw.
  • Compiling applications (hopefully with Xilinx’ compiler)
  • Trying out Xillybus, of course

General flow

  • The main page stays as is. Where applicable, Microblaze is added to where it says PCIe.
  • The docs are separated into two tabs in the main header (will be three): PCIe and Microblaze
  • The main image to be edited to represent the situation better. Maybe a penguin instead of computer.
  • An extra taxonomy term added for each page, which may be empty. It signifies specific-to: If one of its values is assigned, related pages must also have the same value. This will avoid mixing up pages for different pages. Some indication on each page may also be added.
  • The download page is split into the main one (what to expect) and a separate download page for PC and Microblaze.

Making money online: Get real

June 2nd, 2009

Money for nothing: Is it really possible?

Been there, done that: Offers to work from home. Become a billionaire in a minute. Or just making a whole lot of money without moving from your chair. The obvious scams are easy to tell: Buy this book and get rich! Join now, but you just need to pay this little fee (NOW! NOW!). What are a few dollars compared with the millions waiting for you?

It doesn’t work, of course. Some of these offers are nothings but scams, others make it sound so much easier than it is. Affiliate marketing, for example. There are zillions of surfers out there. How difficult could it be to make a million of them click on a banner?

And then we have these pyramids. They call it “referral marketing” but the bottom line is that you get the money your friends wasted. Which works pretty well, if you have a lot of people around you, who mistakenly considers you their friend.

Money doesn’t grow on trees, we’ve all been told. And still some people manage to get it easier than others. What’s their secret?

The key word is opportunity

Everyone who has tried to earn some extra money online will eventually tell you, that there are no free meals out there. The simple rule of supply and demand tells us, that if a deal is too attractive, it will soon balance itself towards am lower equilibrium point. So if someone paid more than the minimum to get the job done, the payment will soon fall as a result of overwhelming demand. Pure business logic means to give away as much as necessary, but not more.

When this logic breaks, we call it an opportunity. It’s when we are offered a deal which may look problematic, but has a potential. It’s a low price for something we’re not so sure about. The difference between a successful businessman and an eternal loser is the whether he can tell an opportunity from a waste of money and time. Some are better at it than others. But we all enjoy those opportunities in our real lives from time to time. It’s now time to do that online as well.

Where you can get a free meal for real

In our real lives, the opportunity to get something for free comes when a new business wants to hit the market. If you know someone who has just opened a restaurant or pub, you’re likely to be offered a free meal literally, just so the place won’t look empty. If you just walk by a new place, someone may approach you with a sincere and good deal. Nobody is playing a trick here; it’s taking advantage of a temporary situation.

The internet is no different. The opportunities are found where things start off. Once a web business reach cruise level, all you can hope for is to get a modest payment for your work. Or possibly use it as a platform for tricking money out of other people. Unless you’re very lucky in some lottery or sweepstakes.

A real online opportunity

Editaste started off on June 1st 2009 with a competition between editions. What an edition is, and all the other details about the competition itself are given at the site itself, so we’ll stick to the basic facts here: The site will hand out prizes to three winners every month, starting from August 1st. The top prize is a reasonable sum of $20 (via Paypal), which may not sound so much, but the way competition works, whoever wins once, has a good chance to keep that position. Starting off early is  important.

In order to participate, you’ll start an edition of your own, which is a bit like a blog, but you don’t have to be good at writing to have one. Instead, you need a good eye for things you can find on the web: Youtube clips, items from the news, or anything else one you watch with your browser. The whole idea is to collect these things (more or less clicking a button), and make this collection so good, that other people will subscribe to your edition, and check it out on a regular basis. If you’re on the web a lot anyhow, this is almost no extra effort.

The competition is about who manages to get the maximal number of regular readers. Your readers will see a fast-loading and simple interface with no hassle at all. Except for a few non-intrusive Google ads, all they’ll see is what you’ve picked for them. If you pick nice things for them, they’ll love it. And they’ll come back for more. In the end of the month, you have more of them than others, and there comes a nice sum through Paypal. It’s not like you did some real work for this. Want to try?

It’s not a pyramide

Most bring-your-friend offers involve a catch. Referral networks tend to ask you for a small startup fee and also from those you invite. They pay you with part of their money. In the end, there are some hard feelings, usually directed upwards in the pyramide. With yourself somewhere in the middle.

Not with Editaste. To begin with, there are no fees at all. And second, nobody you invite is going to be asked to do anything, except for to register. All they do is enjoy your picks. It doesn’t matter if they click the ads or not. All that matters is if they click what you brought to them. They win, you win. There is really no catch here.

The wagon is rolling

As with any opportunity, it’s temporary. Right now, if you start your edition, you’ll get an irreversible advantage: time and experience. Exactly like you’re hesitating right now, so is everybody else. Being first means making the move where others wait. No good opportunity looked good when it was there to be taken. It’s only afterwards that people realize that they had the chance, but missed it.

Besides, there is nothing to lose. You’re not asked to pay anything. If the absolute worst case, you’ll find that you’ve spent an unsignificant amount of time to collect nice things for others. That, in itself, isn’t so bad even if it’s not your intention.

Do you want to win? Don’t wait. Start your edition now and get a head start!

Hello world!

June 2nd, 2009

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

Reader Comments

Hello Eli billauer ,
I have a Nexys 4 FPGA Board .
I have prepared Microblaze Softcore to put it into FPGA .
I’m searching linux kernel to porte it with my Microblaze.
Can you help me to choose one that is compatible with Xilinx FPGA architecture.

Best regards

#1 
Written By Reddex on January 25th, 2014 @ 18:58

Well, I would suggest that you took a look on the Microblaze tutorial on this site: https://billauer.co.il/blog/2011/08/linux-microblaze-howto-tutorial-primer-1/

As for a Linux kernel, I don’t expect any significant differences between Microblaze processors, regardless of the FPGA they are running on. So the procedure should be more or less as described in the tutorial. The boot will be different, and that’s board specific, so I can’t help you much with that, unfortunately.

#2 
Written By eli on January 25th, 2014 @ 19:34

Hello, can you help me to configure the microblaze processor in Nexys 4 FPGA Board

#3 
Written By Vlad on February 19th, 2014 @ 20:10

Add a Comment

required, use real name
required, will not be published
optional, your blog address