mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 05:06:43 +00:00
bcm2835-bootloader: merge image makescript with scripts/mkimage, rename 'mkimage-syslinux' to 'mkimage'
Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
parent
3e1730b120
commit
c0de147498
@ -1,124 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# This file is part of OpenELEC - http://www.openelec.tv
|
|
||||||
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
|
||||||
#
|
|
||||||
# OpenELEC is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# OpenELEC is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
cleanup()
|
|
||||||
{
|
|
||||||
echo "image: cleanup..."
|
|
||||||
umount "$OE_TMP" &>/dev/null || :
|
|
||||||
losetup -d "$LOOP"
|
|
||||||
[ -f "$OE_TMP/ldlinux.sys" ] && chattr -i "$OE_TMP/ldlinux.sys" || :
|
|
||||||
rm -rf "$OE_TMP"
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
|
|
||||||
trap cleanup SIGINT
|
|
||||||
|
|
||||||
# set variables
|
|
||||||
OE_TMP=$(mktemp -d)
|
|
||||||
SYSTEM_SIZE=128
|
|
||||||
# 3STORAGE_SIZE must be >= 32 !
|
|
||||||
STORAGE_SIZE=32
|
|
||||||
DISK_SIZE=$(( $SYSTEM_SIZE + $STORAGE_SIZE ))
|
|
||||||
DISK="$TARGET_IMG/$IMAGE_NAME.img"
|
|
||||||
LOOP=$(losetup -f)
|
|
||||||
|
|
||||||
# ensure loopX not in use
|
|
||||||
umount "$OE_TMP" &>/dev/null || :
|
|
||||||
umount "$LOOP" &>/dev/null >/dev/null || :
|
|
||||||
losetup -d "$LOOP" &>/dev/null >/dev/null || :
|
|
||||||
|
|
||||||
# create an image
|
|
||||||
echo "image: creating image: $DISK..."
|
|
||||||
dd if=/dev/zero of="$DISK" bs=1M count="$DISK_SIZE"
|
|
||||||
sync
|
|
||||||
|
|
||||||
# write a disklabel
|
|
||||||
echo "image: creating partition table on $DISK..."
|
|
||||||
losetup "$LOOP" "$DISK"
|
|
||||||
parted -s "$LOOP" mklabel msdos
|
|
||||||
sync
|
|
||||||
|
|
||||||
# create part1
|
|
||||||
echo "image: creating par1 on $DISK..."
|
|
||||||
SYSTEM_PART_END=$(( $SYSTEM_SIZE * 1024 * 1024 / 512 + 64 ))
|
|
||||||
parted -s "$LOOP" -a min unit s mkpart primary fat32 64 $SYSTEM_PART_END
|
|
||||||
parted -s "$LOOP" set 1 boot on
|
|
||||||
|
|
||||||
# create part2
|
|
||||||
echo "image: creating part2 on $DISK..."
|
|
||||||
STORAGE_PART_START=$(( $SYSTEM_PART_END + 1 ))
|
|
||||||
parted -s "$LOOP" -a min unit s mkpart primary ext4 $STORAGE_PART_START 100%
|
|
||||||
sync
|
|
||||||
|
|
||||||
# create filesystem on part1
|
|
||||||
losetup -d "$LOOP"
|
|
||||||
echo "image: creating filesystem on part1..."
|
|
||||||
OFFSET=$(( 64 * 512 ))
|
|
||||||
SIZELIMIT=$(( $SYSTEM_SIZE * 1024 * 1024 ))
|
|
||||||
losetup -o $OFFSET --sizelimit $SIZELIMIT "$LOOP" "$DISK"
|
|
||||||
mkfs.vfat "$LOOP"
|
|
||||||
sync
|
|
||||||
|
|
||||||
# mount partition
|
|
||||||
echo "image: mounting part1 on $OE_TMP..."
|
|
||||||
mount "$LOOP" "$OE_TMP"
|
|
||||||
|
|
||||||
# create bootloader configuration
|
|
||||||
echo "image: creating bootloader configuration..."
|
|
||||||
cat >"$OE_TMP/cmdline.txt" << EOF
|
|
||||||
boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 quiet
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# copy files
|
|
||||||
echo "image: copying files to part1..."
|
|
||||||
cp $RELEASE_DIR/3rdparty/bootloader/bootcode.bin "$OE_TMP"
|
|
||||||
cp $RELEASE_DIR/3rdparty/bootloader/fixup.dat "$OE_TMP"
|
|
||||||
cp $RELEASE_DIR/3rdparty/bootloader/start.elf "$OE_TMP"
|
|
||||||
cp $TARGET_IMG/$IMAGE_NAME.kernel "$OE_TMP/kernel.img"
|
|
||||||
cp $TARGET_IMG/$IMAGE_NAME.system "$OE_TMP/SYSTEM"
|
|
||||||
|
|
||||||
# unmount part1
|
|
||||||
echo "image: unmounting part1..."
|
|
||||||
umount "$LOOP"
|
|
||||||
sync
|
|
||||||
|
|
||||||
# create filesystem on part2
|
|
||||||
losetup -d "$LOOP"
|
|
||||||
echo "image: creating filesystem on part2..."
|
|
||||||
OFFSET=$(( $STORAGE_PART_START * 512 ))
|
|
||||||
losetup -o $OFFSET "$LOOP" "$DISK"
|
|
||||||
mke2fs -q -t ext4 -m 0 "$LOOP"
|
|
||||||
e2fsck -n "$LOOP"
|
|
||||||
sync
|
|
||||||
|
|
||||||
# add resize mark
|
|
||||||
echo "image: mounting part2 on $OE_TMP..."
|
|
||||||
mount "$LOOP" "$OE_TMP"
|
|
||||||
touch "$OE_TMP/.please_resize_me"
|
|
||||||
echo "image: unmounting part2..."
|
|
||||||
umount "$LOOP"
|
|
||||||
sync
|
|
||||||
|
|
||||||
# gzip
|
|
||||||
echo "image: compressing..."
|
|
||||||
gzip $DISK
|
|
||||||
|
|
||||||
# cleanup
|
|
||||||
cleanup
|
|
@ -25,13 +25,3 @@ mkdir -p $RELEASE_DIR/3rdparty/bootloader
|
|||||||
cp -PR $BUILD/bcm2835-bootloader-*/bootcode.bin $RELEASE_DIR/3rdparty/bootloader/
|
cp -PR $BUILD/bcm2835-bootloader-*/bootcode.bin $RELEASE_DIR/3rdparty/bootloader/
|
||||||
cp -PR $BUILD/bcm2835-bootloader-*/fixup_x.dat $RELEASE_DIR/3rdparty/bootloader/fixup.dat
|
cp -PR $BUILD/bcm2835-bootloader-*/fixup_x.dat $RELEASE_DIR/3rdparty/bootloader/fixup.dat
|
||||||
cp -PR $BUILD/bcm2835-bootloader-*/start_x.elf $RELEASE_DIR/3rdparty/bootloader/start.elf
|
cp -PR $BUILD/bcm2835-bootloader-*/start_x.elf $RELEASE_DIR/3rdparty/bootloader/start.elf
|
||||||
|
|
||||||
if [ "$BUILD_IMAGE" = "yes" -a -x "$BOOTLOADER_DIR/image" ] ; then
|
|
||||||
# variables used in image script must be passed
|
|
||||||
sudo env \
|
|
||||||
PATH="$PATH:/usr/sbin:/sbin" \
|
|
||||||
TARGET_IMG="$TARGET_IMG" \
|
|
||||||
IMAGE_NAME="$IMAGE_NAME" \
|
|
||||||
RELEASE_DIR="$RELEASE_DIR" \
|
|
||||||
$BOOTLOADER_DIR/image
|
|
||||||
fi
|
|
||||||
|
@ -267,8 +267,8 @@ IMAGE_NAME="$DISTRONAME-$TARGET_VERSION"
|
|||||||
tar cf $TARGET_IMG/$IMAGE_NAME.tar -C target $IMAGE_NAME
|
tar cf $TARGET_IMG/$IMAGE_NAME.tar -C target $IMAGE_NAME
|
||||||
|
|
||||||
# create image files if requested
|
# create image files if requested
|
||||||
if [ "$1" = "mkimage" -a -f $SCRIPTS/mkimage-$BOOTLOADER ]; then
|
if [ "$1" = "mkimage" -a -n "$BOOTLOADER" ]; then
|
||||||
. $SCRIPTS/mkimage-$BOOTLOADER
|
. $SCRIPTS/mkimage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# cleanup release dir
|
# cleanup release dir
|
||||||
|
@ -20,7 +20,9 @@
|
|||||||
|
|
||||||
. config/options $1
|
. config/options $1
|
||||||
|
|
||||||
$SCRIPTS/build syslinux:host
|
if [ "$BOOTLOADER" = "syslinux" ]; then
|
||||||
|
$SCRIPTS/build syslinux:host
|
||||||
|
fi
|
||||||
|
|
||||||
# set variables
|
# set variables
|
||||||
UUID_SYSTEM=$(uuidgen)
|
UUID_SYSTEM=$(uuidgen)
|
||||||
@ -28,7 +30,11 @@ $SCRIPTS/build syslinux:host
|
|||||||
OE_TMP=$(mktemp -d)
|
OE_TMP=$(mktemp -d)
|
||||||
LOOP=$(losetup -f)
|
LOOP=$(losetup -f)
|
||||||
|
|
||||||
SYSTEM_SIZE=256
|
if [ "$BOOTLOADER" = "bcm2835-bootloader" ]; then
|
||||||
|
SYSTEM_SIZE=128
|
||||||
|
else
|
||||||
|
SYSTEM_SIZE=256
|
||||||
|
fi
|
||||||
STORAGE_SIZE=32 # STORAGE_SIZE must be >= 32 !
|
STORAGE_SIZE=32 # STORAGE_SIZE must be >= 32 !
|
||||||
|
|
||||||
DISK_SIZE=$(( $SYSTEM_SIZE + $STORAGE_SIZE ))
|
DISK_SIZE=$(( $SYSTEM_SIZE + $STORAGE_SIZE ))
|
||||||
@ -65,7 +71,11 @@ trap cleanup SIGINT
|
|||||||
# create part1
|
# create part1
|
||||||
echo "image: creating part1 on $DISK..."
|
echo "image: creating part1 on $DISK..."
|
||||||
SYSTEM_PART_END=$(( $SYSTEM_SIZE * 1024 * 1024 / 512 + 64 ))
|
SYSTEM_PART_END=$(( $SYSTEM_SIZE * 1024 * 1024 / 512 + 64 ))
|
||||||
sudo parted -s "$LOOP" -a min unit s mkpart primary ext4 64 $SYSTEM_PART_END
|
if [ "$BOOTLOADER" = "syslinux" ]; then
|
||||||
|
sudo parted -s "$LOOP" -a min unit s mkpart primary ext4 64 $SYSTEM_PART_END
|
||||||
|
elif [ "$BOOTLOADER" = "bcm2835-bootloader" ]; then
|
||||||
|
sudo parted -s "$LOOP" -a min unit s mkpart primary fat32 64 $SYSTEM_PART_END
|
||||||
|
fi
|
||||||
sudo parted -s "$LOOP" set 1 boot on
|
sudo parted -s "$LOOP" set 1 boot on
|
||||||
|
|
||||||
# create part2
|
# create part2
|
||||||
@ -74,13 +84,15 @@ trap cleanup SIGINT
|
|||||||
sudo parted -s "$LOOP" -a min unit s mkpart primary ext4 $STORAGE_PART_START 100%
|
sudo parted -s "$LOOP" -a min unit s mkpart primary ext4 $STORAGE_PART_START 100%
|
||||||
sync
|
sync
|
||||||
|
|
||||||
# write mbr
|
if [ "$BOOTLOADER" = "syslinux" ]; then
|
||||||
echo "image: writing mbr..."
|
# write mbr
|
||||||
MBR="$ROOT/$TOOLCHAIN/share/syslinux/mbr.bin"
|
echo "image: writing mbr..."
|
||||||
if [ -n "$MBR" ]; then
|
MBR="$ROOT/$TOOLCHAIN/share/syslinux/mbr.bin"
|
||||||
sudo dd bs=440 count=1 conv=notrunc if="$MBR" of="$LOOP"
|
if [ -n "$MBR" ]; then
|
||||||
fi
|
sudo dd bs=440 count=1 conv=notrunc if="$MBR" of="$LOOP"
|
||||||
sync
|
fi
|
||||||
|
sync
|
||||||
|
fi
|
||||||
|
|
||||||
# create filesystem on part1
|
# create filesystem on part1
|
||||||
sudo losetup -d "$LOOP"
|
sudo losetup -d "$LOOP"
|
||||||
@ -88,19 +100,23 @@ trap cleanup SIGINT
|
|||||||
OFFSET=$(( 64 * 512 ))
|
OFFSET=$(( 64 * 512 ))
|
||||||
SIZELIMIT=$(( $SYSTEM_SIZE * 1024 * 1024 ))
|
SIZELIMIT=$(( $SYSTEM_SIZE * 1024 * 1024 ))
|
||||||
sudo losetup -o $OFFSET --sizelimit $SIZELIMIT "$LOOP" "$DISK"
|
sudo losetup -o $OFFSET --sizelimit $SIZELIMIT "$LOOP" "$DISK"
|
||||||
sudo mke2fs -q -t ext4 -m 0 "$LOOP"
|
if [ "$BOOTLOADER" = "syslinux" ]; then
|
||||||
sudo tune2fs -U $UUID_SYSTEM "$LOOP"
|
sudo mke2fs -q -t ext4 -m 0 "$LOOP"
|
||||||
sudo e2fsck -n "$LOOP"
|
sudo tune2fs -U $UUID_SYSTEM "$LOOP"
|
||||||
|
sudo e2fsck -n "$LOOP"
|
||||||
|
elif [ "$BOOTLOADER" = "bcm2835-bootloader" ]; then
|
||||||
|
sudo mkfs.vfat "$LOOP"
|
||||||
|
fi
|
||||||
sync
|
sync
|
||||||
|
|
||||||
# mount partition
|
# mount partition
|
||||||
echo "image: mounting part1 on $OE_TMP..."
|
echo "image: mounting part1 on $OE_TMP..."
|
||||||
sudo mount "$LOOP" "$OE_TMP"
|
sudo mount "$LOOP" "$OE_TMP"
|
||||||
|
|
||||||
# create bootloader configuration
|
if [ "$BOOTLOADER" = "syslinux" ]; then
|
||||||
echo "image: creating bootloader configuration..."
|
# create bootloader configuration
|
||||||
# cat >"$OE_TMP"/syslinux.cfg << EOF
|
echo "image: creating bootloader configuration..."
|
||||||
cat << EOF | sudo tee "$OE_TMP"/syslinux.cfg
|
cat << EOF | sudo tee "$OE_TMP"/syslinux.cfg
|
||||||
UI vesamenu.c32
|
UI vesamenu.c32
|
||||||
PROMPT 0
|
PROMPT 0
|
||||||
MENU TITLE Boot Menu
|
MENU TITLE Boot Menu
|
||||||
@ -141,18 +157,34 @@ LABEL live
|
|||||||
APPEND boot=UUID=$UUID_SYSTEM disk=UUID=$UUID_STORAGE quiet vga=current
|
APPEND boot=UUID=$UUID_SYSTEM disk=UUID=$UUID_STORAGE quiet vga=current
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# install extlinux
|
# install extlinux
|
||||||
echo "image: installing extlinux to part1..."
|
echo "image: installing extlinux to part1..."
|
||||||
sudo $ROOT/$TOOLCHAIN/bin/extlinux --heads=4 --sector=32 -i "$OE_TMP"
|
sudo $ROOT/$TOOLCHAIN/bin/extlinux --heads=4 --sector=32 -i "$OE_TMP"
|
||||||
|
|
||||||
# copy files
|
# copy files
|
||||||
echo "image: copying files to part1..."
|
echo "image: copying files to part1..."
|
||||||
sudo cp $TARGET_IMG/$IMAGE_NAME.kernel "$OE_TMP/KERNEL"
|
sudo cp $TARGET_IMG/$IMAGE_NAME.kernel "$OE_TMP/KERNEL"
|
||||||
sudo cp $TARGET_IMG/$IMAGE_NAME.system "$OE_TMP/SYSTEM"
|
sudo cp $TARGET_IMG/$IMAGE_NAME.system "$OE_TMP/SYSTEM"
|
||||||
sudo cp $RELEASE_DIR/splash.png "$OE_TMP"
|
sudo cp $RELEASE_DIR/splash.png "$OE_TMP"
|
||||||
sudo cp $ROOT/$TOOLCHAIN/share/syslinux/vesamenu.c32 "$OE_TMP"
|
sudo cp $ROOT/$TOOLCHAIN/share/syslinux/vesamenu.c32 "$OE_TMP"
|
||||||
sudo cp $ROOT/$TOOLCHAIN/share/syslinux/libcom32.c32 "$OE_TMP"
|
sudo cp $ROOT/$TOOLCHAIN/share/syslinux/libcom32.c32 "$OE_TMP"
|
||||||
sudo cp $ROOT/$TOOLCHAIN/share/syslinux/libutil.c32 "$OE_TMP"
|
sudo cp $ROOT/$TOOLCHAIN/share/syslinux/libutil.c32 "$OE_TMP"
|
||||||
|
|
||||||
|
elif [ "$BOOTLOADER" = "bcm2835-bootloader" ]; then
|
||||||
|
# create bootloader configuration
|
||||||
|
echo "image: creating bootloader configuration..."
|
||||||
|
cat << EOF | sudo tee "$OE_TMP"/cmdline.txt
|
||||||
|
boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 quiet
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# copy files
|
||||||
|
echo "image: copying files to part1..."
|
||||||
|
sudo cp $TARGET_IMG/$IMAGE_NAME.kernel "$OE_TMP/kernel.img"
|
||||||
|
sudo cp $TARGET_IMG/$IMAGE_NAME.system "$OE_TMP/SYSTEM"
|
||||||
|
sudo cp $RELEASE_DIR/3rdparty/bootloader/bootcode.bin "$OE_TMP"
|
||||||
|
sudo cp $RELEASE_DIR/3rdparty/bootloader/fixup.dat "$OE_TMP"
|
||||||
|
sudo cp $RELEASE_DIR/3rdparty/bootloader/start.elf "$OE_TMP"
|
||||||
|
fi # bootloader
|
||||||
|
|
||||||
# unmount part1
|
# unmount part1
|
||||||
echo "image: unmounting part1..."
|
echo "image: unmounting part1..."
|
||||||
@ -169,14 +201,18 @@ EOF
|
|||||||
sudo e2fsck -n "$LOOP"
|
sudo e2fsck -n "$LOOP"
|
||||||
sync
|
sync
|
||||||
|
|
||||||
|
# mount part2
|
||||||
echo "image: mounting part2 on $OE_TMP..."
|
echo "image: mounting part2 on $OE_TMP..."
|
||||||
sudo mount "$LOOP" "$OE_TMP"
|
sudo mount "$LOOP" "$OE_TMP"
|
||||||
|
|
||||||
|
# add resize mark
|
||||||
sudo touch "$OE_TMP/.please_resize_me"
|
sudo touch "$OE_TMP/.please_resize_me"
|
||||||
|
sync
|
||||||
|
|
||||||
# unmount part2
|
# unmount part2
|
||||||
echo "image: unmounting part2..."
|
echo "image: unmounting part2..."
|
||||||
sync
|
|
||||||
sudo umount "$LOOP"
|
sudo umount "$LOOP"
|
||||||
|
sync
|
||||||
|
|
||||||
# gzip
|
# gzip
|
||||||
echo "image: compressing..."
|
echo "image: compressing..."
|
Loading…
x
Reference in New Issue
Block a user