Build Atmel ARM9 board Board Support Packets
guowenxue
2024-10-08 e632fdc9ff4880ae65706fcd8f5d950ff26c7c7e
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
diff -Nuar u-boot-at91/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c u-boot-at91-loragw/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
--- u-boot-at91/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c    2019-12-09 22:12:00.000000000 +0800
+++ u-boot-at91-loragw/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c    2024-05-22 11:40:07.019509486 +0800
@@ -164,6 +164,7 @@
 #if defined(CONFIG_USB_OHCI_NEW) || defined(CONFIG_USB_EHCI)
 void at91_uhp_hw_init(void)
 {
+#if 0 /* comment by guowenxue 2020.12.4, PD18 conflict with Relay control board on LoRaGW V2 */
     /* Enable VBus on UHP ports */
     at91_set_pio_output(AT91_PIO_PORTD, 18, 0); /* port A */
     at91_set_pio_output(AT91_PIO_PORTD, 19, 0); /* port B */
@@ -171,6 +172,7 @@
     /* port C is OHCI only */
     at91_set_pio_output(AT91_PIO_PORTD, 20, 0); /* port C */
 #endif
+#endif
 }
 #endif
 
diff -Nuar u-boot-at91/board/atmel/at91sam9x5ek/at91sam9x5ek.c u-boot-at91-loragw/board/atmel/at91sam9x5ek/at91sam9x5ek.c
--- u-boot-at91/board/atmel/at91sam9x5ek/at91sam9x5ek.c    2019-12-09 22:12:00.000000000 +0800
+++ u-boot-at91-loragw/board/atmel/at91sam9x5ek/at91sam9x5ek.c    2024-05-22 11:40:07.019509486 +0800
@@ -263,6 +263,9 @@
     /* adress of boot parameters */
     gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
 
+    /* PD18 is for relay and active on lowlevel, add by guowenxue 2020.12.4 */ 
+    at91_set_pio_output(AT91_PIO_PORTD, 18, 1); 
+
 #ifdef CONFIG_CMD_NAND
     at91sam9x5ek_nand_hw_init();
 #endif
diff -Nuar u-boot-at91/common/autoboot.c u-boot-at91-loragw/common/autoboot.c
--- u-boot-at91/common/autoboot.c    2019-12-09 22:12:00.000000000 +0800
+++ u-boot-at91-loragw/common/autoboot.c    2024-05-22 11:40:07.019509486 +0800
@@ -161,9 +161,11 @@
      */
     if (bootdelay >= 0) {
         if (tstc()) {    /* we got a key press    */
-            (void) getc();  /* consume input    */
-            puts("\b\b\b 0");
-            abort = 1;    /* don't auto boot    */
+            if(27==getc()) /*   Only get ECS key will skip autoboot, add by guowenxue 2019.12.10 */
+            {
+                puts("\b\b\b 0");
+                abort = 1;    /* don't auto boot    */
+            }
         }
     }
 #endif
@@ -174,14 +176,12 @@
         ts = get_timer(0);
         do {
             if (tstc()) {    /* we got a key press    */
-                abort  = 1;    /* don't auto boot    */
-                bootdelay = 0;    /* no more delay    */
-# ifdef CONFIG_MENUKEY
-                menukey = getc();
-# else
-                (void) getc();  /* consume input    */
-# endif
-                break;
+                if(27==getc()) /*    Only get ECS key will skip autoboot, add by guowenxue 2019.12.10 */
+                {
+                    abort  = 1;    /* don't auto boot    */
+                    bootdelay = 0;    /* no more delay    */
+                    break;
+                }
             }
             udelay(10000);
         } while (!abort && get_timer(ts) < 1000);
diff -Nuar u-boot-at91/common/board_r.c u-boot-at91-loragw/common/board_r.c
--- u-boot-at91/common/board_r.c    2019-12-09 22:12:00.000000000 +0800
+++ u-boot-at91-loragw/common/board_r.c    2024-05-22 11:40:07.019509486 +0800
@@ -427,6 +427,17 @@
     else
         set_default_env(NULL);
 
+    /*  add by guowenxue, 2019.12.10. For auto detect rootfs type for 4K/2K nandflash  */ 
+    if( !getenv("nand_pagesize") )
+    {
+        char    buf[64]={'\0'};
+        extern int g_nand_erasesize; /*  defined in drivers/mtd/nand/atmel_nand.c */
+
+        snprintf(buf, sizeof(buf), "p%dk", g_nand_erasesize);
+        setenv("nand_pagesize", buf); 
+        saveenv();
+    }
+
     /* Initialize from environment */
     load_addr = getenv_ulong("loadaddr", 16, load_addr);
 #if defined(CONFIG_SYS_EXTBDINFO)
diff -Nuar u-boot-at91/drivers/mtd/nand/atmel_nand.c u-boot-at91-loragw/drivers/mtd/nand/atmel_nand.c
--- u-boot-at91/drivers/mtd/nand/atmel_nand.c    2019-12-09 22:12:00.000000000 +0800
+++ u-boot-at91-loragw/drivers/mtd/nand/atmel_nand.c    2024-05-22 11:40:07.019509486 +0800
@@ -20,6 +20,8 @@
 #include <watchdog.h>
 #include <linux/mtd/nand_ecc.h>
 
+int g_nand_erasesize; /* add by guowenxue, 2019.12.10 */ 
+
 #ifdef CONFIG_ATMEL_NAND_HWECC
 
 /* Register access macros */
@@ -1519,6 +1521,7 @@
     if (!ret)
         nand_register(devnum);
 
+    g_nand_erasesize = mtd->writesize/1024; /* add by guowenxue, 2019.12.10 */
     return ret;
 }
 
diff -Nuar u-boot-at91/include/configs/at91sam9x5ek.h u-boot-at91-loragw/include/configs/at91sam9x5ek.h
--- u-boot-at91/include/configs/at91sam9x5ek.h    2019-12-09 22:12:00.000000000 +0800
+++ u-boot-at91-loragw/include/configs/at91sam9x5ek.h    2024-05-22 11:40:07.019509486 +0800
@@ -52,7 +52,7 @@
 #define CONFIG_ATMEL_LCD_RGB565
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
 
-#define CONFIG_BOOTDELAY    3
+#define CONFIG_BOOTDELAY    1
 
 /*
  * BOOTP options
@@ -98,7 +98,7 @@
 #ifdef CONFIG_CMD_SF
 #define CONFIG_ATMEL_SPI
 #define CONFIG_SPI_FLASH
-#define CONFIG_SPI_FLASH_ATMEL
+#define CONFIG_SPI_FLASH_WINBOND    /*  modify by guowenxue, 2019.12.09 */
 #define CONFIG_SF_DEFAULT_SPEED        30000000
 #endif
 
@@ -182,15 +182,13 @@
                 "0x22000000 0x200000 0x300000; " \
                 "bootm 0x22000000"
 #elif defined(CONFIG_SYS_USE_SPIFLASH)
-/* bootstrap + u-boot + env + linux in spi flash */
-#define CONFIG_ENV_IS_IN_SPI_FLASH
-#define CONFIG_ENV_OFFSET    0x5000
-#define CONFIG_ENV_SIZE        0x3000
-#define CONFIG_ENV_SECT_SIZE    0x1000
-#define CONFIG_ENV_SPI_MAX_HZ    30000000
-#define CONFIG_BOOTCOMMAND    "sf probe 0; " \
-                "sf read 0x22000000 0x100000 0x300000; " \
-                "bootm 0x22000000"
+
+/*  bootstrap + u-boot in SPI flash and env + linux in nandflash, modify by guowenxue */
+#define CONFIG_ENV_IS_IN_NAND
+#define CONFIG_ENV_OFFSET           0xC0000
+#define CONFIG_ENV_SIZE             0x20000
+#define CONFIG_BOOTCOMMAND          "nand read 0x22000000 0x100000 0x700000; bootm 0x22000000" 
+
 #elif defined(CONFIG_SYS_USE_DATAFLASH)
 /* bootstrap + u-boot + env + linux in data flash */
 #define CONFIG_ENV_IS_IN_SPI_FLASH
@@ -220,12 +218,35 @@
 #else
 #define CONFIG_BOOTARGS                            \
     "console=ttyS0,115200 earlyprintk "                \
-    "mtdparts=atmel_nand:256k(bootstrap)ro,512k(uboot)ro,"        \
-    "256k(env),256k(env_redundant),256k(spare),"            \
-    "512k(dtb),6M(kernel)ro,-(rootfs) "                \
-    "rootfstype=ubifs ubi.mtd=7 root=ubi0:rootfs rw"
+    "rootfstype=ubifs ubi.mtd=2 root=ubi0:rootfs rw"
 #endif
 
+/*  Add by guowenxue, 2019.12.9 */
+#define CONFIG_FIT              1
+#define CONFIG_ENV_OVERWRITE    1
+#define CONFIG_ETHADDR          42:96:ab:be:a7:5d
+#define CONFIG_IPADDR           192.168.2.196
+#define CONFIG_SERVERIP         192.168.2.2
+
+#define CONFIG_BOARDNAME        "LoRaGW"
+#define CONFIG_TFTPBOOT         "tftp 0x22000000 linuxrom-${boardname}.itb && bootm 0x22000000" 
+
+#define CONFIG_BBL              "sf probe && tftp 0x22000000 bootstrap-${boardname}.bin && " \
+                                "tftp 0x23000000 u-boot-${boardname}.bin && " \
+                                "sf erase 0 A0000 && sf write 0x22000000 0 3000 && sf write 0x23000000 8000 80000" 
+
+#define CONFIG_BKR              "tftp 0x22000000 linuxrom-${boardname}.itb && nand erase 0x100000 0x700000; " \
+                                "nand write 0x22000000 0x100000 ${filesize}" 
+
+#define CONFIG_BFS              "tftp 0x21000000 rootfs-${boardname}.ubi-${nand_pagesize} && nand erase 800000 6400000; " \
+                                "nand write 0x21000000 800000 ${filesize}"
+
+#define CONFIG_BSYS             "run bkr; run bfs" 
+#define CONFIG_CLRAPPS          "nand erase d000000 13000000" 
+#define CONFIG_CLRENV           "nand erase 0 100000" 
+#define CONFIG_DBGRUN           "run bfs; run tb"
+/* add end  */
+
 #define CONFIG_BAUDRATE        115200
 
 #define CONFIG_SYS_PROMPT    "U-Boot> "
diff -Nuar u-boot-at91/include/env_default.h u-boot-at91-loragw/include/env_default.h
--- u-boot-at91/include/env_default.h    2019-12-09 22:12:00.000000000 +0800
+++ u-boot-at91-loragw/include/env_default.h    2024-05-22 11:40:07.019509486 +0800
@@ -76,6 +76,35 @@
 #ifdef    CONFIG_SERVERIP
     "serverip="    __stringify(CONFIG_SERVERIP)    "\0"
 #endif
+/*  add by guowenxue, 2019.08.22  */
+#ifdef  CONFIG_BOARDNAME 
+    "boardname="    CONFIG_BOARDNAME    "\0"
+#endif
+#ifdef CONFIG_TFTPBOOT 
+    "tb="   CONFIG_TFTPBOOT "\0"
+#endif
+#ifdef  CONFIG_BBL 
+    "bbl="  CONFIG_BBL  "\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_CLRENV 
+    "clrenv="  CONFIG_CLRENV  "\0"
+#endif
+#ifdef CONFIG_DBGRUN 
+    "dbg="  CONFIG_DBGRUN   "\0"
+#endif
+/* add end */
 #ifdef    CONFIG_SYS_AUTOLOAD
     "autoload="    CONFIG_SYS_AUTOLOAD        "\0"
 #endif