Hello again!
In this post, we'll /finally/ upload to the physical MiniZed AND get it to boot up on its own running a program.
About:
Through Avnet, Xilinx and Element14, a training program to learn about the Zynq 7000 platform which is System On Chip combining an FPGA with an ARM processor. This comes to the students as complete development board packed with goodies like a wireless chip from MuRata (BT/BTLE/WIFI), 8GB Flash memory, onboard RAM, USB to JTAG (JTAG programmable over USB), Arduino-style headers (3.3V compatible only), Microphone, Bi-Color LED, and two additional expansion ports.
See all blog posts for this training here.
Lab 7 - Saving the program to Flash and booting 'stand alone'
In this lab we upload a program into flash memory on the MiniZed so that we can boot from flash and have to run 'tethered' to a computer. This is an important step that hasn't been covered at all in any previous lessons of the training; and this is really key to finalizing a project past the development phase. We will be targeting the QSPI flash which is on board of the MiniZed to hold the program.
See also this post which talks about creating the First Stage Bootloader (FSBL).
We will be using the "Test_Peripherals" application as the startup program. The build configuration is set from "Debug" to "Release" which as noted in the previous post, creates a more compact version of the file. We then create a "BIF" - Boot Image Format" file that will be used to upload; and includes the bitstream of the hardware configuration. It also contains our FSBL and application program (ELF).
This is the dialog to create the boot image. We have changed the "Output Format" in the center to "MCS" to allow targeting the SPI Flash memory as opposed to 'boot from SD' which isn't nativity supported on MiniZed.
The "BIF" file is then generated and saved to disc. My file is very small (1K) and just contains pointers to the FSBL, the bitstream, then finally the Test_Peripherals.elf file containing the software.
Here is the complete contents of the file:
//arch = zynq; split = false; format = MCS the_ROM_image: { [bootloader]C:\Speedway\ZyncSW\2017_4\SDK_Workspace\zynq_fsbl_0\Release\zynq_fsbl_0.elf C:\Speedway\ZyncSW\2017_4\SDK_Workspace\ZynqHW\Z_system_wrapper.bit C:\Speedway\ZyncSW\2017_4\SDK_Workspace\Test_Peripherals\Release\Test_Peripherals.elf }
and /finally/ We can program the flash memory!
This is the "Program Flash" icon at the top of the screen. All that's needed is links to the image and the FSBL file as shown here.
It should take a minute to program the flash from this point.
I got multiple issues with uploading to flash with the following error:
****** Xilinx Program Flash ****** Program Flash v2017.4 (64-bit) **** SW Build 2086221 on Fri Dec 15 20:55:39 MST 2017 ** Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. Connecting to hw_server @ TCP:127.0.0.1:3121 Connected to hw_server @ TCP:127.0.0.1:3121 Available targets and devices: Target 0 : jsn-MiniZed V1-1234-oj1A Device 0: jsn-MiniZed V1-1234-oj1A-4ba00477-0 Retrieving Flash info... Initialization done, programming the memory BOOT_MODE REG = 0x00000000 Problem in running uboot Flash programming initialization failed. ERROR: Flash Operation Failed
I tried building the project again; and I tried doing a "clean" but still am running into problems.
At one point I got an error message "Can't find a source file at "/proj/chipscope/xicom_sys/jenkins_clients/xcordevl108/workspace/mini_uboot/mini_uboot/git_mini_uboot/arch/arm/lib/vectors.S" Locate the file or edit the source lookup path to include its location." but haven't been able to track down what this means for me.
I also played with the "Boot mode" switch - This should be set to JTAG boot (which it was). I tried the Flash boot mode and it was called out in SDK as a potential issue; and of course it still didn't program properly.
Debug log:
Retrieving Flash info... Initialization done, programming the memory BOOT_MODE REG = 0x00000001 WARNING: [Xicom 50-100] The current boot mode is QSPI. If flash programming fails, configure device for JTAG boot mode and try again.
You can see in line 5 where the Boot_MODE registry is set to 1 instead of 0 which is how it knows the position of the swtich.
I'm still able to "Program FPGA" over JTAG and get the blue "ready" LED to come on; but can't get the flash programmed...
Wait - After running the debugger then programming again, I was finally able to get it to succeed!
****** Xilinx Program Flash ****** Program Flash v2017.4 (64-bit) **** SW Build 2086221 on Fri Dec 15 20:55:39 MST 2017 ** Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. Connecting to hw_server @ TCP:127.0.0.1:3121 Connected to hw_server @ TCP:127.0.0.1:3121 Available targets and devices: Target 0 : jsn-MiniZed V1-1234-oj1A Device 0: jsn-MiniZed V1-1234-oj1A-4ba00477-0 Retrieving Flash info... Initialization done, programming the memory BOOT_MODE REG = 0x00000000 f probe 0 0 0 Performing Erase Operation... Erase Operation successful. INFO: [Xicom 50-44] Elapsed time = 3 sec. Performing Program Operation... 0%...50%...100% Program Operation successful. INFO: [Xicom 50-44] Elapsed time = 6 sec. Flash Operation Successful
So the SDK was somehow unhappy with something that I had done and by maunally programming the FPGA first; I was then able to save to Flash.
The final step is to set the Boot Mode switch back to Flash and power cycle the board. I was able to verify that the Test_Peripherals program was now running instead of the stock 'Hello world' program.
That was done and I am able to call this lesson complete!
I had wanted to include the next lesson here (Lab 8 - SDK Project Management) which has a lot to do with source control and sharing files with other team members; but ran out of time tonight. I should have a lot of posts over the next week as I sprint to the finish line. I've got parts which will be here on Tuesday to integrate with the MiniZed. My project was originally to do a line follower robot but due to time constraints, I will be limiting the scope to a single control system of the robot - the line detection. So I'll be adding an analog sensor and reading values in to calculate the line position underneath the sensor.
Until next time!
- James