@@ -834,67 +834,103 @@ pkg_dpdk
834834# ##############################################################################
835835# assembling images
836836# ##############################################################################
837- echo " Assembling kernel and rootfs image"
838- cd $ROOTDIR
839- mkdir -p $ROOTDIR /images/tmp/extlinux/
840- cat > $ROOTDIR /images/tmp/extlinux/extlinux.conf << EOF
841- timeout 30
842- default linux
843- menu title linux-lx2160a boot options
844- label primary
837+ function do_generate_extlinux_conf() {
838+ local EXTLINUX=$1
839+ local DISKIMAGE=$2
840+ local PARTNUMBER=$3
841+ local PARTUUID=` blkid -s PTUUID -o value ${DISKIMAGE} `
842+ PARTUUID=${PARTUUID} ' -0' ${PARTNUMBER} # specific partition uuid
843+
844+ mkdir -p $( dirname ${EXTLINUX} )
845+
846+ cat > ${EXTLINUX} << EOF
847+ timeout 30
848+ default linux
849+ menu title linux-lx2160a boot options
850+ label primary
845851 menu label primary kernel
846852 linux /boot/Image.gz
847853 fdtdir /boot/
848- APPEND console=ttyAMA0,115200 earlycon=pl011,mmio32,0x21c0000 default_hugepagesz=1024m hugepagesz=1024m hugepages=2 pci=pcie_bus_perf root=PARTUUID=30303030-01 rw rootwait
854+ APPEND console=\$ {console} earlycon=pl011,mmio32,0x21c0000 default_hugepagesz=1024m hugepagesz=1024m hugepages=2 pci=pcie_bus_perf root=PARTUUID=$PARTUUID rw rootwait
849855EOF
856+ }
850857
851- e2mkdir -G 0 -O 0 $ROOTDIR /images/tmp/$ROOTFS .ext4:extlinux
852- e2cp -G 0 -O 0 $ROOTDIR /images/tmp/extlinux/extlinux.conf $ROOTDIR /images/tmp/$ROOTFS .ext4:extlinux/
853- e2mkdir -G 0 -O 0 $ROOTDIR /images/tmp/$ROOTFS .ext4:boot
854- e2cp -G 0 -O 0 $ROOTDIR /images/tmp/linux/boot/Image.gz $ROOTDIR /images/tmp/$ROOTFS .ext4:boot/
855- e2mkdir -G 0 -O 0 $ROOTDIR /images/tmp/$ROOTFS .ext4:boot/freescale
856- e2cp -G 0 -O 0 $ROOTDIR /images/tmp/linux/boot/freescale/fsl-lx216* .dtb $ROOTDIR /images/tmp/$ROOTFS .ext4:boot/freescale/
857-
858- # Copy over kernel image
859- echo " Copying kernel modules"
860- cd $ROOTDIR /images/tmp/linux/
861- for i in ` find lib` ; do
862- if [ -d $i ]; then
863- e2mkdir -G 0 -O 0 $ROOTDIR /images/tmp/$ROOTFS .ext4:usr/$i
864- fi
865- if [ -f $i ]; then
866- DIR=` dirname $i `
867- e2cp -v -G 0 -O 0 -p $ROOTDIR /images/tmp/linux/$i $ROOTDIR /images/tmp/$ROOTFS .ext4:usr/$DIR
868- fi
869- done
870- cd -
871-
872- # install restool
873- echo " Install restool"
874- cd $ROOTDIR /
875- e2cp -p -G 0 -O 0 $ROOTDIR /build/restool/install/usr/bin/ls-append-dpl $ROOTDIR /images/tmp/$ROOTFS .ext4:/usr/bin/
876- e2cp -p -G 0 -O 0 $ROOTDIR /build/restool/install/usr/bin/ls-main $ROOTDIR /images/tmp/$ROOTFS .ext4:/usr/bin/
877- e2cp -p -G 0 -O 0 $ROOTDIR /build/restool/install/usr/bin/restool $ROOTDIR /images/tmp/$ROOTFS .ext4:/usr/bin/
878- e2ln images/tmp/$ROOTFS .ext4:/usr/bin/ls-main /usr/bin/ls-addmux
879- e2ln images/tmp/$ROOTFS .ext4:/usr/bin/ls-main /usr/bin/ls-addni
880- e2ln images/tmp/$ROOTFS .ext4:/usr/bin/ls-main /usr/bin/ls-addsw
881- e2ln images/tmp/$ROOTFS .ext4:/usr/bin/ls-main /usr/bin/ls-listmac
882- e2ln images/tmp/$ROOTFS .ext4:/usr/bin/ls-main /usr/bin/ls-listni
883-
884- # install udev rules
885- find " $ROOTDIR /configs/linux" -type f -iname " *.rules" -printf " %f\0" | e2cp -v -G 0 -O 0 -P 644 -0 -s " $ROOTDIR /configs/linux" -d " $ROOTDIR /images/tmp/$ROOTFS .ext4:/etc/udev/rules.d"
858+ function do_install_extlinux_conf() {
859+ local EXTLINUX=" $1 "
860+ local FSIMG=" $2 "
861+
862+ e2mkdir -G 0 -O 0 $FSIMG :extlinux
863+ e2cp -G 0 -O 0 $EXTLINUX $FSIMG :extlinux/
864+ }
865+
866+ function do_install_kernel() {
867+ local FSIMG=" $1 "
868+
869+ echo " Installing kernel to rootfs"
870+ e2mkdir -G 0 -O 0 $FSIMG :boot
871+ e2cp -v -G 0 -O 0 $ROOTDIR /images/tmp/linux/boot/Image.gz $FSIMG :boot/
872+ e2mkdir -G 0 -O 0 $FSIMG :boot/freescale
873+ e2cp -v -G 0 -O 0 $ROOTDIR /images/tmp/linux/boot/freescale/fsl-lx216* .dtb $FSIMG :boot/freescale/
874+
875+ cd $ROOTDIR /images/tmp/linux/
876+ for i in ` find lib` ; do
877+ if [ -d $i ]; then
878+ e2mkdir -G 0 -O 0 $FSIMG :usr/$i
879+ fi
880+ if [ -f $i ]; then
881+ DIR=` dirname $i `
882+ e2cp -v -G 0 -O 0 -p $ROOTDIR /images/tmp/linux/$i $FSIMG :usr/$DIR
883+ fi
884+ done
885+ }
886+
887+ function do_install_restool() {
888+ local FSIMG=" $1 "
889+
890+ echo " Installing restool to rootfs"
891+ cd $ROOTDIR /
892+ e2cp -p -G 0 -O 0 $ROOTDIR /build/restool/install/usr/bin/ls-append-dpl $FSIMG :/usr/bin/
893+ e2cp -p -G 0 -O 0 $ROOTDIR /build/restool/install/usr/bin/ls-main $FSIMG :/usr/bin/
894+ e2cp -p -G 0 -O 0 $ROOTDIR /build/restool/install/usr/bin/restool $FSIMG :/usr/bin/
895+ e2ln images/tmp/$ROOTFS .ext4:/usr/bin/ls-main /usr/bin/ls-addmux
896+ e2ln images/tmp/$ROOTFS .ext4:/usr/bin/ls-main /usr/bin/ls-addni
897+ e2ln images/tmp/$ROOTFS .ext4:/usr/bin/ls-main /usr/bin/ls-addsw
898+ e2ln images/tmp/$ROOTFS .ext4:/usr/bin/ls-main /usr/bin/ls-listmac
899+ e2ln images/tmp/$ROOTFS .ext4:/usr/bin/ls-main /usr/bin/ls-listni
900+ }
901+
902+ function do_install_udev_rules() {
903+ local FSIMG=" $1 "
904+
905+ find " $ROOTDIR /configs/linux" -type f -iname " *.rules" -printf " %f\0" | e2cp -v -G 0 -O 0 -P 644 -0 -s " $ROOTDIR /configs/linux" -d " $FSIMG :/etc/udev/rules.d"
906+ }
907+
908+ function do_allocate_disk_image() {
909+ local IMAGE=" $1 "
910+ local PART1_SIZE=$2
911+
912+ rm -f $IMAGE
913+ truncate -s 64M $IMAGE
914+ truncate -s +$PART1_SIZE $IMAGE
915+
916+ parted --script $IMAGE mklabel msdos mkpart primary 64MiB $(( 64 * 1024 * 1024 + PART1 _SIZE- 1 )) B
917+ }
918+
919+ echo " Assembling rootfs"
920+ do_install_kernel $ROOTDIR /images/tmp/$ROOTFS .ext4
921+ do_install_restool $ROOTDIR /images/tmp/$ROOTFS .ext4
922+ do_install_udev_rules $ROOTDIR /images/tmp/$ROOTFS .ext4
886923
887924# collect generated images
888925declare -a IMAGES
889926
890- echo " Assembling rootfs Image"
891- cd $ROOTDIR /
892- truncate -s 64M $ROOTDIR /images/tmp/$ROOTFS .img
893- truncate -s +$ROOTFS_SIZE $ROOTDIR /images/tmp/$ROOTFS .img
927+ echo " Assembling disk images"
928+ do_allocate_disk_image $ROOTDIR /images/tmp/$ROOTFS .img $ROOTFS_SIZE
894929ROOTFS_IMG_SIZE=$( stat -c " %s" $ROOTDIR /images/tmp/$ROOTFS .img)
895- parted --script $ROOTDIR /images/tmp/$ROOTFS .img mklabel msdos mkpart primary 64MiB $(( 64 * 1024 * 1024 + ROOTFS_SIZE- 1 )) B
896- # Generate the above partuuid 3030303030 which is the 4 characters of '0' in ascii
897- echo " 0000" | dd of=$ROOTDIR /images/tmp/$ROOTFS .img bs=1 seek=440 conv=notrunc
930+
931+ # generate extlinux.conf after partition table, to pick up generated random partuuid
932+ do_generate_extlinux_conf $ROOTDIR /images/tmp/extlinux/extlinux.conf $ROOTDIR /images/tmp/$ROOTFS .img 1
933+ do_install_extlinux_conf $ROOTDIR /images/tmp/extlinux/extlinux.conf $ROOTDIR /images/tmp/$ROOTFS .ext4
898934dd if=$ROOTDIR /images/tmp/$ROOTFS .ext4 of=$ROOTDIR /images/tmp/$ROOTFS .img bs=1M seek=64 conv=notrunc
899935
900936# add default prefix for short DPL/DPC variables
@@ -1001,9 +1037,7 @@ if [ "${BOOTSOURCE}" = "auto" ]; then
10011037 # generate boot image
10021038 IMG=${SOC,,} _rev${CPU_REVISION} _${MODULE,,} _${BOARD,,} _multi_${CPU_SPEED} _${BUS_SPEED} _${DDR_SPEED} _${SERDES} -${REPO_PREFIX} .img
10031039 rm -rf $ROOTDIR /images/${IMG}
1004- truncate -s 64M $ROOTDIR /images/${IMG}
1005- truncate -s +$BOOTPART_SIZE $ROOTDIR /images/${IMG}
1006- parted --script $ROOTDIR /images/${IMG} mklabel msdos mkpart primary 64MiB $(( 64 * 1024 * 1024 + BOOTPART_SIZE- 1 )) B
1040+ do_allocate_disk_image $ROOTDIR /images/${IMG} $BOOTPART_SIZE
10071041
10081042 e2cp -G 0 -O 0 $ROOTDIR /images/${XSPI_IMG} $ROOTDIR /images/tmp/boot.part:/xspi.img
10091043
0 commit comments