Changes

Jump to: navigation, search

Diva Embedded Linux Kit (DIVELK)

2,303 bytes added, 14:49, 3 April 2018
no edit summary
** all files can be retrieved from [[Diva_Embedded_Linux_Kit_(DIVELK)#Downloadable_binary_images|here]]
* extract rfs on ext3 partition
 
Alternatively, it is also possible to create a bootable sd using this script:
<pre>
#!/bin/bash
 
if [[ -z $1 || -z $2 || -z $3 ]]
then
echo "$0 Usage:"
echo " $0 <device> <binaries directory> <rootfs tar.bz2>"
echo " Example: $0 /dev/sdc binaries/ rootfs.tar.bz2"
exit
fi
 
if [ "$(whoami)" != "root" ]
then
echo "you must be root to run this script!"
exit
fi
 
if ! [[ -b $1 ]]
then
echo "$1 is not a valid block device!"
exit
fi
 
if ! [[ -d $2 ]]
then
echo "Incorrect Binaries location!"
exit
fi
 
if ! [[ -f $3 ]]
then
echo "Incorrect rootfs location!"
exit
fi
 
DRIVE=$1
if [[ "$DRIVE" == *"mmcblk"* ]]
then
echo "You're using a mmc device, I need to fix partition names"
PART="p"
else
PART=""
fi
BINARIES=$2
RFS=$3
 
echo "All data on "$DRIVE" now will be destroyed! Continue? [y/n]"
read ans
if ! [ $ans == 'y' ]
then
exit
fi
 
echo "[Partitioning $1...]"
 
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
 
SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
 
echo DISK SIZE - $SIZE bytes
 
CYLINDERS=`echo $SIZE/255/63/512 | bc`
 
# check if we're running an old (e.g. 2.20.x) or new (e.g. 2.24.x) sfdisk
sfdisk --help | grep -- -H
 
if [ "$?" -eq "0" ]
then
{
echo 10,1380,0x0c,*
echo 1390,,83,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
else
{
echo 10,4086M,0x0c,*
echo 4096M,,83,-
} | sfdisk $DRIVE
fi
 
partprobe
 
 
echo "[Making filesystems...]"
mkfs.vfat -F 32 -n BOOT "$DRIVE$PART"1 #> /dev/null
mkfs.ext3 -L ROOTFS "$DRIVE$PART"2 #> /dev/null
 
echo "[Copying files...]"
 
binaries_dir=${BINARIES%/}
mount "$DRIVE$PART"1 /mnt
cp -av --no-preserve=ownership $binaries_dir/* /mnt/
umount "$DRIVE$PART"1
 
echo "[Extracting rfs (this may take a while...)]"
mount "$DRIVE$PART"2 /mnt
tar jxf $RFS -C /mnt > /dev/null
chmod 755 /mnt
umount "$DRIVE$PART"2
 
echo "[Done]"
</pre>
 
To use this script, simply copy its content to a mksd.sh file.
 
Then, run:
<pre>
chmod a+x mksd.sh
</pre>
to give executable permissions to the file.
 
Once this has been done, insert a 16gb microsd card and run:
 
<pre>
./mksd /dev/sdX binaries-folder rootfs.tar.bz2
</pre>
The script will partition the sd card and copy the binaries and rootfs to the correct partition on the sd card.
The operation will take few minutes.
=== DIVELK Updates ===
116
edits

Navigation menu