Downloading and Compiling Code

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.

Table of Contents

Install Necessary Software Packages

Before downloading or compiling the SP7350 code, ensure the following software packages, libraries, and Python3 packages are installed:

Packages:

  • bison

  • flex

  • git

  • make

  • mtd-utils

  • mtools

  • openssl

  • pv

  • python3-pip

  • u-boot-tools

Libraries:

  • libncurses*

  • libgmp-dev

  • libmpc-dev

  • libssl-dev

Python3 Packages:

  • crypto

  • pycryptodomex

  • pyelftools

If not yet installed, use the following commands:

sudo apt install bison flex git make mtd-utils mtools openssl pv python3-pip u-boot-tools sudo apt install libncurses* libgmp-dev libmpc-dev libssl-dev pip install crypto pycryptodomex pyelftools

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 # Initialize and update submodules git submodule update --init --recursive # Ensure all submodules are on the master branch git submodule foreach git checkout master

Update to the latest code after the initial download:

# Navigate to the Q654 directory cd Q654 # Pull the latest changes from the repository git pull # Pull updates for all submodules 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:

This structure confirms that you have successfully updated the Q654 codebase, and your development environment is now aligned with the latest changes.

While the master branch contains the latest development code, stable versions of the code are maintained in branches such as v1.0 and v1.1.

To switch to a stable branch, use the following commands:

By following these steps, your Q654 environment will be up to date with the latest stable code.

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:

image-20241007-023231.png

In the configuration menu:

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

  2. Choose the device from which the system will boot. For example, press 2 to specify booting from the SD card.

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

  4. 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.

Configure X-Boot Features (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.

Configure U-Boot Features (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.

Configure Linux Kernel Features (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.

Build Code

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

make

Alternatively, if you're not using the English version of Ubuntu, use:

LANG=C make

This command instructs make to avoid using your native language.

make will then proceed to 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.

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:

  • 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.

Create SD Card

To create your SD card for booting SP7350 platforms, you can write the image file, ISP_SD_BOOOT.img, to an SD card directly using the dd command. For instance:

where the SD card is accessed via a USB SD card reader and mounted on /dev/sda

Depend on system you are using, you may need to unmount the SD card:

umount /dev/sda

Booting Your SP7350 Platform

  1. After creating your SD card, insert it into the SD card socket on your SP7350 platform.

  2. Set the boot-switch to "Boot from SD card".

  3. Connect the cable of your UART console.

  4. Power on your SP7350 platform.

  5. The platform will initiate booting from the SD card.

  6. Once booted, you can enter your commands in the console.

For boot-switch selection guidance, please consult:

In-system Programming Flash Devices | Appendix

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.

In-system Programming a Flash Device and Booting from It.

If you intend to in-system program a flash device (e.g., eMMC) on the SP7350 platform and boot from it, please refer to:

In-system Programming Flash Devices

Log of Booting from SD Card

Refer to the log generated during the system booting from the SD card. After the boot process is complete, the 'df -hT' command is issued to display disk space usage on your SP7350 platform.