blob: 27b8da41e4876d987144f444f53aad261246505a [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
shijie.xionga5091132022-12-13 15:16:17 +080011#Board Mapping Combination
12BOARD_DEFINE_REF=(c3_aw409 c3_aw402 c3_aw419)
13BOARD_DEFINE_PAR=(aw409_c302x aw402_c302x aw419_c308l)
14
shijie.xiongffcaf582022-11-08 17:16:58 +080015## external resource path ##
shijie.xionga5091132022-12-13 15:16:17 +080016if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then
shijie.xiongfec9efd2022-11-10 11:32:33 +080017 echo -e "\033[41;33m Notice: parameter error !!! \033[0m"
shijie.xionga5091132022-12-13 15:16:17 +080018 echo -e "\033[33m usage: ./c3_fastboot.sh bl22_path u-boot_path board_type\033[0m"
shijie.xiongfec9efd2022-11-10 11:32:33 +080019 exit 1
20else
21 BL22_DIR=$1
22 UBOOT_DIR=$2
shijie.xionga5091132022-12-13 15:16:17 +080023 BOARD_TYPE=$3
24fi
25
26#Parse the specified hardware type
27for ((i = 0; i < ${#BOARD_DEFINE_PAR[@]}; i++)); do
28 if [ ${BOARD_DEFINE_PAR[i]} == $BOARD_TYPE ]; then
29 BOARD_TYPE_MAPPING=${BOARD_DEFINE_REF[i]}
30 break
31 fi
32done
33
34#parameter check
35if [ -z $BOARD_TYPE_MAPPING ]; then
36 echo -e "\033[41;33m Notice: parameter error !!! \033[0m"
37 echo -e "\033[33m board_type: aw409_c302x / aw402_c302x / aw419_c308l\033[0m"
38 exit 1
shijie.xiongfec9efd2022-11-10 11:32:33 +080039fi
shijie.xiongffcaf582022-11-08 17:16:58 +080040
shijie.xiongc143e9c2022-11-18 17:58:30 +080041#Clear cache files
42[ -d $RTOS_BASE_DIR/output ] && rm -rf $RTOS_BASE_DIR/output
shijie.xionga5091132022-12-13 15:16:17 +080043
shijie.xiongffcaf582022-11-08 17:16:58 +080044#Get the current project environment variables
shijie.xionga5091132022-12-13 15:16:17 +080045source $RTOS_BASE_DIR/scripts/env.sh arm64 c3 $BOARD_TYPE fastboot
shijie.xiongffcaf582022-11-08 17:16:58 +080046
47#RTOS object file path
48RTOS_BUILD_DIR=$RTOS_BASE_DIR/output/$ARCH-$BOARD-$PRODUCT/freertos
49RTOS_IMAGE_A=$RTOS_BUILD_DIR/rtos_1.bin
50RTOS_IMAGE_B=$RTOS_BUILD_DIR/rtos_2.bin
51
shijie.xiongfec9efd2022-11-10 11:32:33 +080052function lz4_rtos() {
53 pushd $RTOS_BASE_DIR/lib/utilities/lz4
54 cp $RTOS_IMAGE_A .
shijie.xionga5091132022-12-13 15:16:17 +080055 if [ "c3_aw409" == $BOARD_TYPE_MAPPING ]; then
56 ./self_decompress_tool.sh -a ./self_decompress_head.bin -b ./rtos_1.bin -l 0x04c00000 -j 0x05400000 -d 0
57 elif [ "c3_aw402" == $BOARD_TYPE_MAPPING ]; then
58 ./self_decompress_tool.sh -a ./self_decompress_head.bin -b ./rtos_1.bin -l 0x04c00000 -j 0x05400000 -d 0
59 else
60 ./self_decompress_tool.sh -a ./self_decompress_head.bin -b ./rtos_1.bin -l 0x04c00000 -j 0x09000000 -d 0
61 fi
shijie.xiongfec9efd2022-11-10 11:32:33 +080062 cp ./self_decompress_firmware.bin $RTOS_IMAGE_A
63 popd
64}
65
shijie.xiongffcaf582022-11-08 17:16:58 +080066function bl22_compile() {
67 if [ -d $BL22_DIR ]; then
68 pushd $BL22_DIR
shijie.xiongfec9efd2022-11-10 11:32:33 +080069 if [ -f ./mk ]; then
shijie.xiongfec9efd2022-11-10 11:32:33 +080070 ./mk c3
71 fi
shijie.xiongffcaf582022-11-08 17:16:58 +080072 cp ./bl22.bin $RTOS_BUILD_DIR/bl22.bin
73 popd
74 fi
75}
76
shijie.xiongffcaf582022-11-08 17:16:58 +080077function package_fastboot() {
shijie.xiongffcaf582022-11-08 17:16:58 +080078 pushd $UBOOT_DIR
shijie.xiongfec9efd2022-11-10 11:32:33 +080079 if [ -d ./fastboot ]; then
80 rm -rf ./fastboot
81 fi
82 mkdir -p ./fastboot
83 cp $RTOS_IMAGE_A ./fastboot
84 cp $RTOS_IMAGE_B ./fastboot
85 cp $RTOS_BUILD_DIR/bl22.bin ./fastboot
shijie.xiongffcaf582022-11-08 17:16:58 +080086 #./mk c3_aw419 --update-bl2 --bl31 ./blob-bl31.bin.signed
shijie.xiongc2bab512022-11-10 17:53:37 +080087 #./mk c3_aw419 --update-bl2 --update-bl2e --bl31 ./blob-bl31.bin.signed
shijie.xiong5fc0ac12022-11-21 10:08:21 +080088 #./mk c3_aw419 --update-bl2 --update-bl2e --bl31 ./fip/blob-bl31.bin.signed
shijie.xionga5091132022-12-13 15:16:17 +080089 ./mk $BOARD_TYPE_MAPPING
shijie.xiongffcaf582022-11-08 17:16:58 +080090 popd
91}
92
shijie.xiong5fc0ac12022-11-21 10:08:21 +080093function debug_info() {
94 echo "<============ Kconfig RTOS ============>"
95 cat $RTOS_BASE_DIR/Kconfig
96 echo "<============ CMakeLists RTOS ============>"
97 cat $RTOS_BASE_DIR/CMakeLists.txt
98 echo "<============ XML RTOS ============>"
99 cat $RTOS_BUILD_DIR/rtos_sdk_manifest.xml
100 echo "<============ XML OLD RTOS ============>"
101 cat $RTOS_BUILD_DIR/rtos_sdk_manifest_old.xml
shijie.xionga5091132022-12-13 15:16:17 +0800102 echo "<============ JENKINS FOR RTOS ============>"
shijie.xiong5fc0ac12022-11-21 10:08:21 +0800103}
104
shijie.xionga5091132022-12-13 15:16:17 +0800105function toolchain_prepare() {
106 echo "<============ TOOLCHAIN INFO RTOS ============>"
107 CROSSTOOL=$RTOS_BASE_DIR/arch/$ARCH/toolchain/$COMPILER*$TOOLCHAIN_KEYWORD
108 rm -rf $RTOS_BASE_DIR/output/toolchains
109 mkdir $RTOS_BASE_DIR/output/toolchains
110 tar -xf $CROSSTOOL.tar.xz -C $RTOS_BASE_DIR/output/toolchains --strip-components=1
111 ls -la $RTOS_BASE_DIR/output/toolchains/bin
112 $RTOS_BASE_DIR/output/toolchains/bin/aarch64-none-elf-gcc -v
113 echo "<============ TOOLCHAIN INFO RTOS ============>"
114}
115
116toolchain_prepare
shijie.xiongffcaf582022-11-08 17:16:58 +0800117#compile the rtos image
118cd $RTOS_BASE_DIR && make scatter
119#lz4 compression
120lz4_rtos
121#compile the bl22 image
122bl22_compile
123#compile the u-boot image
124package_fastboot
shijie.xiong5fc0ac12022-11-21 10:08:21 +0800125#debug
126debug_info