summaryrefslogtreecommitdiff
path: root/SamsungPlatformPkg/Apps/Tools/mkbl2/imgburn.sh
blob: dee12604aa91537ee18f12b3d7060252dde58c30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash

# set the default image filename, this can be overwritten by a parameter
IMAGE=../../../../Build/Arndale-Exynos/DEBUG_ARMLINUXGCC/FV/ARNDALE_EFI.fd

# set the default SoC, this can be overwritten by a parameter
SOC=5250

function usage
{
	echo "Usage: $0"
	echo "	--disk  path to the SD card device to write to, eg /dev/sdd"
	echo "	        This can be found by looking at dmesg output"
	echo "	--image The image to write to the SD card"
	echo "	        This defaults to:"
	echo "	            $IMAGE"
	echo "	--soc   Which SoC we are using"
	echo "	        This defaults to: 5250"
}

while [ "$1" != "" ]; do
    case $1 in
        -s | --soc )
			shift
			SOC=$1
            ;;

        -d | --disk )
			shift
			DISK=$1
            ;;

        -i | --image )
			shift
			IMAGE=$1
            ;;

        /h | /? | -? | -h | --help )
            usage
            exit
            ;;
        -* )
            usage
			echo "unknown arg $1"
            exit 1
    esac
    shift
done

echo "Config:"
echo "IMAGE    $IMAGE"
echo "SoC      $SOC"
echo "DISK     $DISK"


if [ ! -b "$DISK" ]
then
	echo "You must specify a valid --disk option"
	exit 1
fi

if [ ! -f $IMAGE ]
then
	echo ""
	echo "ERROR: UEFI image $IMAGE does not exist.."
	echo ""
	exit
fi

# make mkbl2
if [ ! -f mkbl2 ]
then
	make
fi

# make BL2
./mkbl2 $IMAGE

if [ ! -f fwbl2.bin ]
then
	echo ""
	echo "ERROR: Failed to create BL2 image."
	echo ""
	exit
fi

# select platform
if [ "$SOC" = "5250" ]
then
	# write BL1
	dd if=./5250/fwbl1_5250.bin of=$DISK seek=1 count=16
else
	echo ""
	echo "ERROR: Please select platform.."
	echo ""
	exit
fi


# write BL2
dd if=./fwbl2.bin of=$DISK seek=17 count=32

# write bootloader file e.g. u-boot or UEFI firmware image
dd if=$IMAGE of=$DISK seek=49

sync