Initial support for Dragino2, not working - need to rebuild memory initialization
authorPiotr Dymacz <pepe2k@gmail.com>
Sun, 2 Feb 2014 18:51:57 +0000 (19:51 +0100)
committerPiotr Dymacz <pepe2k@gmail.com>
Sun, 2 Feb 2014 18:51:57 +0000 (19:51 +0100)
Makefile
u-boot/Makefile
u-boot/board/ar7240/ap121/ap121.c
u-boot/common/cmd_bootm.c
u-boot/common/cmd_custom.c
u-boot/include/common.h
u-boot/include/configs/ap121.h

index baca25dae16ab581ac4dd260a7a869eb9c400567..002971e91bad020fa817369db7821e752d3edbae 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -163,6 +163,14 @@ gs-oolite_v1_dev:
        @cp $(BUILD_TOPDIR)/u-boot/u-boot.bin $(BUILD_TOPDIR)/bin/temp.bin
        @make show_size
 
+dragino_v2_ms14:       export UBOOT_FILE_NAME=uboot_for_dragino_v2_ms14
+dragino_v2_ms14:       export MAX_UBOOT_SIZE=192
+dragino_v2_ms14:
+       @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) dragino_v2_ms14_config
+       @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all
+       @cp $(BUILD_TOPDIR)/u-boot/u-boot.bin $(BUILD_TOPDIR)/bin/temp.bin
+       @make show_size
+
 show_size:
        @echo -e "\n======= Preparing $(MAX_UBOOT_SIZE)KB file filled with 0xFF... ======="
        @`tr "\000" "\377" < /dev/zero | dd ibs=1k count=$(MAX_UBOOT_SIZE) of=$(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME).bin`
index f0d601e3bb9b0402a27c887be43281d98df039d2..87b66ca97665205a49cbae5e3948dda1625d4278 100755 (executable)
@@ -487,6 +487,25 @@ carambola2_config : unconfig hornet_common_config
        
        @./mkconfig -a ap121 mips mips ap121 ar7240 ar7240
 
+dragino_v2_ms14_config : unconfig hornet_common_config
+       @echo '======= Configuring for Dragino Dragino v2 (MS14) at:' `date` '======='
+       @echo "#define CONFIG_FOR_DRAGINO_V2                1" >> include/config.h
+       @echo "#undef  COMPRESSED_UBOOT"                       >> include/config.h
+       @echo "#define GPIO_WLAN_LED_BIT                    0" >> include/config.h
+       @echo "#define GPIO_WLAN_LED_ON                     1" >> include/config.h
+       @echo "#define GPIO_WAN_LED_BIT                    17" >> include/config.h
+       @echo "#define GPIO_WAN_LED_ON                      0" >> include/config.h
+       @echo "#define GPIO_LAN_LED_BIT                    13" >> include/config.h
+       @echo "#define GPIO_LAN_LED_ON                      0" >> include/config.h
+       @echo "#define GPIO_INTERNET_LED_BIT               28" >> include/config.h
+       @echo "#define GPIO_INTERNET_LED_ON                 1" >> include/config.h
+       @echo "#define GPIO_RST_BUTTON_BIT                 11" >> include/config.h
+       @echo "#define GPIO_RST_BUTTON_IS_ACTIVE_LOW        1" >> include/config.h
+       @echo "#define DEFAULT_FLASH_SIZE_IN_MB            16" >> include/config.h
+       @echo "#define BOARD_CUSTOM_STRING                  \"AP121 (AR9331) U-Boot for Dragino v2 MS14\"" >> include/config.h
+       
+       @./mkconfig -a ap121 mips mips ap121 ar7240 ar7240
+
 wasp_common_config : common_config
        @echo "#define CONFIG_AR7240                        1" >> include/config.h
        @echo "#define CONFIG_WASP                          1" >> include/config.h
index 4aa13defbd8fc48bef58509a8a70e90c2b0fa8ca..79882b2e4703e5721b91d959b1228efa0d474e1f 100755 (executable)
@@ -35,6 +35,8 @@ void led_toggle(void){
        gpio ^= 1 << GPIO_SYS_LED_BIT;
 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
        gpio ^= 1 << GPIO_WLAN_LED_BIT;
+#elif defined(CONFIG_FOR_DRAGINO_V2)
+       gpio ^= 1 << GPIO_WLAN_LED_BIT;
 #else
        #error "Custom GPIO in leg_toggle() not defined!"
 #endif
@@ -82,6 +84,11 @@ void all_led_on(void){
        SETBITVAL(gpio, GPIO_LAN2_LED_BIT, GPIO_LAN2_LED_ON);
 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
        SETBITVAL(gpio, GPIO_WLAN_LED_BIT, GPIO_WLAN_LED_ON);
+#elif defined(CONFIG_FOR_DRAGINO_V2)
+       SETBITVAL(gpio, GPIO_WLAN_LED_BIT,     GPIO_WLAN_LED_ON);
+       SETBITVAL(gpio, GPIO_WAN_LED_BIT,      GPIO_WAN_LED_ON);
+       SETBITVAL(gpio, GPIO_LAN_LED_BIT,      GPIO_LAN_LED_ON);
+       SETBITVAL(gpio, GPIO_INTERNET_LED_BIT, GPIO_INTERNET_LED_ON);
 #else
        #error "Custom GPIO in all_led_on() not defined!"
 #endif
@@ -129,6 +136,11 @@ void all_led_off(void){
        SETBITVAL(gpio, GPIO_LAN2_LED_BIT, !GPIO_LAN2_LED_ON);
 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
        SETBITVAL(gpio, GPIO_WLAN_LED_BIT, !GPIO_WLAN_LED_ON);
+#elif defined(CONFIG_FOR_DRAGINO_V2)
+       SETBITVAL(gpio, GPIO_WLAN_LED_BIT,     !GPIO_WLAN_LED_ON);
+       SETBITVAL(gpio, GPIO_WAN_LED_BIT,      !GPIO_WAN_LED_ON);
+       SETBITVAL(gpio, GPIO_LAN_LED_BIT,      !GPIO_LAN_LED_ON);
+       SETBITVAL(gpio, GPIO_INTERNET_LED_BIT, !GPIO_INTERNET_LED_ON);
 #else
        #error "Custom GPIO in all_led_off() not defined!"
 #endif
@@ -293,6 +305,20 @@ void gpio_config(void){
        //ar7240_reg_wr (AR7240_GPIO_FUNC, (ar7240_reg_rd(AR7240_GPIO_FUNC) & 0xffe7e07f));
 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
        // TODO: check GPIO config for C2
+#elif defined(CONFIG_FOR_DRAGINO_V2)
+
+       /* LED's GPIOs on MR3220v2:
+        *
+        * 0    => WLAN
+        * 13   => LAN
+        * 17   => WAN
+        * 28   => INTERNET
+        *
+        */
+
+       /* set GPIO_OE */
+       ar7240_reg_wr(AR7240_GPIO_OE, (ar7240_reg_rd(AR7240_GPIO_OE) | 0x10022001));
+
 #elif defined(CONFIG_FOR_DLINK_DIR505_A1)
 
        /* LED's GPIOs on DIR-505:
index ef2fb72b3d49b8935282e556977a83a0affda82b..53634f29cc22786b557fdc3cfd55bd310e68966f 100755 (executable)
@@ -68,7 +68,8 @@ image_header_t header;
 ulong load_addr = CFG_LOAD_ADDR; /* default load address */
 
 #if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && \
-       !defined(CONFIG_FOR_DLINK_DIR505_A1)
+       !defined(CONFIG_FOR_DLINK_DIR505_A1)     && \
+       !defined(CONFIG_FOR_DRAGINO_V2)
 void fake_image_header(image_header_t *hdr, tplink_image_header_t *tpl_hdr){
        memset(hdr, 0, sizeof(image_header_t));
 
@@ -87,7 +88,7 @@ void fake_image_header(image_header_t *hdr, tplink_image_header_t *tpl_hdr){
 
        strncpy((char *)hdr->ih_name, (char *)tpl_hdr->signiture_1, IH_NMLEN);
 }
-#endif /* if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && !defined(CONFIG_FOR_DLINK_DIR505_A1) */
+#endif /* if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && !defined(CONFIG_FOR_DLINK_DIR505_A1) && !defined(CONFIG_FOR_DRAGINO_V2) */
 
 int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){
        ulong addr, data, len;
@@ -95,7 +96,8 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){
        int i;
        image_header_t *hdr = &header;
 #if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && \
-       !defined(CONFIG_FOR_DLINK_DIR505_A1)
+       !defined(CONFIG_FOR_DLINK_DIR505_A1)     && \
+       !defined(CONFIG_FOR_DRAGINO_V2)
        tplink_image_header_t *fileTag;
 #endif
 
@@ -108,7 +110,8 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){
        printf("Booting image at: 0x%08lX\n", addr);
 
 #if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \
-       defined(CONFIG_FOR_DLINK_DIR505_A1)
+       defined(CONFIG_FOR_DLINK_DIR505_A1)     || \
+       defined(CONFIG_FOR_DRAGINO_V2)
        memmove(&header, (char *)addr, sizeof(image_header_t));
        print_image_hdr(hdr);
 
@@ -214,7 +217,8 @@ static void fixup_silent_linux(){
 #endif /* CONFIG_SILENT_CONSOLE */
 
 #if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \
-       defined(CONFIG_FOR_DLINK_DIR505_A1)
+       defined(CONFIG_FOR_DLINK_DIR505_A1)     || \
+       defined(CONFIG_FOR_DRAGINO_V2)
 static void print_type(image_header_t *hdr){
        char *os, *arch, *type, *comp;
 
@@ -391,7 +395,7 @@ void print_image_hdr(tplink_image_header_t *hdr){
        print_size(ntohl(hdr->kernelLen), "\n");
        printf("   Load address: 0x%08X\n   Entry point:  0x%08X\n\n", ntohl(hdr->kernelTextAddr), ntohl(hdr->kernelEntryPoint));
 }
-#endif /* defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || defined(CONFIG_FOR_DLINK_DIR505_A1) */
+#endif /* defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || defined(CONFIG_FOR_DLINK_DIR505_A1) || defined(CONFIG_FOR_DRAGINO_V2) */
 
 #if (CONFIG_COMMANDS & CFG_CMD_IMI)
 int do_iminfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){
index e778d3efa74fdcc57565c91dda2bc699e2f02195..b1163aa4c65186fbea2c755ce8618756509b9104 100755 (executable)
@@ -197,7 +197,8 @@ U_BOOT_CMD(startsc, 1, 0, do_start_sc, "start serial console\n", NULL);
 
 #endif /* if defined(CONFIG_NETCONSOLE) */
 
-#if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
+#if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \
+    defined(CONFIG_FOR_DRAGINO_V2)
 /*
  * Erase environment sector
  */
@@ -215,7 +216,7 @@ int do_erase_env(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]){
 }
 
 U_BOOT_CMD(eraseenv, 1, 1, do_erase_env, "erase environment sector in flash\n", NULL);
-#endif /* if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) */
+#endif /* if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || defined(CONFIG_FOR_DRAGINO_V2) */
 
 #if defined(PLL_IN_FLASH_MAGIC_OFFSET)
 
index 41aa508aa978fba0608737819e8aa1ef8dda9f02..7f3e9ea9e9b03426e0097bd6054a699d9c9fe64c 100755 (executable)
@@ -195,13 +195,15 @@ int       autoscript (ulong addr);
  * use different (simply) image header
  */
 #if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && \
-       !defined(CONFIG_FOR_DLINK_DIR505_A1)
+       !defined(CONFIG_FOR_DLINK_DIR505_A1)     && \
+       !defined(CONFIG_FOR_DRAGINO_V2)
 #include "tpLinuxTag.h"
 #endif
 
 /* common/cmd_bootm.c */
 #if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \
-       defined(CONFIG_FOR_DLINK_DIR505_A1)
+       defined(CONFIG_FOR_DLINK_DIR505_A1)     || \
+       defined(CONFIG_FOR_DRAGINO_V2)
 void print_image_hdr(image_header_t *hdr);
 #else
 void print_image_hdr(tplink_image_header_t *hdr);
index 9f09014eb9f5e5bf956981cf4db4fb098efa4575..6aa30a29a4d593ddab6fb0c6e6e6bf44d5bc2b68 100755 (executable)
 
        #define CONFIG_BOOTARGS "console=ttyS0,115200 root=31:02 rootfstype=squashfs init=/sbin/init mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),16000k(firmware),64k(ART)"
 
+#elif defined(CONFIG_FOR_DRAGINO_V2)
+
+       #define CONFIG_BOOTARGS "console=ttyS0,115200 root=31:02 rootfstype=squashfs init=/sbin/init mtdparts=ar7240-nor0:192k(u-boot),64k(u-boot-env),16064k(firmware),64k(ART)"
+
 #endif
 
 /*
@@ -76,6 +80,8 @@
        #define CFG_LOAD_ADDR           0x9F080000
 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
        #define CFG_LOAD_ADDR           0x9F050000
+#elif defined(CONFIG_FOR_DRAGINO_V2)
+       #define CFG_LOAD_ADDR           0x9F040000
 #else
        #define CFG_LOAD_ADDR           0x9F020000
 #endif
@@ -84,6 +90,8 @@
        #define CONFIG_BOOTCOMMAND "bootm 0x9F080000"
 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
        #define CONFIG_BOOTCOMMAND "bootm 0x9F050000"
+#elif defined(CONFIG_FOR_DRAGINO_V2)
+       #define CONFIG_BOOTCOMMAND "bootm 0x9F040000"
 #else
        #define CONFIG_BOOTCOMMAND "bootm 0x9F020000"
 #endif
 #define CONFIG_IPADDR          192.168.1.1
 #define CONFIG_SERVERIP                192.168.1.2
 
+/*
+ * Dragino 2 uses different prompt
+ */
+#if defined(CONFIG_FOR_DRAGINO_V2)
+       #if defined(CFG_PROMPT)
+               #undef CFG_PROMPT
+       #endif
+       #define CFG_PROMPT "dr_boot> "
+#endif
+
 #undef CFG_HZ
 #define        CFG_HZ                          bd->bi_cfg_hz
 #undef CPU_PLL_CONFIG_VAL
 /*
  * Address and size of Primary Environment Sector
  */
-#if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
+#if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \
+       defined(CONFIG_FOR_DRAGINO_V2)
        #define CFG_ENV_IS_IN_FLASH     1
        #undef CFG_ENV_IS_NOWHERE
 #else
        #define CFG_ENV_IS_NOWHERE      1
 #endif
 
-#define CFG_ENV_ADDR                   0x9F040000
+#if defined(CONFIG_FOR_DRAGINO_V2)
+       #define CFG_ENV_ADDR            0x9F030000
+#else
+       #define CFG_ENV_ADDR            0x9F040000
+#endif
 #define CFG_ENV_SIZE                   0x10000
 
 /*
  */
 #if defined(CONFIG_FOR_DLINK_DIR505_A1)
        #define CONFIG_COMMANDS (CFG_CMD_MEMORY | CFG_CMD_DHCP | CFG_CMD_PING | CFG_CMD_FLASH | CFG_CMD_NET | CFG_CMD_RUN | CFG_CMD_DATE | CFG_CMD_IMI | CFG_CMD_SNTP )
-#elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
+#elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \
+      defined(CONFIG_FOR_DRAGINO_V2)
        #define CONFIG_COMMANDS (CFG_CMD_MEMORY | CFG_CMD_DHCP | CFG_CMD_PING | CFG_CMD_ENV | CFG_CMD_FLASH | CFG_CMD_NET | CFG_CMD_RUN | CFG_CMD_DATE | CFG_CMD_IMI | CFG_CMD_SNTP)
 #else
        #define CONFIG_COMMANDS (CFG_CMD_MEMORY | CFG_CMD_DHCP | CFG_CMD_PING | CFG_CMD_FLASH | CFG_CMD_NET | CFG_CMD_RUN | CFG_CMD_DATE | CFG_CMD_SNTP )
        #define WEBFAILSAFE_UPLOAD_UBOOT_SIZE_IN_BYTES          (64 * 1024)
 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
        #define WEBFAILSAFE_UPLOAD_UBOOT_SIZE_IN_BYTES          (256 * 1024)
+#elif defined(CONFIG_FOR_DRAGINO_V2)
+       #define WEBFAILSAFE_UPLOAD_UBOOT_SIZE_IN_BYTES          (192 * 1024)
 #else
        #define WEBFAILSAFE_UPLOAD_UBOOT_SIZE_IN_BYTES          (64 * 1024)
 #endif
        #define WEBFAILSAFE_UPLOAD_KERNEL_ADDRESS                       WEBFAILSAFE_UPLOAD_UBOOT_ADDRESS + 0x80000
 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
        #define WEBFAILSAFE_UPLOAD_KERNEL_ADDRESS                       WEBFAILSAFE_UPLOAD_UBOOT_ADDRESS + 0x50000
+#elif defined(CONFIG_FOR_DRAGINO_V2)
+       #define WEBFAILSAFE_UPLOAD_KERNEL_ADDRESS                       WEBFAILSAFE_UPLOAD_UBOOT_ADDRESS + 0x40000
 #else
        #define WEBFAILSAFE_UPLOAD_KERNEL_ADDRESS                       WEBFAILSAFE_UPLOAD_UBOOT_ADDRESS + 0x20000
 #endif
 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
        // Carambola 2: 256k(U-Boot),64k(U-Boot env),64k(ART)
        #define WEBFAILSAFE_UPLOAD_LIMITED_AREA_IN_BYTES        (384 * 1024)
+#elif defined(CONFIG_FOR_DRAGINO_V2)
+       // Dragino 2: 192k(U-Boot),64k(U-Boot env),64k(ART)
+       #define WEBFAILSAFE_UPLOAD_LIMITED_AREA_IN_BYTES        (320 * 1024)
 #elif defined (CONFIG_FOR_GS_OOLITE_V1_DEV)
        // GS-Oolite v1: 128k(U-Boot + MAC),64k(ART)
        #define WEBFAILSAFE_UPLOAD_LIMITED_AREA_IN_BYTES        (192 * 1024)
        //#define OFFSET_MAC_DATA_BLOCK_LENGTH  0x010000
        //#define OFFSET_MAC_ADDRESS                            0x000004
        //#define OFFSET_MAC_ADDRESS2                           0x000016
-#elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2)
+#elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \
+      defined(CONFIG_FOR_DRAGINO_V2)
+       // Carambola 2 and Dragino 2 have two MAC addresses at the beginning of ART partition
        #define OFFSET_MAC_DATA_BLOCK                   0xFF0000
        #define OFFSET_MAC_DATA_BLOCK_LENGTH    0x010000
-       #define OFFSET_MAC_ADDRESS                              0x000000        // Carambola 2 has two MAC addresses at the beginning of ART partition
+       #define OFFSET_MAC_ADDRESS                              0x000000
        #define OFFSET_MAC_ADDRESS2                             0x000006
 #elif defined (CONFIG_FOR_GS_OOLITE_V1_DEV)
        // GS-OOlite has only one MAC, inside second block
 
 #if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && \
        !defined(CONFIG_FOR_DLINK_DIR505_A1)     && \
-       !defined (CONFIG_FOR_GS_OOLITE_V1_DEV)
+       !defined (CONFIG_FOR_GS_OOLITE_V1_DEV)   && \
+       !defined(CONFIG_FOR_DRAGINO_V2)
 #define OFFSET_ROUTER_MODEL                                    0x00FD00
 #endif