SAMA5D4 Xplained Ultra Board BSP
guowenxue
2019-08-24 a6177b46d08f140c3287e79d4b99f78621ddfa5e
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
#!/bin/bash
# This shell script used to setup ok335x build envrionment
#
# 1. U-boot, Linux kernel and root file system all compiled or generated by this crosstool.
# 2. This crsootool is built in i386, running on x86-64 depends on lib32
# 3. Install mkimage and mkfs.ubifs tools
 
LYFTP_PUB=ftp://master.iot-yun.club/pub/
 
function sudo_banner()
{
    if [ `id -u` != 0 ] ; then
       echo "WARRNING: Follow linux command maybe need input sudo passwd here:"
       echo ""
    fi
}
 
function msg_banner()
{
    echo "" 
    echo "+-----------------------------------------------------------------------" 
    echo "|  $1 " 
    echo "+-----------------------------------------------------------------------" 
    echo ""
}
 
function prepare_instpath()
{
    if [ -w /apps -a -w /opt ] ; then
        msg_banner "Install path [/apps and /opt] already setup, skip it"
        return ;
    fi
 
    msg_banner "/apps and /opt not writable, use chmod to give writable permissions"
 
    sudo_banner
 
    #QT build will installed to this path
    sudo mkdir -p /apps && sudo chmod 777 /apps
 
    #crosstool will installed to this path
    sudo chmod 777 /opt/
}
 
function install_systools()
{
    mkimage -V > /dev/null 2>&1
    if [ $? == 0 ] ;  then
        msg_banner "All development system tools already installed, skip it"
        return 0;
    fi
 
    msg_banner "start apt-get install system devlopment tools(commands)" 
 
    systools="gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat \
        libsdl1.2-dev xterm sed cvs subversion coreutils texi2html docbook-utils python-pysqlite2 \
        help2man make gcc g++ desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf \
        automake groff curl lzop asciidoc lib32z1 lib32ncurses5"
 
    devtools="u-boot-tools mtd-utils device-tree-compiler"
 
 
    sudo_banner
 
    sudo apt-get update > /dev/null 2>&1
    sudo apt-get install -y $systools $devtools
}
 
function install_crosstool()
{
    CROSSTOOL_PATH=/opt/crosstool
    CROSSTOOL_NAME=cortex-a7
 
    CROSSTOOL_VER=gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi
    CROSSTOOL_TAR=${CROSSTOOL_VER}.tar.xz
    CROSSTOOL_DLADDR=${LYFTP_PUB}/$CROSSTOOL_TAR
 
    if [ -d ${CROSSTOOL_PATH}/${CROSSTOOL_NAME} ] ; then
        msg_banner "$CROSSTOOL_VER already installed to $CROSSTOOL_PATH/$CROSSTOOL_NAME"
        return 0;
    fi
 
 
    mkdir -p ${CROSSTOOL_PATH} 
 
    if [ ! -f $CROSSTOOL_TAR ] ; then 
        msg_banner "download $CROSSTOOL_VER now..."
        wget -c $CROSSTOOL_DLADDR 
    fi 
 
    msg_banner "install $CROSSTOOL_VER to $CROSSTOOL_PATH/$CROSSTOOL_NAME now..."
    tar -xJf ${CROSSTOOL_TAR} -C ${CROSSTOOL_PATH} 
    mv ${CROSSTOOL_PATH}/${CROSSTOOL_VER}/  ${CROSSTOOL_PATH}/${CROSSTOOL_NAME}
}
 
function install_buildroot()
{
    BUILDROOT_PATH=/opt/buildroot
    BUILDROOT_NAME=cortex-a5
 
    BUILDROOT_VER=buildroot-2019.02-gcc7.4.0-cortexA5-x86_64_arm-linux-gnueabihf
    BUILDROOT_TAR=${BUILDROOT_VER}.tar.xz
    BUILDROOT_DLADDR=${LYFTP_PUB}/$BUILDROOT_TAR
 
    if [ -d ${BUILDROOT_PATH}/${BUILDROOT_NAME} ] ; then
        msg_banner "$BUILDROOT_VER already installed to $BUILDROOT_PATH/$BUILDROOT_NAME"
        return 0;
    fi
 
 
    mkdir -p ${BUILDROOT_PATH} 
 
    if [ ! -f $BUILDROOT_TAR ] ; then 
        msg_banner "download $BUILDROOT_VER now..."
        wget -c $BUILDROOT_DLADDR 
    fi 
 
    msg_banner "install $BUILDROOT_VER to $BUILDROOT_PATH/$BUILDROOT_NAME now..."
    tar -xJf ${BUILDROOT_TAR} -C ${BUILDROOT_PATH}  -C  ${BUILDROOT_PATH}
}
 
 
prepare_instpath
 
install_systools
 
# u-boot must use arm-linux-gcc 4.9
install_crosstool
 
# bootstrap and linux kernel use arm-linux-gcc 7.4.0 in buildroot
install_buildroot
 
exit;