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 12 Next »

The goal of the document is to illustrate how to create an SD card with SP7021 Linux kernel and root file-system. 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/sdc$ ll
total 52
drwxr-xr-x 12 wellslu sp 4096 Oct 15 12:08 ./
drwxr-xr-x 19 wellslu sp 4096 Oct 15 12:03 ../
drwxr-xr-x  8 wellslu sp 4096 May 26 17:29 boot/
drwxr-xr-x  4 wellslu sp 4096 Aug 25 17:17 build/
drwxr-xr-x  7 wellslu sp 4096 Aug 19 11:45 crossgcc/
drwxr-xr-x  6 wellslu sp 4096 Sep  9  2019 eCos/
drwxr-xr-x  9 wellslu sp 4096 Jun  5 19:10 freertos/
drwxr-xr-x  8 wellslu sp 4096 Aug 19 11:45 ipack/
drwxr-xr-x  7 wellslu sp 4096 Sep  9  2019 linux/
-r--r--r--  1 wellslu sp   23 Sep  9  2019 Makefile
drwxr-xr-x  4 wellslu sp 4096 Sep  9  2019 nonos/
drwxr-xr-x  7 wellslu sp 4096 Sep  9  2019 .repo/
drwxr-xr-x  3 wellslu sp 4096 Jun 29 10:43 yocto/

2. Configure environment

Get latest source files of SP7021 from git server of SP7021 (2. HOW TO GET SOURCE FILE AND PACKAGE) and run make config command on top folder. After configuration menu pops up, first, choose board you want to build image for. For example, press 4 for SP7021 Demo Board (V3). Second, press 2 to choose to build image for SD card and then enter to start to configure building environment. Refer to screenshot below,

make config is starting to configure building environment. It takes 1~2 minutes to complete.

3. Build all images

Run make all command to start to create image for SD card. It might take several minutes to complete. After 'make all' completes, you will see screen like:

From information on screen, two partitions are created in the image of SD card. The first partition starts at sector 2048 and ends at sector 206847. Its size is 100 MiB and file-system is W95 FAT. The second partition starts at sector 206848 and ends at sector 239615. Its size is 16 MiB and file-system is Linux (ext3).

4. Image files

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. u-boot is the second stage boot-loader. It loads and runs Linux kernel image. uImage is an image file of compressed Linux kernel with u-boot header. uEnv.txt is an environment file of u-boot. u-boot imports environment variables in the file after it completes initializing. If uenvcmd command is defined in uEnv.txt, u-boot runs the uenvcmd command after it completes importing uEnv.txt. a926.img is an image file for processor A926. A926 processor is designed for taking care of real-time tasks. The default script of u-boot will load and run a926.img it if it exists in root of boot partition.

ISP_SD_BOOOT.img is an image for burning an SD card. It actually contains all files in both partitions.

5. 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 and run it. After application window pops, select “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 (G:\) below:

Another example is using “balenaEtcher”. Refer to screenshot when “balenaEtcher” is writing image file, ISP_SD_BOOOT.img, to an SD card below:

6. Boot from an SD card

Insert your SD card to SP7021 board and set its DIP-SW to “boot 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 is set to ON-ON. Refer to Selection of boot devices of SP7021 (Plus1) for details of boot selection.

Turn on power of SP7021 board to start booting.

7. Extend size of root file-system

At the first time, Linux boots from a new SD card. The built-in script of Linux will 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 partition:

[    1.706696] EXT4-fs (mmcblk1p2): mounting ext3 file system using the ext4 subsystem
[    1.793441] EXT4-fs (mmcblk1p2): mounted filesystem with ordered data mode. Opts: (null)
[    1.793709] VFS: Mounted root (ext3 filesystem) on device 179:2.
[    1.797172] devtmpfs: mounted
[    1.801289] Freeing unused kernel memory: 1024K
[    1.816633] Run /sbin/init as init process
/etc/init.d/rcS starts...
Mounting other filesystems ...
rc.extra [bg]
sdcard boot set...
partition set
0x00009BBA
totalsize=15836643328
0x00000007
extra done
totalsize=30930936 startsector=206848

The number of cylinders for this disk is set to 483296.
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, 15836643328 bytes, 30930944 sectors
483296 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     12,223,19         2048     206847     204800  100M  b Win95 FAT32
/dev/mmcblk1p2    12,223,20   15,10,59        206848     241663      34816 17.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-30930943, default 16): Last sector or +size{,K,M,G,T} (206848-30930943, default               30930943):
Command (m for help): Disk /dev/mmcblk1: 15 GB, 15836643328 bytes, 30930944 sectors
483296 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     12,223,19         2048     206847     204800  100M  b Win95 FAT32
/dev/mmcblk1p2    1023,3,16   1023,3,16       206848   30930936   30724089 14.6G 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
[    3.396729] 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
[    8.317512] reboot: Restarting system
sp_restart
+++iBoot v1.02 Jan 10 2019 11:20:28
-- B --
[d] iboot.c :96

The latest command in the script is reboot command. You’ll see system re-boot after script completes extending size of rootfs partition.

After system re-boots successfully, built-in script of Linux will run resize2fs to resize the root file-system to make use of the whole partition (It was extended in previous step.). It takes a while for completing resizing rootfs. Refer to log when resizing:

[    1.737678] EXT4-fs (mmcblk1p2): mounting ext3 file system using the ext4 subsystem
[    1.752778] EXT4-fs (mmcblk1p2): mounted filesystem with ordered data mode. Opts: (null)
[    1.753050] VFS: Mounted root (ext3 filesystem) on device 179:26.
[    1.756553] devtmpfs: mounted
[    1.760744] Freeing unused kernel memory: 1024K
[    1.879524] Run /sbin/init as init process
/etc/init.d/rcS starts...
Mounting other filesystems ...
rc.extra [bg]
sdcard boot set...
resize2fs partition
0x0000B37D
0x00000007
extra done
Filesystem at /dev/mmcblk1p2 is mounted on /; on-line resizing required
[    2.221203] EXT4-fs (mmcblk1p2): resizing filesystem from 4352 to 3840511 blocks
old_desc_blocks = 1, new_desc_blocks = 1
[   10.648447] random: crng init done
[   12.290148] EXT4-fs (mmcblk1p2): resized to 1867776 blocks
[   22.952843] EXT4-fs (mmcblk1p2): resized to 2686976 blocks
[   33.218081] EXT4-fs (mmcblk1p2): resized to 3342336 blocks
[   41.925326] EXT4-fs (mmcblk1p2): resized filesystem to 3840511
The filesystem on /dev/mmcblk1p2 is now 3840511 (4k) blocks long.

Filesystem                Size      Used Available Use% Mounted on
/dev/root                14.6G      9.9M     14.6G   0% /
devtmpfs                248.3M         0    248.3M   0% /dev
tmpfs                   248.8M         0    248.8M   0% /dev/shm
tmpfs                   248.8M         0    248.8M   0% /tmp
End of /etc/init.d/rcS

login[711]: root login on 'console'
~ #

Resizing has completed. You are ready to use SP7021 Linux.

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

where 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, 206848 and then 31116279 to add back the second (rootfs) partition. Note that 206848 is start-LBA while 31116279 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

  • No labels