-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
artik: add build scripts to generate sdfuse image
This patch adds build scripts to generate sdfuse image which can do recovery from sdcard into eMMC. This script also can generate sd card bootable image with -m option. Signed-off-by: Chanho Park <[email protected]>
- Loading branch information
0 parents
commit efe2c15
Showing
20 changed files
with
511 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
test -d $TARGET_DIR || mkdir -p $TARGET_DIR | ||
|
||
cd $KERNEL_DIR | ||
make distclean | ||
make $KERNEL_DEFCONFIG | ||
make zImage -j$JOBS | ||
make $KERNEL_DTB | ||
|
||
./scripts/mk_modules.sh | ||
|
||
cp arch/arm/boot/zImage $TARGET_DIR | ||
cp arch/arm/boot/dts/$KERNEL_DTB $TARGET_DIR | ||
cp vmlinux $TARGET_DIR | ||
cp usr/modules.img $TARGET_DIR | ||
|
||
KERNEL_VERSION=`make ARCH=arm kernelrelease` | ||
|
||
echo "RELEASE_KERNEL=${KERNEL_VERSION}" >> $TARGET_DIR/artik_release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
test -d $TARGET_DIR || mkdir -p $TARGET_DIR | ||
|
||
pushd $UBOOT_DIR | ||
make distclean O=$UBOOT_DIR/output | ||
make $UBOOT_DEFCONFIG O=$UBOOT_DIR/output | ||
make -j$JOBS O=$UBOOT_DIR/output | ||
|
||
pushd output | ||
cp `find . -name "env_common.o"` copy_env_common.o | ||
arm-linux-gnueabihf-objcopy -O binary --only-section=.rodata `find . -name "copy_env_common.o"` | ||
tr '\0' '\n' < copy_env_common.o | grep '=' > default_envs.txt | ||
cp default_envs.txt default_envs.txt.orig | ||
tools/mkenvimage -s 16384 -o params.bin default_envs.txt | ||
|
||
# Generate recovery param | ||
sed -i -e 's/bootcmd=run ramfsboot/bootcmd=run recoveryboot/g' default_envs.txt | ||
tools/mkenvimage -s 16384 -o params_recovery.bin default_envs.txt | ||
|
||
# Generate sd-boot param | ||
sed -i -e 's/rootdev=0/rootdev=1/g' default_envs.txt.orig | ||
tools/mkenvimage -s 16384 -o params_sdboot.bin default_envs.txt.orig | ||
rm copy_env_common.o default_envs.txt default_envs.txt.orig | ||
|
||
cp u-boot.bin $TARGET_DIR | ||
chmod 664 params.bin params_recovery.bin params_sdboot.bin | ||
cp params.bin params_recovery.bin params_sdboot.bin $TARGET_DIR | ||
cp u-boot $TARGET_DIR | ||
|
||
UBOOT_VERSION=`cat include/generated/version_autogenerated.h | grep U_BOOT_VERSION | awk -F \" '{print $2}'` | ||
|
||
echo "RELEASE_UBOOT=${UBOOT_VERSION}" >> $TARGET_DIR/artik_release | ||
|
||
popd | ||
rm -rf output | ||
|
||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
. config/common.cfg | ||
|
||
export TARGET_BOARD=artik10 | ||
export TARGET_BOARD_REAL=artik1020 | ||
export TARGET_DIR=$IMAGE_DIR/$TARGET_BOARD | ||
|
||
export KERNEL_DEFCONFIG=artik10_defconfig | ||
export KERNEL_DTB=exynos5422-artik10.dtb | ||
|
||
export UBOOT_DEFCONFIG=artik10_config | ||
export UBOOT_SPL=smdk5422-spl.bin | ||
|
||
export BL1_OFFSET=1 | ||
export BL2_OFFSET=31 | ||
export UBOOT_OFFSET=63 | ||
export TZSW_OFFSET=719 | ||
export ENV_OFFSET=1231 | ||
|
||
export EMMC_BL1_OFFSET=0 | ||
export EMMC_BL2_OFFSET=30 | ||
export EMMC_UBOOT_OFFSET=62 | ||
export EMMC_TZSW_OFFSET=718 | ||
export EMMC_ENV_OFFSET=1230 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
. config/common.cfg | ||
|
||
export TARGET_BOARD=artik5 | ||
export TARGET_BOARD_REAL=artik520 | ||
export TARGET_DIR=$IMAGE_DIR/$TARGET_BOARD | ||
|
||
export KERNEL_DEFCONFIG=artik5_defconfig | ||
export KERNEL_DTB=exynos3250-artik5.dtb | ||
|
||
export UBOOT_DEFCONFIG=artik5_config | ||
export UBOOT_SPL=espresso3250-spl.bin | ||
|
||
export BL1_OFFSET=1 | ||
export BL2_OFFSET=31 | ||
export UBOOT_OFFSET=63 | ||
export TZSW_OFFSET=719 | ||
export ENV_OFFSET=1031 | ||
|
||
export EMMC_BL1_OFFSET=0 | ||
export EMMC_BL2_OFFSET=30 | ||
export EMMC_UBOOT_OFFSET=62 | ||
export EMMC_TZSW_OFFSET=718 | ||
export EMMC_ENV_OFFSET=1031 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export ARTIK_BUILD_DIR=`pwd` | ||
export OUTPUT_DIR=$ARTIK_BUILD_DIR/output | ||
export IMAGE_DIR=$OUTPUT_DIR/images | ||
export PREBUILT_DIR=$ARTIK_BUILD_DIR/prebuilt | ||
|
||
export KERNEL_DIR=$ARTIK_BUILD_DIR/../linux-artik | ||
export UBOOT_DIR=$ARTIK_BUILD_DIR/../u-boot-artik | ||
|
||
export JOBS=`getconf _NPROCESSORS_ONLN` | ||
export CROSS_COMPILE=arm-linux-gnueabihf- | ||
export ARCH=arm | ||
|
||
export TMP_DIR=$OUTPUT_DIR/tmp | ||
|
||
export BOOT_SIZE=32 | ||
export MODULE_SIZE=32 | ||
export INITRD=$PREBUILT_DIR/uInitrd | ||
|
||
export RELEASE_VER=artik_os_1.0.0 | ||
|
||
export ROOTFS_FILE=fedora-arm-artik-rootfs-20151209112052.tar.gz | ||
export ROOTFS_FILE_MD5=8493add7641a2ae4ef975ba6929fda4e | ||
export ROOTFS_TAG=release/${TARGET_BOARD_REAL}/${RELEASE_VER} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
if [ "$#" != "1" ]; then | ||
echo "Please specify a device node of sdcard" | ||
echo "ex) sudo ./expand_rootfs.sh /dev/sdc" | ||
echo "You can see the node from lsblk command" | ||
exit 0 | ||
fi | ||
|
||
DEVICE=$1 | ||
|
||
for disk in ${DEVICE}* | ||
do | ||
sudo umount $disk | ||
done | ||
|
||
sudo fdisk $DEVICE <<EOF | ||
p | ||
d | ||
3 | ||
n | ||
p | ||
3 | ||
w | ||
EOF | ||
|
||
sync; sync | ||
|
||
sudo e2fsck -f -y ${DEVICE}3 | ||
sudo resize2fs ${DEVICE}3 | ||
|
||
sync; sync | ||
|
||
echo "Resize complete" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
set -e | ||
|
||
die() { | ||
if [ -n "$1" ]; then echo $1; fi | ||
exit 1 | ||
} | ||
|
||
test -e $TARGET_DIR/zImage || die "not found" | ||
test -e $TARGET_DIR/$KERNEL_DTB || die "not found" | ||
test -e $INITRD || die "not found" | ||
|
||
test -e $TARGET_DIR || mkdir -p $TARGET_DIR | ||
test -e $TMP_DIR || mkdir -p $TMP_DIR | ||
|
||
cp $INITRD $TARGET_DIR/uInitrd | ||
|
||
pushd $TMP_DIR | ||
dd if=/dev/zero of=boot.img bs=1M count=$BOOT_SIZE | ||
sudo mkfs.vfat -n boot boot.img | ||
test -d mnt || mkdir mnt | ||
sudo mount -o loop boot.img mnt | ||
|
||
sudo cp $TARGET_DIR/zImage mnt | ||
sudo cp $TARGET_DIR/$KERNEL_DTB mnt | ||
sudo cp $TARGET_DIR/uInitrd mnt | ||
|
||
sync; sync; | ||
sudo umount mnt | ||
|
||
test -d $TARGET_DIR || mkdir -p $TARGET_DIR | ||
mv boot.img $TARGET_DIR | ||
|
||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
set -e | ||
|
||
MICROSD_IMAGE=$1 | ||
|
||
SD_BOOT_SZ=`expr $ENV_OFFSET + 32` | ||
|
||
test -e $PREBUILT_DIR/$TARGET_BOARD/bl1.bin || exit 0 | ||
test -e $PREBUILT_DIR/$TARGET_BOARD/bl2.bin || exit 0 | ||
test -e $PREBUILT_DIR/$TARGET_BOARD/tzsw.bin || exit 0 | ||
test -e $TARGET_DIR/u-boot.bin || exit 0 | ||
|
||
if [ "$MICROSD_IMAGE" == "1" ]; then | ||
PARAMS_NAME="params_sdboot.bin" | ||
else | ||
PARAMS_NAME="params_recovery.bin" | ||
fi | ||
|
||
test -e $TARGET_DIR/$PARAMS_NAME || exit 0 | ||
|
||
IMG_NAME=sd_boot.img | ||
|
||
test -d ${TARGET_DIR} || mkdir -p ${TARGET_DIR} | ||
test -d ${TMP_DIR} || mkdir -p ${TMP_DIR} | ||
|
||
pushd ${TMP_DIR} | ||
|
||
cp $PREBUILT_DIR/$TARGET_BOARD/bl1.bin $TARGET_DIR/ | ||
cp $PREBUILT_DIR/$TARGET_BOARD/bl2.bin $TARGET_DIR/ | ||
cp $PREBUILT_DIR/$TARGET_BOARD/tzsw.bin $TARGET_DIR/ | ||
|
||
dd if=/dev/zero of=$IMG_NAME bs=512 count=$SD_BOOT_SZ | ||
|
||
dd conv=notrunc if=$TARGET_DIR/bl1.bin of=$IMG_NAME bs=512 seek=$BL1_OFFSET | ||
dd conv=notrunc if=$TARGET_DIR/bl2.bin of=$IMG_NAME bs=512 seek=$BL2_OFFSET | ||
dd conv=notrunc if=$TARGET_DIR/u-boot.bin of=$IMG_NAME bs=512 seek=$UBOOT_OFFSET | ||
dd conv=notrunc if=$TARGET_DIR/tzsw.bin of=$IMG_NAME bs=512 seek=$TZSW_OFFSET | ||
dd conv=notrunc if=$TARGET_DIR/$PARAMS_NAME of=$IMG_NAME bs=512 seek=$ENV_OFFSET | ||
|
||
sync | ||
|
||
mv $IMG_NAME $TARGET_DIR | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
test -e $TARGET_DIR/boot.img || exit 0 | ||
test -e $TARGET_DIR/sd_boot.img || exit 0 | ||
test -e $TARGET_DIR/params.bin || exit 0 | ||
test -e $TARGET_DIR/rootfs.tar.gz || exit 0 | ||
test -e $TARGET_DIR/modules.img || exit 0 | ||
|
||
MICROSD_IMAGE=$1 | ||
|
||
repartition() { | ||
fdisk $1 << __EOF__ | ||
n | ||
p | ||
1 | ||
+${BOOT_SIZE}M | ||
n | ||
p | ||
2 | ||
+${MODULE_SIZE}M | ||
n | ||
p | ||
3 | ||
w | ||
__EOF__ | ||
} | ||
|
||
if [ "$MICROSD_IMAGE" == "1" ]; then | ||
IMG_NAME=${TARGET_BOARD}_sdcard.img | ||
else | ||
IMG_NAME=${TARGET_BOARD}_sdfuse.img | ||
fi | ||
|
||
if [ "$MICROSD_IMAGE" == "1" ]; then | ||
ROOTFS_SIZE=`gzip -l $TARGET_DIR/rootfs.tar.gz | grep rootfs | awk '{ print $2 }'` | ||
ROOTFS_GAIN=200 | ||
else | ||
ROOTFS_SIZE=`stat -c%s $TARGET_DIR/rootfs.tar.gz` | ||
ROOTFS_GAIN=100 | ||
fi | ||
ROOTFS_SZ=$((ROOTFS_SIZE >> 20)) | ||
TOTAL_SZ=`expr $ROOTFS_SZ + $BOOT_SIZE + $MODULE_SIZE + 2 + $ROOTFS_GAIN` | ||
|
||
pushd ${TMP_DIR} | ||
dd if=/dev/zero of=$IMG_NAME bs=1M count=$TOTAL_SZ | ||
|
||
cp $PREBUILT_DIR/$TARGET_BOARD/bl1.bin $TARGET_DIR/ | ||
cp $PREBUILT_DIR/$TARGET_BOARD/tzsw.bin $TARGET_DIR/ | ||
|
||
dd conv=notrunc if=$TARGET_DIR/sd_boot.img of=$IMG_NAME bs=512 | ||
|
||
repartition $IMG_NAME | ||
|
||
sync;sync;sync | ||
|
||
sudo kpartx -a -v ${IMG_NAME} | ||
|
||
LOOP_DEV1=`sudo kpartx -l ${IMG_NAME} | awk '{ print $1 }' | awk 'NR == 1'` | ||
LOOP_DEV2=`sudo kpartx -l ${IMG_NAME} | awk '{ print $1 }' | awk 'NR == 3'` | ||
|
||
sudo dd conv=notrunc if=$TARGET_DIR/boot.img of=$IMG_NAME bs=1M seek=1 count=$BOOT_SIZE | ||
|
||
let SEEK_MODULES=(${BOOT_SIZE} + 1) | ||
sudo dd conv=notrunc if=$TARGET_DIR/modules.img of=$IMG_NAME bs=1M seek=$SEEK_MODULES count=$MODULE_SIZE | ||
|
||
sudo mkfs.ext4 -F -b 4096 -L rootfs /dev/mapper/${LOOP_DEV2} | ||
test -d mnt || mkdir mnt | ||
|
||
sudo mount /dev/mapper/${LOOP_DEV2} mnt | ||
sync | ||
|
||
if [ "$MICROSD_IMAGE" == "1" ]; then | ||
sudo tar xf $TARGET_DIR/rootfs.tar.gz -C mnt | ||
sudo sed -i "s/mmcblk0p/mmcblk1p/g" mnt/etc/fstab | ||
else | ||
sudo cp $TARGET_DIR/bl1.bin mnt | ||
sudo cp $TARGET_DIR/bl2.bin mnt | ||
sudo cp $TARGET_DIR/u-boot.bin mnt | ||
sudo cp $TARGET_DIR/tzsw.bin mnt | ||
sudo cp $TARGET_DIR/params.bin mnt | ||
sudo cp $TARGET_DIR/boot.img mnt | ||
sudo cp $TARGET_DIR/modules.img mnt | ||
sudo cp $TARGET_DIR/rootfs.tar.gz mnt | ||
sudo cp $TARGET_DIR/artik_release mnt | ||
fi | ||
|
||
sync;sync | ||
|
||
sudo umount mnt | ||
sudo kpartx -d ${IMG_NAME} | ||
|
||
mv ${IMG_NAME} $TARGET_DIR | ||
|
||
popd | ||
|
||
ls -al ${TARGET_DIR}/${IMG_NAME} | ||
|
||
echo "Done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.tar.gz |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.