In-system Programming Flash Devices

This guide is designed to provide a step-by-step walkthrough on in-system programming (ISP) for flash devices on the SP7350 platform. Covering a range of devices including eMMC, SPI-NOR flashes, SPI-NAND flashes, and 8-bit NAND flashes, the document aims to simplify the ISP process. Follow the outlined steps to seamlessly download, compile, and write images to flash devices, ultimately enabling you to boot the system from these devices.

Table of Contents

Download Sources of SP7350

Please refer to: Downloading and Compiling Code

for downloading, setup compilation environment for SP7350 platforms.

Configure Building Environment

Navigate to the top folder of your Q654 (SP7350) project. Run the following command to initiate the configuration menu.

make config

Upon executing this command, a configuration menu will appear, providing several options for customization:

image-20241007-023021.png

In the configuration menu:

  1. Choose the board you want to build the image for. For instance, press 1 to select "SP7350 Ev Board."

  2. Choose the device from which the system will boot. For example, press 1 to specify booting from the eMMC device. SP7350 supports booting from eMMC, SPI-NAND, SPI-NOR and 8-bit NAND flashes.

  3. Choose the size of the flash device. For example, press 4 to select an 8 GiB eMMC device.

  4. Choose the root file-system for Linux. For example, press 7 to opt for “Ubuntu MATE MATE 24.04.1” as the root file-system.

  5. Decide whether to use the overlay file system. For example, press 1 to choose not to use an overlay file-system.

  6. Choose boot modes. Press 1 to select building “Normal boot” images.

Once you have completed the configuration selections in the menu, the system will start configuring the building environment. This process may take tens seconds or even a few minutes, depending on your computer's performance. Please wait patiently for the configuration process to conclude.

Please note that the system takes additional time to complete its initial run during the configuration process, as it requires the download of the toolchain.

Build Code

After completing all configurations, you are ready to initiate the code build. Execute the following command to commence the build process:

make

This will compile the code based on your chosen configurations. The duration of this process depends on your computer's performance, typically taking a few minutes. Kindly exercise patience and allow the system to complete the build.

After make command completes, it will display information similar to the following screenshot:

image-20240719-094439.png

The output screen indicates the creation of 6 partitions within the binary ISPBOOOT.BIN. For instance, the size of the fip partition is 0x63c00 (408,576 bytes), utilizing 38.96% of the maximum allowable size of 0x100000 (1,048,576 bytes). Other partitions include dtb (0xd000 or 53,248 bytes), kernel (0x964000 or 9,846,784 bytes), and rootfs (0x219e7000 or 564,031,488 bytes).

All generated image files are stored in the 'out' folder. Refer to the 'll out' command screenshot below:

wellslu@scdiu3:~/Q654$ ll out total 915672 drwxr-xr-x 2 wellslu sp 4096 Jan 1 14:59 ./ drwxr-xr-x 11 wellslu sp 4096 Jan 1 14:47 ../ -rw-r--r-- 1 wellslu sp 134144 Jan 1 14:47 down_32M.exe -rw-r--r-- 1 wellslu sp 53248 Jan 1 14:58 dtb -rw-r--r-- 1 wellslu sp 408526 Jan 1 14:58 fip.img -rw-r--r-- 1 wellslu sp 577901568 Jan 1 14:59 ISPBOOOT.BIN lrwxrwxrwx 1 wellslu sp 36 Jan 1 14:47 isp.sh -> /home/wellslu/Q654/build/isp.sh* lrwxrwxrwx 1 wellslu sp 40 Jan 1 14:47 nor_isp.sh -> /home/wellslu/Q654/build/nor_isp.sh* lrwxrwxrwx 1 wellslu sp 37 Jan 1 14:47 part.sh -> /home/wellslu/Q654/build/part.sh* -rw-r--r-- 1 wellslu sp 564031488 Jan 1 14:58 rootfs.img -rw-r--r-- 1 wellslu sp 834528 Jan 2 14:58 u-boot.img -rw-r--r-- 1 wellslu sp 9846045 Jan 2 14:58 uImage -rw-r--r-- 1 wellslu sp 135516 Jan 2 14:58 xboot.img wellslu@scdiu3:~/Q654$
  • xboot.img: Image file of X-Boot, the first-stage boot-loader responsible for DDR SDRAM initialization and training, loading images of TF-A, OP-TEE, U-Boot, and initiating the execution of TF-A.

  • u-boot.img: Image file of U-boot, the second-stage boot-loader responsible for loading and running the Linux kernel image.

  • uImage: Image file of the compressed Linux kernel with a U-Boot header.

  • rootfs.img: Image file of the root file-system of Linux.

  • dtb: Device-tree blob file. Note: dtb has been merged into the U-Boot image. This copy is provided for your reference; U-Boot will load the dtb inside it.

  • fip.img: Image file comprising images of Trusted Firmware-A (TF-A) and Open Portable Trusted Execution Environment (OP-TEE).

  • ISPBOOOT.BIN: Binary file containing X-boot, U-boot, and all other images. It is for in-system programming.

Copy Flash Image File ISPBOOOT.BIN to a USB Flash Drive

After compilation processes, a flash image file ISPBOOOT.BIN is stored in out folder in project’s top directory. Refer to the report of 'll out/ISPBOOOT.BIN'command below:

wellslu@scdiu3:~/Q654$ ll out/ISPBOOOT.BIN -rw-r--r-- 1 wellslu sp 577901568 Jan 1 14:59 ISPBOOOT.BIN wellslu@scdiu3:~/Q654$

Please copy the ISPBOOOT.BIN file to the root directory of a USB flash drive formatted to DOS/Windows FAT32 or FAT16 file-system. Note that the FAT32 or FAT16 file-system should be in the first or the sole partition of the USB flash drive.

If size of rootfs image is greater 4032 MiB, more than one flash image files will be created. For example, if size of rootffs image is 6000 MiB, two flash image image files, ISPBOOOT.BIN and ISPBOOT1.BIN, will be created. If size of rootffs image is 9000 MiB, three flash image image files, ISPBOOOT.BIN, ISPBOOT1.BIN and ISPBOOT2.BIN, will be created. Please copy all flash image files to the USB flash drive.

Set Boot-selection Switches to “Boot from USB”

Set boot-selection switches to “Boot from USB”. For example, if you are using SP7350 Evaluation Board, please set boot-selection switch SW2 to all OFF (1111) and SW3 to OFF-OFF-ON-OFF (1101) for booting from a USB flash drive. Refer to picture below, boot-selection switches SW2 and SW3 of SP7350 Evaluation Board are set to “Boot from USB.”

Refer to Appendix for details of boot selection switches of SP7350 Evaluation Board and boot-strap pins of SP7350.

Write All Images to a Flash Device

Plug the USB flash drive which contains ISPBOOOT.BIN into a USB socket (either USB2.0 or USB3.0 socket) of SP7350 platforms and turn on power of it. After power on, SP7350 will initiate the boot process, loading images from the USB drive. It first loads x-boot from ISPBOOOT.BIN. x-boot loads fip and U-Boot images. U-Boot will then loads all images, verify md5-checksum and write them to flash device one by one.

Wait for the process to complete. Finally, you will see screen like:

ISP all: Done” means all images were written to eMMC successfully.

Boot System from the Flash Device

Set boot-select switches to boot from a flash device, for example, in previous step, if images are written into an eMMC device, please set boot select switches to “boot from eMMC device”. If you are using SP7350 Evaluation board, please set boot-selection switch SW2 to all OFF (1111) and SW3 to all OFF (1111) for booting from the eMMC device. Refer to picture below:

Now, you are ready to boot SP7350 from eMMC device. Turn on power of SP7350 platform again to boot system.

In-system Program (ISP) from an SD Card

Note that you can also copy the flash image file ISPBOOOT.BIN (or plus ISPBOOT1.BIN, ISPBOOT2.BIN, and etc.) to root directory of a micro SD card to do the in-system-program to a flash device. The SD card should be formatted to DOS/Windows FAT32 or FAT16 file-system. Note that SP7350 only detects ISPBOOOT.BIN in the first partition.

Set boot-selection switches to “boot from SD card”. For example, if you are using SP7350 Evaluation Board, please set boot-selection switch SW2 to all OFF (1111) and SW3 to OFF-OFF-ON-ON (1100) for booting from SD card.

Plug your SD card into micro SD socket of the SP7350 platform, and then turn on its power. SP7350 will start to do the ISP process by booting from the SD card.

Appendix

Boot-selection Switches of SP7350 Evaluation Board

Refer to definition of boot selection switches of SP7350 Evaluation Board below:

Boostrap pins

-

-

MX2

MX0

MX6

MX5

MX3

MX2

Boot switches

DIP-SW2

DIP-SW3

Boot devices

1

2

3

4

1

2

3

4

eMMC boot

x

x

1

x

1

1

1

1

SPI-NAND boot

x

x

1

x

1

1

1

0

USB boot

x

x

1

x

1

1

0

1

SDC boot

x

x

1

x

1

1

0

0

SPI-NOR boot

x

x

1

x

1

0

1

1

8-bit NAND

x

x

1

x

1

0

0

0

Note “1” means switch OFF while “0” means switch ON. “x” means don’t care.

Bootstrap Pins of SP7350

State of bootstrap pins of SP7350 will be read into bootstrap register (G0.31) at the moment that power-on reset is released. Refer to definition of boot-strap pins of SP7350 below:

Boot-strap pins of SP7350

Boot devices

MX6

MX5

MX4

MX3

MX2

MX1

MX0

1

1

1

1

1

x

x

eMMC boot

1

1

1

0

1

x

x

SPI-NAND boot

1

1

0

1

1

x

x

USB boot

1

1

0

0

1

x

x

SDC boot

1

0

1

1

1

x

x

SPI-NOR

1

0

0

0

1

x

x

8-bit NAND

Note:

  1. If MX1 = 0, JTAG interface of CA55 of SP7350 will be enabled.

  2. If MX2 = 0, SP7350 will enter test mode. Always set to 1 for normal operation.