commit | author | age
|
849fbd
|
1 |
#!/bin/bash |
G |
2 |
# This shell script used to install system tools |
|
3 |
|
|
4 |
# display in red |
|
5 |
function pr_error() { |
|
6 |
echo -e "\033[40;31m --E-- $1 \033[0m\n" |
|
7 |
} |
|
8 |
|
|
9 |
# display in green |
|
10 |
function pr_info() { |
|
11 |
echo -e "\033[40;32m --I-- $1 \033[0m\n" |
|
12 |
} |
|
13 |
|
|
14 |
if [ `id -u` != 0 ] ; then |
|
15 |
echo "" |
|
16 |
pr_error "This shell script must be excuted as root privilege" |
|
17 |
exit; |
|
18 |
fi |
|
19 |
|
|
20 |
function install_systools() |
|
21 |
{ |
|
22 |
if command -v jq > /dev/null 2>&1 ; then |
|
23 |
pr_info "All system tools already installed, skip it" |
|
24 |
return 0; |
|
25 |
fi |
|
26 |
|
|
27 |
pr_info "start apt install system tools(commands)" |
|
28 |
|
|
29 |
systools="coreutils jq wget curl tree gawk sed unzip cpio bc lzop zstd rsync kmod kpartx \ |
|
30 |
desktop-file-utils iputils-ping xterm diffstat chrpath asciidoc docbook-utils help2man \ |
|
31 |
build-essential gcc g++ make cmake automake groff socat flex texinfo bison texi2html \ |
|
32 |
git cvs subversion mercurial autoconf autoconf-archive parted dosfstools \ |
|
33 |
python3 python3-pip python3-pexpect python3-git python3-jinja2 \ |
|
34 |
lib32z1 libssl-dev libncurses-dev libgl1-mesa-dev libglu1-mesa-dev libsdl1.2-dev " |
|
35 |
|
|
36 |
apt update > /dev/null 2>&1 |
|
37 |
apt install -y $systools |
|
38 |
} |
|
39 |
|
|
40 |
|
|
41 |
function install_devtools() |
|
42 |
{ |
|
43 |
if command -v debootstrap > /dev/null 2>&1 ; then |
|
44 |
pr_info "All development tools already installed, skip it" |
|
45 |
return 0; |
|
46 |
fi |
|
47 |
|
|
48 |
pr_info "start apt install devlopment tools(commands)" |
|
49 |
|
|
50 |
devtools="u-boot-tools mtd-utils device-tree-compiler binfmt-support \ |
|
51 |
qemu qemu-user-static debootstrap debian-archive-keyring " |
|
52 |
|
|
53 |
apt install -y $devtools |
|
54 |
} |
|
55 |
|
|
56 |
|
|
57 |
# NXP document suggest cross compiler from ARM Developer: |
|
58 |
# https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads |
|
59 |
function install_crosstool() |
|
60 |
{ |
|
61 |
ARMTOOL_VER=10.3-2021.07 |
|
62 |
|
|
63 |
CortexM_PACK=gcc-arm-none-eabi-$ARMTOOL_VER-`uname -p`-linux |
|
64 |
CortexM_TAR=$CortexM_PACK.tar.bz2 |
|
65 |
CortexM_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/$ARMTOOL_VER/ |
|
66 |
CortexM_NAME=gcc-cortexM-$ARMTOOL_VER |
|
67 |
|
|
68 |
# Crosstool for Cortex-M download from ARM Developer |
|
69 |
|
|
70 |
if [ -d /opt/$CortexM_NAME ] ; then |
|
71 |
pr_info "Cortex-M crosstool /opt/$CortexM_NAME installed already, skip it" |
|
72 |
else |
|
73 |
if [ ! -s $CortexM_TAR ] ; then |
|
74 |
pr_info "start download cross compiler from ARM Developer for Cortex-M core" |
|
75 |
wget $CortexM_URL/$CortexM_TAR |
|
76 |
fi |
|
77 |
|
|
78 |
pr_info "start decompress cross compiler for Cortex-M core" |
|
79 |
tar -xjf $CortexM_TAR -C /opt |
|
80 |
mv /opt/gcc-arm-none-eabi-$ARMTOOL_VER /opt/$CortexM_NAME |
|
81 |
rm -f $CortexM_TAR |
|
82 |
|
|
83 |
/opt/$CortexM_NAME/bin/arm-none-eabi-gcc -v |
|
84 |
pr_info "cross compiler for Cortex-M installed to \"/opt/$CortexM_NAME\" successfully" |
|
85 |
fi |
|
86 |
|
|
87 |
# Crosstool for Cortex-A download from ARM Developer |
|
88 |
|
|
89 |
CortexA_PACK=gcc-arm-$ARMTOOL_VER-`uname -p`-aarch64-none-linux-gnu |
|
90 |
CortexA_TAR=$CortexA_PACK.tar.xz |
|
91 |
CortexA_URL=https://developer.arm.com/-/media/Files/downloads/gnu-a/$ARMTOOL_VER/binrel/ |
|
92 |
CortexA_NAME=gcc-aarch64-$ARMTOOL_VER |
|
93 |
|
|
94 |
if [ -d /opt/$CortexA_NAME ] ; then |
|
95 |
pr_info "Cortex-A crosstool /opt/$CortexA_NAME installed already, skip it" |
|
96 |
else |
|
97 |
if [ ! -s $CortexA_TAR ] ; then |
|
98 |
pr_info "start download cross compiler from ARM Developer for Cortex-A core" |
|
99 |
wget $CortexA_URL/$CortexA_TAR |
|
100 |
fi |
|
101 |
|
|
102 |
pr_info "start decompress cross compiler for Cortex-A core" |
|
103 |
tar -xJf $CortexA_TAR -C /opt |
|
104 |
mv /opt/$CortexA_PACK /opt/$CortexA_NAME |
|
105 |
rm -f $CortexA_TAR |
|
106 |
|
|
107 |
/opt/$CortexA_NAME/bin/aarch64-none-linux-gnu-gcc -v |
|
108 |
pr_info "cross compiler for Cortex-A installed to \"/opt/$CortexA_NAME\" successfully" |
|
109 |
fi |
|
110 |
} |
|
111 |
|
|
112 |
echo "" |
|
113 |
set -e |
|
114 |
|
|
115 |
install_systools |
|
116 |
|
|
117 |
install_devtools |
|
118 |
|
|
119 |
install_crosstool |
|
120 |
|