SAMA5D4 Xplained Ultra Board BSP
guowenxue
2019-08-22 b5a0e1f270688ad03f0d20199d194c948b097bd2
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
diff -Nuar u-boot-at91/build.sh u-boot-at91-sama5d4/build.sh
--- u-boot-at91/build.sh    1970-01-01 08:00:00.000000000 +0800
+++ u-boot-at91-sama5d4/build.sh    2019-08-22 18:55:28.199236657 +0800
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+BOARD=sama5d4
+TFTP_PATH=/tftp
+IMGS_PATH=../images
+IMG_NAME=u-boot-${BOARD}.bin
+
+CROSSTOOL=/opt/buildroot/cortex-a5/bin/arm-linux-
+JOBS=`cat /proc/cpuinfo |grep "processor"|wc -l`
+
+
+function do_clean()
+{
+    make CROSS_COMPILE=${CROSSTOOL} distclean
+    rm -f cscope* tags
+    rm -f ${IMG_NAME}
+}
+
+function do_modify()
+{
+    grep "arm-linux-gnueabi" Makefile > /dev/null
+
+    if [ $? == 0  ] ; then
+        return ;
+    fi
+
+    echo "Modify Makefile for  ARCH and cross compiler"
+    sed -i -e "s|^CROSS_COMPILE=.*|CROSS_COMPILE=${CROSSTOOL}|g" Makefile
+}
+
+function do_build()
+{
+    make ${BOARD}_xplained_nandflash_config
+
+    make -j${JOBS}
+
+    cp u-boot.bin ${IMG_NAME}
+
+    chmod a+x ${IMG_NAME}
+}
+
+function do_install()
+{
+    if [ -d $TFTP_PATH ] ;then 
+        cp ${IMG_NAME} $TFTP_PATH
+    fi
+
+    if [ -d ${IMGS_PATH} ] ; then
+        cp ${IMG_NAME} $IMGS_PATH
+    fi
+}
+
+if [ "$1" == "clean" ] ; then 
+
+    do_clean
+    exit 0;
+fi
+
+do_modify
+
+set -e
+
+do_build
+
+do_install
+
+
diff -Nuar u-boot-at91/include/configs/sama5d4_xplained.h u-boot-at91-sama5d4/include/configs/sama5d4_xplained.h
--- u-boot-at91/include/configs/sama5d4_xplained.h    2019-08-04 21:52:13.000000000 +0800
+++ u-boot-at91-sama5d4/include/configs/sama5d4_xplained.h    2019-08-22 16:37:32.807077915 +0800
@@ -38,7 +38,7 @@
 #define CONFIG_USART_BASE        ATMEL_BASE_USART3
 #define    CONFIG_USART_ID            ATMEL_ID_USART3
 
-#define CONFIG_BOOTDELAY        3
+#define CONFIG_BOOTDELAY        1
 
 /*
  * BOOTP options
@@ -173,9 +173,9 @@
 #define CONFIG_ENV_OFFSET        0xc0000
 #define CONFIG_ENV_OFFSET_REDUND    0x100000
 #define CONFIG_ENV_SIZE            0x20000
-#define CONFIG_BOOTCOMMAND    "nand read 0x21000000 0x180000 0x80000;" \
+#define CONFIG_BOOTCOMMAND    "nand read 0x21000000 0x180000 0x40000;" \
                 "nand read 0x22000000 0x200000 0x600000;" \
-                "bootz 0x22000000 - 0x21000000"
+                "bootm 0x22000000 - 0x21000000"
 #elif CONFIG_SYS_USE_MMC
 /* bootstrap + u-boot + env in sd card */
 #define CONFIG_ENV_IS_IN_FAT
@@ -194,6 +194,37 @@
                 "bootz 0x22000000 - 0x21000000"
 #endif
 
+/* add by guowenxue, 2019.08.22 */
+#define CONFIG_ENV_OVERWRITE    1
+#define CONFIG_ETHADDR          42:96:ab:be:a7:5e
+#define CONFIG_IPADDR           192.168.2.199
+#define CONFIG_SERVERIP         192.168.2.2
+
+
+#define CONFIG_TFTPBOOT         "tftp 0x22000000 linuxrom-sama5d4.bin && tftp 0x21000000 linuxrom-sama5d4.dtb; " \
+                                "bootm 0x22000000 - 0x21000000"
+
+#define CONFIG_BBL              "tftp 0x21000000 u-boot-sama5d4.bin && nand erase 0x40000 0x140000;" \
+                                "nand write 0x21000000 0x40000 ${filesize}"
+     
+#define CONFIG_BDTB             "tftp 0x21000000 linuxrom-sama5d4.dtb && nand erase 0x180000 0x80000; " \
+                                "nand write 0x21000000 0x180000 ${filesize}"
+
+#define CONFIG_BKR              "tftp 0x22000000 linuxrom-sama5d4.bin && nand erase 0x200000 0x600000; " \
+                                "nand write 0x22000000 0x200000 ${filesize}"
+
+#define CONFIG_BFS              "tftp 0x21000000 rootfs-sama5d4.ubi && nand erase 800000 c800000; " \
+                                "nand write 0x21000000 800000 ${filesize}"
+
+#define CONFIG_BSYS             "run bbl; run bdtb; run bkr; run bfs"
+
+#define CONFIG_CLRAPPS          "nand erase d000000 13000000"
+
+#define CONFIG_DBGRUN           "run bfs; run tb"
+
+
+
+
 #ifdef CONFIG_SYS_USE_MMC
 #define CONFIG_BOOTARGS                            \
     "console=ttyS0,115200 earlyprintk "                \
@@ -203,8 +234,8 @@
     "console=ttyS0,115200 earlyprintk "                \
     "mtdparts=atmel_nand:256k(bootstrap)ro,512k(uboot)ro,"        \
     "256K(env),256k(evn_redundent),256k(spare),"            \
-    "512k(dtb),6M(kernel)ro,-(rootfs) "                \
-    "rootfstype=ubifs ubi.mtd=7 root=ubi0:rootfs"
+    "512k(dtb),6M(kernel)ro,200M(rootfs),-(apps) "                \
+    "rootfstype=ubifs ubi.mtd=7 root=ubi0:rootfs rw"
 #endif
 
 #define CONFIG_BAUDRATE            115200
diff -Nuar u-boot-at91/include/env_default.h u-boot-at91-sama5d4/include/env_default.h
--- u-boot-at91/include/env_default.h    2019-08-04 21:52:13.000000000 +0800
+++ u-boot-at91-sama5d4/include/env_default.h    2019-08-22 16:33:49.407073630 +0800
@@ -76,6 +76,33 @@
 #ifdef    CONFIG_SERVERIP
     "serverip="    __stringify(CONFIG_SERVERIP)    "\0"
 #endif
+
+/* add by guowenxue, 2019.08.22  */
+#ifdef    CONFIG_TFTPBOOT
+    "tb="    CONFIG_TFTPBOOT    "\0"
+#endif
+#ifdef  CONFIG_BBL
+    "bbl="    CONFIG_BBL    "\0"
+#endif
+#ifdef  CONFIG_BDTB
+    "bdtb="    CONFIG_BDTB    "\0"
+#endif
+#ifdef CONFIG_BKR
+    "bkr="    CONFIG_BKR    "\0"
+#endif 
+#ifdef    CONFIG_BFS
+    "bfs="    CONFIG_BFS    "\0"
+#endif
+#ifdef CONFIG_BSYS
+    "bsys="    CONFIG_BSYS    "\0"
+#endif
+#ifdef    CONFIG_CLRAPPS
+    "clrapps="    CONFIG_CLRAPPS    "\0"
+#endif
+#ifdef    CONFIG_DBGRUN
+    "dbg="    CONFIG_DBGRUN    "\0"
+#endif
+
 #ifdef    CONFIG_SYS_AUTOLOAD
     "autoload="    CONFIG_SYS_AUTOLOAD        "\0"
 #endif
diff -Nuar u-boot-at91/Makefile u-boot-at91-sama5d4/Makefile
--- u-boot-at91/Makefile    2019-08-04 21:52:12.000000000 +0800
+++ u-boot-at91-sama5d4/Makefile    2019-08-22 11:46:09.222742538 +0800
@@ -194,6 +194,9 @@
 
 #########################################################################
 
+ARCH=arm
+CROSS_COMPILE=/opt/crosstool/cortex-a7/bin/arm-linux-gnueabi-
+
 # set default to nothing for native builds
 ifeq ($(HOSTARCH),$(ARCH))
 CROSS_COMPILE ?=