Wednesday, August 30, 2023

User interface test verification part 27

THE EVIDENCE IS PILING UP THAT THE DEVICE TREE FOR U-BOOT IS BAD

The U-boot archives that get downloaded in order to generate a new version of U-boot to reflect the settings you want in your System on a Chip (SOC) such as the Cyclone V in my Terasic DE10-Nano board, generate a stripped down device tree that is used by the preloader and by U-boot to know how to execute on the ARM processors, how to get to and initialize the DRAM memory and how to communicate over the serial port. 

Somebody, usually the maker of the board, provides the base device tree source for the board and the default configuration settings to allow the make process to build a working preloader and U-boot. Over time as the tools that manipulate the device trees evolve in newer versions of U-boot, one would hope that somebody was responsible for verifying that they still work properly. That may not be correct.

I have two archives I am working with. One is the official U-boot code stream and another is a version of U-boot that was modified by Altera, the original designer of the Cyclone V SOC chip. Neither of these create an image that boots up on my board, not even to issuing the first messages on the console. 

I grabbed the two device tree blobs that were created for the preloader, converted them back to device tree source using the device tree compiler dtc, and looked closely at them. Neither of them seems complete enough to allow the preloader to work. 

DTS FILE FROM OFFICIAL U-BOOT ARCHIVE AFTER MAKE OF PRELOADER

One issues only two commands to build a preloader and U-boot. First, run the vendor provided default configuration file. Second, run a make all. The file socfpga_de10_nano_defconfig is the file that is run to set up for a U-boot that should run on the Terasic board. After the make all is run, it has created a folder SPL that holds the preloader. In that, a number of transformations are run on the files from the archive in order to produce u-boot-spl.dtb a device tree blob for the preloader. 

Here is what was produced when I ran this through dtc to recreate a device tree source. 

/dts-v1/;

/memreserve/ 0x0000000000000000 0x0000000000001000;
/ {
#address-cells = <0x1>;
#size-cells = <0x1>;
model = "Terasic DE10-Nano";
compatible = "altr,socfpga-cyclone5", "altr,socfpga";

aliases {
serial0 = "/soc/serial0@ffc02000";
};

soc {
#address-cells = <0x1>;
#size-cells = <0x1>;
compatible = "simple-bus";
device_type = "soc";
ranges;

clkmgr@ffd04000 {
compatible = "altr,clk-mgr";
reg = <0xffd04000 0x1000>;
};

l2-cache@fffef000 {
compatible = "arm,pl310-cache";
reg = <0xfffef000 0x1000>;
cache-unified;
cache-level = <0x2>;
arm,tag-latency = <0x1 0x1 0x1>;
arm,data-latency = <0x2 0x1 0x1>;
prefetch-data = <0x1>;
prefetch-instr = <0x1>;
arm,shared-override;
arm,double-linefill = <0x1>;
arm,double-linefill-incr = <0x0>;
arm,double-linefill-wrap = <0x1>;
arm,prefetch-drop = <0x0>;
arm,prefetch-offset = <0x7>;
phandle = <0x1>;
};

dwmmc0@ff704000 {
compatible = "altr,socfpga-dw-mshc";
reg = <0xff704000 0x1000>;
fifo-depth = <0x400>;
#address-cells = <0x1>;
#size-cells = <0x0>;
resets = <0x6 0x36>;
status = "okay";
broken-cd;
bus-width = <0x4>;
cap-mmc-highspeed;
cap-sd-highspeed;
};

rstmgr@ffd05000 {
#reset-cells = <0x1>;
compatible = "altr,rst-mgr";
reg = <0xffd05000 0x1000>;
altr,modrst-offset = <0x10>;
phandle = <0x6>;
};

sdr@ffc20000 {
compatible = "altr,sdr-ctl", "syscon";
reg = <0xffc20000 0x6000>;
resets = <0x6 0x3d>;
phandle = <0x2f>;
};

sysmgr@ffd08000 {
compatible = "altr,sys-mgr", "syscon";
reg = <0xffd08000 0x4000>;
cpu1-start-addr = <0xffd080c4>;
phandle = <0x25>;
};

serial0@ffc02000 {
compatible = "snps,dw-apb-uart";
reg = <0xffc02000 0x1000>;
reg-shift = <0x2>;
reg-io-width = <0x4>;
dmas = <0x32 0x1c 0x32 0x1d>;
dma-names = "tx", "rx";
resets = <0x6 0x30>;
clock-frequency = <0x5f5e100>;
};
};

memory {
device_type = "memory";
reg = <0x0 0x40000000>;
};

chosen {
bootargs = "console=ttyS0,115200";
stdout-path = "serial0:115200n8";
};
};

DTS FILE FROM ALTERA U-BOOT ARCHIVE AFTER MAKE OF PRELOADER

The resulting device tree source from the Altera version of U-boot is:

/dts-v1/;

/memreserve/ 0x0000000000000000 0x0000000000001000;
/ {
#address-cells = <0x1>;
#size-cells = <0x1>;
model = "Terasic DE10-Nano";
compatible = "altr,socfpga-cyclone5", "altr,socfpga";

chosen {
bootargs = "console=ttyS0,115200";
};

soc {
#address-cells = <0x1>;
#size-cells = <0x1>;
compatible = "simple-bus";
device_type = "soc";
ranges;
u-boot,dm-pre-reloc;

dwmmc0@ff704000 {
compatible = "altr,socfpga-dw-mshc";
reg = <0xff704000 0x1000>;
interrupts = <0x0 0x8b 0x4>;
fifo-depth = <0x400>;
#address-cells = <0x1>;
#size-cells = <0x0>;
num-slots = <0x1>;
broken-cd;
bus-width = <0x4>;
cap-mmc-highspeed;
cap-sd-highspeed;
drvsel = <0x3>;
smplsel = <0x0>;
status = "okay";
u-boot,dm-pre-reloc;
};
};
};

This file does not even have an entry for memory, which fully explains why nothing takes place when I boot this preloader. It can't find DRAM in order to initialize it, copy in its code and continue execution. It refers to ttyS0 for the console but does not contain any entries defining that. At least the top file has an alias for serial0 to an entry for the serial port where the messages should be issued. 

This appear to me as fragments of what would be needed to make the preloader actually function. I need to investigate a few things in order to figure this out and then find a way to correct it. It would have been helpful to have documentation that tells you what the parameters must be in the device tree for the preloader, but that doesn't exist. 

FIGURING OUT WHAT IS MISSING AND HOW TO FIX IT COMES NEXT

Somehow I need to see a working device tree source for this board. It may be that the transformation tools in U-boot have evolved and no longer process it correctly but that it did work at some time in the past with an earlier version. Too, I might be able to locate and dump the device tree blob from within the working preloader I have from the Terasic distributions, allowing me to see what should be in there. 

The harder method would be to read through and understand the hundreds and hundreds of source code files in the U-boot archive and then study all the hardware configuration steps and register configurations that would be needed to run the preloader. Again, no documentation that spells this out, so it requires digging through many thousands of pages of Cyclone V and other documentation. Possible but very high work effort. 

Thursday, August 24, 2023

User interface test verification part 26

ATTEMPTED TO RUN OFF FLATTENED IMAGE SUPPORT BUT MAKE PROCESS FAILS

My boot files are the traditional compressed Linux kernel and a device tree blob (DTB), not the flattened tree that combines them into a different structure. I thought that the boot might be failing because the preloader (SPL) was looking for the flattened image file and wanted to eliminate that code as a stab in the dark.

I changed the default configuration file to specify CONFIG_FIT=n which would turn off all the code for flattened images. When I then tried to make U-boot and the SPL, it failed trying to build all the DTBs for the various types of boards that use the Altera/Intel SOCFPGA chips. The first it tried, the Agilex N6100, failed with an error that it couldn't find binman in the DTB it was processing. Binman is used for trusted boot, which we are not using with the Terasic DE-10 Nano board, but is required for the Agilex one.

I don't know why the make process insists on building every DTB for every SOCFPGA chip when we are in fact doing a build for one specific board, but it does. It has a very very convoluted process of scripts, makefiles and other tools that result in the attempt to build all the DTBs. There is no method I can find to block it and the SOCFPGA section of U-boot apparently cannot successfully complete a Make if FIT is deselected. 

This represents the issue with the System on a Chip products and toolchains. You can skim along doing almost exactly the same as the reference/example projects, but once you step off that cliff edge you plummet to where you need to understand virtually everything about complex subjects just to move forward. I am forced to gain considerable expertise in U-boot, for example, both the actual code and the make process, just to get a working loader. Getting features of the SoC chip to work required diving very deep into the chip architecture, the toolchain and other topics. Essentially this is a pool with one step at 6" depth and the next step is 10,000 feet down requiring deep sea diving gear. Nothing in between. 

DIGGING INTO OTHER DETAILS IN CONFIGURATION FILES

There are hundreds of configuration settings, any one of which might be the cause of the failure to boot up SPL. I will first look into every setting that explicitly mentions SPL, dig into the hundreds of source code files and work out what it does. As one example, the start address for SPL is set to 0x08000000 in the configuration file. Not sure why that is the number and more importantly what number it should be. Will report on what my research uncovers and whether I finally (or ever, it seems like) find the smoking gun. 

Wednesday, August 23, 2023

Did some cleanup on the System Source 1130 system

RAN OVER TO THE SHOP TO IMPROVE SERVICEABILITY OF THE 1130

I had added a simple capability to the System Source 1130 system, just as I had designed it for mine and for The National Museum of Computing in the UK. It has a bank of relays wired to the console entry switches and several of the console pushbuttons. This allows the user to rapidly load any content into core memory without the time consuming effort of manually flipping switches and pushing buttons.

In order to load a word into memory at some location, one first sets up the load address by flipping the 16 console entry switches to the desired address. The Mode rotary switch is set to Load and the Load IAR button is pushed. This sets the Storage Address Register to the intended address. 

The user then sets the 16 console entry switches to the first data word to be entered, then pushes the Start button to load it into storage. The memory address is automatically incremented to the next sequential address, so that one can load subsequent data words by 'only' switching sixteen console entry switches and then pushing Start, for each one. 

Loading a very long program into memory is tedious and error prone using the physical switches and buttons. This modification installs an Arduino that drives relay boards to electronically set the console entry switches and to electronically push Load IAR or Start. The Arduino is connected via USB to a serial terminal, usually a laptop, where an ASCII file can be transmitted line by line. The file format uses characters like @ to designate setting the memory address otherwise the characters are the hex value to set in the console entry switches. 

Thus a very long set of words to put in memory is typed into a file as sets of four hex digits with optional prefix characters. That file is opened by the serial terminal program which looks for the prompt character coming from the Arduino before sending each line to be loaded into the 1130. 

The implementation required adding sixteen wires to the console entry switches, which are on the inside of the front panel of the 1053 console typewriter. The normal cable from that panel runs down into the 1130 logic gates but has some spare length to allow the panel to be moved from its fixed spot. This is because the panel is attached to the front of the console typewriter itself, so then whenever the typewriter must be removed for service, cumbersome disassembly is needed.

The typewriter is lifted off its normal location but is limited by the length of the console entry switch cable. The typewriter is turned on its side and screws are removed to detach the front panel with the switches. This allows the typewriter to mover over a bit further, but the typewriter is cabled into the 1130 with three SMS cards attached deep in the bowels. Two are the signals for the typewriter and one is the power for the device. These must be detached after unsrewing and swinging things around underneath, then snaked up to finally be able to move the typewriter to some remote workbench for service. 

When I added the Arduino based loader, I added my own wires to the back of the console entry switch panel. These were wired directly to relay boards screwed down between the keyboard and the typewriter front panel, under the tabletop. Thus, the front panel was further restricted, not just by the standard cable down to the logic gates but also by my new wires which were shorter. This made the cumbersome juggling even harder.

I therefore inserted a set of connectors so that my wires come out of the panel to a connector, then the wires from the relay boards run to the other connector. This allows separation of the wires so that the only anchor on movement of the front panel is the length of the standard IBM cable down to the logic gates. 

Tuesday, August 22, 2023

Quick feasibility investigation for emulating all devices on an 1130 for machines without the Storage Access Channel feature

THE PERIPHERALS CHALLENGE FACING MOST 1130 OWNERS

Most of the surviving 1130 systems, either in museums or private collector hands, do not have sufficient working peripherals to demonstrate the system adequately. Many did not have the input-output devices saved or they are very difficult to restore to operation. 

In order to show the machine in typical operation, we would want to have the internal disk drive, a card reader and a line printer operational. The demonstrator puts a boot card in the reader, loads DMS2 monitor from the disk cartridge and that prints a startup page on the printer. At this point, decks of cards can be read into the monitor and any output from the programs will print. 

While one can switch to the console to type in card images to fire up previously stored programs on disk and those programs might only write to the console typewriter, it is not feasible with DMS2 as it is written to get to that point without a reader and a line printer.

One can image a demonstration environment where the user types virtual cards into files on a support PC, has them read through a virtual card reader and any printed output from the 1130 is captured by a virtual line printer as another file. Systems that have a working internal disk drive but nothing else would be usefully demonstrated in this case.

Even more so, full emulation would allow a machine that did not have a working disk drive or other peripherals to boot up and run jobs, using virtual peripherals and files on the support PC. My own IBM 1130 is a mixed situation. I have a working 1132 line printer and working internal disk drive, thus with some work manually entering the boot card image to memory I can fire up DMS2 to the point of the start page printing. 

My 1442 card reader is not currently working, so that I can't do much more. I believe I could hack the DMS2 image to have it request card input from the console keyboard, allowing me to fire up previously loaded programs as long as they didn't need the card reader. 

I designed, built and installed an FPGA based box that connects to the IBM 1130 and implements virtual peripherals, such as additional 2310 cartridge disk drives, 1442 or 2501 card readers, 1132 or 1403 line printers and the 1053 console typewriter/keyboard. It attaches via a feature on the IBM 1130 that presents a large connector on the 1130 for a cable that would be hooked to other devices including the 1133 Multiplexor box that supports devices like the 1403 printer and 2310 disk drive. 

MY PREVIOUSLY BUILT EMULATOR DEPENDED UPON THE SAC FEATURE

IBM provided a set of signals on the Storage Access Channel feature that allows an external box, including their own 1133, to become device controllers for additional peripherals. It has the ability to send data in and out of the 1130, intercept the XIO instruction that controls peripherals, trigger interrupts and drive cycle stealing to access memory on behalf of the peripheral.

IBM attached devices through SAC such as the 1403 printer, 2310 disk drive, 2250 graphics workstation, 2420 tape drives, and others. Larger installations used the SAC to make use of these peripherals; my first experience with an 1130 at Florida Institute of Technology had a 1403 and two 2310 drives attached through an 1133. 

An 1130 itself can have device controllers for the 1132 printer, 1442 card reader, 2501 card reader, 1627 plotter, internal disk drive, 1053 console typewriter/keyboard, 1054/1055/1134 paper tape devices, the 12xx optical mark reader and the SCA communications adapter, but each is installed only if that peripheral were ordered with that 1130 machine. 

The SAC signals allow peripherals that make use of interrupt levels 2 through 5, but not levels 0 and 1. Those are used by the 1132 printer, the 1442 card reader/punch and the SCA, thus one cannot emulate these devices using the SAC connector. I therefore expanded the SAC with a second small cable that added signals for those two interrupt levels plus a signal to trigger a sequencer I also built to 'push' the three buttons needed for a boot - IMM STOP, RESET, and PROG LOAD. 

I am willing to share the design so that any owner of an 1130 that has the SAC feature can build my box and emulate any device on the 1130. One has to disable the internal controller for devices if emulating a device whose controller logic is installed in the 1130. In my case, to emulate 1442, 1132 or 1053, for example, I had to disable their logic in my machine to that did not try to respond to the XIO for the emulated devices. I did this manually. 

FINDING SIGNAL AVAILABILITY ON NON-SAC MACHINES

The SAC feature not only provides the connector, it implements line drivers to send the signals the relatively long distances over a cable and adds some logic that is not in the standard 1130 to handle some special cases needed by the 1133 and 2250 boxes. Thus I had believed it was not practical to emulate on non-SAC machines because of all the additional logic that was added.

It came to me, however, that I could capture signals with local PCBs I attached inside the covers of the 1130 and thus not need all of IBM's line drivers. The question was whether all the signalsspo needed for SAC were available on backplane pins of a machine that did not have SAC installed. I began to investigate.

I quickly found spots to pick up or inject almost all the signals. Injected a signal with IBM's SLT logic technology is easy - you find a line that is active when low and then just add a modern open collector logic gate to pull it to ground when you want it active. 

The nature of SLT circuitry is that this is perfectly fine to add and has no impact on the gates that are 'driving' the line high, since in reality the receiving gate has a weak pullup and the drivers only pull to ground or are inactive. 

There was a signal that was manufactured by a combinatorial logic circuit in the SAC version of the 1130 but not in the standard machine. This turned out to be a 5 way OR of signals which were available on the backplane pins, so I only needed to grab those five to produce the missing signal. 

A few inputs to the 1130 on the SAC commanded actions to stall the cycle steal clock, present data earlier in the cycle steal protocol than normal, to gate incoming data onto the CPU B bus, and to keep the CPU meter running while a mechanical peripheral was still physically active. None of these were needed to control when incoming data was put on B, as I could control that in my box through timing of asserting the incoming data lines. My emulated peripherals would not need to stall the cycle steal clock nor to enter data early, so those lines were moot. Finally, I don't care about running the CPU meter as I am not collecting hourly fees from renters of the 1130. Thus I didn't need any of these signals. 

On my system, I manually switched when disabling the internal device controller logic whenever I was emulating a peripheral that was configured into my machine. However, as I worked on the non-SAC version I realized that I could add a few more signal lines so that my box could disable the controller logic for any emulated device electronically. 

DETERMINATION - IT IS FEASIBLE TO MAKE SUCH AN EMULATOR

I carefully checked the locations against multiple sets of ALDs I had collected from various machines and am confident that this will work. It would require a small PCB located near four compartments on the two swing out logic gates of the 1130 - A gate compartment C1 plus on B gate all three compartments A1, B1 and C1. These small board would have wire-wrap connections from the compartment backplane and a connector taking the signals to the FPGA board mounted elsewhere inside the 1130. 

Essentially I would modify the FPGA logic I used in my SAC based emulator, which wouldn't be a huge job. The PC based application that communicates with the FPGA is attached via USB thus the 1130 would simply have a USB connector into which the laptop gets plugged to control the emulator. 

PROJECT MUST WAIT FOR CURRENT RESTORATION TO FINISH

I have an IBM 1130 I am restoring for the System Source Museum and it is already delayed while I finish the Virtual 2315 Cartridge Facility I developed. This has been bogged down in toolchain issues for too long already. I won't take on any additional project until I have the machine fully operational and ready for pickup by that museum. 

This will be very handy for owners of 1130 systems so that I will probably start on it after finishing the current 1130 restoration. 


Monday, August 21, 2023

User interface test verification part 25

DIGGING INTO POSSIBILITY THAT THIS IS A DEVICE TREE ISSUE

Before I begin hacking the code to the preloader (SPL) to give me clues about what is going wrong, I focused on the idea that the most likely cause is a failure to copy itself to RAM and load u-boot code. Most comments I found through extensive google searches pin this on errors in the device tree blob, so that was my focus for a couple of days.

The process of  building the device tree blob is not simple. There is a submitted file provided with the distribution of U-boot that presumably the maker of the board or a code contributor has provided. This is massaged in various ways to produce two device tree blobs, one for U-boot and a stripped down small one for SPL due to size limitations in the initial storage used for preloader execution. 

The initial source for the board is merged with various other source files to build up a device tree source. This is because a specific board has unique features but also shares a lot with every board built using the same SoC chip, in my case Cyclone 5, and in common with every Altera/Intel based SoC board regardless of the chip type. 

The C preprocessor will merge all those common elements with the board specific details to form the first source file. The device tree compiler dtc is then run to convert the source format dts file to a binary blob format dtb. This watches for a number of warnings as it processes the source file. 

All further processing is done on the binary format files thus harder to observe without converting the dtb back to dts format temporarily for inspections. 

The dtb file is combined with the compiled U-boot code in the next few commands. We then copy the dtb file to the directory where we will build the preloader (spl) and skinny it up.  A few passes through a tool called fdtgrep do the trick. The first pass drops everything that is not tagged with special markers u-boot,dm-pre-reloc and u-boot,dm-spl but also some special sections like chosen that are used to direct serial console messages. The second pass does more exclusion of specific properties within entries to further reduce the size of the resulting dtb file. 

The files are moved various places, the dtb files appended to binary files and then the specific bootable images are created using the mkimage tool.  Eventually we end up with four copies of the preloader (including its small dtb) then the U-boot binary with its larger dtb, forming the data to be copied into a special partition on the SD card from which the Cyclone 5 chip will boot. 

Something is going wrong in this process, perhaps, resulting in a dtb that doesn't give the preloader the data it needs to at initial DRAM, copy code and emit the first output to the serial console. We don't yet know if this is a missing or incorrect element in the dtb, a dtb that is so large it exceeds the limited SRAM space on the Cyclone 5 chip into which the preloader must fit, or something entirely different. 

Below is the extract of the make process that builds the device tree blob from the initial source and then uses it to create the SPL and U-boot images:

  mkdir -p arch/arm/dts/ ;
  
     (cat arch/arm/dts/socfpga_cyclone5_de10_nano.dts; ) > arch/arm/dts/.socfpga_cyclone5_de10_nano.dtb.pre.tmp;
     
     cc -E -Wp,-MD,arch/arm/dts/.socfpga_cyclone5_de10_nano.dtb.d.pre.tmp -nostdinc -Iinclude     -I./arch/arm/include -include/
      ./include/linux/kconfig.h -I./arch/arm/dts -I./arch/arm/dts/include -I./include -D__ASSEMBLY__\
       -undef -D__DTS__ -x assembler-with-cpp -o arch/arm/dts/.socfpga_cyclone5_de10_nano.dtb.dts.tmp arch/arm/dts/.socfpga_cyclone5_de10_nano.dtb.pre.tmp ;
       
      ./scripts/dtc/dtc -O dtb 
      -o arch/arm/dts/socfpga_cyclone5_de10_nano.dtb 
      -b 0 
      -i arch/arm/dts/ 
      -Wno-unit_address_vs_reg 
      -Wno-unit_address_format\
       -Wno-avoid_unnecessary_addr_size 
       -Wno-alias_paths 
       -Wno-graph_child_address 
       -Wno-graph_port 
       -Wno-unique_unit_address 
       -Wno-simple_bus_reg\
        -Wno-pci_device_reg 
        -Wno-pci_bridge 
        -Wno-pci_device_bus_num  
        -a 0x8 
        -Wno-unit_address_vs_reg 
        -Wno-unit_address_format 
        -Wno-avoid_unnecessary_addr_size\
         -Wno-alias_paths 
         -Wno-graph_child_address 
         -Wno-graph_port 
         -Wno-unique_unit_address 
         -Wno-simple_bus_reg 
         -Wno-pci_device_reg\
          -Wno-pci_bridge 
          -Wno-pci_device_bus_num  
          -d arch/arm/dts/.socfpga_cyclone5_de10_nano.dtb.d.dtc.tmp 
          arch/arm/dts/.socfpga_cyclone5_de10_nano.dtb.dts.tmp 
          ||
           (echo "Check /home/carl/Documents/quartus/Virtual2315Cartridge/software/u-boot-socfpga/arch/arm/dts/.socfpga_cyclone5_de10_nano.dtb.pre.tmp for errors" && false) ;
            sed "s:arch/arm/dts/.socfpga_cyclone5_de10_nano.dtb.pre.tmp:arch/arm/dts/socfpga_cyclone5_de10_nano.dts:"\
            arch/arm/dts/.socfpga_cyclone5_de10_nano.dtb.d.pre.tmp 
            arch/arm/dts/.socfpga_cyclone5_de10_nano.dtb.d.dtc.tmp 
            > arch/arm/dts/.socfpga_cyclone5_de10_nano.dtb.d
            
  cat arch/arm/dts/socfpga_cyclone5_de10_nano.dtb > dts/dt.dtb
  
  cat u-boot-nodtb.bin dts/dt.dtb > u-boot-dtb.bin
  
  cp u-boot-dtb.bin u-boot.bin
  
mkdir -p spl/dts/

          ./tools/fdtgrep -b u-boot,dm-pre-reloc -b u-boot,dm-spl -RT dts/dt.dtb -n /chosen -n /config -O dtb 
              |
          ./tools/fdtgrep -r -O dtb - -o spl/dts/dt-spl.dtb -P u-boot,dm-pre-reloc -P u-boot,dm-spl -P u-boot,dm-tpl -P u-boot,dm-vpl/
             -P pinctrl-0 -P pinctrl-names -P clocks -P clock-names -P interrupt-parent -P interrupts
             
  cp spl/dts/dt-spl.dtb spl/u-boot-spl.dtb
  
  cat spl/u-boot-spl-nodtb.bin spl/u-boot-spl-pad.bin spl/u-boot-spl.dtb > spl/u-boot-spl-dtb.bin
  
  cp spl/u-boot-spl-dtb.bin spl/u-boot-spl.bin
  
  arm-none-eabi-objdump -t spl/u-boot-spl > spl/u-boot-spl.sym
  
  ./tools/mkimage -T socfpgaimage -d spl/u-boot-spl.bin spl/u-boot-spl.sfp >/dev/null  && cat /dev/null
  
  ./tools/mkimage -A arm -T firmware -C none -O u-boot -a 0x01000040 -e 0x01000040 -n "U-Boot 2022.10-24689-gfdfea6b32f-dirty for de10-nano board" -d u-boot.bin u-boot.img >/dev/null  && cat /dev/null
  
  cp dts/dt.dtb u-boot.dtb
  
  ./tools/mkimage -A arm -T firmware -C none -O u-boot -a 0x01000040 -e 0x01000040 -n "U-Boot 2022.10-24689-gfdfea6b32f-dirty for de10-nano board"\
   -d u-boot.bin u-boot-dtb.img >/dev/null  && cat /dev/null
   
  arm-none-eabi-objcopy -I binary -O binary --gap-fill=0x0 --pad-to=0x10000 spl/u-boot-spl.sfp spl/u-boot-spl.sfp 
    && cat spl/u-boot-spl.sfp spl/u-boot-spl.sfp spl/u-boot-spl.sfp spl/u-boot-spl.sfp > spl/u-boot-splx4.sfp ;
  
   cat spl/u-boot-splx4.sfp u-boot.img > u-boot-with-spl.sfp 
   || rm -f u-boot-with-spl.sfp
   
  ./scripts/check-config.sh u-boot.cfg ./scripts/config_whitelist.txt .
  
  ./scripts/check-of.sh .config ./scripts/of_allowlist.txt

Wednesday, August 16, 2023

User interface test verification part 24

MORE TOOLCHAIN FUN AND  GAMES

I have six ways to make U-boot, three cross compiler chains and two versions of U-boot source. The older SOC_EDS (System on a Chip Embedded Design Suite), we will call A, a version of Gnu for Ubuntu for ARM chip cross compilation we term B, and a separately downloaded ARM GNU cross compilation chain as C to round out the ways that we can compile assemble and link code. The two source versions are the latest official U-Boot source plus some Altera and DE10 modified source I found on Github.

I tried the Ubuntu chain, setting up both of the source code directories to make with these tools. I did bump into a well know flaw where the device tree compiler DTC gets errors on duplicate definitions of a global variable YYLLOC but deleting one of them in the source is the workaround. I then found the GCC compiler complaining about a parameter passed to it, -march=armv5, which it didn't know how to support. 

My chip should be the armv7-a architecture level since they implemented Cortex A7 processors on the chip. The configuration process should have set this up to build for the A7 processors, I can see the settings in the related configuration files, but when it drops into the lib subdirectory to compile libraries it somehow lost the architecture setting and picked armV5. This could well be the reason that the code doesn't successfully execute to the point of issuing the welcome banner on the console. 

Apparently the two other toolchains do support armV5, issue no messages but build defective code. What this happens is the subject of forensic investigation. U-boot source consists of many hundreds of files and quite a few interlocked Makefiles, thus this is not trivial to debug. 

I attempted to set up a user gcc override, passing in the -march=armv7 parameter but then ran into some errors in the assembler with instructions that didn't match the architecture. Setting it as -march=armv7-a solved those problems. However, when it was time to link SPL, the preloader, it specified a file eabi_compat.o that is needed for certain toolchains (per the comments in its source code) but was not set up for this build. Toolchain B will not work with the official repository. 

I shifted to use the external toolchain C with the official repository, but overriding the -march=armv7-a parameter. This built with no error messages but once again the card won't boot on the DE10-Nano board. 

I did a quick test using chain A just to prove to myself that even with the -march=armv7-a flag, it will sit on the board doing absolutely nothing. In desperation I looked for another toolchain - the embedded Cortex compiler from ARM - which we will call toolchain D.  Absolutely the same results - no signs of life.

Sunday, August 13, 2023

User interface test verification part 23

CLUE TO BE CHASED

After interminable permutations of configuring the U-boot and testing I was looking very closely at the SPL (preloader) since that is what should execute to the point that see messages on the console, but it does not. In the directory where the SPL is built a noticed a subdirectory DTS and looked into it.

There is a device tree blob in there, dt-spl.dtb, which when I converted it to source format had no entries at all describing the SDRAM on the board. Without RAM, the SPL will fail quickly. It runs from some limited memory on the board, initializes the regular RAM and copies itself to RAM to continue. If the RAM configuration is incorrect then SPL cannot get very far.


This sounds like the root cause of the completely silent behavior of every SPL I generate, regardless of which of the newer U-boot source versions I use. I will dig into how this is generated during the make process and see if there is a missing file or a failure I can detect somewhere in this godawful toolchain. 

Somehow I detect that absolutely NOBODY tried to generate U-Boot for the Terasic DE10-Nano board in recent years, in spite of Intel having changed their embedded generation process and tools many many times and in spite of many newer versions of U-boot having been released. Nobody responsible or cared enough to try. Since almost every user of these boards that posts videos or blogs simply follow the reference examples exactly, they don't have to address U-boot and therefore don't stumble over the problem.