This page details the work being done to better support the programming of the Altera devices in the HPSDR system.
This is going to be a 3-prong approach.
- Document a manual way using the Altera tools of programming the devices from both Windows and Linux (Ubuntu) with all boards in-situ (no board shuffling).
- Develop a program to automate the process of updating firmware by a simple point and click process. Programming will utilise the Altera tools.
- Develop a stand alone programmer that does not require the Altera tools.
The first step is to use the tools as are, that is, both the developed USB-Blaster code and the Alter Quartus programmer to program boards in-situ.
General (os independent)
Up to now the programming has required pulling boards in and out of the Atlas bus and moving them around in order to program. This is actually not necessary because the Quartus programmer is quite capable of determining the jtag chain and directing its program loading to a specific device.
The jtag chain loops through each board on the atlas bus and requires the last board in the chain to have the 'last jtag' jumper set. In order to program any board in the chain therefore the boards have to be in adjacent slots otherwise the chain will be broken.
The configuration I have been testing with is:
- Ozy in the furthest slot from the PSU.
- Penny in the next slot.
- Mercury in the next slot with the 'last jtag' jumper set.
Setting up the configuration scripts
In order to program a board there has to be a .cdf file to feed to the programmer (quartus_pgm).
Below is a script that programs penny given the above configuration of boards.
|/* Quartus II Version 9.0 Build 235 06/17/2009 Service Pack 2 SJ Full Version */
Device PartName(EP2C8) Path("/home/bob/dev/projects/acorn-sdr/ozy/") File("Penelope_V1.1.jic") MfrSpec(OpMask(1) SEC_Device(EPCS4) Child_OpMask(1 1));
Device PartName(EP3C25) MfrSpec(OpMask(0));
The easiest way to generate this is to run up the Quartus GUI (this must be done in Windows unless you want to pay the subscription fee for Linux (see later for Linux 'free' use). You only have to do this once. Once the script files are generated you can use them with the command line tools.
- First load USB-Blaster code into Ozy. Follow the general instructions for doing this except you don't need to remove any boards, just leave them where they are.
- Start Quartus II GUI.
- Press the 'Hardware Setup' button (top left) and connect to USB-Blaster.
- Press the Auto-Detect button on the left and you should get two devices displayed. The first will be Penny and the second Mercury (or in whever order you have boards plugged in). Note that Ozy itself will not appear on the chain due to the way the hardware connects things up on the Ozy board.
- Right click on either one and select 'Change File'. Select the .jic file you want to load into the device. The file will then be shown under the device.
- Check the 'program/configure' checkbox.
- At this point you could just hit 'Run' to program the device but the object is to get the config file so do a 'save-as' and save the generated .cdf file.
- Repeat this for each device you have so you end up with a .cdf file for each board.
- To program the board from the command line:
quartus_pgm -c USB-Blaster <your path>/ (or \ if you are Windows)whatever.cdf
Programming should commence and terminate correctly.
There really isnt much to say. The Altera tools are free, install simply and work well. If you are on Windows you have easy life with Altera.
In contrast there is quite a lot to say about Linux.
Firstly, I have by no means exhaustively tested anything but this is how things are to the best of my current knowledge.
The Altera Linux support is patchy and poorly documented. In principal you have to take out a subscription edition license (very expensive) and only RedHat and Susse is officially supported. Some versions have a 30 day trial period, but that seems to apply to very few of the Linux versions. Having said that, there are ways to make it work on pretty much any Linux distro and more importantly the command line tools seem not to require a license. This means that there is a route to Linux programming.
I have struggled on and off for at least a week trying to get things working. I have two machines, a quad-core running Ubuntu 8.04 and a laptop running Ubuntu 9.04. I have so far failed to get it to work on 8.04 (for reasons that I know not) but I have successfully programmed from 9.04. Your milage may vary and I would be pleased to know of any success on other versions or distros.
These are the steps you need to go through. These are taken from a number of sources all of which seemed to miss out something.Again there may be other things you need to do in some circumstances.
Get the install from Altera
The install requires tcsh not csh
Run the install
Create a file required by jtagconf
Create a script to mimic arch as this is an old RedHat command.
Copy the parts library
Testing and Running
- Load the USB-Blaster code into Ozy.
- cd to the /opt/altera7.2/quartus/bin (again you can set this stuff on your path)
- sudo ./jtagd (there is an init file you can use to run the service at startup, I will ad this later). This runs the jtag daemon.
- ./jtagconfig. This should give you the device list of your boards.
- Also try ./quartus_pgm -l (should report the blaster) and quartus_pgm -c USB-Blaster -a (again should report the boards).
- To program ./quartus_pgm -c USB-Blaster <your path>/whatever.cdf
The second prong will automate all of the above. This is only thoughts at the moment but the plan is to do a stand-alone programmer which will run on Windows and Linux (this will be written in Python). It will have a graphical interface and give simple programming of all devices. This will probably be driven by a configuration file (possibly XML) that contains all necessary firmware release details. All the firmware files and the configuration file could be held on an FTP server. At some point I will integrate this into Acorn.
The sequence could be something like the following:
- Ask the user what boards/sequence they have. This part can be remembered so they only need to change it when they change boards.
- Ask them to power up the hardware.
- Load some preliminary firmware in Ozy and interrogate the remaining hardware to find the versions of firmware loaded.
- Load up the USB-Blaster firmware.
- From inside the app we now run quartus_pgm commands and intercept the responses.
- run quartus_pgm -l to make sure we have a usbblaster.
- run quartus_pgm -c (the result from (a)) -a to get the jtag chain.
- compare the chain to the given board sequence. We want to match the number of devices and the device types on the boards. Tell the user if there are discrepancies.
- Give the user a list of firmware releases available by board and highlight their current configuration, the latest releases and possibly recommend an update. Full compatibility details and descriptions of the firmware versions will be displayed.
- allow the user to choose what devices they want to program and the firmware version. Only allow compatible versions.
- generate the .cdf file from a template to match the jtag chain and the files the user wants to update.
- run the update, first getting the necessary files from an ftp server
The 3rd prong is where it gets difficult. At this point I don't even know if it's possible and I would need a deal of help to implement it. The game plan is something like create an embedded programmer in the FX2 which can perform jtag programming. This could be based on the Altera JRunner code which is freely available and some work was already in progress on that by Michael G3WOE. A bespoke piece of code will probably be required for the FPGA to emulate the Serial Flash Loader that Quartus provides. A relatively simple piece of PC software would then be required to download the files and guide the programming. If this means nothing to you, don't worry, it means very little to me yet and would have meant nothing a couple of weeks ago.