declare CONV_ASCII=""
declare -i FUS_ENTRY_NUM=0
-declare -r FUSING_IMG="fusing.img"
# binary name | part number | offset | bs
declare -a PART_TABLE=(
"system-data.img" 3 0 4M
"user.img" 5 0 4M
"modules.img" 6 0 512
- $FUSING_IMG "" 3072 512
)
-declare -r -i PART_TABLE_ROW=4
-declare -r -i PART_TABLE_COL=${#PART_TABLE[*]}/${PART_TABLE_ROW}
+declare -r -i PART_TABLE_COL=4
+declare -r -i PART_TABLE_ROW=${#PART_TABLE[*]}/${PART_TABLE_COL}
# partition table support
function get_index_use_name () {
local -r binary_name=$1
- for ((idx=0;idx<$PART_TABLE_COL;idx++)); do
- if [ ${PART_TABLE[idx * ${PART_TABLE_ROW} + 0]} == $binary_name ]; then
+ for ((idx=0;idx<$PART_TABLE_ROW;idx++)); do
+ if [ ${PART_TABLE[idx * ${PART_TABLE_COL} + 0]} == $binary_name ]; then
return $idx
fi
done
rm entry_size
}
-function make_fusing_header () {
- # header magic
- echo -n "BFUS" > fus_hdr_magic
- cat fus_hdr_magic | head -c 4 > fus_hdr
-
- # entry number: 1 byte
- convert_num_to_ascii $FUS_ENTRY_NUM
- echo -n $CONV_ASCII > fus_hdr_entry_num
- cat fus_hdr_entry_num /dev/zero | head -c 4 >> fus_hdr
-
- rm fus_hdr_magic
- rm fus_hdr_entry_num
-}
-
-function make_fusing_struct {
- if [ -f entry ];then
- make_fusing_header
- cat fus_hdr entry /dev/zero | head -c 512 > $FUSING_IMG
- rm fus_hdr entry
-
- # Write Fusing Magic Number */
- fusing_image $FUSING_IMG
- rm $FUSING_IMG
- fi
-}
-
function fusing_image () {
local -r fusing_img=$1
get_index_use_name $(basename $fusing_img)
local -r -i part_idx=$?
- if [ $part_idx -ne $PART_TABLE_COL ];then
- local -r device=$DEVICE${PART_TABLE[${part_idx} * ${PART_TABLE_ROW} + 1]}
- local -r seek=${PART_TABLE[${part_idx} * ${PART_TABLE_ROW} + 2]}
- local -r bs=${PART_TABLE[${part_idx} * ${PART_TABLE_ROW} + 3]}
+ if [ $part_idx -ne $PART_TABLE_ROW ];then
+ local -r device=$DEVICE${PART_TABLE[${part_idx} * ${PART_TABLE_COL} + 1]}
+ local -r seek=${PART_TABLE[${part_idx} * ${PART_TABLE_COL} + 2]}
+ local -r bs=${PART_TABLE[${part_idx} * ${PART_TABLE_COL} + 3]}
else
echo "Not supported binary: $fusing_img"
return
function show_usage () {
echo "- Usage:"
- echo " sudo ./sd_fusing*.sh -d <device> [-b <path> <path> ..] [--format]"
+ echo " sudo ./sd_fusing_xu4.sh -d <device> [-b <path> <path> ..] [--format]"
}
function check_partition_format () {
function print_logo () {
echo ""
- echo "Odroid-XU4 downloader, version 0.5"
- echo "Authors: Inha Song <ideal.song@samsung.com>"
+ echo "Odroid-XU3/4 downloader"
echo ""
}
check_args
check_partition_format
fuse_image
-
-make_fusing_struct