4 echo "Usage: prepare_image image_type kernel_image rootfs_image header_size"
5 echo "Padd root and kernel image to the correct size and append the jffs2 start marker as needed"
10 echo "Padding $1 to size $2"
11 dd if=$1 of
=$1.paddingtempfile bs
=$2 count
=1 conv
=sync
&> /dev
/null
12 mv $1.paddingtempfile
$1
15 #filesize filestart padding
17 [ $
((($1 + $2) & ($3 - 1))) == 0 ] && {
21 echo $
(((($1 + $2) |
($3 - 1)) + 1 - $2))
24 function prep_squash
{
25 echo "kernel_size: $kernel_size"
26 echo "header_size: $header_size"
27 kernel_pad_size
=$
(calc_pad
$kernel_size $header_size 32)
28 kernel_end
=$
(($header_size + $kernel_pad_size))
29 pad_file
$kernel_image $kernel_pad_size
32 rootfs_pad_size
=$
(calc_pad
$rootfs_size $kernel_end 4096)
33 pad_file
$rootfs_image $rootfs_pad_size
34 echo -ne '\xde\xad\xc0\xde' >> $rootfs_image
37 rootfs_pad_size
=$
(calc_pad
$rootfs_size $kernel_end 8192)
38 [ $rootfs_pad_size == rootfs_old_padsize
] ||
{
39 pad_file
$rootfs_image $rootfs_pad_size
40 rootfs_old_padsize
=$rootfs_pad_size
41 echo -ne '\xde\xad\xc0\xde' >> $rootfs_image
45 rootfs_pad_size
=$
(calc_pad
$rootfs_size $kernel_end 65536)
46 [ $rootfs_pad_size == rootfs_old_padsize
] ||
{
47 pad_file
$rootfs_image $rootfs_pad_size
48 rootfs_old_padsize
=$rootfs_pad_size
49 echo -ne '\xde\xad\xc0\xde' >> $rootfs_image
53 rootfs_pad_size
=$
(calc_pad
$rootfs_size $kernel_end 131072)
54 [ $rootfs_pad_size == rootfs_old_padsize
] ||
{
55 pad_file
$rootfs_image $rootfs_pad_size
56 rootfs_old_padsize
=$rootfs_pad_size
57 echo -ne '\xde\xad\xc0\xde' >> $rootfs_image
63 kernel_pad_size
=$
(calc_pad
$kernel_size $header_size $1)
64 pad_file
$kernel_image $kernel_pad_size
72 if [ -z "$image_type" ] ||
[ -z "$rootfs_image" ] ||
[ -z "$kernel_image" ] ||
[ -z "$header_size" ]; then
76 if [ ! -e "$rootfs_image" ] ||
[ -z "$kernel_image" ]; then
77 echo "input file not found"
81 kernel_size
=$
(stat
-c "%s" "$kernel_image")
82 rootfs_size
=$
(stat
-c "%s" "$rootfs_image")
84 if [ $kernel_size == 0 ] ||
[ $rootfs_size == 0 ]; then
85 echo "kernel or rootfs empty"
97 echo "Unknown image type"
This page took 0.046086 seconds and 5 git commands to generate.