From ed0e2836138849c3d66efb7462a505d5cd3e348e Mon Sep 17 00:00:00 2001
From: guowenxu <guowenxue@gmail.com>
Date: Sat, 20 Nov 2021 20:52:48 +0800
Subject: [PATCH] update images build shell script

---
 bsp/images/build.sh |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/bsp/images/build.sh b/bsp/images/build.sh
index 8db2ddf..76377d6 100755
--- a/bsp/images/build.sh
+++ b/bsp/images/build.sh
@@ -7,7 +7,7 @@
 # +-------------------------------+-----------------------+---------------------------------+
 # |         Start  Address        |         Size          |           Usage                 |
 # +-------------------------------+-----------------------+---------------------------------+
-# |             0x0               |   32 sectors(16K)     |  Reserved for partition table   |
+# |             0x0               |     2 sectors(1K)     |  Reserved for partition table   |
 # +-------------------------------+-----------------------+---------------------------------+
 # |      2 sector(1K, 0x400)      |  20414 sectors(9M+)   |     i.MX6ULL  u-boot image      |
 # +-------------------------------+-----------------------+---------------------------------+
@@ -26,7 +26,7 @@
 ROOTFS=buildroot
 
 # linux kernel tarball path and branch
-TAR_PATH=/home/guowenxue/imx6ull/bsp/tarball
+TAR_PATH=${PRJ_PATH}/../tarball
 
 BOOT=emmc
 
@@ -37,18 +37,19 @@
     IMAGE_SIZE=2048
 fi
 
-# 1 sector - for i.MX6 or i.MX7
-UBOOT_OFSET=1
+#i.MX6/i.MX7 read uboot from mmc start on sector #2
+UBOOT_OFSET=2
+MMC_SECSIZE=512
 
-# BootRom(U-boot) Size 10MB:  20480 Sectors * 512B
+# U-boot space Size 10MB
 UBOOT_SIZE=10
 
-# vfat boot partition size
+# vfat boot partition 100MB
 BOOT_SIZE=100
 
 
 IMG_UBOOT=${IMAGE_PATH}/u-boot-imx6ull-emmc.imx
-IMG_KERNEL=${IMAGE_PATH}/Image
+IMG_KERNEL=${IMAGE_PATH}/zImage
 IMG_DTB=${IMAGE_PATH}/imx6ull-emmc.dtb
 ROOTFS_TAR=${TAR_PATH}/rootfs_${ROOTFS}.tar.bz2
 
@@ -101,16 +102,13 @@
 
 function generate_image()
 {
-    # system image block count by block=512k
-    BLOCK_CNT=`expr 2 \* ${IMAGE_SIZE}`
-
     # FAT32 boot partition start/end address in MB
     BOOT_START=${UBOOT_SIZE}
     BOOT_END=`expr ${BOOT_START} + ${BOOT_SIZE}`
 
     msg_banner " <${STAGE}> Generate system image "
 
-    dd if=/dev/zero of=${IMAGE_NAME} bs=512k count=${BLOCK_CNT}  && sync
+    dd if=/dev/zero of=${IMAGE_NAME} bs=1024k count=${IMAGE_SIZE}  && sync
     chmod a+x ${IMAGE_NAME}
 
     msg_banner " <${STAGE}> Partition system image "
@@ -139,7 +137,7 @@
 function install_sysimg()
 {
     msg_banner " <${STAGE}> Install u-boot image"
-    sudo dd if=${IMG_UBOOT} of=${IMAGE_NAME} bs=1k seek=${UBOOT_OFSET} conv=notrunc,sync
+    sudo dd if=${IMG_UBOOT} of=${IMAGE_NAME} bs=${MMC_SECSIZE} seek=${UBOOT_OFSET} conv=notrunc,sync
 
     msg_banner " <${STAGE}> Install linux kernel image"
 
@@ -180,5 +178,8 @@
 
 install_rootfs
 
+cp ${IMG_UBOOT} .
+bzip2 ${IMAGE_NAME}
+
 rm -rf ${MNT_POINT}
 

--
Gitblit v1.9.1