In this article, we will guide you through the process of downloading and compiling the SP7350 code. The source code for SP7350 is automatically updated on both GitHub and Gitee every day, ensuring users have access to the latest developments.
It's recommended to have the latest version of Ubuntu installed on your computer. This choice is optimal for compatibility and ensures a seamless compilation process. Additionally, to enhance performance and reduce compilation time, your PC should be equipped with a minimum of 4 GB DRAM.
Contents
1. Install necessary software packages
Before downloading or compiling the SP7350 code, ensure the following software packages, libraries, and Python3 packages are installed:
Packages:
git
make
u-boot-tools
openssl
bison
flex
mtd-utils
python3-pip
pv
Libraries:
libssl-dev
libmpc-dev
libgmp-dev
Python3 packages:
pycryptodomex
pyelftools
crypto
If not yet installed, use the following commands:
sudo apt install git make u-boot-tools openssl bison flex mtd-utils python3-pip pv sudo apt install libssl-dev libmpc-dev libgmp-dev pip install pycryptodomex pyelftools crypto
2. Download code from GitHub or Gitee.
Clone the repository from GitHub:
git clone https://github.com/sunplus-plus1/Q654.git
Or, clone it from Gitee:
git clone https://gitee.com/sunplus-plus1/q654.git
Update the code:
# Navigate to the Q654 directory cd Q654 # Update the code and its submodules git submodule update --init --recursive git submodule foreach git checkout master
Update to the latest code after the initial download:
cd Q654 git pull git submodule foreach git pull
These commands ensure you have the latest changes from the main repository and update all submodules within the SP7350 codebase. This guarantees that your development environment is always synced with the most recent version of the code.
After completing the update, your Q654 top folder structure should resemble the following:
wellslu@scdiu3:~/Q654$ ll total 52 drwxr-xr-x 11 wellslu sp 4096 Dec 15 12:27 ./ drwxr-xr-x 7 wellslu sp 4096 Nov 15 18:33 ../ drwxr-xr-x 6 wellslu sp 4096 Nov 15 15:38 boot/ drwxr-xr-x 3 wellslu sp 4096 Dec 29 13:20 build/ drwxr-xr-x 9 wellslu sp 4096 Nov 15 16:19 crossgcc/ drwxr-xr-x 3 wellslu sp 4096 Nov 15 15:38 firmware/ drwxr-xr-x 9 wellslu sp 4096 Dec 29 13:20 .git/ -rw-r--r-- 1 wellslu sp 1117 Nov 15 15:38 .gitmodules drwxr-xr-x 7 wellslu sp 4096 Nov 15 15:40 ipack/ drwxr-xr-x 4 wellslu sp 4096 Nov 15 15:38 linux/ -rw-r--r-- 1 wellslu sp 23 Nov 15 15:38 Makefile drwxr-xr-x 5 wellslu sp 4096 Dec 29 13:20 optee/ -rw-r--r-- 1 wellslu sp 1003 Nov 15 15:38 README.md wellslu@scdiu3:~/Q654$
This structure confirms that you have successfully updated the Q654 codebase, and your development environment is now aligned with the latest changes.
3. Configure building environment
Navigate to the top folder of your Q654 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:
In the configuration menu:
Choose the board you want to build the image for. For instance, press 1 to select "SP7350 Ev Board."
Choose the boot device. For example, press 5 to specify booting from the SD card.
Choose root file-system of Linux. For example, press 1 to opt for “BusyBox 1.31.1” as root file-system.
Choose image security. Press 1 to select building “No secure” 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.
4. Configure X-Boot feature (optional)
If you want to activate additional features or deactivate specific ones within the X-Boot, run the following command to initiate the configuration menu of X-Boot.
make xconfig
Upon executing this command, a configuration menu will appear.
Once you have made the necessary adjustments in the menu, please ensure to save the changes before exiting the menu.
5. Configure U-Boot feature (optional)
To customize U-Boot settings, run the following command to initiate the configuration menu of U-Boot.
make uconfig
Upon executing this command, a configuration menu will be displayed.
After making the necessary adjustments in the menu, please be sure to save the changes before exiting.
6. Configure Linux kernel feature (optional)
For those who want to configure specific features in the Linux kernel, run the following command to initiate the configuration menu of Linux kernel.
make kconfig
Upon executing this command, a configuration menu will appear.
After making the necessary adjustments in the menu, please ensure to save the changes before exiting.
7. 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:
The screenshot provides details about two partitions created in the SD card image. The first partition spans from sector 2,048 to sector 526,335, with a size of 256 MB and a W95 FAT file system. The second partition extends from sector 526,336 to sector 1,627,959, with a size of 537.9 MB and a Linux (ext4) file system.
8. Resulting images for SD card
Upon completion of the build process, the resulting image files are stored in the out/boot2linux_SDcard/
directory. Refer to the list below:
wellslu@scdiu3:~/Q654$ ll out/boot2linux_SDcard/ total 823876 drwxr-xr-x 2 wellslu sp 4096 Jan 1 13:53 ./ drwxr-xr-x 3 wellslu sp 4096 Jan 1 13:53 ../ -rw-r--r-- 1 wellslu sp 408526 Jan 1 13:53 fip.img -rw-r--r-- 1 wellslu sp 135516 Jan 1 13:53 ISPBOOOT.BIN -rw-r--r-- 1 wellslu sp 833515520 Jan 1 13:53 ISP_SD_BOOOT.img -rw-r--r-- 1 wellslu sp 764728 Jan 1 13:53 u-boot.img -rw-r--r-- 1 wellslu sp 1101 Jan 1 13:53 uEnv.txt -rw-r--r-- 1 wellslu sp 9846041 Jan 1 13:53 uImage wellslu@scdiu3:~/Q654$
ISPBOOOT.BIN: Binary file storing 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.
fip.img: Image file comprising images of Trusted Firmware-A (TF-A) and Open Portable Trusted Execution Environment (OP-TEE).
u-boot.img: Image file of the U-Boot boot-loader, the second-stage boot-loader responsible for loading and running the Linux kernel image.
uEnv.txt: Environment file for U-Boot. U-Boot imports environment variables from this file after initialization. If the uenvcmd command is defined in uEnv.txt, U-Boot executes the specified command after importing uEnv.txt.
uImage: Image file of the compressed Linux kernel with the U-Boot header.
ISP_SD_BOOOT.img: Image file for burning an SD card, containing all files in both partitions.
9. Create SD card
To create your SD card for booting SP7350 platforms, you can copy ISP_SD_BOOOT.img to SD card directly using the dd command. For instance:
dd if=out/boot2linux_SDcard/ISP_SD_BOOOT.img of=/dev/sda bs=1M; sync
where the SD card is accessed via a USB SD card reader and mounted on /dev/sda
10. Resulting images and in-system-program (ISP) file for flash devices.
If you choose to compile code for flash devices such as eMMC, SPI-NAND flash, 8-bit NAND flash or SPI-NOR flash, in the make config command, the output of the make will present information resembling the screenshot below:
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/Q654/build/isp.sh* lrwxrwxrwx 1 wellslu sp 40 Jan 1 14:47 nor_isp.sh -> /home/wellslu/q654/Q654/build/nor_isp.sh* lrwxrwxrwx 1 wellslu sp 37 Jan 1 14:47 part.sh -> /home/wellslu/q654/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.
11. In-system program (ISP)
To perform in-system programming of flash devices on SP7350 platforms, simply copy the ISPBOOOT.BIN file to the root directory of a USB flash drive or SD card formatted with the DOS/Windows FAT16/FAT32 file system. Ensure that the FAT32/FAT16 file system is in the first or sole partition. Insert the USB flash drive or SD card into the SP7350 platform, adjust the boot-switch to booting from the USB flash drive or SD card, power on your platform, and the system will automatically program the images into the flash devices.
Refer to: A guide to in-system programming flash devices on the SP7350 platforms