Thursday, March 30, 2023

Clean build again, time to move onward to Linux side development and testing of the board

BUILT NEW PROJECT AND WORKED THROUGH VARIOUS ERROR MESSAGES

I carried over the files produced by SystemBuilder, used them to open the project in Quartus, added in all my files, updated the top level file and generated the SoC in Platform Designer. I then began rounds of compilation, knocking down various minor errors that arose.

REVERTED TO ISSUE WITH THE TCL SCRIPTS NOT WORKING PROPERLY

It is typical of all toolchains for FPGA, at least the ones from Xilinx, Altera and Intel, that the internal files beneath the GUI can get in a confused state, such that residue of old logic or parameters remain in the files and cause obscure problems when trying to generate results. 

At least with Intel/Altera, these are reasonably well described and can be read with an editor like Notepad or Linux vi/ed/etc. It does allow me to look into the files and spot why the errors are arising, although the toolchain won't easily correct them. I have found that doing a clean of the files will cause the toolchain to rebuild them all from the current contents entered on the files visible through the GUI, thus resolving the stale data problem.

After a clean and some careful review of my code, I did a compilation. The first pass produces fitter errors because the pins and parameters for the sdram connections are not set up; the TCL scripts are run to establish these settings. The second try of compilation, after script execution, should complete successfully. It did not. The TCL script was still failing SILENTLY and not adding the sdram pin assignments.

I manually appended them to the settings file xxxx.qsf to complete the assignments. Next I added IO Buffers for the signals coming from and going to the HPS side (the three HPS_GPIO signals) and did a compile. 

There were some battles with hidden tristate connections for a signal I wanted to connect to the FPGA IO connector and route that to the HPS side to be read by the Linux application. After I abandoned attempts to use the HPS GPIO pins, it completed the build without error.

THE CHALLENGE OF OVERLOADED WORDS

Altera, Intel and Terasic toss around the term GPIO in a number of contexts with different meanings or subtleties, which is quite confusing. Having read around 6000 pages of documentation to date, I recognize the places where this term switches meaning but it was hard fought knowledge, not spelled out anywhere clearly.

FPGAs have a building block called a General Purpose Input Output block - GPIO - which is basically all the normal pins that you would connect to other chips or the outside world. It includes debouncing, control over drive strength and slew rate, voltage standard selection and other capabilities.

The Cyclone V chip on its HPS side also has GPIOs - a facility that routes 67 bidirectional signals from the HPS side over to the FPGA side, but only when the peripheral mux bits are set. Essentially every pin (pad on the chip) has multiple possible connections, up to four, selected by the mux bits. A given pad might connect to an I2C serial signal, to another device on the HPS, or to the GPIO facility. Note this is NOT the same GPIO as the paragraph above.

The documentation on the HPS GPIO function shows that the signals are assigned across three GPIO banks - 0, 1 and 2. Signals 0 to 28 are on bank 0, signals 29 to 57 are on bank 1, and the remaining signals are on bank 2. 

Terasic provides two 40 pin connectors on the DE10-Nano board which is based on the Cyclone V chip. These are called GPIO 0 and GPIO 1. Each of the two provide 36 input/output pins as well as power and ground. This is a third use of the term GPIO. The HPS GPIO signals have no routing to the board GPIO connectors. The only way to connect them is via IO buffer functions in the FPGA side, using a signal passed through the hps_io conduit from the HPS side which can be redriven out a GPIO pin (of your choice). 

Just to add insult to injury, Terasic provides a single pin on the 2 x 7 pin LTC connector on the HPS side which is called a GPIO signal. That is a fourth use of the term. This GPIO signal is connected to one of the HPS GPIO signals, but also acts as a drive to a relay to switch contacts on the LTC connector between the SPI and the I2C functions on the SoC chip. 

SUCCESS IN BUILD

After some time tweaking things, I had a successfully built file for the Field Programmable Gate Array (FPGA) side of the System on a Chip (SoC). It was time to install some C code onto the Linux image for the Hard Processor System (HPS) side of the SoC then fire up the board. 

Monday, March 27, 2023

Minor issue with Quartus build of my SoC design - damned toolchains again

CHECKING IO PIN ASSIGNMENTS AND FOUND MISMATCH

As part of my desk checking, I was cross checking the external connector pins I had assigned to the logical signals within my Field Programmable Gate Array (FPGA) and the Hard Processor System (HPS) sides of the System on a Chip installed on this board. The manual for the board lists the SoC chip pins associated with each connector pin, but I quickly discovered that these did not match. 

There were very serious mismatches, as for instance the main clock input to the SoC was on the wrong pin. As a result, the board would have sat there mutely doing nothing. After double checking that the SoC chip was the Cyclone V 5SEBA6U2317 which was configured in Quartus toolchain, I began searching the web for others experiencing mismatched assignments.

Voila - I quickly found that the assignment of these is either done manually or by a tool provided by Terasic - SystemBuilder. It updates the xxxx.qsf file in Quartus to make various assignments for IO pins. This step was not done on my project, for a very good reason. 

THESE ASSIGNMENTS SET BY TERASIC SYSTEMBUILDER TOOL - IN WINDOWS

The tool provided by Terasic is a windows executable. It does not have a Linux counterpart. It also produces a Verilog top level file, rather than VHDL as I would have preferred, but I long ago rolled with the punches to use the top level as it was.

Thus I moved all my VHDL files and the top level Verilog file over to the Linux instance, created the new project and then set up my SoC and other logic statements. This did not carry over the contents produced by SystemBuilder in the xxx.qsf file, thus I didn't have the proper assignments. 

FOLDING IN SYSTEM BUILDER STATEMENTS INTO MY FILES ON LINUX

I used SystemBuilder to create a dummy project with its high level file and xxxx.qsf file. That file was transported via USB drive over to my Ubuntu image and I merged this with my project. The proof of the pudding will be proper pin assignments for all the important signals. 

REBUILD OF THE DESIGN

Alas now the toolchain can't see my SoC design from Platform Designer (QSYS), thus it can't do the compile process properly. It appears that I must go all the way back to step 1, using the output file from SystemBuilder on my Windows machine as the input to a fresh project. I can then import all my other VHDL modules and tediously set up the SoC in Platform Designer. 

This is the kind of issue that arises from a fragile toolchain that is a patchwork of layers and add-ons. The way forward is very clear and success is assured, so I will be starting over now. 

Sunday, March 26, 2023

Success - full build of the logic for the SoC with my new Linux image

SUCCESSFUL SYNTHESIS, ROUTE, PLACE AND BIT GENERATION

This is a quick blog post to let everyone know that I was able, using the newly created Ubuntu virtual machine and newly installed Quartus Prime 22.1 toolchain, to complete a build of my logic for the FPGA and SoC side of the design. Finally!

NEXT STEPS

At this point I want to go over all the signal pathways between modules, to be sure that everything is linked as I intended. I will also carefully examine the messages produced in order to clean up things like unused signals or unintended latches. 


Saturday, March 25, 2023

While fighting the USB drive access by VMWare, the virtual machine came back!

REBUILT THE UBUNTU LINUX IMAGE AND RETURNED TO QUARTUS WORK

Although the virtual machine did resume booting up and Quartus would launch, I thought that the condition of the files on it was suspect. I used a USB Drive to retrieve the entire project directory but encountered a number of errors trying to read certain files and directories, which reinforced my assessment that this virtual machine image wasn't usable

I set up an entirely new Ubuntu image and installed Quartus on it, going carefully through the many scattered documents on the Intel site. One listed quite a few libraries that should be added to Ubuntu Enterprise, with no separate guidance about Ubuntu Desktop which I was running, all of which I added or updated before installing Quartus.

The image is up, I finished up the fixes for the environmental variables that I had previously had to discover. At this point the system appears to be working properly.

RECREATED THE PROJECT ON MY NEW LINUX IMAGE

I moved all the source files over and then used Platform Designer (QSYS) to create the System on a Chip (SoC) and link it into my FPGA code. I am now in the process of working through various issues getting everything compiled successfully.


Thursday, March 23, 2023

Preparing USB bootable Ubuntu to attempt to recover the VMWare disk image

UBUNTU DOWNLOADED AND PUT ON USB DRIVE

I built a USB drive using Rufus to load the Ubuntu ISO file in order to boot the virtual machine with it. That would give me a working Linux system with which I could run the fsck utility to check and repair the virtual disk drive. It may not be possible but I hope it will work so that I can recover my work. 

ATTACH THE USB DRIVE TO THE VMWARE IMAGE IN ORDER TO BOOT IT

Next issue - of course - is that VMWare Player is not seeing the thumb drive, although it has successfully seen all my other drives when inserted. I am now chasing down information about correcting this to boot up. Alternatively I can load the Ubuntu image and access it as a virtual floppy, I guess.


Wednesday, March 22, 2023

Close, too close for the fates to allow, thus . . .

WORKED THROUGH THE TCL SCRIPT ISSUES AND ABLE TO WORK ON COMPILATION

I eventually sorted out the environmental variables and paths in order to get the two key scripts, hps_sdram_p0_parameters.tcl and hps_sdram_p0_pin_assignments.tcl, to execute successfully. As a consequence the bizarre errors of the fitter process of compilation were not occurring. 

DISCOVERED THAT THE GPIO SIGNALS FROM HPS ARE HARD ASSIGNED

The Hard Processor System (HPS) side of the chip has a peripheral multiplexing capability that allows some signals to be routed as LoanerIO or GPIO to the Field Programmable Gate Array (FPGA) side. There are almost 70 possible GPIO or LoanerIO numbers to be assigned. 

Since I was going to route signals related to driving the LCD touch module, I put the GPIO signals close to the Serial Peripheral Interface (SPI) master signals, which gave them numbers in the 60s. I assumed that on the FPGA side this was just a signal that I could then assign to some real FPGA side connector pin in an arbitrary manner.

I came across a small section in one of the manuals (of the tens of thousands of pages of such documents that are essential to reference to work with the System on a Chip - SoC) that showed me a fixed assignment of these almost 70 numbers from the HPS side to the connector pins on the FPGA side. For example, the signals in the 60s are routed to GPIO Bank 2, which is NOT implemented on the board I am using. 

I changed these down to the range of numbers that correspond to the second 40 pin connector block on my board. Thus, GPIO-29 in the HPS side is GPIO Bank 1 pin 0 on the FPGA side. Some of the errors I was experiencing were due to the use of Bank 2 numbers. 

NEARING FINAL STROKES, I THINK

With these sorted out, I just had a few minor HDL issues to repair and I expect that I can finish the Compilation to produce the binary load file that will configure the SoC chip on my board. I had a meeting in a restaurant, after which I will complete the work, or so I thought. 

ALAS IT IS NOT TO BE

I returned, fired up VMWare Player, and attempted to start my Ubuntu image. It failed to activate due to a corrupt Virtual disk image. Unless I can find a way to recover this, which doesn't sound promising from the Google searches I have done so far, then I am going to have to back way up, set up another Ubuntu virtual machine, install Quartus again, then do all the fixes if I can remember them to make it operational.

This won't stop me in the long term but it does senselessly waste a day or so of effort fighting my way through all those steps to return to this afternoon's state.

Tuesday, March 21, 2023

Debugging and repairing the Quartus software on Ubuntu Linux

ENVIRONMENTAL VARIABLES NOT FULLY SET

The installer updated one environmental variable but left another unset and did not include the Quartus executables in the PATH variable. I worked through that and was able to have all the components of Quartus execute properly. 

ERROR MESSAGES FINDING TEMPORARY FILES DURING QSYS

When you complete using Platform Designer (formerly called Qsys), the resulting design that ties the Field Programmable Gate Array (FPGA) side with the Hard Processor System (HPS) side has to be generated. In that process, TCL scripts are run and these failed for several intellectual property elements (i.e. not code I wrote or control). 

After a bit of digging and debugging I found that it was failing to open some temporary file, which I presume should have been written earlier in the generation process. I got lucky and found a match with a Google search which referenced another post that clarified the problem. Quartus depends on a number of Linux facilities being installed, but does NOT check during installation nor throw an intelligible error. 

NOW ABLE TO GENERATE THE SOC CORE FILES

I updated my Ubuntu system with the (secret) requisite functions and the generation completed fully successfully. That is the process which also generates the TCL scripts that have famously failed for me on all the other releases and OS platforms. Fingers crossed, it would now compile and run those scripts. 

COMPILATION OF MY LOGIC STILL FAILING ON SCRIPT ERRORS

Regardless of the OS or the Quartus version, I get the same error attempting to execute the provided TCL script. Right at the start of the script it attempts to run the SDC_EXT package which is rejected because that can only be loaded from STA or FIT packages. As far as I understand the intent of Quartus, it should be running STA for the command line and any scripts. Trying to manually load STA results in an error that no such package exists.

I see a few possible causes for this inept behavior of the installed Quartus product (not back at Intel but when running on my various systems):

  1. Some path or environmental variable is missing which lets the software find the STA package
  2. Permissions are incorrect for the package or its path
  3. The installer failed to install those packages
  4. Configuration of Quartus is incorrect such that it doesn't execute STA for the console
  5. Another secret prerequisite is some specific older version of TCL instead of the version installed on my various Windows and Linux systems
WHY THE SCRIPTS MATTER

The Quartus system builds these helpful but somewhat opaque scripts to set up all the parameters and pin assignments that are needed to build the FPGA logic. The DDR3 RAM, for example, has a myriad of pin assignments, voltages, modes and other settings that are essential in order to have the ram access work properly. 

Until these scripts are run and thereby configure these settings for the FPGA, the router/fitter logic can't implement the logic that was synthesized from your HDL plus all the IP HDL from Altera/Intel that glues everything together. This is where I was failing, with issues placing components and discrepancies in voltage levels. I set up the HPS side DRAM for 1.25V logic but the error messages showed pins set to 2.5V, clearly residual values which would have been overridden had the script executed properly. 

SEEKING OUT THE STA PACKAGE TO ELIMINATE (3) AND INFORMS FUTURE DIAGNOSIS

I do indeed see the STA executable as well as the general TCL library of packages such as SDC_EXT, so they were installed. One avenue would be to dig into whether there is a missing environmental variable or something wrong in the path permissions. 

NEXT STEPS DIGGING INTO THE FAILURE

I discovered that I could execute some scripts by using the command line and issuing quartus_sta with a parameter of the TCL script. I was able to run the offending script that had failed before, but it still had not set all the pin assignments and slew rates required for the fitter to assign logic to locations in the FPGA. 

I tried to run the script hps_sdram_p0_pin_assignments.tcl from command line with quartus_sta but it kept complaining about invalid project name, a required parameter on the command line for the script. I feel that I am getting closer and closer to the point where I can produce a binary file to load the FPGA with my logic. 

SCRIPT EXECUTION ATTEMPT NUMBER 999 - RESULTS xxxxxxxxxx

xxxxxxxxxx