Introduction
Altera® (Intel®) SoC FPGAs are devices that contain a processor unit called the Hard Processor System (HPS) on a single die, in addition to the traditional FPGA part. This SoC FPGA uses a bootloader called U-Boot when booting Linux, and this U-Boot has various functions that can be used for debugging and development.
This section introduces how to use U-Boot to write to QSPI on the board, which is one of the functions!
Although it depends on the size of the file, writing with the Preloader is about 15 times faster than with the HPS Flash Programmer, which is usually used to write QSPI.
This time, we will explain two methods: (1)"How to do it with SD card boot" and (2)"How to do this from Arm® DS (DS-5) using U-Boot".
For details on how to create an environment to boot the U-Boot, please refer to "Beginner's Guide to SoC - How to use Preloader Generator (In Japanese)".
For instructions on how to create an environment to start U-Boot from Arm® DS (DS-5), please refer to "Perfect for simple debugging! How to start U-Boot with DS-5 (in Japanese)".
Demonstration Environment
[Tools]
- Terminal software: Tera Term
[Prepared items]
- U-Boot boot environment
SD card boot environment or an environment that can boot U-Boot on DS-5 - Files to be written to QSPI
Preloader image for QSPI Boot (preloader-mkpimage.bin : 256 KB)
* In hexadecimal 0x40000
1. Preparation of write file
First, prepare the file to be written. Depending on the boot method, the location of the file to be written differs depending on (1) and (2).
(1) In the case of "How to do it with SD card boot" :
Save the file to be written in the FAT area of the SD boot image. (Figure 1)
Then insert the SD card into the SD card slot on the board.
(2) In the case of "How to do this from Arm® DS (DS-5) using U-Boot" :
Save the file to be written in the workspace set by Arm® DS (DS-5). (Figure 2)
Figure 1. Contents of SD card
Figure 2. In the Arm DS workspace
2. Start Tera Term and U-Boot
After Tera Term is started and the UART on the HPS side is recognized, power on the board.
When the power is turned on, U-Boot will be started from the Preloader and the countdown will start to move to the next image. (Figure 3)
(1) In the case of "How to do it with SD card boot" :
After Tera Term is started and the UART on the HPS side is recognized, turn on the power of the board.
When the power is turned on, U-Boot is started from the Preloader, and the countdown starts to move to the next image. (Figure 3)
(2) In the case of "How to do this from Arm® DS (DS-5) using U-Boot" :
Follow the instructions in "Perfect for simple debugging! How to start U-Boot with DS-5 (in Japanese)" and press the Enter Key to stop the countdown to the next image. (Figure 3)
Figure 3. After enabling the U-Boot console
3. File expansion to SDRAM
After booting U-Boot, the file to be written is extracted to SDRAM. 0x0200_0000 is set as the address to extract the file to be written on SDRAM.
Since U-Boot is also deployed on SDRAM, it is necessary to use the area not used by U-Boot. For this reason, the file is deployed to 0x0200_0000 this time.
(1) In the case of "How to do it with SD card boot" :
First, check the file to be written and the file size on the SD card.
$ fatls mmc 0:1
You can see that there is a 262,144 (Byte) preloader-mkpimage.bin file to be written this time. (Figure 4)
Now calculate the file size to be written in hexadecimal.
Example) Decimal: 262144 Hexadecimal: 0x40000
After confirming the file to be written, extract the file to be written to QSPI (preloader-mkimage.bin) onto SDRAM. (Figure 4)
The 0x2000000 specified here is the address in SDRAM where the file is to be extracted.
$ fatload mmc 0:1 0x2000000 preloader-mkpimage.bin
Figure 4. Verifying the file and extracting the image to SDRAM
(2) In the case of "How to do this from Arm® DS (DS-5) using U-Boot" :
If the CPU is running, pause it by pressing the interrupt button, and in the command view, expand the file (preloader-mkimage.bin) to be written to QSPI by the following command once on SDRAM. (Figure 5)
Where 0x2000000 is the address in SDRAM where the file will be extracted.
$ restore $sdir/preloader-mkpimage.bin binary 0x2000000
Then press the Continue button to run the CPU.
Figure 5. Extract the write file from Arm DS to SDRAM
4. Recognize QSPI and write the file
Finally, write the write file developed on SDRAM to QSPI. The writing method is the same for both (1) and (2).
First, initialize QSPI on U-Boot in order to write to QSPI.
$ sf probe
sf probe recognizes the QSPI flash connected on the target device. This command will tell you the page size and total size of the QSPI you are using. (Figure 6)
QSPI can only be read/written by page size, so this QSPI can only be operated in units of 64 KiB (decimal) or 0x10000 (hexadecimal).
Figure 6. sf probe command identifies QSPI flash
Finally, write the file extracted on SDRAM to QSPI.
$ sf update 0x2000000 0x0 0x40000
The parameters to be specified are
- First address of the data to be written that has been expanded on SDRAM: 0x2000000
- Offset value on QSPI to be written: 0x0 (because the preloader is placed at the first address)
- Data size of file to be written (in hexadecimal): 0x40000
When the console is enabled, writing is complete!
Figure 7. Write the file extracted on the SDRAM to the QSPI
Conclusion
This time we have explained how to write using the binary file of the Preloader, but other files can be written to QSPI in the same way by changing the file. Also, the larger the file size to be written, the more you can benefit from this method using U-Boot rather than HPS Flash Programmer to shorten the writing time.
We hope you will make use of this method as well!