tools: burner_image_kits: Add code
1.Support burner_image_kits consult to the developer guide:
Rockchip_Developer_Guide_Linux_Flash_Open_Source_Solution_CN.md
2.Update upgrade_tool ver 1.53
3.Update mkimage from next-dev commit: 3ac03e83
Change-Id: Ib83a825d1d5954ecb7a787df41a1a99a837c06f6
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
This commit is contained in:
158
tools/burner_image_kits/make.sh
Normal file
158
tools/burner_image_kits/make.sh
Normal file
@@ -0,0 +1,158 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
src_path=$1
|
||||
dst_path=$2
|
||||
soc=$3
|
||||
block_size=$4
|
||||
page_size=$5
|
||||
oob_size=$6
|
||||
is_slc_nand=$7
|
||||
|
||||
ddr=
|
||||
spl=
|
||||
|
||||
transfer_4K_2_2K=$DIR/tools/transfer_4K_2_2K.sh
|
||||
rk_bch=$DIR/tools/rk_bch
|
||||
mkimage=$DIR/../mkimage
|
||||
upgrade_tool=$DIR/../upgrade_tool
|
||||
align_to_flash_block_size=$DIR/tools/align_to_flash_block_size.sh
|
||||
boot_merger=$DIR/../boot_merger
|
||||
|
||||
function gen_idblock()
|
||||
{
|
||||
$mkimage -n $soc -T rksd -d $1:$2 idblock1.img.temp > /dev/null
|
||||
echo $3": gen_idblock: success!"
|
||||
if [[ $is_slc_nand == 1 && $page_size == 4096 ]]; then
|
||||
$transfer_4K_2_2K idblock1.img.temp $3
|
||||
rm idblock1.img.temp
|
||||
else
|
||||
mv idblock1.img.temp $3
|
||||
fi
|
||||
}
|
||||
|
||||
function is_miniloader_or_update_or_parameter()
|
||||
{
|
||||
ret=0
|
||||
ls $1 | grep "MiniLoaderAll.bin" > /dev/null
|
||||
if [ $? -eq 0 ] ;then
|
||||
$boot_merger --unpack $1 > /dev/null
|
||||
ddr=FlashData
|
||||
spl=FlashBoot
|
||||
gen_idblock $ddr $spl $src_path"/"idblock1.img
|
||||
is_img_and_gen_file_from_src_2_dst idblock1.img
|
||||
gen_idblock $ddr $spl $src_path"/"idblock2.img
|
||||
is_img_and_gen_file_from_src_2_dst idblock2.img
|
||||
gen_idblock $ddr $spl $src_path"/"idblock3.img
|
||||
is_img_and_gen_file_from_src_2_dst idblock3.img
|
||||
gen_idblock $ddr $spl $src_path"/"idblock4.img
|
||||
is_img_and_gen_file_from_src_2_dst idblock4.img
|
||||
rm $src_path"/"idblock*.img
|
||||
rm $ddr
|
||||
rm $spl
|
||||
ret=1
|
||||
fi
|
||||
|
||||
ls $1 | grep "update" > /dev/null
|
||||
if [ $? -eq 0 ] ;then
|
||||
ret=1
|
||||
fi
|
||||
|
||||
ls $1 | grep "parameter.txt" > /dev/null
|
||||
if [ $? -eq 0 ] ;then
|
||||
$upgrade_tool gpt $1 $src_path"/"gpt.img > /dev/null
|
||||
is_img_and_gen_file_from_src_2_dst gpt.img
|
||||
rm $src_path"/"gpt.img
|
||||
ret=1
|
||||
fi
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
function is_img_and_gen_file_from_src_2_dst()
|
||||
{
|
||||
ls $src_path"/"$1 | grep "img" > /dev/null
|
||||
if [ $? -eq 0 ] ;then
|
||||
$align_to_flash_block_size $src_path"/"$1 $dst_path"/"$1 $block_size
|
||||
if [ $is_slc_nand -eq 1 ] ;then
|
||||
$rk_bch $dst_path"/"$1 $dst_path"/"$1".bch" $page_size $oob_size 0
|
||||
mv $dst_path"/"$1".bch" $dst_path"/"$1
|
||||
echo "$src_path"/"$1: rk_bch: success!"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -f "$src_path" ]; then
|
||||
echo "input error, $src_path is a file!"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -x "$src_path" ]; then
|
||||
echo "input error, $src_path not exit!"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ $is_slc_nand != 0 && $is_slc_nand != 1 ]]; then
|
||||
echo "param is_slc_nand: $is_slc_nand not support!"
|
||||
echo "support:"
|
||||
echo " 1(for SLC Nand, 8 pins io)"
|
||||
echo " 0(others)"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $is_slc_nand -eq 1 ] ;then
|
||||
if [[ $oob_size != 64 && $oob_size != 128 && oob_size != 256 ]]; then
|
||||
echo "param oob_size: $oob_size not support!"
|
||||
echo "support:"
|
||||
echo " 64(B)"
|
||||
echo " 128(B)"
|
||||
echo " 256(B)"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $page_size != 2048 && $page_size != 4096 ]]; then
|
||||
echo "param page_size: $page_size not support!"
|
||||
echo "support:"
|
||||
echo " 2048(B)"
|
||||
echo " 4096(B)"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ $block_size != 128 && $block_size != 256 ]]; then
|
||||
echo "param block_size: $block_size not support!"
|
||||
echo "support:"
|
||||
echo " 128(KB)"
|
||||
echo " 256(KB)"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ $soc != "rk3308" && $soc != "rv1126" ]]; then
|
||||
echo "param soc: $soc not support!"
|
||||
echo "support:"
|
||||
echo " rk3308"
|
||||
echo " rv1126"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -x "$dst_path" ]; then
|
||||
rm -rf $dst_path
|
||||
fi
|
||||
|
||||
dst_path=$dst_path"/"$page_size"B_"$block_size"KB"
|
||||
if [[ $is_slc_nand == 1 ]]; then
|
||||
dst_path=$dst_path"_SLC"
|
||||
else
|
||||
dst_path=$dst_path"_SPI"
|
||||
fi
|
||||
mkdir -p $dst_path
|
||||
|
||||
for file in `ls -a $src_path`
|
||||
do
|
||||
if [ -f $src_path"/"$file ] ;then
|
||||
is_miniloader_or_update_or_parameter $src_path"/"$file
|
||||
if [ $? -eq 0 ] ;then
|
||||
is_img_and_gen_file_from_src_2_dst $file
|
||||
fi
|
||||
fi
|
||||
done
|
||||
12
tools/burner_image_kits/make_slc_nand.sh
Normal file
12
tools/burner_image_kits/make_slc_nand.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
src_path=$1
|
||||
dst_path=$2
|
||||
soc=$3
|
||||
block_size=$4
|
||||
page_size=$5
|
||||
oob_size=$6
|
||||
is_slc_nand=1
|
||||
|
||||
$DIR/make.sh $src_path $dst_path $soc $block_size $page_size $oob_size $is_slc_nand
|
||||
12
tools/burner_image_kits/make_spi_nand.sh
Normal file
12
tools/burner_image_kits/make_spi_nand.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
src_path=$1
|
||||
dst_path=$2
|
||||
soc=$3
|
||||
block_size=$4
|
||||
page_size=2048
|
||||
oob_size=64
|
||||
is_slc_nand=0
|
||||
|
||||
$DIR/make.sh $src_path $dst_path $soc $block_size $page_size $oob_size $is_slc_nand
|
||||
42
tools/burner_image_kits/tools/align_to_flash_block_size.sh
Normal file
42
tools/burner_image_kits/tools/align_to_flash_block_size.sh
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
# align_to_flash_block_size.sh
|
||||
# param1: path-to-file
|
||||
# param2: flash block size
|
||||
|
||||
input=$1
|
||||
out=$2
|
||||
block_size=$3
|
||||
|
||||
function gen_file() {
|
||||
filename=$1
|
||||
output_file=$2
|
||||
|
||||
# get file align size
|
||||
filesize=`stat -c "%s" $filename`
|
||||
filesize=`echo "scale=0; (($filesize + 1023) / 1024 + $block_size - 1) / $block_size * $block_size" | bc`
|
||||
|
||||
# gen file
|
||||
`dd if=/dev/zero of=$output_file bs=1K count=$filesize > /dev/null 2>&1`
|
||||
`dd if=$filename of=$output_file bs=1K count=$filesize conv=notrunc > /dev/null 2>&1`
|
||||
echo $filename": aligned_to_flash_block_size "$block_size"KB: success!"
|
||||
}
|
||||
|
||||
if [[ $block_size != 128 && $block_size != 256 ]]; then
|
||||
echo "$block_size not support!"
|
||||
echo "support:"
|
||||
echo " 128(KB)"
|
||||
echo " 256(KB)"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -f "$input" ]; then
|
||||
echo "$input not exist!"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -f "$out" ]; then
|
||||
rm $out
|
||||
exit
|
||||
fi
|
||||
|
||||
gen_file $input $out
|
||||
BIN
tools/burner_image_kits/tools/rk_bch
Normal file
BIN
tools/burner_image_kits/tools/rk_bch
Normal file
Binary file not shown.
43
tools/burner_image_kits/tools/transfer_4K_2_2K.sh
Normal file
43
tools/burner_image_kits/tools/transfer_4K_2_2K.sh
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
# transfer_4K_2_2K.sh
|
||||
# param1: path-to-file
|
||||
# param2: flash block size
|
||||
|
||||
input=$1
|
||||
out=$2
|
||||
|
||||
function gen_file() {
|
||||
filename=$1
|
||||
output_file=$2
|
||||
|
||||
# get file align size
|
||||
filesize=`stat -c "%s" $filename`
|
||||
filesize=`expr $filesize + 2047`
|
||||
filesize=`expr $filesize / 2048 \* 2048`
|
||||
filesize_x2=`expr $filesize \* 2`
|
||||
page_num=`expr $filesize / 2048`
|
||||
|
||||
echo $filesize $filesize_x2 $page_num
|
||||
|
||||
# gen file
|
||||
`dd if=/dev/zero of=$output_file bs=1 count=$filesize_x2 > /dev/null 2>&1`
|
||||
for ((i=0;i<$page_num;i++));
|
||||
do
|
||||
`dd if=$filename of=2KB bs=2K skip=$i count=1 > /dev/null 2>&1`
|
||||
`dd if=2KB of=$output_file bs=4K seek=$i count=1 conv=notrunc > /dev/null 2>&1`
|
||||
done
|
||||
echo $filename": transfer_2KB_2_4KB success"
|
||||
rm 2KB
|
||||
}
|
||||
|
||||
if [ ! -f "$input" ]; then
|
||||
echo "$input not exist!"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -f "$out" ]; then
|
||||
rm $out
|
||||
exit
|
||||
fi
|
||||
|
||||
gen_file $input $out
|
||||
Binary file not shown.
Reference in New Issue
Block a user