凌云实验室推出的ARM Linux物联网网关开发板IGKBoard(IoT Gateway Kit Board)项目源码
guowenxue
2023-03-30 f67c45dd4ba4081ec4f8b82cee2b2da0f5d06143
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
# This shell script used to setup imx6ull build envrionment
#
 
LYFTP_PUB=http://wekei-iot.com:2211/imx/igkboard/tools/lintools
 
# display in yellow
function pr_warn() {
    echo -e "\033[40;33m --W-- $1 \033[0m\n"
}
 
# display in green
function pr_info() {
    echo -e "\033[40;32m --I-- $1 \033[0m\n"
}
 
if [ `id -u` != 0 ] ; then
    pr_warn "This shell script must be excuted as root privilege"
    exit;
fi
 
function prepare_instpath()
{
    if [ -w /apps -a -w /opt ] ; then
        pr_warn "Install path [/apps and /opt] already setup, skip it"
        return ;
    fi
 
    pr_info "/apps and /opt not writable, use chmod to give writable permissions"
 
    # QT build will installed to this path
    mkdir -p /apps && chmod 777 /apps
 
    # buildroot crosstool will installed to this path
    chmod 777 /opt/
}
 
function install_systools()
{
    if command -v jq > /dev/null 2>&1 ; then
        pr_warn "All system tools already installed, skip it"
        return 0;
    fi
 
    pr_warn "start apt install system tools(commands)"
 
    systools="coreutils jq wget curl tree gawk sed unzip cpio lz4 lzop zstd rsync kmod kpartx tmux \
        desktop-file-utils iputils-ping xterm diffstat chrpath asciidoc docbook-utils help2man \
        build-essential gcc g++ make cmake automake groff socat flex texinfo bison texi2html \
        git cvs subversion mercurial autoconf autoconf-archive \
        python2 python3 python3-pip python3-pexpect python3-git python3-jinja2 libsdl1.2-dev \
        lib32z1 libssl-dev libncurses-dev lib32ncurses-dev libgl1-mesa-dev libglu1-mesa-dev \
        "
 
    apt update > /dev/null 2>&1
    apt install -y $systools
}
 
function install_devtools()
{
    if command -v arm-linux-gnueabihf-gcc > /dev/null 2>&1 ; then
        pr_warn "All development tools already installed, skip it"
        return 0;
    fi
 
    pr_info "start apt install devlopment tools(commands)"
 
    devtools="u-boot-tools mtd-utils device-tree-compiler gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \
        binfmt-support qemu qemu-user-static debootstrap debian-archive-keyring "
 
    apt install -y $devtools
 
    #sudo update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-9 10
}
 
function install_buildroot()
{
    BUILDROOT_PATH=/opt/buildroot
    BUILDROOT_NAME=cortexA7
 
    BUILDROOT_VER=buildroot-2021.02.7-cortexA7
    BUILDROOT_TAR=${BUILDROOT_VER}.tar.bz2
    BUILDROOT_DLADDR=${LYFTP_PUB}/$BUILDROOT_TAR
 
    if [ -d ${BUILDROOT_PATH}/${BUILDROOT_NAME} ] ; then
        pr_warn "Buildroot already installed to $BUILDROOT_PATH/$BUILDROOT_NAME"
        return 0;
    fi
 
    mkdir -p ${BUILDROOT_PATH}
 
    if [ ! -f $BUILDROOT_TAR ] ; then
        pr_info "download $BUILDROOT_VER now..."
        wget -c $BUILDROOT_DLADDR
    fi
 
    pr_info "install $BUILDROOT_VER to $BUILDROOT_PATH/$BUILDROOT_NAME now..."
    tar -xjf ${BUILDROOT_TAR} -C ${BUILDROOT_PATH}
 
    $BUILDROOT_PATH/$BUILDROOT_NAME/bin/arm-linux-gcc -v
 
    pr_info "Cross compiler: $BUILDROOT_PATH/$BUILDROOT_NAME/bin/arm-linux-"
 
    rm -f ${BUILDROOT_TAR}
}
 
# NXP document suggest cross compiler from ARM Developer:
#   https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads
function install_crosstool()
{
    ARMTOOL_VER=10.3-2021.07
    ARMTOOL_NAME=gcc-arm-$ARMTOOL_VER
    ARMTOOL_PACK=${ARMTOOL_NAME}-`uname -p`-arm-none-linux-gnueabihf
    ARMTOOL_URL=https://developer.arm.com/-/media/Files/downloads/gnu-a/$ARMTOOL_VER/binrel/
 
    if [ -d /opt/$ARMTOOL_NAME ]  ; then
        pr_info "$ARMTOOL_NAME crosstool already installed, skip it"
        return 0;
    fi
 
    pr_info "start download cross compiler from ARM Developer"
 
    if [ ! -s $ARMTOOL_PACK.tar.xz ] ; then
        wget $ARMTOOL_URL/$ARMTOOL_PACK.tar.xz
    fi
 
    tar -xJf $ARMTOOL_PACK.tar.xz -C /opt
    rm -f $ARMTOOL_PACK.tar.xz
 
    mv /opt/$ARMTOOL_PACK /opt/$ARMTOOL_NAME
 
    /opt/$ARMTOOL_NAME/bin/arm-none-linux-gnueabihf-gcc -v
    pr_info "cross compiler installed to \"/opt/$ARMTOOL_NAME\" successfully"
}
 
echo ""
 
prepare_instpath
 
install_systools
 
install_devtools
 
install_crosstool
 
#install_buildroot