Bug Fix: PRSDK-8528: Patch 4
[processor-sdk/pdk.git] / packages / pdkAppImageCreate.sh
1 #!/bin/bash
2 # ******************************************************************************
3 # * FILE PURPOSE: Creates the bootable application binary
4 # ******************************************************************************
5 # * FILE NAME: pdkAppImageCreate.sh
6 # *
7 # * DESCRIPTION: 
8 # *  Creates bootable application binary from the .out file generated by the
9 # *  CCS projects.
10 # *
11 # * USAGE:
12 # *  pdkAppImageCreate.sh [PDK_PATH] [CG_TOOL_PATH] [APP_PATH] [APP_NAME] [SOC] [PROCESSOR] [SECUREMODE=yes/no]
13 # *
14 # *  SECUREMODE parameter is optional. Will fall back to GP build if not specified
15 # *
16 # * Copyright (C) 2016 - 2018, Texas Instruments, Inc.
17 # *****************************************************************************
19 export PDK_PATH=$1
20 export CG_TOOL_PATH=$2
21 export APP_PATH=$3
22 export APP_NAME=$4
23 export SOC=$5
24 export PROCESSOR=$6
25 export SECUREMODE=$7
27 if [ $SOC == AM437x ] || [ $SOC == AM335x ]; then
28         $CG_TOOL_PATH/bin/arm-none-eabi-objcopy -O binary $APP_NAME.out $APP_NAME.bin
29         $PDK_PATH/ti/starterware/tools/ti_image/tiimage_bin/tiimage 0x80000000 NONE $APP_NAME.bin app
31         if [ "$SECUREMODE" == "SECUREMODE=yes" ]; then
33             # setting the TI_SECURE_SEC_DEV_PKG variable
34             source $PDK_PATH/pdksetupenv.sh
36             if [ ! -z $TI_SECURE_DEV_PKG ]; then
37                 echo TI_SECURE_DEV_PKG set. Secure the app ...
38                 $TI_SECURE_DEV_PKG/scripts/secure-binary-image.sh $APP_NAME.bin "$APP_NAME"_signed.bin
39                 $PDK_PATH/ti/starterware/tools/ti_image/tiimage_bin/tiimage 0x80000000 NONE "$APP_NAME"_signed.bin "$APP_NAME"_signed_ti.bin
40                 echo "$APP_NAME"_signed.bin can be loaded by SBL UART boot
41                 echo "$APP_NAME"_signed_ti.bin can be loaded by SBL MMCSD boot
42             else
43                 echo "SECURE mode requested but TI_SECURE_DEV_PKG is not defined..."
44             fi
45         fi
46 fi
48 if [ $SOC == AM572x ] || [ $SOC == AM571x ] || [ $SOC == AM574x ]; then
49     if [ "$PROCESSOR" == "arm" ]; then
50         export BIN_PATH=$APP_PATH
51         export APP_MPU_CPU0=$APP_PATH/$APP_NAME.out
52         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
53         . $PDK_PATH/ti/boot/sbl/tools/scripts/AM57xImageGen.sh
54     elif [ "$PROCESSOR" == "dsp" ]; then
55         export BIN_PATH=$APP_PATH
56         export APP_DSP1=$APP_PATH/$APP_NAME.out
57         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
58         . $PDK_PATH/ti/boot/sbl/tools/scripts/AM57xImageGen.sh
59     elif [ "$PROCESSOR" == "m4" ]; then
60         export BIN_PATH=$APP_PATH
61         export APP_IPU1_CPU0=$APP_PATH/$APP_NAME.out
62         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
63         . $PDK_PATH/ti/boot/sbl/tools/scripts/AM57xImageGen.sh
64     else
65         echo Invalid Processor core
66     fi
67 fi
69 if [ $SOC == K2G ]; then
70     if [ "$PROCESSOR" == "arm" ]; then
71         export BIN_PATH=$APP_PATH
72         export APP_MPU_CPU0=$APP_PATH/$APP_NAME.out
73         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
74         . $PDK_PATH/ti/boot/sbl/tools/scripts/K2GImageGen.sh
75     elif [ "$PROCESSOR" == "dsp" ]; then
76         export BIN_PATH=$APP_PATH
77         export APP_DSP0=$APP_PATH/$APP_NAME.out
78         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
79         . $PDK_PATH/ti/boot/sbl/tools/scripts/K2GImageGen.sh
80     else
81         echo Invalid Processor core
82     fi
83 fi
85 if [ $SOC == OMAPL137 ] || [ $SOC == OMAPL138 ]; then
86     if [ "$PROCESSOR" == "arm" ]; then
87         export BIN_PATH=$APP_PATH
88         export APP_MPU_CPU0=$APP_PATH/$APP_NAME.out
89         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
90         . $PDK_PATH/ti/boot/sbl/tools/scripts/OMAPL13xImageGen.sh
91     elif [ "$PROCESSOR" == "dsp" ]; then
92         export BIN_PATH=$APP_PATH
93         export APP_DSP0=$APP_PATH/$APP_NAME.out
94         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
95         . $PDK_PATH/ti/boot/sbl/tools/scripts/OMAPL13xImageGen.sh
96     else
97         echo Invalid Processor core
98     fi
99 fi
102 if [ $SOC == am65xx ] || [ $SOC == j721e ]; then
103     #Refer to SBL document for core ID value (0, or 4 bellow).
104     if [ "$PROCESSOR" == "mpu" ]; then
105         export BIN_PATH=$APP_PATH
106         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
107         . $PDK_PATH/ti/boot/sbl/tools/scripts/K3ImageGen.sh 0 $APP_PATH/$APP_NAME.out
108     elif [ "$PROCESSOR" == "mcu" ]; then
109         export BIN_PATH=$APP_PATH
110         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
111         . $PDK_PATH/ti/boot/sbl/tools/scripts/K3ImageGen.sh 4 $APP_PATH/$APP_NAME.out
112     else
113         echo Invalid Processor core
114     fi
115 fi