Merge "c3: fastboot manifest scripts issue. [1/1]" into projects/amlogic-dev
diff --git a/env.sh b/env.sh
index 0a510d9..f1ec468 100755
--- a/env.sh
+++ b/env.sh
@@ -52,7 +52,10 @@
return 0
elif [ $# -eq 4 ]; then
PROJECT="$1 $2 $3 $4"
- echo "Choose project: $PROJECT"
+ echo "Choose project:$PROJECT"
+elif [ $# -eq 5 ]; then
+ PROJECT="$1 $2 $3 $4 $5"
+ echo "Choose project:$PROJECT"
else
unset ARRAY
@@ -64,10 +67,6 @@
j=0
for j in "${!ARRAY[@]}"; do
NR=$j
- ARCH=`echo "${ARRAY[$j]}"|awk '{print $1}'`
- SOC=`echo "${ARRAY[$j]}"|awk '{print $2}'`
- BOARD=`echo "${ARRAY[$j]}"|awk '{print $3}'`
- PRODUCT=`echo "${ARRAY[$j]}"|awk '{print $4}'`
j=$((j+1))
echo -e "\t$NR. ${ARRAY[$j-1]}"
done
@@ -91,6 +90,7 @@
SOC=`echo "$PROJECT"|awk '{print $2}'`
BOARD=`echo "$PROJECT"|awk '{print $3}'`
PRODUCT=`echo "$PROJECT"|awk '{print $4}'`
+COMPILER=`echo "$PROJECT"|awk '{print $5}'`
# Check current project
check_build_combination $ARCH $SOC $BOARD $PRODUCT
err=$?
@@ -100,10 +100,17 @@
[ "$err" -eq 4 ] && echo "Invalid PRODUCT: $PRODUCT!" && return $err
case $ARCH in
- arm) COMPILER=gcc;TOOLCHAIN_KEYWORD="arm-none-eabi" ;;
- arm64) COMPILER=gcc;TOOLCHAIN_KEYWORD="aarch64-none-elf" ;;
- riscv) COMPILER=gcc;TOOLCHAIN_KEYWORD="riscv-none" ;;
- xtensa) COMPILER=xcc;TOOLCHAIN_KEYWORD="xt" ;;
+ arm) COMPILER=gcc; TOOLCHAIN_KEYWORD="arm-none-eabi" ;;
+ arm64) if [ "$COMPILER" == "clang+llvm" ]; then
+ TOOLCHAIN_KEYWORD="arm"
+ TOOLCHAIN_PATH=$PWD/output/toolchains/clang+llvm-arm
+ else
+ COMPILER="gcc"
+ TOOLCHAIN_KEYWORD="aarch64-none-elf"
+ fi
+ ;;
+ riscv) COMPILER="gcc"; TOOLCHAIN_KEYWORD="riscv-none" ;;
+ xtensa) COMPILER="xcc"; TOOLCHAIN_KEYWORD="xt" ;;
*) echo "Failed to identify ARCH $ARCH";return 1;;
esac
@@ -115,4 +122,4 @@
KERNEL=freertos
-export ARCH BOARD COMPILER KERNEL PRODUCT SOC TOOLCHAIN_KEYWORD BACKTRACE_ENABLE
+export ARCH BOARD COMPILER KERNEL PRODUCT SOC TOOLCHAIN_KEYWORD TOOLCHAIN_PATH BACKTRACE_ENABLE
diff --git a/map_analyzer_clang_llvm.py b/map_analyzer_clang_llvm.py
new file mode 100755
index 0000000..4d54e0a
--- /dev/null
+++ b/map_analyzer_clang_llvm.py
@@ -0,0 +1,142 @@
+#!/usr/bin/python3
+#coding:utf-8
+#
+# Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: MIT
+#
+
+
+from __future__ import print_function
+
+import sys
+import os
+import argparse
+import operator
+
+parser = argparse.ArgumentParser(description='total size of each object file in an ld linker map.')
+parser.add_argument('map_file', help="A map file generated by passing -M/--print-map to ld during linking.")
+parser.add_argument('--combine', action='store_true',
+ help="All object files in an .a archive or in a directory are combined")
+args = parser.parse_args()
+
+class SectionSize():
+ text = 0
+ data = 0 # Including metadata like import tables
+ bss = 0
+ customize = 0
+ def rom(self):
+ return self.text + self.data
+ def ram(self):
+ return self.data + self.bss
+ def total(self):
+ return self.text + self.data + self.bss
+ def add_clang_llvm_section(self, section, size):
+ if section == ".text":
+ self.text += size
+ elif section == ".bss":
+ self.bss += size
+ elif section == ".data" or section == ".rodata":
+ self.data += size
+ else:
+ if (size > 0):
+ print("customer section:%s, size:%d" % (section, size))
+ self.customize += size
+
+size_by_source = {}
+current_section = None
+last_section = None
+last_source = None
+current_addr = 0x00;
+last_addr = "0"
+size = 0x00;
+last_size = 0x00;
+last_real_size = 0x00;
+heap = 0
+stack = 0
+with open(args.map_file) as f:
+ print("clang+llvm toolchain map analyzer")
+ lines = iter(f)
+ for line in lines:
+ line = line.strip('\n')
+
+ if operator.contains(line, ":(.debug_") or operator.contains(line, ":(.comment"):
+ continue
+ elif operator.contains(line, ":(.shstrtab") or operator.contains(line, ":(.symtab") or operator.contains(line, ":(.strtab"):
+ continue
+ elif (line.endswith(".text")) or (line.endswith(".data")) or (line.endswith(".rodata")) or (line.endswith(".bss")):
+ pieces = line.split(None, 5)
+ current_section = pieces[4]
+ elif operator.contains(line, ":(.") \
+ or operator.contains(line, ".heap") \
+ or operator.contains(line, ".stack") \
+ or operator.contains(line, ":(.text") \
+ or operator.contains(line, ":(.data") \
+ or operator.contains(line, ":(.bss") \
+ or operator.contains(line, ":(.rodata."):
+ pieces = line.split(None, 5) # Don't split paths containing spaces
+ size = int(pieces[2], 16)
+ source = pieces[4]
+ current_addr = pieces[1]
+ if operator.contains(line, '.heap'):
+ heap += size
+ elif operator.contains(line, '.stack'):
+ stack += size
+
+ if args.combine:
+ if '.a(' in source:
+ source = source[:source.index('.a(') + 2]
+ elif '.dir' in source:
+ source = source[:source.find(".dir")]
+ elif '<internal>' in source:
+ source = last_source
+ else:
+ source = os.path.basename(source)
+
+ if source not in size_by_source:
+ size_by_source[source] = SectionSize()
+
+ last_real_size = operator.sub(int(current_addr, 16), int(last_addr, 16))
+ if operator.ne(last_size, 0x00) and operator.gt(last_real_size, last_size):
+ #fixed the last size from address by the size not from last section
+ if (last_section != None) and (current_section != last_section ):
+ #fixed the last size from last source
+ if (last_source != None) and (source != last_source):
+ size_by_source[last_source].add_clang_llvm_section(last_section, (last_real_size - last_size))
+ else:
+ size_by_source[source].add_clang_llvm_section(last_section, (last_real_size - last_size))
+ else:
+ if (last_source != None) and (source != last_source):
+ size_by_source[last_source].add_clang_llvm_section(current_section, (last_real_size - last_size))
+ else:
+ size_by_source[source].add_clang_llvm_section(current_section, (last_real_size - last_size))
+ size_by_source[source].add_clang_llvm_section(current_section, size)
+
+ last_addr = current_addr
+ last_size = size
+ last_section = current_section;
+ last_source = source;
+
+# Print out summary
+sources = list(size_by_source.keys())
+sources.sort(key = lambda x: size_by_source[x].total())
+sumrom = sumram = sumcode = sumdata = sumbss = sumcustomize = 0
+
+print('---------------------------------------------------------------------------------------------------')
+col_format = "%-20s\t%-12s\t%-12s\t%-7s\t%-12s\t%-12s\t%-7s"
+print(col_format % ("module file", "ROM(text+data)", "RAM(data+bss)", ".text", ".data", ".bss", "customize"))
+for source in sources:
+ size = size_by_source[source]
+ sumcode += size.text
+ sumdata += size.data
+ sumbss += size.bss
+ sumrom += size.rom()
+ sumram += size.ram()
+ sumcustomize += size.customize
+ print(col_format % (os.path.basename(source), size.rom(), size.ram(), size.text, size.data, size.bss, size.customize))
+
+print('---------------------------------------------------------------------------------------------------')
+col_format = "%-5s\t%-12s\t%-12s\t%-7s\t%-12s\t%-12s\t%-7s\t%-7s\t%-7s"
+print(col_format % (" ", "ROM(text+data)", "RAM(data+bss)", ".text", ".data", ".bss", "cust", "stack", "heap" ))
+print(col_format % ("total", sumrom, sumram, sumcode, sumdata, sumbss, sumcustomize, stack, heap))
+print('---------------------------------------------------------------------------------------------------')
diff --git a/map_analyzer.py b/map_analyzer_gcc_xcc.py
similarity index 99%
rename from map_analyzer.py
rename to map_analyzer_gcc_xcc.py
index f29295a..c19391b 100755
--- a/map_analyzer.py
+++ b/map_analyzer_gcc_xcc.py
@@ -88,7 +88,7 @@
size_by_source = {}
with open(args.map_file) as f:
- if os.getenv('arch') == "xtensa":
+ if os.getenv('COMPILER') == "xcc":
arch_toolchain = "XCC"
toolchain_keyword = "xtensa-elf"
is_xtensa = 1
diff --git a/setup.sh b/setup.sh
index ceea88d..ffe9604 100755
--- a/setup.sh
+++ b/setup.sh
@@ -14,7 +14,6 @@
build_dir="build_system"
exclude_dirs="boot products docs"
special_dirs="arch soc boards"
-toolchain_dir="arch/$ARCH/toolchain"
DEFAULT_RTOS_SDK_MANIFEST="$PWD/products/$PRODUCT/rtos_sdk_manifest.xml"
RTOS_SDK_MANIFEST_FILE="$kernel_BUILD_DIR/rtos_sdk_manifest.xml"
@@ -85,15 +84,6 @@
cat <<EOF > $kconfig_file
EOF
-# Write the toolchain options to Kconfig
-if [ -f $toolchain_dir/Kconfig ]; then
- category=`basename $toolchain_dir`
- toolchain_kconfig_path="arch/\${ARCH}/toolchain"
- echo "menu \"${category^} Options\"" > $kconfig_file
- echo "source \"$toolchain_kconfig_path/Kconfig\"" >> $kconfig_file
- echo -e "endmenu\n" >> $kconfig_file
-fi
-
# Figure out the $relative_dir and its column
[ -z "$REPO_DIR" ] && REPO_DIR=$PWD
pattern="path="