Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
508 additions
and
32 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
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
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
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
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
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,188 @@ | ||
#!/bin/sh | ||
# | ||
# Flash Raspberry Pi SD card [buildroot] | ||
# | ||
# Guillermo A. Amaral B. <g@maral.me> | ||
# | ||
|
||
SDCARD="${1}" | ||
|
||
usage() { | ||
echo "Usage: ${0} [SDCARD]" | ||
echo "Where SDCARD is your SD card device node, for example: /dev/sdx" | ||
echo | ||
echo "You will require *root* privileges in order to use this script." | ||
echo | ||
} | ||
|
||
confirm() { | ||
echo "You are about to totally decimate the following device node: ${SDCARD}" | ||
echo | ||
echo "If you are sure you want to continue? (Please write \"YES\" in all caps)" | ||
|
||
read CONTUNUE | ||
|
||
if [ "${CONTUNUE}" != "YES" ]; then | ||
echo "User didn't write \"YES\"... ABORTING!" | ||
exit 1 | ||
fi | ||
} | ||
|
||
section() { | ||
echo "*****************************************************************************************" | ||
echo "> ${*}" | ||
echo "*****************************************************************************************" | ||
sleep 1 | ||
} | ||
|
||
# environment overrides | ||
|
||
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | ||
OUTPUT_PREFIX="" | ||
|
||
# check parameters | ||
|
||
if [ -z "${SDCARD}" ] || [ "${SDCARD}" = "-h" ] || [ "${SDCARD}" = "--help" ]; then | ||
usage | ||
exit 0 | ||
fi | ||
|
||
# check if node is a block device | ||
|
||
if [ ! -b "${SDCARD}" ]; then | ||
echo "${SDCARD} is not a block device!" | ||
exit 1 | ||
fi | ||
|
||
# root privilege check | ||
|
||
USERID=`id -u` | ||
if [ ${USERID} -ne 0 ]; then | ||
echo "${0} requires root privileges in order to work." | ||
exit 0 | ||
fi | ||
|
||
# dependencies | ||
|
||
CP=`which cp` | ||
FDISK=`which fdisk` | ||
MKDIR=`which mkdir` | ||
MKFS_EXT4=`which mkfs.ext4` | ||
MKFS_VFAT=`which mkfs.vfat` | ||
MOUNT=`which mount` | ||
RMDIR=`which rmdir` | ||
SYNC=`which sync` | ||
TAR=`which tar` | ||
UMOUNT=`which umount` | ||
|
||
if [ -z "${CP}" ] || | ||
[ -z "${FDISK}" ] || | ||
[ -z "${MKDIR}" ] || | ||
[ -z "${MKFS_EXT4}" ] || | ||
[ -z "${MKFS_VFAT}" ] || | ||
[ -z "${MOUNT}" ] || | ||
[ -z "${RMDIR}" ] || | ||
[ -z "${TAR}" ] || | ||
[ -z "${UMOUNT}" ]; then | ||
echo "Missing dependencies:\n" | ||
echo "CP=${CP}" | ||
echo "FDISK=${FDISK}" | ||
echo "MKDIR=${MKDIR}" | ||
echo "MKFS_EXT4=${MKFS_EXT4}" | ||
echo "MKFS_VFAT=${MKFS_VFAT}" | ||
echo "MOUNT=${MOUNT}" | ||
echo "RMDIR=${RMDIR}" | ||
echo "TAR=${TAR}" | ||
echo "UMOUNT=${UMOUNT}" | ||
exit 1 | ||
fi | ||
|
||
# sanity check | ||
|
||
if [ ! -d "images/rpi-firmware" ] || [ ! -f "images/rootfs.tar" ]; then | ||
if [ -d "output/images/rpi-firmware" ] && [ -f "output/images/rootfs.tar" ]; then | ||
OUTPUT_PREFIX="output/" | ||
else | ||
echo "Didn't find rpi-firmware and/or rootfs.tar! ABORT." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# warn user | ||
|
||
confirm | ||
|
||
# partition image | ||
|
||
section "Partitioning SD card..." | ||
|
||
${FDISK} ${SDCARD} <<END | ||
o | ||
n | ||
p | ||
1 | ||
+32M | ||
n | ||
p | ||
2 | ||
t | ||
1 | ||
e | ||
a | ||
1 | ||
w | ||
END | ||
|
||
sleep 1 | ||
|
||
# figure out partition pattern | ||
|
||
case "${SDCARD}" in | ||
*mmcblk*) SDCARDP="${SDCARD}p" ;; | ||
*) SDCARDP="${SDCARD}" ;; | ||
esac | ||
|
||
# format partitions | ||
|
||
section "Formatting partitions..." | ||
|
||
${MKFS_VFAT} -F 16 -n BOOT -I "${SDCARDP}1" || exit 1 | ||
${MKFS_EXT4} -F -q -L rootfs "${SDCARDP}2" || exit 1 | ||
|
||
|
||
# prepare to fill partitions | ||
|
||
${MKDIR} .mnt | ||
|
||
# fill boot | ||
|
||
section "Populating boot partition..." | ||
${MOUNT} "${SDCARDP}1" .mnt || exit 2 | ||
|
||
${CP} ${OUTPUT_PREFIX}images/rpi-firmware/bootcode.bin .mnt | ||
${CP} ${OUTPUT_PREFIX}images/rpi-firmware/fixup.dat .mnt | ||
${CP} ${OUTPUT_PREFIX}images/rpi-firmware/start.elf .mnt | ||
${CP} ${OUTPUT_PREFIX}images/zImage .mnt/kernel.img | ||
${CP} ${OUTPUT_PREFIX}images/*.dtb .mnt | ||
${SYNC} | ||
${UMOUNT} .mnt | ||
|
||
# fill rootfs | ||
|
||
section "Populating rootfs partition..." | ||
${MOUNT} "${SDCARDP}2" .mnt || exit 2 | ||
|
||
${TAR} -xpsf ${OUTPUT_PREFIX}images/rootfs.tar -C .mnt | ||
${SYNC} | ||
${UMOUNT} .mnt | ||
|
||
# clean up | ||
|
||
${RMDIR} .mnt | ||
|
||
section "Finished!" | ||
|
||
exit 0 |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
# $Id:$ | ||
|
||
. /etc/vmfw.conf | ||
. /etc/ffw4.conf | ||
. /etc/dmz.info | ||
|
||
if [ "$DMZ_DOMAIN" ] | ||
|
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
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
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
Oops, something went wrong.