Commit ca4f0729 authored by Federico Vaga's avatar Federico Vaga

file-system: flash-wrs makes cpio and jffs2, wrs-build-all makes tar.gz

This patch change the build of a package. Following the main change:
- wrs-build-all: it does not build cpio and jffs2 images, but only
  a .tar.gz archive which will be included into the package
- flash-wrs: it create the cpio and jffs2 images before flashing
Signed-off-by: 's avatarFederico Vaga <federico.vaga@gmail.com>
parent 12c9e296
...@@ -93,7 +93,8 @@ if CC=cc make -s -C ${WRS_BASE_DIR}/usb-loader; then true; else ...@@ -93,7 +93,8 @@ if CC=cc make -s -C ${WRS_BASE_DIR}/usb-loader; then true; else
echo "$0: Error compiling usb-loader" >&2; exit 1; echo "$0: Error compiling usb-loader" >&2; exit 1;
fi fi
# parse command line # add /usr/sbin for mkfs.jffs2
export PATH="$PATH:/usr/sbin"
# Default MAC address for the switch board ethernet # Default MAC address for the switch board ethernet
MAC1_DEF="02:34:56:78:9A:BC" MAC1_DEF="02:34:56:78:9A:BC"
...@@ -105,10 +106,20 @@ MAC2=$MAC2_DEF ...@@ -105,10 +106,20 @@ MAC2=$MAC2_DEF
DEV="" DEV=""
FLAGS="" FLAGS=""
at91bs="${WRS_BASE_DIR}/binaries/at91bootstrap.bin" # full path to the at91boot binary
barebox="${WRS_BASE_DIR}/binaries/barebox.bin" at91bs=""
kernel="${WRS_OUTPUT_DIR}/images/zImage" # full path to the barebox binary
rootfs="${WRS_OUTPUT_DIR}/images/wrs-image.jffs2.img" barebox=""
# full path to the kernel image
kernel=""
# full path to the tar.gz file system
rootfsgz=""
# full path to the cpio image
rootfscpio=""
# full path to the jffs2 image
rootfsjffs2=""
# full path to the file system directory
TMPFS=""
while [ $# -ge 1 ]; do while [ $# -ge 1 ]; do
case $1 in case $1 in
...@@ -116,8 +127,7 @@ while [ $# -ge 1 ]; do ...@@ -116,8 +127,7 @@ while [ $# -ge 1 ]; do
at91bs=${WRS_OUTPUT_DIR}/images/at91bootstrap.bin; at91bs=${WRS_OUTPUT_DIR}/images/at91bootstrap.bin;
barebox=${WRS_OUTPUT_DIR}/images/barebox.bin barebox=${WRS_OUTPUT_DIR}/images/barebox.bin
kernel=${WRS_OUTPUT_DIR}/images/zImage kernel=${WRS_OUTPUT_DIR}/images/zImage
rootfs=${WRS_OUTPUT_DIR}/images/wrs-image.jffs2.img rootfsgz=${WRS_OUTPUT_DIR}/images/wrs-image.tar.gz
rootfscpio=${WRS_OUTPUT_DIR}/images/wrs-image.cpio.gz
shift;; shift;;
*.tar.gz) *.tar.gz)
...@@ -126,8 +136,7 @@ while [ $# -ge 1 ]; do ...@@ -126,8 +136,7 @@ while [ $# -ge 1 ]; do
at91bs=/tmp/at91bootstrap.bin; at91bs=/tmp/at91bootstrap.bin;
barebox=/tmp/barebox.bin barebox=/tmp/barebox.bin
kernel=/tmp/zImage kernel=/tmp/zImage
rootfs=/tmp/wrs-image.jffs2.img rootfsgz=/tmp/wrs-image.tar.gz
rootfscpio=${WRS_OUTPUT_DIR}/images/wrs-image.cpio.gz
shift;; shift;;
-h|--help) showhelp; shift;; -h|--help) showhelp; shift;;
...@@ -168,19 +177,23 @@ while [ $# -ge 1 ]; do ...@@ -168,19 +177,23 @@ while [ $# -ge 1 ]; do
esac esac
done done
if [ "x$rootfsgz" = "x" ]; then
showhelp
fi
echo "---------------------------------------"
## MAC1 and MAC2 are really recommended ## MAC1 and MAC2 are really recommended
if [ "x$MAC1" = "x$MAC1_DEF" ]; then if [ "x$MAC1" = "x$MAC1_DEF" ]; then
echo "---------------------------------------"
echo "WARNING: YOU DID NOT SET THE MAC1 FIELD" echo "WARNING: YOU DID NOT SET THE MAC1 FIELD"
echo "---------------------------------------" echo "---------------------------------------"
fi fi
if [ "x$MAC2" = "x$MAC2_DEF" ]; then if [ "x$MAC2" = "x$MAC2_DEF" ]; then
echo "---------------------------------------"
echo "WARNING: YOU DID NOT SET THE MAC2 FIELD" echo "WARNING: YOU DID NOT SET THE MAC2 FIELD"
echo "---------------------------------------" echo "---------------------------------------"
fi fi
echo "Starting flashing procedure in 3 seconds ..."
sleep 3 echo "Starting flashing procedure in 5 seconds ..."
sleep 5
## Selecting the running memmode ## Selecting the running memmode
if [ "x$memmode" = "xdf" ]; then if [ "x$memmode" = "xdf" ]; then
...@@ -219,6 +232,7 @@ checkExit $barebox ...@@ -219,6 +232,7 @@ checkExit $barebox
Tbarebox=$(mktemp /tmp/barebox.XXXXXX) Tbarebox=$(mktemp /tmp/barebox.XXXXXX)
modifyMAC ${barebox} ${Tbarebox} modifyMAC ${barebox} ${Tbarebox}
## Flashing DataFlash ## Flashing DataFlash
if [ $df ]; then if [ $df ]; then
checkExit $at91bs checkExit $at91bs
...@@ -228,11 +242,11 @@ fi ...@@ -228,11 +242,11 @@ fi
## Prepare for the NAND flashing procedure ## Prepare for the NAND flashing procedure
if [ $nf ]; then if [ $nf ]; then
checkExit $kernel checkExit $kernel
checkExit $rootfscpio checkExit $rootfsgz
TMPFS=$(mktemp -d /tmp/wrsfs.XXXXXX)
TMPCPIO=$(mktemp /tmp/wrsflash-cpio.XXXXXX.cpio.gz) TMPCPIO=$(mktemp /tmp/wrsflash-cpio.XXXXXX.cpio.gz)
TMPSCRIPT=$(mktemp /tmp/wrsrootfs-script.XXXXXX)
TMPFS=$(mktemp -d /tmp/wrsfs-tgz.XXXXXX)
rootfsjffs2=/tmp/wrs-image.jffs2.img
# The TMPCPIO is used for the NAND flashing procedure. It # The TMPCPIO is used for the NAND flashing procedure. It
# contains the magic string "paperino" (0x61706570 0x69726f6e) # contains the magic string "paperino" (0x61706570 0x69726f6e)
...@@ -240,11 +254,13 @@ if [ $nf ]; then ...@@ -240,11 +254,13 @@ if [ $nf ]; then
# file system. Barebox use this magic string to identify # file system. Barebox use this magic string to identify
# the flashing procedure. # the flashing procedure.
echo -n "paperino" > $TMPCPIO echo -n "paperino" > $TMPCPIO
# make flashing cpio from the unzipped file system
TMPSCRIPT=$(mktemp /tmp/wrsrootfs-script.XXXXXX)
cat > $TMPSCRIPT << EOF cat > $TMPSCRIPT << EOF
cd $TMPFS tar --directory $TMPFS -xzf $rootfsgz
zcat $rootfscpio | cpio --extract
mkdir flashing mkfs.jffs2 --little-endian --eraseblock=0x20000 -n --pad -d $TMPFS -o $rootfsjffs2
# Remove heavy and useless stuff to make a light file system to # Remove heavy and useless stuff to make a light file system to
# load in RAM # load in RAM
...@@ -254,13 +270,16 @@ rm -rf $TMPFS/usr/bin ...@@ -254,13 +270,16 @@ rm -rf $TMPFS/usr/bin
rm -rf $TMPFS/usr/lib rm -rf $TMPFS/usr/lib
rm -rf $TMPFS/usr/share rm -rf $TMPFS/usr/share
cp ${rootfs} $TMPFS/flashing/wrs-image.jffs2.img mkdir $TMPFS/flashing/
cp -a /dev/kmsg $TMPFS/dev/kmsg
cp ${rootfsjffs2} $TMPFS/flashing/wrs-image.jffs2.img
cp ${kernel} $TMPFS/flashing/zImage cp ${kernel} $TMPFS/flashing/zImage
cp ${WRS_BASE_DIR}/usb-loader/S99flash-from-kernel.sh $TMPFS/etc/init.d/ cp ${WRS_BASE_DIR}/usb-loader/S99flash-from-kernel.sh $TMPFS/etc/init.d/
cd .. cd ..
(cd "$TMPFS" && find . | cpio -o -H newc | gzip) >> $TMPCPIO (cd "$TMPFS" && find . | cpio -o -H newc | gzip) >> $TMPCPIO
EOF EOF
fakeroot bash $TMPSCRIPT fakeroot bash $TMPSCRIPT
rm $TMPSCRIPT
# Erase all nand memory # Erase all nand memory
${WRS_BASE_DIR}/usb-loader/mch_flasher -e -m nand ${WRS_BASE_DIR}/usb-loader/mch_flasher -e -m nand
...@@ -269,15 +288,27 @@ EOF ...@@ -269,15 +288,27 @@ EOF
rm -rf $TMPFS rm -rf $TMPFS
rm -rf $TMPCPIO rm -rf $TMPCPIO
rm -rf $TMPSCRIPT rm -rf $rootfsjffs2
fi fi
## Loading in DDR ## Loading in DDR
if [ $test ]; then if [ $test ]; then
checkExit $kernel checkExit $kernel
checkExit $rootfs checkExit $rootfsgz
TMPFS=$(mktemp -d /tmp/wrsfs-tgz.XXXXXX)
rootfsjffs2=/tmp/wrs-image.jffs2.img
# make cpio and jffs2 image
TMPSCRIPT=$(mktemp /tmp/wrsrootfs-script.XXXXXX)
cat > $TMPSCRIPT << EOF
tar --directory $TMPFS -xzf $rootfsgz
mkfs.jffs2 --little-endian --eraseblock=0x20000 -n --pad -d $TMPFS -o $rootfsjffs2
EOF
fakeroot bash $TMPSCRIPT
rm $TMPSCRIPT
rm $TMPFS
${WRS_BASE_DIR}/usb-loader/mch_flasher -m ddr $FLAGS $DEV ${Tbarebox} 0x0 ${kernel} 0x1000000 ${rootfs} 0x2000000 ${WRS_BASE_DIR}/usb-loader/mch_flasher -m ddr $FLAGS $DEV ${Tbarebox} 0x0 ${kernel} 0x1000000 ${rootfsjffs2} 0x2000000
fi fi
rm $Tbarebox rm $Tbarebox
......
...@@ -25,9 +25,7 @@ rootfs_vanilla="$WRS_OUTPUT_DIR/build/buildroot-2011.11/output/target" ...@@ -25,9 +25,7 @@ rootfs_vanilla="$WRS_OUTPUT_DIR/build/buildroot-2011.11/output/target"
rootfs_override="$WRS_BASE_DIR/../userspace/rootfs_override" rootfs_override="$WRS_BASE_DIR/../userspace/rootfs_override"
TMPSCRIPT=$(mktemp /tmp/rootfs-script.XXXXXX) TMPSCRIPT=$(mktemp /tmp/rootfs-script.XXXXXX)
ROOTFS_IMAGE_CPIO="$WRS_OUTPUT_DIR/images/wrs-image.cpio.gz"
ROOTFS_IMAGE_TGZ="$WRS_OUTPUT_DIR/images/wrs-image.tar.gz" ROOTFS_IMAGE_TGZ="$WRS_OUTPUT_DIR/images/wrs-image.tar.gz"
ROOTFS_IMAGE_JFFS2="$WRS_OUTPUT_DIR/images/wrs-image.jffs2"
cat > $TMPSCRIPT << EOF cat > $TMPSCRIPT << EOF
mkdir -p $TMPFS/wr mkdir -p $TMPFS/wr
...@@ -53,10 +51,7 @@ chown -R root:root $TMPFS/root ...@@ -53,10 +51,7 @@ chown -R root:root $TMPFS/root
chown -R root:root $TMPFS/etc/dropbear chown -R root:root $TMPFS/etc/dropbear
##Test Anchor ##Test Anchor
(cd "$TMPFS" && find . | cpio -o -H newc | gzip) > $ROOTFS_IMAGE_CPIO
(cd "$TMPFS" && tar cz .> $ROOTFS_IMAGE_TGZ) (cd "$TMPFS" && tar cz .> $ROOTFS_IMAGE_TGZ)
mkfs.jffs2 --little-endian --eraseblock=0x20000 -n --pad -d $TMPFS -o $ROOTFS_IMAGE_JFFS2.img
EOF EOF
fakeroot bash $WRS_SH_OPTIONS $TMPSCRIPT fakeroot bash $WRS_SH_OPTIONS $TMPSCRIPT
......
...@@ -63,6 +63,13 @@ showhelp() { ...@@ -63,6 +63,13 @@ showhelp() {
exit 0; exit 0;
} }
## Create a package for distribution. The package contains:
# - at91bootstrap.bin
# - barebox.bin
# - zImage
# - wrs-image.tar.gz
# it includes wrs-image.tar.gz because it is easier to generate cpio
# and jff2 images
pack() pack()
{ {
#Check if the current git repo correspond to a tag #Check if the current git repo correspond to a tag
...@@ -70,7 +77,7 @@ pack() ...@@ -70,7 +77,7 @@ pack()
name=$(git describe --always --dirty) name=$(git describe --always --dirty)
echo "Packing into wrs-firmware-$name.tar.gz"; echo "Packing into wrs-firmware-$name.tar.gz";
tar -czvf "$WRS_OUTPUT_DIR/wrs-firmware-$name.tar.gz" -C ${WRS_OUTPUT_DIR}/images/ at91bootstrap.bin barebox.bin zImage wrs-image.jffs2.img tar -czvf "$WRS_OUTPUT_DIR/wrs-firmware-$name.tar.gz" -C ${WRS_OUTPUT_DIR}/images/ at91bootstrap.bin barebox.bin zImage wrs-image.tar.gz
exit 0 exit 0
} }
......
#!/bin/bash #!/bin/bash
# Write kernel and filesystem to NAND memory # Write kernel and filesystem to NAND memory
ls /
cat /etc/init.d/rcS
echo "FLASHING: flashing kernel to /dev/mtd0 ..." echo "FLASHING: flashing kernel to /dev/mtd0 ..."
nandwrite -m -p -a /dev/mtd0 /flashing/zImage nandwrite -m -p -a /dev/mtd0 /flashing/zImage
echo "FLASHING: flashing file system to /dev/mtd1 ..." echo "FLASHING: flashing file system to /dev/mtd1 ..."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment