blob: eb08a7dd02d9d8e8650b07d6acb810b98be40ff7 [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 .
shijie.xiong5fc0ac12022-11-21 10:08:21 +080034 ./self_decompress_tool.sh -a ./self_decompress_head.bin -b ./rtos_1.bin -l 0x04c00000 -j 0x09000000 -d 0
shijie.xiongfec9efd2022-11-10 11:32:33 +080035 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
shijie.xiongfec9efd2022-11-10 11:32:33 +080043 ./mk c3
44 fi
shijie.xiongffcaf582022-11-08 17:16:58 +080045 cp ./bl22.bin $RTOS_BUILD_DIR/bl22.bin
46 popd
47 fi
48}
49
shijie.xiongffcaf582022-11-08 17:16:58 +080050function package_fastboot() {
shijie.xiongffcaf582022-11-08 17:16:58 +080051 pushd $UBOOT_DIR
shijie.xiongfec9efd2022-11-10 11:32:33 +080052 if [ -d ./fastboot ]; then
53 rm -rf ./fastboot
54 fi
55 mkdir -p ./fastboot
56 cp $RTOS_IMAGE_A ./fastboot
57 cp $RTOS_IMAGE_B ./fastboot
58 cp $RTOS_BUILD_DIR/bl22.bin ./fastboot
shijie.xiongffcaf582022-11-08 17:16:58 +080059 #./mk c3_aw419 --update-bl2 --bl31 ./blob-bl31.bin.signed
shijie.xiongc2bab512022-11-10 17:53:37 +080060 #./mk c3_aw419 --update-bl2 --update-bl2e --bl31 ./blob-bl31.bin.signed
shijie.xiong5fc0ac12022-11-21 10:08:21 +080061 #./mk c3_aw419 --update-bl2 --update-bl2e --bl31 ./fip/blob-bl31.bin.signed
shijie.xiongc2bab512022-11-10 17:53:37 +080062 ./mk c3_aw419
shijie.xiongffcaf582022-11-08 17:16:58 +080063 popd
64}
65
shijie.xiong5fc0ac12022-11-21 10:08:21 +080066function debug_info() {
67 echo "<============ Kconfig RTOS ============>"
68 cat $RTOS_BASE_DIR/Kconfig
69 echo "<============ CMakeLists RTOS ============>"
70 cat $RTOS_BASE_DIR/CMakeLists.txt
71 echo "<============ XML RTOS ============>"
72 cat $RTOS_BUILD_DIR/rtos_sdk_manifest.xml
73 echo "<============ XML OLD RTOS ============>"
74 cat $RTOS_BUILD_DIR/rtos_sdk_manifest_old.xml
75}
76
shijie.xiongffcaf582022-11-08 17:16:58 +080077#compile the rtos image
78cd $RTOS_BASE_DIR && make scatter
79#lz4 compression
80lz4_rtos
81#compile the bl22 image
82bl22_compile
83#compile the u-boot image
84package_fastboot
shijie.xiong5fc0ac12022-11-21 10:08:21 +080085#debug
86debug_info