Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

The goal of the document is to illustrate how to build SP7021 Linux image for booting from SPI-NOR flash on SP7021 boards. SP7021 build (make) system supports two types of root file-system for SPI-NOR flash. One is initramfs file-system and other is jffs2 file-system. If you choose initramfs file-system, build system merges root file-system into Linux kernel. The whole kernel (kernel + root file-system) is loaded into and operates in DRAM directly. The advantage of initramfs file-system is that accessing speed is very fast. But since it is stored in DRAM, all changes disappear when power off. If you choose jffs2 file-system, root file-system is compressed and is stored in rootfs partition of SPI-NOR flash. The drawback of jffs2 file-system is that accessing speed is slow. But all changes are kept in SPI-NOR flash when power off.

To build image of SPI-NOR flash, first, you need to get source files of SP7021 from git server of SP7021. Second, you need to run make to build all images of SP7021. After make processes complete successfully, it will create two binary files named spi_all.bin and ISPBOOOT.BIN. Third, you need to either use flash programmer to write the spi_all.bin to SPI-NOR flash or copy ISPBOOOT.BIN to an USB drive to in-system program SPI-NOR flash. Finally, set DIP-SW to “boot from SPI-NOR flash”. You are now ready to turn on SP7021 power to boot Linux from SPI-NOR flash. For details, please follow the following steps.

1. Download source files

Get latest source files from git server of SP7021 (2. HOW TO GET SOURCE FILE AND PACKAGE). Refer to report of ll command for the contents of top folder of source of SP7021:

wellslu@scdiu3:~/q628/nor$ ll
total 52
drwxr-xr-x 12 wellslu sp 4096 Oct 15 12:01 ./
drwxr-xr-x 19 wellslu sp 4096 Oct 15 11:53 ../
drwxr-xr-x  8 wellslu sp 4096 Apr 27 18:51 boot/
drwxr-xr-x  4 wellslu sp 4096 Aug 25 12:05 build/
drwxr-xr-x  7 wellslu sp 4096 Jul 27 12:23 crossgcc/
drwxr-xr-x  6 wellslu sp 4096 Apr 27 18:51 eCos/
drwxr-xr-x  9 wellslu sp 4096 Jun  5 09:30 freertos/
drwxr-xr-x  8 wellslu sp 4096 Aug 11 16:40 ipack/
drwxr-xr-x  7 wellslu sp 4096 Apr 27 18:51 linux/
-r--r--r--  1 wellslu sp   23 Apr 27 18:51 Makefile
drwxr-xr-x  4 wellslu sp 4096 Apr 27 18:51 nonos/
drwxr-xr-x  7 wellslu sp 4096 Apr 27 18:51 .repo/
drwxr-xr-x  3 wellslu sp 4096 Jun 29 09:44 yocto/

2. Configure environment

Run make config command on top folder. After configuration menu pops up, first, choose a board you want to build image for. For example, press 1 to choose “SP7021 Ev Board”. Second, press 1 to choose to use C chip (quad core CA7). Finally, press 3 (jffs2) or 4 (initramfs) to choose to boot from SPI-NOR flash and then enter to start to configure building environment. Refer to screenshot below,

make config starts to build compiler environment. It may take a few minutes. Please wait for make config completing the processes.

3. Modify device-tree source file

This step is for jffs2 (3) root file-system. Please skip this step if you are using initramfs (4) root file-system.

Modify device-tree node sp_spinor0 in device-tree source file linux/kernel/arch/arm/boot/dts/sp7021-ev.dts to setup operating frequency SPI-NOR flash and pins as shown below:

&sp_spinor0 {
	spi-max-frequency = <50000000>;
	spi-chip-selection = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&spi_flash2_mux &spi_fla4b2_mux>;
}

where operating frequency of SPI-NOR flash is 50 MHz and SPI-NOR flash is installed in pin-group: spi_flash2_mux and spi_fla4b2_mux. Set them base on your real hardware installation.

4. Remove SECT_4K flag of SPI-NOR flash

This step is for jffs2 (3) root file-system. Please skip this step if you are using initramfs (4) root file-system.

Some SPI-NOR flashes support 4 kB sector-erase, but mkfs.jffs2 -e option does not support 4 kB size of erase. Please remove SECT_4K flag in C file “driver/mtd/spi-nor/spi-nor.c” if your NOR flash support 4 KB sector-erase . Refer to screenshot of diff report, SECT_4K flag of Winbond w25q128 flashes are removed.

5. Build SPI-NOR image

Run make all command to start to create all images of SP7021. It may take several minutes to complete. At almost final stage of building processes, make will ask you to select the use of iBoot,

Please press x and enter to continue the processes. After make all completes, you will see screenshot like:

Two binary files spi_all.bin and ISPBOOOT.BIN are built and copied to folder out. You Refer to screenshot of output of ll out command:

Binary file spi_all.bin is a pure image of SPI-NOR flash. You can use a flash programmer to write the image into an SPI-NOR flash. Refer to step 6 for detail.

Binary file ISPBOOOT.BIN consists of boot-loader (x-boot), u-boot and image of SPI-NOR flash. You can copy it to an USB drive to in-system program SPI-NOR image to SPI-NOR flash on SP7021 boards. Refer to step 7 for detail.

6. Write your SPI-NOR flash using flash programmer

Put your SPI-NOR flash chip into socket of a flash programmer. Be careful about the pin 1 position of the chip. It should be at the same corner of pin 1 of socket. Refer to picture below, an SPI-NOR flash is placed at socket of a GZUT USB flash programmer.

Run flash programmer application, for example, run GZUT_OnePro in Windows. After application window pops up, then load binary file, spi_all.bin. Press “Auto” to start to write processes automatically (including erase, write and verify). Refer to screenshot below, a Winbond 128 Mibit (16 MiB) flash chip (W25Q128) has been programmed and verified successfully.

Remove the SPI-NOR flash chip from socket. Plug the written SPI-NOR flash into socket of SPI-NOR flash of SP7021 boards.

Note that the size of spi_all.bin is about 12 MiB. So, size of SPI-NOR flash chip should be 16 MiB (or 128 Mibit) or greater.

7. In-system program SPI-NOR flash

First, copy the file ISPBOOOT.BIN to root directory of an USB flash drive. Note that the USB flash drive should be formatted to DOS/Windows FAT32 file-system. SP7021 can only load files from an USB flash drive which is formatted to FAT32 file-system. Also note that FAT32 file-system should be in the first or the sole partition of the USB flash drive.

Second, set DIP-SW (boot-select switch) to “boot from USB”. For example, if you are using SP7021 Ev Board, please set DIP-SW to OFF-OFF-OFF-OFF-ON-OFF (1-1-1-1-0-1) for booting from USB flash drive. Refer to picture below, DIP-SW is set to OFF-OFF-OFF-OFF-ON-OFF.

Refer to Selection of boot devices of SP7021 (Plus1) for details of boot selection of SP7021.

Third, plug your USB flash drive which contains ISPBOOOT.BIN into either USB socket of SP7021 board.

Finally, turn on power of SP7021 board. After power on, SP7021 starts to ”boot from USB” drive. It first loads boot-loader (x-boot) from ISPBOOOT.BIN in USB flash drive. Boot-loader loads u-boot. u-boot then runs built-in scripts which writes image to SPI-NOR flash and verify it. The processes takes 1 ~ 2 minutes. Please wait for the processes completing. At the end of processes, you will see screen like:

“ISP all: Done” means in-system program processes are done successfully.

8. Set DIP-SW to “boot from SPI-NOR flash”

Set DIP-SW (boot-select switch) to “boot from SPI-NOR flash”. For example, if you are using SP7021 Ev Board, please set DIP-SW to OFF-OFF-ON-OFF-ON-OFF (1-1-0-1-0-1) for booting from SPI-NOR flash. Refer to picture below, DIP-SW is set to OFF-OFF-ON-OFF-ON-OFF.

Now, you are ready to boot SP7021 Linux from SPI-NOR flash. Turn on power of SP7021 board to boot system.

Appendix. Layout of partitions of SPI-NOR flash

Refer to layout of partitions of a 16 MiB SPI-NOR flash. There are 6 partitions in SPI-NOR flash. The figures in parenthesis of each partition is the size of the partition. Note that root file-system of Linux is built into kernel.

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.