shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: MIT |
| 6 | # |
| 7 | |
| 8 | #RTOS root directory |
| 9 | RTOS_BASE_DIR=$(realpath $(dirname $(readlink -f ${BASH_SOURCE[0]:-$0}))/..) |
| 10 | |
shijie.xiong | 3c518aa | 2024-10-15 14:40:25 +0800 | [diff] [blame] | 11 | #Board default config |
yongbing.he | cb647a7 | 2024-09-11 15:46:34 +0800 | [diff] [blame] | 12 | RTOS_TARGET_ADDRESS=0x2200000 |
| 13 | BOARD_TYPE=aw402_c302x |
| 14 | SENSOR_TYPE=SC301IOT |
| 15 | DDR_SIZE=128m |
| 16 | UBOOT_CFG=c3_aw402 |
| 17 | |
shijie.xiong | 3c518aa | 2024-10-15 14:40:25 +0800 | [diff] [blame] | 18 | #ISP default config |
| 19 | ISP_MCNR_BUFFER_BASE=0x3000000 |
| 20 | ISP_PTNR_BUFFER_BASE=0x37C6000 |
| 21 | ISP_STATS_BUFFER_BASE=0x3B86000 |
| 22 | ISP_PARAM_BUFFER_BASE=0x3C86000 |
| 23 | ISP_PRESET_BASE=0x3D06000 |
| 24 | ISP_IMG_BUFFER_BASE=0x3E00000 |
| 25 | ISP_RGB_IMG_BUFFER_BASE=0x6000000 |
| 26 | ISP_WDR_VI_RAW_BASE=0x01000000 |
| 27 | |
yongbing.he | 9dab874 | 2024-08-30 18:29:05 +0800 | [diff] [blame] | 28 | while [[ $# -gt 0 ]]; do |
shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 29 | case "$1" in |
| 30 | -a | --address) |
| 31 | RTOS_TARGET_ADDRESS=$2 |
| 32 | shift 2 |
| 33 | ;; |
| 34 | -b | --board) |
| 35 | BOARD_TYPE=$2 |
| 36 | shift 2 |
| 37 | ;; |
| 38 | -s | --sensor) |
yongbing.he | fc75937 | 2024-08-05 17:51:39 +0800 | [diff] [blame] | 39 | SENSOR_TYPE=$2 |
shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 40 | if [[ "$2" =~ ^SENSOR=.* ]]; then |
| 41 | SENSOR_TYPE=${2#SENSOR=} |
| 42 | fi |
| 43 | shift 2 |
| 44 | ;; |
| 45 | --bl22) |
| 46 | BL22_DIR=$2 |
| 47 | shift 2 |
| 48 | ;; |
yongbing.he | fc75937 | 2024-08-05 17:51:39 +0800 | [diff] [blame] | 49 | --uboot) |
| 50 | UBOOT_DIR=$2 |
| 51 | shift 2 |
| 52 | ;; |
| 53 | --ipc-ddr-size) |
| 54 | DDR_SIZE=$2 |
| 55 | shift 2 |
| 56 | ;; |
| 57 | --ubootcfg) |
| 58 | UBOOT_CFG=$2 |
| 59 | shift 2 |
| 60 | ;; |
shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 61 | -o | --out) |
| 62 | INSTALL_DIR=$2 |
| 63 | shift 2 |
| 64 | ;; |
shijie.xiong | 3c518aa | 2024-10-15 14:40:25 +0800 | [diff] [blame] | 65 | --rtos-dir) |
| 66 | RTOS_BASE_DIR=$2 |
| 67 | shift 2 |
| 68 | ;; |
shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 69 | -h | --help) |
| 70 | echo -e "\033[41;33m gen_fastboot.sh help info \033[0m" |
| 71 | echo "Usage: fastboot [OPTIONS]" |
| 72 | echo |
| 73 | echo "Options:" |
| 74 | echo " -a/--address et address to load (e.g., -a 0x2200000)" |
| 75 | echo " -b/--board Set board type (e.g., -b aw402_c302x)" |
| 76 | echo " -s/--sensor Set ipc sensor type (e.g., -s IMX290)" |
| 77 | echo " --b22 PATH Set BL22 path" |
| 78 | echo " -h Display this help information" |
| 79 | echo |
| 80 | echo "For more details, refer to the fastboot documentation." |
| 81 | exit 1 |
| 82 | shift |
| 83 | ;; |
| 84 | --) |
| 85 | shift |
| 86 | break |
| 87 | ;; |
yongbing.he | 9dab874 | 2024-08-30 18:29:05 +0800 | [diff] [blame] | 88 | -*|--*) |
shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 89 | echo "Invalid option: $1" >&2 |
| 90 | exit 1 |
| 91 | ;; |
yongbing.he | 9dab874 | 2024-08-30 18:29:05 +0800 | [diff] [blame] | 92 | *) |
| 93 | echo "No more options, just arguments" >&2 |
| 94 | exit 1 |
| 95 | ;; |
shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 96 | esac |
| 97 | done |
| 98 | |
| 99 | if [[ ! -d "$BL22_DIR" ]]; then |
| 100 | echo "The provided bl22 path is not a directory: $BL22_DIR" |
| 101 | exit 1 |
| 102 | fi |
| 103 | |
| 104 | #Retrieve the RTOS loading address; if none exists, set it to the default address. |
| 105 | if [ -z $RTOS_TARGET_ADDRESS ]; then |
yongbing.he | fc75937 | 2024-08-05 17:51:39 +0800 | [diff] [blame] | 106 | RTOS_TARGET_ADDRESS=0x02200000 |
shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 107 | fi |
| 108 | |
| 109 | #Calculate the RTOS2 loading address |
| 110 | let "RTOS2_TARGET_ADDRESS=$RTOS_TARGET_ADDRESS+0x100000" |
| 111 | RTOS2_TARGET_ADDRESS=$(printf '0x%x\n' $RTOS2_TARGET_ADDRESS) |
| 112 | |
| 113 | #Clear cache files |
| 114 | [ -d $RTOS_BASE_DIR/output ] && rm -rf $RTOS_BASE_DIR/output |
| 115 | |
| 116 | #Get the current project environment variables |
| 117 | source $RTOS_BASE_DIR/scripts/env.sh arm64 c3 $BOARD_TYPE fastboot |
| 118 | if [ "$?" -ne 0 ]; then |
| 119 | echo "Error: Incorrect board type selection!" |
| 120 | exit 1 |
| 121 | fi |
| 122 | |
| 123 | #IPC sensor model configuration. |
| 124 | if [ -z $SENSOR_TYPE ]; then |
| 125 | case $BOARD_TYPE in |
| 126 | 'aw402_c302x') |
| 127 | SENSOR_TYPE=SC301IOT |
| 128 | ;; |
| 129 | *) |
| 130 | SENSOR_TYPE=IMX290 |
| 131 | ;; |
| 132 | esac |
| 133 | fi |
| 134 | |
| 135 | #RTOS object file path |
| 136 | RTOS_BUILD_DIR=$RTOS_BASE_DIR/output/$ARCH-$BOARD-$PRODUCT/freertos |
| 137 | RTOS_IMAGE_1=$RTOS_BUILD_DIR/rtos_1.bin |
| 138 | RTOS_IMAGE_2=$RTOS_BUILD_DIR/rtos_2.bin |
| 139 | BL22_IMAGE=$RTOS_BUILD_DIR/bl22.bin |
| 140 | |
| 141 | function toolchain_prepare() { |
| 142 | echo "<============ TOOLCHAIN INFO RTOS ============>" |
| 143 | CROSSTOOL=$RTOS_BASE_DIR/arch/$ARCH/toolchain/$COMPILER*$TOOLCHAIN_KEYWORD |
| 144 | TOOLCHAIN_DIR=$RTOS_BASE_DIR/output/toolchains/$COMPILER-$TOOLCHAIN_KEYWORD |
| 145 | rm -rf $RTOS_BASE_DIR/output/toolchains |
| 146 | mkdir -p $TOOLCHAIN_DIR |
| 147 | tar -xf $CROSSTOOL.tar.xz -C $TOOLCHAIN_DIR --strip-components=1 |
| 148 | ls -la $TOOLCHAIN_DIR/bin |
| 149 | $TOOLCHAIN_DIR/bin/aarch64-none-elf-gcc -v |
| 150 | echo "<============ TOOLCHAIN INFO RTOS ============>" |
| 151 | } |
| 152 | |
shijie.xiong | 3c518aa | 2024-10-15 14:40:25 +0800 | [diff] [blame] | 153 | function sensor_config_choose() { |
| 154 | VENC_CONFIG_H=lib/venc/include/venc_config.h |
shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 155 | CONFIG_FILE=$RTOS_BASE_DIR/boards/$ARCH/$BOARD/lscript.h |
shijie.xiong | 3c518aa | 2024-10-15 14:40:25 +0800 | [diff] [blame] | 156 | |
| 157 | #Configure the compile-time address. |
shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 158 | sed -i '/.*#define configTEXT_BASE*/c\#define configTEXT_BASE '${RTOS_TARGET_ADDRESS}'' $CONFIG_FILE |
| 159 | sed -i '/.*#define CONFIG_SCATTER_LOAD_ADDRESS*/c\#define CONFIG_SCATTER_LOAD_ADDRESS '${RTOS2_TARGET_ADDRESS}'' $CONFIG_FILE |
shijie.xiong | 3c518aa | 2024-10-15 14:40:25 +0800 | [diff] [blame] | 160 | |
| 161 | sed -i '/CONFIG_SENSOR_SC301IOT/d' $RTOS_BASE_DIR/boards/$ARCH/$BOARD/defconfig |
| 162 | sed -i '/CONFIG_SENSOR_SC401AI/d' $RTOS_BASE_DIR/boards/$ARCH/$BOARD/defconfig |
| 163 | sed -i '/CONFIG_SENSOR_SC5336P/d' $RTOS_BASE_DIR/boards/$ARCH/$BOARD/defconfig |
| 164 | sed -i '/.*#define MINI_ENC_300W*/c\#define MINI_ENC_300W '0'' $VENC_CONFIG_H |
| 165 | sed -i '/.*#define MINI_ENC_400W*/c\#define MINI_ENC_400W '0'' $VENC_CONFIG_H |
| 166 | sed -i '/.*#define MINI_ENC_2880X1620*/c\#define MINI_ENC_2880X1620 '0'' $VENC_CONFIG_H |
| 167 | |
yongbing.he | fc75937 | 2024-08-05 17:51:39 +0800 | [diff] [blame] | 168 | case $DDR_SIZE in |
| 169 | '128m') |
shijie.xiong | 3c518aa | 2024-10-15 14:40:25 +0800 | [diff] [blame] | 170 | case $SENSOR_TYPE in |
| 171 | 'SC301IOT') |
| 172 | sed -i '$ a CONFIG_SENSOR_SC301IOT=y' $RTOS_BASE_DIR/boards/$ARCH/$BOARD/defconfig |
| 173 | sed -i '/.*#define MINI_ENC_300W*/c\#define MINI_ENC_300W '1'' $VENC_CONFIG_H |
| 174 | ISP_MCNR_BUFFER_BASE=0x3000000 |
| 175 | ISP_PTNR_BUFFER_BASE=0x37C6000 |
| 176 | ISP_STATS_BUFFER_BASE=0x3B86000 |
| 177 | ISP_PARAM_BUFFER_BASE=0x3C86000 |
| 178 | ISP_PRESET_BASE=0x3D06000 |
| 179 | ISP_IMG_BUFFER_BASE=0x3E00000 |
| 180 | ISP_RGB_IMG_BUFFER_BASE=0x6000000 |
| 181 | ISP_WDR_VI_RAW_BASE=0x01000000 |
| 182 | ;; |
| 183 | 'SC401AI') |
| 184 | sed -i '$ a CONFIG_SENSOR_SC401AI=y' $RTOS_BASE_DIR/boards/$ARCH/$BOARD/defconfig |
| 185 | sed -i '/.*#define MINI_ENC_400W*/c\#define MINI_ENC_400W '1'' $VENC_CONFIG_H |
| 186 | ISP_MCNR_BUFFER_BASE=0x3000000 |
| 187 | ISP_PTNR_BUFFER_BASE=0x391A000 |
| 188 | ISP_STATS_BUFFER_BASE=0x3D7F000 |
| 189 | ISP_PARAM_BUFFER_BASE=0x3E7F000 |
| 190 | ISP_PRESET_BASE=0x3EFF000 |
| 191 | ISP_IMG_BUFFER_BASE=0x3F00000 |
| 192 | ISP_RGB_IMG_BUFFER_BASE=0x6000000 |
| 193 | ISP_WDR_VI_RAW_BASE=0x01000000 |
| 194 | ;; |
| 195 | esac |
| 196 | |
| 197 | sed -i '/.*#define configSRAM_START*/c\#define configSRAM_START '0x3000000'' $CONFIG_FILE |
| 198 | sed -i '/.*#define configSRAM_LEN*/c\#define configSRAM_LEN '0x1700000'' $CONFIG_FILE |
| 199 | sed -i '/.*#define configVENC_BASE*/c\#define configVENC_BASE '0x04700000'' $CONFIG_FILE |
| 200 | sed -i '/.*#define configVENC_LEN*/c\#define configVENC_LEN '0x0B00000'' $CONFIG_FILE |
| 201 | sed -i '/.*#define configISP_RGB_BASE*/c\#define configISP_RGB_BASE '0x6000000'' $CONFIG_FILE |
| 202 | |
| 203 | sed -i '/.*#define VENC_PHY_MEM_BASE_ADDR*/c\#define VENC_PHY_MEM_BASE_ADDR '0x4700000'' $VENC_CONFIG_H |
| 204 | sed -i '/.*#define VENC_PHY_MEM_SIZE*/c\#define VENC_PHY_MEM_SIZE '0x900000'' $VENC_CONFIG_H |
| 205 | ;; |
yongbing.he | fc75937 | 2024-08-05 17:51:39 +0800 | [diff] [blame] | 206 | '256m') |
shijie.xiong | 3c518aa | 2024-10-15 14:40:25 +0800 | [diff] [blame] | 207 | case $SENSOR_TYPE in |
| 208 | 'SC301IOT') |
| 209 | sed -i '$ a CONFIG_SENSOR_SC301IOT=y' $RTOS_BASE_DIR/boards/$ARCH/$BOARD/defconfig |
| 210 | sed -i '/.*#define MINI_ENC_300W*/c\#define MINI_ENC_300W '1'' $VENC_CONFIG_H |
| 211 | # start_addr |
| 212 | ISP_MCNR_BUFFER_BASE=0x9B00000 |
| 213 | ISP_PTNR_BUFFER_BASE=0xA2C6000 |
| 214 | ISP_STATS_BUFFER_BASE=0xA686000 |
| 215 | ISP_PARAM_BUFFER_BASE=0xA786000 |
| 216 | ISP_PRESET_BASE=0xA806000 |
| 217 | ISP_IMG_BUFFER_BASE=0xA807000 |
| 218 | ISP_RGB_IMG_BUFFER_BASE=0x6000000 |
| 219 | ISP_WDR_VI_RAW_BASE=0x01000000 |
| 220 | ;; |
| 221 | 'SC401AI') |
| 222 | sed -i '$ a CONFIG_SENSOR_SC401AI=y' $RTOS_BASE_DIR/boards/$ARCH/$BOARD/defconfig |
| 223 | sed -i '/.*#define MINI_ENC_400W*/c\#define MINI_ENC_400W '1'' $VENC_CONFIG_H |
| 224 | ISP_MCNR_BUFFER_BASE=0x9B00000 |
| 225 | ISP_PTNR_BUFFER_BASE=0xA41A000 |
| 226 | ISP_STATS_BUFFER_BASE=0xA87F000 |
| 227 | ISP_PARAM_BUFFER_BASE=0xA97F000 |
| 228 | ISP_PRESET_BASE=0xA9FF000 |
| 229 | ISP_IMG_BUFFER_BASE=0xAA00000 |
| 230 | ISP_RGB_IMG_BUFFER_BASE=0x6000000 |
| 231 | ISP_WDR_VI_RAW_BASE=0x01000000 |
| 232 | ;; |
| 233 | 'SC5336P') |
| 234 | sed -i '$ a CONFIG_SENSOR_SC5336P=y' $RTOS_BASE_DIR/boards/$ARCH/$BOARD/defconfig |
| 235 | sed -i '/.*#define MINI_ENC_2880X1620*/c\#define MINI_ENC_2880X1620 '1'' $VENC_CONFIG_H |
| 236 | ISP_MCNR_BUFFER_BASE=0x9B00000 |
| 237 | ISP_PTNR_BUFFER_BASE=0xA681000 |
| 238 | ISP_STATS_BUFFER_BASE=0xAC11000 |
| 239 | ISP_PARAM_BUFFER_BASE=0xAD11000 |
| 240 | ISP_PRESET_BASE=0xAD91000 |
| 241 | ISP_IMG_BUFFER_BASE=0xAD92000 |
| 242 | ISP_RGB_IMG_BUFFER_BASE=0x3700000 |
| 243 | ISP_WDR_VI_RAW_BASE=0x01000000 |
| 244 | ;; |
| 245 | esac |
yongbing.he | fc75937 | 2024-08-05 17:51:39 +0800 | [diff] [blame] | 246 | sed -i '/.*#define configSRAM_START*/c\#define configSRAM_START '0x9B00000'' $CONFIG_FILE |
| 247 | sed -i '/.*#define configSRAM_LEN*/c\#define configSRAM_LEN '0x3200000'' $CONFIG_FILE |
| 248 | sed -i '/.*#define configVENC_BASE*/c\#define configVENC_BASE '0xCD00000'' $CONFIG_FILE |
| 249 | sed -i '/.*#define configVENC_LEN*/c\#define configVENC_LEN '0x2A00000'' $CONFIG_FILE |
| 250 | sed -i '/.*#define configISP_RGB_BASE*/c\#define configISP_RGB_BASE '0x3700000'' $CONFIG_FILE |
shijie.xiong | 3c518aa | 2024-10-15 14:40:25 +0800 | [diff] [blame] | 251 | |
| 252 | sed -i '/.*#define VENC_PHY_MEM_BASE_ADDR*/c\#define VENC_PHY_MEM_BASE_ADDR '0xCD00000'' $VENC_CONFIG_H |
| 253 | sed -i '/.*#define VENC_PHY_MEM_SIZE*/c\#define VENC_PHY_MEM_SIZE '0x2800000'' $VENC_CONFIG_H |
yongbing.he | fc75937 | 2024-08-05 17:51:39 +0800 | [diff] [blame] | 254 | ;; |
| 255 | esac |
shijie.xiong | 3c518aa | 2024-10-15 14:40:25 +0800 | [diff] [blame] | 256 | #config isp buffer base |
| 257 | sed -i '/.*#define AML_ISP_MCNR_BUFFER_BASE_ADDR*/c\#define AML_ISP_MCNR_BUFFER_BASE_ADDR '${ISP_MCNR_BUFFER_BASE}'' $CONFIG_FILE |
| 258 | sed -i '/.*#define AML_ISP_PTNR_BUFFER_BASE_ADDR*/c\#define AML_ISP_PTNR_BUFFER_BASE_ADDR '${ISP_PTNR_BUFFER_BASE}'' $CONFIG_FILE |
| 259 | sed -i '/.*#define AML_ISP_STATS_BUFFER_BASE_ADDR*/c\#define AML_ISP_STATS_BUFFER_BASE_ADDR '${ISP_STATS_BUFFER_BASE}'' $CONFIG_FILE |
| 260 | sed -i '/.*#define AML_ISP_PARAM_BUFFER_BASE_ADDR*/c\#define AML_ISP_PARAM_BUFFER_BASE_ADDR '${ISP_PARAM_BUFFER_BASE}'' $CONFIG_FILE |
| 261 | sed -i '/.*#define AML_ISP_PRESET_BASE_ADDR*/c\#define AML_ISP_PRESET_BASE_ADDR '${ISP_PRESET_BASE}'' $CONFIG_FILE |
| 262 | sed -i '/.*#define AML_ISP_IMG_BUFFER_BASE_ADDR*/c\#define AML_ISP_IMG_BUFFER_BASE_ADDR '${ISP_IMG_BUFFER_BASE}'' $CONFIG_FILE |
| 263 | sed -i '/.*#define AML_ISP_RGB_IMG_BUFFER_BASE_ADDR*/c\#define AML_ISP_RGB_IMG_BUFFER_BASE_ADDR '${ISP_RGB_IMG_BUFFER_BASE}'' $CONFIG_FILE |
| 264 | sed -i '/.*#define AML_ISP_WDR_VI_RAW_BASE_ADDR*/c\#define AML_ISP_WDR_VI_RAW_BASE_ADDR '${ISP_WDR_VI_RAW_BASE}'' $CONFIG_FILE |
shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 265 | |
shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | function lz4_rtos() { |
| 269 | pushd $RTOS_BASE_DIR/lib/utilities/lz4 |
| 270 | cp $RTOS_IMAGE_1 . |
| 271 | #Get the rtos target address |
| 272 | ./self_decompress_tool.sh -a ./self_decompress_head.bin -b ./rtos_1.bin -l 0x04c00000 -j $RTOS_TARGET_ADDRESS -d 0 -s $RTOS2_TARGET_ADDRESS |
| 273 | cp ./self_decompress_firmware.bin $RTOS_IMAGE_1 |
| 274 | rm ./self_decompress_firmware.bin ./rtos_1.bin |
| 275 | popd |
| 276 | } |
| 277 | |
| 278 | function bl22_compile() { |
| 279 | pushd $BL22_DIR |
| 280 | if [ -f ./mk ]; then |
yongbing.he | fc75937 | 2024-08-05 17:51:39 +0800 | [diff] [blame] | 281 | echo "./mk c3 $BOARD_TYPE $SENSOR_TYPE" |
| 282 | ./mk c3 $BOARD_TYPE $SENSOR_TYPE |
shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 283 | if [ "$?" -ne 0 ]; then |
| 284 | echo "RTOS-SDK: BL22 compilation failed !!!" |
| 285 | exit 1 |
| 286 | fi |
| 287 | fi |
| 288 | cp ./bl22.bin $RTOS_BUILD_DIR/bl22.bin |
| 289 | popd |
| 290 | } |
| 291 | |
| 292 | function build_header() { |
| 293 | local bl2_2=$1 |
| 294 | local rtos_1=$2 |
| 295 | local rtos_2=$3 |
| 296 | |
| 297 | local size=0 |
| 298 | # 4KB for header (reserve for sign) |
| 299 | local offset=4096 |
| 300 | local rem=0 |
| 301 | |
| 302 | # build head for bl2-2.bin |
| 303 | size=$(stat -c %s ${bl2_2}) |
| 304 | # insert uuid |
| 305 | echo -n -e "\x6b\xe6\x1e\x1f\xac\xc0\x45\x12\x97\x3b\x32\x5f\x2e\x17\xa7\x2d" >${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 306 | # insert size |
| 307 | printf "%02x%02x%02x%02x" $(((size) & 0xff)) $((((size) >> 8) & 0xff)) \ |
| 308 | $((((size) >> 16) & 0xff)) $((((size) >> 24) & 0xff)) | xxd -r -ps >>${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 309 | # insert offset |
| 310 | printf "%02x%02x%02x%02x" $(((offset) & 0xff)) $((((offset) >> 8) & 0xff)) \ |
| 311 | $((((offset) >> 16) & 0xff)) $((((offset) >> 24) & 0xff)) | xxd -r -ps >>${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 312 | # insert 8 bytes padding |
| 313 | printf "\0\0\0\0\0\0\0\0" >>${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 314 | # insert sha256 |
| 315 | openssl dgst -sha256 -binary ${bl2_2} >>${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 316 | |
| 317 | # build header for RTOS_1 |
| 318 | offset=$(expr ${offset} + ${size} + 4095) |
| 319 | rem=$(expr ${offset} % 4096) |
| 320 | offset=$(expr ${offset} - ${rem}) |
| 321 | size=$(stat -c %s ${rtos_1}) |
| 322 | echo -n -e "\x31\x9f\xb3\x9e\x1f\x9f\x48\x98\x96\x38\xca\xfa\x7e\xa4\x2c\xe9" >>${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 323 | printf "%02x%02x%02x%02x" $(((size) & 0xff)) $((((size) >> 8) & 0xff)) \ |
| 324 | $((((size) >> 16) & 0xff)) $((((size) >> 24) & 0xff)) | xxd -r -ps >>${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 325 | printf "%02x%02x%02x%02x" $(((offset) & 0xff)) $((((offset) >> 8) & 0xff)) \ |
| 326 | $((((offset) >> 16) & 0xff)) $((((offset) >> 24) & 0xff)) | xxd -r -ps >>${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 327 | printf "\0\0\0\0\0\0\0\0" >>${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 328 | openssl dgst -sha256 -binary ${rtos_1} >>${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 329 | |
| 330 | # build header for RTOS_2 |
| 331 | offset=$(expr ${offset} + ${size} + 4095) |
| 332 | rem=$(expr ${offset} % 4096) |
| 333 | offset=$(expr ${offset} - ${rem}) |
| 334 | size=$(stat -c %s ${rtos_2}) |
| 335 | echo -n -e "\x33\x71\xb3\x2b\x17\xca\x43\xe2\xb4\xdb\x11\xe1\x3e\xc0\xa5\xf3" >>${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 336 | printf "%02x%02x%02x%02x" $(((size) & 0xff)) $((((size) >> 8) & 0xff)) \ |
| 337 | $((((size) >> 16) & 0xff)) $((((size) >> 24) & 0xff)) | xxd -r -ps >>${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 338 | printf "%02x%02x%02x%02x" $(((offset) & 0xff)) $((((offset) >> 8) & 0xff)) \ |
| 339 | $((((offset) >> 16) & 0xff)) $((((offset) >> 24) & 0xff)) | xxd -r -ps >>${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 340 | printf "\0\0\0\0\0\0\0\0" >>${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 341 | openssl dgst -sha256 -binary ${rtos_2} >>${RTOS_BUILD_DIR}/_tmp_hdr.bin |
| 342 | } |
| 343 | |
| 344 | function package_binary() { |
| 345 | local fw_size= |
| 346 | local rem_val= |
| 347 | local bin1=$1 |
| 348 | local bin2=$2 |
| 349 | local out_bin=$3 |
| 350 | |
| 351 | # align bin1 size up to 4KB and padding bin2 at the end of bin1 |
| 352 | fw_size=$(stat -c %s ${bin1}) |
| 353 | fw_size=$(expr ${fw_size} + 4095) |
| 354 | rem_val=$(expr ${fw_size} % 4096) |
| 355 | fw_size=$(expr ${fw_size} - ${rem_val}) |
| 356 | dd if=/dev/zero of=${RTOS_BUILD_DIR}/_tmp.bin bs=1 count=${fw_size} &>/dev/null |
| 357 | dd if=${bin1} of=${RTOS_BUILD_DIR}/_tmp.bin bs=1 count=${fw_size} conv=notrunc &>/dev/null |
| 358 | |
| 359 | cat ${bin2} >>${RTOS_BUILD_DIR}/_tmp.bin |
| 360 | mv ${RTOS_BUILD_DIR}/_tmp.bin ${RTOS_BUILD_DIR}/${out_bin} |
| 361 | echo ==== package ${bin1} ${bin2} to ${out_bin} ==== |
| 362 | } |
| 363 | |
| 364 | function package_fastboot() { |
yongbing.he | fc75937 | 2024-08-05 17:51:39 +0800 | [diff] [blame] | 365 | if [ -n $UBOOT_DIR ]; then |
| 366 | pushd $UBOOT_DIR |
| 367 | if [ -d ./fastboot ]; then |
| 368 | rm -rf ./fastboot |
| 369 | fi |
| 370 | mkdir -p ./fastboot |
| 371 | cp $RTOS_IMAGE_1 ./fastboot |
| 372 | cp $RTOS_IMAGE_2 ./fastboot |
| 373 | cp $BL22_IMAGE ./fastboot |
| 374 | echo "./mk $UBOOT_CFG --build-nogit --ipc-ddr-size $DDR_SIZE" |
| 375 | ./mk $UBOOT_CFG --build-nogit --ipc-ddr-size $DDR_SIZE |
| 376 | if [ "$?" -ne 0 ]; then |
| 377 | if [ -d ./fastboot ]; then |
| 378 | rm -rf ./fastboot |
| 379 | fi |
| 380 | echo "RTOS-SDK: Uboot compilation failed !!!" |
| 381 | exit 1 |
| 382 | fi |
| 383 | |
| 384 | if [ -d ./fastboot ]; then |
| 385 | rm -rf ./fastboot |
| 386 | fi |
| 387 | popd |
| 388 | fi |
shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 389 | build_header $BL22_IMAGE $RTOS_IMAGE_1 $RTOS_IMAGE_2 |
| 390 | package_binary ${RTOS_BUILD_DIR}/_tmp_hdr.bin ${RTOS_BUILD_DIR}/bl22.bin bl22.bin |
| 391 | package_binary ${RTOS_BUILD_DIR}/bl22.bin ${RTOS_BUILD_DIR}/rtos_1.bin bl22.bin |
| 392 | package_binary ${RTOS_BUILD_DIR}/bl22.bin ${RTOS_BUILD_DIR}/rtos_2.bin rtos_fastboot.bin |
| 393 | if [[ -d "$INSTALL_DIR" ]]; then |
| 394 | cp ${RTOS_BUILD_DIR}/rtos_fastboot.bin ${INSTALL_DIR} -rf |
| 395 | fi |
| 396 | } |
| 397 | |
| 398 | function debug_info() { |
| 399 | echo "<============ Kconfig RTOS ============>" |
| 400 | cat $RTOS_BASE_DIR/Kconfig |
| 401 | echo "<============ CMakeLists RTOS ============>" |
| 402 | cat $RTOS_BASE_DIR/CMakeLists.txt |
| 403 | echo "<============ XML RTOS ============>" |
| 404 | cat $RTOS_BUILD_DIR/rtos_sdk_manifest.xml |
| 405 | echo "<============ XML OLD RTOS ============>" |
| 406 | cat $RTOS_BUILD_DIR/rtos_sdk_manifest_old.xml |
| 407 | echo "<============ JENKINS FOR RTOS ============>" |
| 408 | } |
| 409 | |
shijie.xiong | 3da90db | 2024-06-27 17:13:42 +0800 | [diff] [blame] | 410 | #choose sensor |
| 411 | sensor_config_choose |
| 412 | #Compile toolchain preparation |
| 413 | toolchain_prepare |
| 414 | #compile the rtos image |
| 415 | cd $RTOS_BASE_DIR && make |
| 416 | if [ "$?" -ne 0 ]; then |
| 417 | echo "RTOS-SDK: RTOS compilation failed !!!" |
| 418 | exit 1 |
| 419 | fi |
| 420 | #lz4 compression |
| 421 | lz4_rtos |
| 422 | #compile the bl22 image |
| 423 | bl22_compile |
| 424 | #Packaging RTOS binary files |
| 425 | package_fastboot |
| 426 | #debug |
| 427 | # debug_info |