Introduction
The DE0-nano-SoC documentation provided some great tutorials to get started with FPGA, HPS and then establish links between them. I can see that there is a lot more to find out about the device, software and working environment.
My efforts with the Golden Hardware Reference Design (GHRD) were eventually successful and the hard work involved was centred around choosing the right versions of software to match the tutorials.
I learned quite a bit through this process of trial and error, in particular Quartus and EDS version 15 (c.2016) are preferred where possible. If there are bugs, version 16.1 may be more appropriate. Version 18.1 is my newer favoured release but doesn't include suitable EDS/DS-5 capabilities as they have become chargeable.
Rocketboards.org provides a set of three workshops for familiarisation and they seem to go down a considerable depth into the internals of the product. I am reasonably happy that I understand enough about FPGAs for my current purposes, I can compile and load a design using my own verilog or Altera IP modules. However the Linux environment and FPGA-HPS bridges are mysterious.
The
WS1 course materials provide an excellent overview of documentation available / required. The format is a
slide deck so there isn't much detail included but technical areas are summarised. The Cyclone V boot process is covered in some detail and forms the basis for the four labs within the workshop.
Preparation
In preparation for lab activities we download an SD card image which contains linux and course files. The card is tailored for Atlas / DE0 and assumes that Quartus 15.1.2 is used. Once the image is unzipped and burned to card using BalenaEtcher it can be booted. This is excellent as I now have a known source for an SD card image which is tailored for my board.
We have a general WS1-IntroToSoc folder and device specific hps_isw_handoff, DE0_NANO_SOC.sof, soc_system.sopcinfo.
LAB 1 Generating and compiling the preloader
When you boot the Atlas board from SDcard a very small BootROM program loads the
preloader into on-chip memory. The preloaders job is to setup the FGPA, define HPS I/O and memory and then copy the Linux bootloader into DDR memory which allows the HPS to boot in the usual manner, load the OS etc.
Our first task is to generate a Board Support Package (BSP) which will define various hardware details relating to the FPGA design and HPS interface. We have a pre-generated QSYS design, whose details are provideed in hps_isw_handoff/soc_system_hps_0. We create a new BSP using the Altera BSP Editor tool, give it a copy of the design and generate a BSP.
The BSP folder contains source code, preloader settings and a Makefile to build the Preloader.
We now run make to compile the preloader and create a image file preloader-mkpimage.bin.
Finally we use the Altera Boot Disk Utility to copy the file to the correct partition on the SDcard so that the Boot Rom program will read it in and execute it.
Inserting the SDcard into the Atlas board we see the preloader booting up the system. This is great progress but the system doesn't do a lot at this stage so we reset to the original preloader for now.
The lab is very instructive in showing the files required produced and the steps needed to generate a preloader. We don't need to understand more detail as the design provides details and the BSP Editor interprets them to generate a preloader.
LAB 2 Verifying Hardware with System Console
Quite a short lab showing you how to use the System Console which looks to be hugely powerful. It allows you see and set values within the FPGA. Our FPGA demo design runs a Fast Fourier Transform in hardware and sends the results back to HPS. Using the system console you can provide values to the FPGA, run the algorithm and using scripts, capture and display output.
It requires a far better understanding of the hardware than I have currently so I don't expect to use it in practice.
LAB 3 Bare Metal FFT app
A bare metal C program is provided for us and our mission is to run it.
The file soc_system.sopcinfo which was given to us contains information about the FPGA memory layout. Using sopc-create-header-files utility a number of headers are created from .sopcinfo which are required by our C program.
Now run make to use the provided Makefile to compile our bare metal program fft.bin.
C the executable across to the SDcard FAT partition which is mounted on our PC.
We now boot the SDcard and type "stop" to get to a u-boot prompt.
Commands are used to:
load the FPGA program
configure HPS-to-FPGA bridges
load the bare metal application into memory
run the application
See the output, Hello world followed by FFT inputs and outputs.
Finally we automate the load of the bare metal application. This is (intentionally) partially successful, when our application runs it only prints hello world. This is because we haven't configured or started the FPGA and bridges.
The tutorial covers a lot of ground. Although I am unlikely to write bare metal programs it is wonderful to set up a working example so that we can see what a program does without an operating system there to help it.
LAB 4 Linux FFT Application
After the complexities of the previous labs this one is quite easy.
The fft app is compiled in EDS and copied to the SDcard.
We can then run the fft program on Atlas linux.
The linux configuration includes a lighttpd web server which can be used to specify input parameters and graph the output from the FFT.
It is deceptively simple as the C program looks complex and has a lot of code concerned with sending fft values to the FPGA, controlling it and reading back results before formatting them for the web server.