1#!/bin/bash
2
3if [[ "$OSTYPE" == "linux-gnu" ]]; then
4  ARCH=`uname -m`
5  if [[ "$ARCH" == "i686" ]]; then
6    IMGUTIL=../bin/imgutil
7  else
8    IMGUTIL=../bin/imgutil64
9  fi
10elif [[ "$OSTYPE" == "darwin"* ]]; then
11  IMGUTIL=../bin/mac/imgutil
12else
13  IMGUTIL=../bin/imgutil.exe
14fi
15
16if [ "$#" -ne 1 ] || ! [ "$1" == "ram" -o "$1" == "ram_secure" -o "$1" == "flash"  -o "$1" == "flash_secure" ] ; then
17  echo "Usage: $0 target"
18  echo "       target: ram -- the image will be loaded to RAM and run, the application must be built with ram link file"
19  echo "       target: ram_secure -- The final RAM image includes a CSF pointer to support HABv4."
20  echo "       target: flash -- the image will be run on flash directly, the application must be build with flash link file"
21  echo "       target: flash_secure -- The final flash image includes a CSF pointer to support HABv4."
22  echo "Example: $0 ram"
23  exit 1
24fi
25
26#../dcdgen dcd.config dcd.bin
27if [ "$1" == "ram" ]; then
28    $IMGUTIL --combine base_addr=0x1FFD0000 ivt_offset=0x1000 config_offset=0x400 config_file=qcb.bin app_offset=0x2000 app_file=sdk20-app.bin ofile=sdk20-app.img
29elif [ "$1" == "ram_secure" ]; then
30    $IMGUTIL --combine base_addr=0x1FFD0000 ivt_offset=0x1000 config_offset=0x400 config_file=qcb.bin has_csf=1 app_offset=0x2000 app_file=sdk20-app.bin ofile=sdk20-app.img
31elif [ "$1" == "flash" ]; then
32    $IMGUTIL --combine base_addr=0x04000000 ivt_offset=0x1000 config_offset=0x400 config_file=qcb.bin app_offset=0x2000 app_file=sdk20-app.bin ofile=sdk20-app.img
33elif [ "$1" == "flash_secure" ]; then
34    $IMGUTIL --combine base_addr=0x04000000 ivt_offset=0x1000 config_offset=0x400 config_file=qcb.bin has_csf=1 app_offset=0x2000 app_file=sdk20-app.bin ofile=sdk20-app.img
35fi
36