[PDK-8866] Add PDK_INSTALL_PATH path to pdkAppImageCreate scripts
[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 PDK_INSTALL_PATH=$PDK_PATH
21 export CG_TOOL_PATH=$2
22 export APP_PATH=$3
23 export APP_NAME=$4
24 export SOC=$5
25 export PROCESSOR=$6
26 export SECUREMODE=$7
28 if [ $SOC == AM437x ] || [ $SOC == AM335x ]; then
29         $CG_TOOL_PATH/bin/arm-none-eabi-objcopy -O binary $APP_NAME.out $APP_NAME.bin
30         $PDK_PATH/ti/starterware/tools/ti_image/tiimage_bin/tiimage 0x80000000 NONE $APP_NAME.bin app
32         if [ "$SECUREMODE" == "SECUREMODE=yes" ]; then
34             # setting the TI_SECURE_SEC_DEV_PKG variable
35             source $PDK_PATH/pdksetupenv.sh
37             if [ ! -z $TI_SECURE_DEV_PKG ]; then
38                 echo TI_SECURE_DEV_PKG set. Secure the app ...
39                 $TI_SECURE_DEV_PKG/scripts/secure-binary-image.sh $APP_NAME.bin "$APP_NAME"_signed.bin
40                 $PDK_PATH/ti/starterware/tools/ti_image/tiimage_bin/tiimage 0x80000000 NONE "$APP_NAME"_signed.bin "$APP_NAME"_signed_ti.bin
41                 echo "$APP_NAME"_signed.bin can be loaded by SBL UART boot
42                 echo "$APP_NAME"_signed_ti.bin can be loaded by SBL MMCSD boot
43             else
44                 echo "SECURE mode requested but TI_SECURE_DEV_PKG is not defined..."
45             fi
46         fi
47 fi
49 if [ $SOC == AM572x ] || [ $SOC == AM571x ] || [ $SOC == AM574x ]; then
50     if [ "$PROCESSOR" == "arm" ]; then
51         export BIN_PATH=$APP_PATH
52         export APP_MPU_CPU0=$APP_PATH/$APP_NAME.out
53         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
54         . $PDK_PATH/ti/boot/sbl/tools/scripts/AM57xImageGen.sh
55     elif [ "$PROCESSOR" == "dsp" ]; then
56         export BIN_PATH=$APP_PATH
57         export APP_DSP1=$APP_PATH/$APP_NAME.out
58         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
59         . $PDK_PATH/ti/boot/sbl/tools/scripts/AM57xImageGen.sh
60     elif [ "$PROCESSOR" == "m4" ]; then
61         export BIN_PATH=$APP_PATH
62         export APP_IPU1_CPU0=$APP_PATH/$APP_NAME.out
63         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
64         . $PDK_PATH/ti/boot/sbl/tools/scripts/AM57xImageGen.sh
65     else
66         echo Invalid Processor core
67     fi
68 fi
70 if [ $SOC == K2G ]; then
71     if [ "$PROCESSOR" == "arm" ]; then
72         export BIN_PATH=$APP_PATH
73         export APP_MPU_CPU0=$APP_PATH/$APP_NAME.out
74         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
75         . $PDK_PATH/ti/boot/sbl/tools/scripts/K2GImageGen.sh
76     elif [ "$PROCESSOR" == "dsp" ]; then
77         export BIN_PATH=$APP_PATH
78         export APP_DSP0=$APP_PATH/$APP_NAME.out
79         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
80         . $PDK_PATH/ti/boot/sbl/tools/scripts/K2GImageGen.sh
81     else
82         echo Invalid Processor core
83     fi
84 fi
86 if [ $SOC == OMAPL137 ] || [ $SOC == OMAPL138 ]; then
87     if [ "$PROCESSOR" == "arm" ]; then
88         export BIN_PATH=$APP_PATH
89         export APP_MPU_CPU0=$APP_PATH/$APP_NAME.out
90         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
91         . $PDK_PATH/ti/boot/sbl/tools/scripts/OMAPL13xImageGen.sh
92     elif [ "$PROCESSOR" == "dsp" ]; then
93         export BIN_PATH=$APP_PATH
94         export APP_DSP0=$APP_PATH/$APP_NAME.out
95         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
96         . $PDK_PATH/ti/boot/sbl/tools/scripts/OMAPL13xImageGen.sh
97     else
98         echo Invalid Processor core
99     fi
100 fi
103 if [ $SOC == am65xx ] || [ $SOC == j721e ] || [ $SOC == am64x ]; then
104     #Refer to SBL document for core ID value (0, or 4 bellow).
105     if [ "$PROCESSOR" == "mpu" ]; then
106         export BIN_PATH=$APP_PATH
107         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
108         . $PDK_PATH/ti/boot/sbl/tools/scripts/K3ImageGen.sh 0 $APP_PATH/$APP_NAME.out
109     elif [ "$PROCESSOR" == "mcu" ]; then
110         export BIN_PATH=$APP_PATH
111         export TOOLS_PATH=$PDK_PATH/ti/boot/sbl/tools
112         . $PDK_PATH/ti/boot/sbl/tools/scripts/K3ImageGen.sh 4 $APP_PATH/$APP_NAME.out
113     else
114         echo Invalid Processor core
115     fi
116 fi