From: Piotr Dymacz Date: Sun, 2 Feb 2014 18:51:57 +0000 (+0100) Subject: Initial support for Dragino2, not working - need to rebuild memory initialization X-Git-Tag: 2014-11-19~32^2~12 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=29b8a3d48caa6549f13e768b2ace73c89563e0dd;p=oweals%2Fu-boot_mod.git Initial support for Dragino2, not working - need to rebuild memory initialization --- diff --git a/Makefile b/Makefile index baca25d..002971e 100755 --- 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` diff --git a/u-boot/Makefile b/u-boot/Makefile index f0d601e..87b66ca 100755 --- a/u-boot/Makefile +++ b/u-boot/Makefile @@ -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 diff --git a/u-boot/board/ar7240/ap121/ap121.c b/u-boot/board/ar7240/ap121/ap121.c index 4aa13de..79882b2 100755 --- a/u-boot/board/ar7240/ap121/ap121.c +++ b/u-boot/board/ar7240/ap121/ap121.c @@ -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: diff --git a/u-boot/common/cmd_bootm.c b/u-boot/common/cmd_bootm.c index ef2fb72..53634f2 100755 --- a/u-boot/common/cmd_bootm.c +++ b/u-boot/common/cmd_bootm.c @@ -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[]){ diff --git a/u-boot/common/cmd_custom.c b/u-boot/common/cmd_custom.c index e778d3e..b1163aa 100755 --- a/u-boot/common/cmd_custom.c +++ b/u-boot/common/cmd_custom.c @@ -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) diff --git a/u-boot/include/common.h b/u-boot/include/common.h index 41aa508..7f3e9ea 100755 --- a/u-boot/include/common.h +++ b/u-boot/include/common.h @@ -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); diff --git a/u-boot/include/configs/ap121.h b/u-boot/include/configs/ap121.h index 9f09014..6aa30a2 100755 --- a/u-boot/include/configs/ap121.h +++ b/u-boot/include/configs/ap121.h @@ -61,6 +61,10 @@ #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 @@ -91,6 +99,16 @@ #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 @@ -726,7 +744,8 @@ /* * 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 @@ -734,7 +753,11 @@ #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 /* @@ -742,7 +765,8 @@ */ #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 ) @@ -798,6 +822,8 @@ #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 @@ -807,6 +833,8 @@ #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 @@ -825,6 +853,9 @@ #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) @@ -863,10 +894,12 @@ //#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 @@ -882,7 +915,8 @@ #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