blob: 02f38f54a4f5ad227f391a30bdccab9ef486b026 [file] [log] [blame]
shijie.xiongffcaf582022-11-08 17:16:58 +08001#!/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
9RTOS_BASE_DIR=$(realpath $(dirname $(readlink -f ${BASH_SOURCE[0]:-$0}))/..)
10
11## external resource path ##
shijie.xiongfec9efd2022-11-10 11:32:33 +080012if [ -z $1 ] || [ -z $2 ]; then
13 echo -e "\033[41;33m Notice: parameter error !!! \033[0m"
14 echo -e "\033[33m usage: ./c3_fastboot.sh bl22_path u-boot_path \033[0m"
15 exit 1
16else
17 BL22_DIR=$1
18 UBOOT_DIR=$2
19fi
shijie.xiongffcaf582022-11-08 17:16:58 +080020
shijie.xiongc143e9c2022-11-18 17:58:30 +080021#Clear cache files
22[ -d $RTOS_BASE_DIR/output ] && rm -rf $RTOS_BASE_DIR/output
shijie.xiongffcaf582022-11-08 17:16:58 +080023#Get the current project environment variables
24source $RTOS_BASE_DIR/scripts/env.sh arm64 c3 aw419_c308l fastboot
25
26#RTOS object file path
27RTOS_BUILD_DIR=$RTOS_BASE_DIR/output/$ARCH-$BOARD-$PRODUCT/freertos
28RTOS_IMAGE_A=$RTOS_BUILD_DIR/rtos_1.bin
29RTOS_IMAGE_B=$RTOS_BUILD_DIR/rtos_2.bin
30
shijie.xiongfec9efd2022-11-10 11:32:33 +080031function lz4_rtos() {
32 pushd $RTOS_BASE_DIR/lib/utilities/lz4
33 cp $RTOS_IMAGE_A .
34 ./self_decompress_tool.sh -a ./self_decompress_head.bin -b ./rtos_1.bin -l 0x04c00000 -j 0x04e00000 -d 0
35 cp ./self_decompress_firmware.bin $RTOS_IMAGE_A
36 popd
37}
38
shijie.xiongffcaf582022-11-08 17:16:58 +080039function bl22_compile() {
40 if [ -d $BL22_DIR ]; then
41 pushd $BL22_DIR
shijie.xiongfec9efd2022-11-10 11:32:33 +080042 if [ -f ./mk ]; then
43 echo aaaaaaa
44 ./mk c3
45 fi
shijie.xiongffcaf582022-11-08 17:16:58 +080046 cp ./bl22.bin $RTOS_BUILD_DIR/bl22.bin
47 popd
48 fi
49}
50
shijie.xiongffcaf582022-11-08 17:16:58 +080051function package_fastboot() {
shijie.xiongffcaf582022-11-08 17:16:58 +080052 pushd $UBOOT_DIR
shijie.xiongfec9efd2022-11-10 11:32:33 +080053 if [ -d ./fastboot ]; then
54 rm -rf ./fastboot
55 fi
56 mkdir -p ./fastboot
57 cp $RTOS_IMAGE_A ./fastboot
58 cp $RTOS_IMAGE_B ./fastboot
59 cp $RTOS_BUILD_DIR/bl22.bin ./fastboot
shijie.xiongffcaf582022-11-08 17:16:58 +080060 #./mk c3_aw419 --update-bl2 --bl31 ./blob-bl31.bin.signed
shijie.xiongc2bab512022-11-10 17:53:37 +080061 #./mk c3_aw419 --update-bl2 --update-bl2e --bl31 ./blob-bl31.bin.signed
62 ./mk c3_aw419
shijie.xiongffcaf582022-11-08 17:16:58 +080063 popd
64}
65
66#compile the rtos image
67cd $RTOS_BASE_DIR && make scatter
68#lz4 compression
69lz4_rtos
70#compile the bl22 image
71bl22_compile
72#compile the u-boot image
73package_fastboot