The goal of the document is to illustrate how to create an SD card with SP7021 Linux kernel.
Please follow the following steps.
1. Run ‘make config’
Get latest code from git server of SP7021 (2. HOW TO GET SOURCE FILE AND PACKAGE ) and run make config on top folder. After configuration menu pops up, choose board you have. For example, press 3 for SP7021 Demo Board (V3). Press enter and then press 1 for selecting C-chip. Finally, press 4 and then enter to start to prepare building environment. Refer to screenshot below:
Wait for ‘make config’ completing.
2. Run ‘make all’
Run make all to start to create image for SD card. After 'make all' completes, you will see screen like:
From information on screen, you find two partitions are created in the image for SD card. The first partition starts at sector 2048 and ends at sector 104447. Its size is 50 MiB and file-system is W95 FAT. The second partition starts at sector 104448 and ends at sector 137215. Its size is 16MiB and file-system is Linux (ext3).
3. Image files of output
The built image files are stored at out/boot2linux_SDcard/. Refer to screenshot of list of the folder:
ISPBOOOT.BIN is a binary file in which xboot is stored. xboot is a boot-loader which loads and runs u-boot during power-on booting processes. u-boot.img is u-boot image file. uImage is image file of compressed Linux kernel. uEnv.txt is an environment file of u-boot. u-boot will import the environment variables in the file after it completes initializing. If uenvcmd command is defined in uEnv.txt, u-boot will run the uenvcmd command after completing importing uEnv.txt. a926.img is an image file for processor A926. The default script of u-boot will load a926.img and run it if it exists.
ISP_SD_BOOOT.img is an image for burning an SD card. It contains all files in both partitions.
4. Write image to an SD card
Use an application to write image file, ISP_SD_BOOOT.img, to an SD card. The capacity of SD card should be larger than size of image file, ISP_SD_BOOOT.img. For example, if you want to use “Win32 Disk Imager” to write image to an SD card. First, download the it from https://sourceforge.net/projects/win32diskimager/:
Then, install it and run. After application window pops, selection “Image File” and “Device”. Finally, press “Write” button to start to write. Refer to screenshot when “Win32 Disk Imager” is writing image file, ISP_SD_BOOOT.img, to an SD card (F:\):
Another example is using balenaEther. Refer to screenshot when balena Etcher” is writing image file, ISP_SD_BOOOT.img, to an SD card:
5. Boot from an SD card
Insert your SD card and set DIP-SW for booting from SD card. For example, if you are using SP7021 Demo Board (V1/V2/V3), you need to set DIP-SW to ON-ON for booting from SD card. Refer to picture below:
DIP-SW was set to ON-ON.
Turn on power of SP7021 board to start.
At the first time, you boot Linux from a new burn SD card. The built-in script of Linux to run fdisk command to extend the size of rootfs partition to the end of SD card and then re-boot. Refer to log while Linux script is extending size of rootfs:
[ 2.002577] devtmpfs: mounted [ 2.004625] Freeing unused kernel memory: 1024K [ 2.004826] Run /sbin/init as init process /etc/init.d/rcS starts... Mounting other filesystems ... rc.extra [bg] sdcard boot set... partition set 0x00001746 totalsize=16358834176 0x0000000A extra done totalsize=31950840 startsector=104448 The number of cylinders for this disk is set to 499232. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): Disk /dev/mmcblk1: 15 GB, 16358834176 bytes, 31950848 sectors 499232 cylinders, 4 heads, 16 sectors/track Units: sectors of 1 * 512 = 512 bytes Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type /dev/mmcblk1p1 0,32,33 6,127,57 2048 104447 102400 50.0M b Win95 FAT32 /dev/mmcblk1p2 6,127,58 8,138,2 104448 137215 32768 16.0M 83 Linux Command (m for help): Partition number (1-4): Command (m for help): Partition type p primary partition (1-4) e extended Partition number (1-4): First sector (16-31950847, default 16): Last sector or +size{,K,M,G,T} (104448-31950847, default 31950847): Command (m for help): Disk /dev/mmcblk1: 15 GB, 16358834176 bytes, 31950848 sectors 499232 cylinders, 4 heads, 16 sectors/track Units: sectors of 1 * 512 = 512 bytes Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type /dev/mmcblk1p1 0,32,33 6,127,57 2048 104447 102400 50.0M b Win95 FAT32 /dev/mmcblk1p2 1023,3,16 1023,3,16 104448 31950840 31846393 15.1G 83 Linux Command (m for help): The partition table has been altered. Calling ioctl() to re-read partition table fdisk: WARNING: rereading partition table failed, kernel still uses old table: Device or resource busy End of /etc/init.d/rcS [ 4.319145] EXT4-fs (mmcblk1p2): re-mounted. Opts: (null) The system is going down NOW! Sent SIGTERM to all processes Sent SIGKILL to all processes Requesting system reboot
After completing rebooting, built-in script of Linux will run resize2fs to resize the rootfs file-system to make use of whole partition. It takes a while for completing resizing rootfs. Refer to screenshot when resizing:
You are ready to use SP7021 Linux after resizing.
Appendix: How to extend size of rootfs partition to maximum manually?
1. Use fdisk to extend size of rootfs partition to end of the SD card.
Run fdisk as below:
fdisk /dev/mmcblk1
Note that SD card device is at /dev/mmcblk1.
a) Press p to list partitions of the SD card.
b) Press d and then 2 to delete the second (rootfs) partition.
c) Press p to list partitions of the SD card again.
d) Press n and, p, 2, 104448 and then 31950839 to add back the second (rootfs) partition. Note that 104448 is start-LBA while 31950839 is new end-LBA of the partition.
e) Press p to list partitions of the SD card again. Confirm modification of partitions.
f) Press w to write back partition to the SD card.
g) Run reboot command to re-boot system.
Refer to screenshot below:
2. Run resize2fs to extend size of file-system to make use the whole partition
Run resize2fs command as below:
resize2fs /dev/mmcblk1p2
0 Comments