blob: ff5b5a07170c3cb271956e53efd5e682da9492c4 [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 ##
12BL22_DIR=$RTOS_BASE_DIR/bl22
13UBOOT_DIR=$RTOS_BASE_DIR/boot
14LZ4_DIR=$RTOS_BASE_DIR/lib/utilities/lz4
15
16#Get the current project environment variables
17source $RTOS_BASE_DIR/scripts/env.sh arm64 c3 aw419_c308l fastboot
18
19#RTOS object file path
20RTOS_BUILD_DIR=$RTOS_BASE_DIR/output/$ARCH-$BOARD-$PRODUCT/freertos
21RTOS_IMAGE_A=$RTOS_BUILD_DIR/rtos_1.bin
22RTOS_IMAGE_B=$RTOS_BUILD_DIR/rtos_2.bin
23
24function bl22_compile() {
25 if [ -d $BL22_DIR ]; then
26 pushd $BL22_DIR
27 ./mk c3
28 cp ./bl22.bin $RTOS_BUILD_DIR/bl22.bin
29 popd
30 fi
31}
32
33function lz4_rtos() {
34 if [ -d $LZ4_DIR ]; then
35 pushd $LZ4_DIR
36 cp $RTOS_IMAGE_A .
37 ./self_decompress_tool.sh -a ./self_decompress_head.bin -b ./rtos_1.bin -l 0x04c00000 -j 0x04e00000 -d 0
38 cp ./self_decompress_firmware.bin $RTOS_IMAGE_A
39 popd
40 fi
41}
42
43function package_fastboot() {
44 if [ -d $UBOOT_DIR ]; then
45 if [ -d $UBOOT_DIR/fastboot ]; then
46 rm -rf $UBOOT_DIR/fastboot
47 fi
48 mkdir -p $UBOOT_DIR/fastboot
49 fi
50 pushd $UBOOT_DIR
51 cp $RTOS_IMAGE_A $UBOOT_DIR/fastboot
52 cp $RTOS_IMAGE_B $UBOOT_DIR/fastboot
53 cp $RTOS_BUILD_DIR/bl22.bin $UBOOT_DIR/fastboot
54 #./mk c3_aw419 --update-bl2 --bl31 ./blob-bl31.bin.signed
55 ./mk c3_aw419 --update-bl2 --update-bl2e --bl31 ./blob-bl31.bin.signed
56 popd
57}
58
59#compile the rtos image
60cd $RTOS_BASE_DIR && make scatter
61#lz4 compression
62lz4_rtos
63#compile the bl22 image
64bl22_compile
65#compile the u-boot image
66package_fastboot