From 76ac9cff60740aecd3f0dc59e8631b266a23ac1b Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Mon, 8 Sep 2014 03:34:28 +0200 Subject: [PATCH] Support for Village Telco Mesh Potato 2 (which is based on Dragino 2 hardware) --- Makefile | 8 +++++++ u-boot/Makefile | 21 ++++++++++++++++++ u-boot/board/ar7240/ap121/ap121.c | 8 +++---- u-boot/common/cmd_bootm.c | 16 ++++++++----- u-boot/common/cmd_custom.c | 5 +++-- u-boot/include/common.h | 6 +++-- u-boot/include/configs/ap121.h | 37 +++++++++++++++++++++---------- u-boot/lib_mips/mips_linux.c | 2 +- 8 files changed, 76 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index d2b33d6..4245a0a 100755 --- a/Makefile +++ b/Makefile @@ -192,6 +192,14 @@ dragino_v2_ms14: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all @make --no-print-directory show_size +villagetelco_mp2: export UBOOT_FILE_NAME=uboot_for_villagetelco_mp2 +villagetelco_mp2: export MAX_UBOOT_SIZE=192 +villagetelco_mp2: export DEVICE_VENDOR=villagetelco +villagetelco_mp2: + @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) villagetelco_mp2_config + @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all + @make --no-print-directory show_size + gl-inet: export UBOOT_FILE_NAME=uboot_for_gl-inet gl-inet: export MAX_UBOOT_SIZE=64 ifndef CONFIG_SKIP_LOWLEVEL_INIT diff --git a/u-boot/Makefile b/u-boot/Makefile index 89b280a..302f3e0 100755 --- a/u-boot/Makefile +++ b/u-boot/Makefile @@ -531,6 +531,27 @@ dragino_v2_ms14_config : unconfig hornet_common_config @./mkconfig -a ap121 mips mips ap121 ar7240 ar7240 +villagetelco_mp2_config : unconfig hornet_common_config + @/bin/echo -e '\e[32m> Configuring for Village Telco Mesh Potato 2 at:' `date` '\e[0m' + @echo "#define CONFIG_FOR_MESH_POTATO_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 WEBFAILSAFE_DISABLE_ART_UPGRADE 1" >> include/config.h + @echo "#define WEBFAILSAFE_DISABLE_UBOOT_UPGRADE 1" >> include/config.h + @echo "#define BOARD_CUSTOM_STRING \"AP121 (AR9331) U-Boot for Village Telco Mesh Potato 2\"" >> include/config.h + + @./mkconfig -a ap121 mips mips ap121 ar7240 ar7240 + gl-inet_config : unconfig hornet_common_config @/bin/echo -e '\e[32m> Configuring for GL.iNet at:' `date` '\e[0m' @echo "#define CONFIG_FOR_GL_INET 1" >> include/config.h diff --git a/u-boot/board/ar7240/ap121/ap121.c b/u-boot/board/ar7240/ap121/ap121.c index acd43f7..cdaec80 100755 --- a/u-boot/board/ar7240/ap121/ap121.c +++ b/u-boot/board/ar7240/ap121/ap121.c @@ -36,7 +36,7 @@ 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) +#elif defined(CONFIG_FOR_DRAGINO_V2) || defined(CONFIG_FOR_MESH_POTATO_V2) gpio ^= 1 << GPIO_WLAN_LED_BIT; #elif defined(CONFIG_FOR_GL_INET) gpio ^= 1 << GPIO_WLAN_LED_BIT; @@ -87,7 +87,7 @@ 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) +#elif defined(CONFIG_FOR_DRAGINO_V2) || defined(CONFIG_FOR_MESH_POTATO_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); @@ -142,7 +142,7 @@ 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) +#elif defined(CONFIG_FOR_DRAGINO_V2) || defined(CONFIG_FOR_MESH_POTATO_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); @@ -316,7 +316,7 @@ 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) +#elif defined(CONFIG_FOR_DRAGINO_V2) || defined(CONFIG_FOR_MESH_POTATO_V2) /* LED's GPIOs on MR3220v2: * diff --git a/u-boot/common/cmd_bootm.c b/u-boot/common/cmd_bootm.c index c71d293..510953b 100755 --- a/u-boot/common/cmd_bootm.c +++ b/u-boot/common/cmd_bootm.c @@ -73,7 +73,8 @@ ulong load_addr = CFG_LOAD_ADDR; /* default load address */ #if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && \ !defined(CONFIG_FOR_DLINK_DIR505_A1) && \ - !defined(CONFIG_FOR_DRAGINO_V2) + !defined(CONFIG_FOR_DRAGINO_V2) && \ + !defined(CONFIG_FOR_MESH_POTATO_V2) void fake_image_header(image_header_t *hdr, tplink_image_header_t *tpl_hdr){ memset(hdr, 0, sizeof(image_header_t)); @@ -92,7 +93,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) && !defined(CONFIG_FOR_DRAGINO_V2) */ +#endif /* if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && !defined(CONFIG_FOR_DLINK_DIR505_A1) && !defined(CONFIG_FOR_DRAGINO_V2) && !defined(CONFIG_FOR_MESH_POTATO_V2) */ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ ulong addr, data, len; @@ -101,7 +102,8 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ image_header_t *hdr = &header; #if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && \ !defined(CONFIG_FOR_DLINK_DIR505_A1) && \ - !defined(CONFIG_FOR_DRAGINO_V2) + !defined(CONFIG_FOR_DRAGINO_V2) && \ + !defined(CONFIG_FOR_MESH_POTATO_V2) tplink_image_header_t *fileTag; #endif @@ -115,7 +117,8 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ #if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \ defined(CONFIG_FOR_DLINK_DIR505_A1) || \ - defined(CONFIG_FOR_DRAGINO_V2) + defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_V2) memmove(&header, (char *)addr, sizeof(image_header_t)); print_image_hdr(hdr); @@ -222,7 +225,8 @@ static void fixup_silent_linux(){ #if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \ defined(CONFIG_FOR_DLINK_DIR505_A1) || \ - defined(CONFIG_FOR_DRAGINO_V2) + defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_V2) static void print_type(image_header_t *hdr){ char *os, *arch, *type, *comp; @@ -399,7 +403,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) || defined(CONFIG_FOR_DRAGINO_V2) */ +#endif /* defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || defined(CONFIG_FOR_DLINK_DIR505_A1) || defined(CONFIG_FOR_DRAGINO_V2) || defined(CONFIG_FOR_MESH_POTATO_V2) */ #if (CONFIG_COMMANDS & CFG_CMD_BOOTD) int do_bootd(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 59f5981..46a994d 100755 --- a/u-boot/common/cmd_custom.c +++ b/u-boot/common/cmd_custom.c @@ -198,7 +198,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) || \ - defined(CONFIG_FOR_DRAGINO_V2) + defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_V2) /* * Erase environment sector */ @@ -235,7 +236,7 @@ int do_default_env(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]){ } U_BOOT_CMD(defenv, 1, 0, do_default_env, "reset environment variables to their default values\n", NULL); -#endif /* if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || defined(CONFIG_FOR_DRAGINO_V2) */ +#endif /* if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || defined(CONFIG_FOR_DRAGINO_V2) || defined(CONFIG_FOR_MESH_POTATO_V2) */ #if defined(PLL_IN_FLASH_MAGIC_OFFSET) diff --git a/u-boot/include/common.h b/u-boot/include/common.h index 6a85284..89ce9dc 100755 --- a/u-boot/include/common.h +++ b/u-boot/include/common.h @@ -196,14 +196,16 @@ int autoscript (ulong addr); */ #if !defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) && \ !defined(CONFIG_FOR_DLINK_DIR505_A1) && \ - !defined(CONFIG_FOR_DRAGINO_V2) + !defined(CONFIG_FOR_DRAGINO_V2) && \ + !defined(CONFIG_FOR_MESH_POTATO_V2) #include "tpLinuxTag.h" #endif /* common/cmd_bootm.c */ #if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \ defined(CONFIG_FOR_DLINK_DIR505_A1) || \ - defined(CONFIG_FOR_DRAGINO_V2) + defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_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 2a3947d..4a1e915 100755 --- a/u-boot/include/configs/ap121.h +++ b/u-boot/include/configs/ap121.h @@ -62,7 +62,8 @@ #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) +#elif defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_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)" @@ -83,7 +84,8 @@ #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) #define CFG_LOAD_ADDR 0x9F050000 #define UPDATE_SCRIPT_FW_ADDR "0x9F050000" -#elif defined(CONFIG_FOR_DRAGINO_V2) +#elif defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_V2) #define CFG_LOAD_ADDR 0x9F040000 #define UPDATE_SCRIPT_FW_ADDR "0x9F040000" #else @@ -95,7 +97,8 @@ #define CONFIG_BOOTCOMMAND "bootm 0x9F080000" #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) #define CONFIG_BOOTCOMMAND "bootm 0x9F050000" -#elif defined(CONFIG_FOR_DRAGINO_V2) +#elif defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_V2) #define CONFIG_BOOTCOMMAND "bootm 0x9F040000" #else #define CONFIG_BOOTCOMMAND "bootm 0x9F020000" @@ -115,7 +118,8 @@ /* * Dragino 2 uses different prompt */ -#if defined(CONFIG_FOR_DRAGINO_V2) +#if defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_V2) #if defined(CFG_PROMPT) #undef CFG_PROMPT #endif @@ -758,7 +762,8 @@ * Address and size of Primary Environment Sector */ #if defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \ - defined(CONFIG_FOR_DRAGINO_V2) + defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_V2) #define CFG_ENV_IS_IN_FLASH 1 #undef CFG_ENV_IS_NOWHERE #else @@ -766,7 +771,8 @@ #define CFG_ENV_IS_NOWHERE 1 #endif -#if defined(CONFIG_FOR_DRAGINO_V2) +#if defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_V2) #define CFG_ENV_ADDR 0x9F030000 #define CFG_ENV_SIZE 0x8000 #define CFG_ENV_SECT_SIZE 0x10000 @@ -798,7 +804,8 @@ CFG_CMD_IMI) #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \ - defined(CONFIG_FOR_DRAGINO_V2) + defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_V2) #define CONFIG_COMMANDS (CFG_CMD_MEMORY | \ CFG_CMD_DHCP | \ @@ -882,7 +889,8 @@ #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) #define WEBFAILSAFE_UPLOAD_UBOOT_SIZE_IN_BYTES (256 * 1024) #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES "0x40000" -#elif defined(CONFIG_FOR_DRAGINO_V2) +#elif defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_V2) #define WEBFAILSAFE_UPLOAD_UBOOT_SIZE_IN_BYTES (192 * 1024) #define UPDATE_SCRIPT_UBOOT_SIZE_IN_BYTES "0x30000" #else @@ -895,7 +903,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) +#elif defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_V2) #define WEBFAILSAFE_UPLOAD_KERNEL_ADDRESS WEBFAILSAFE_UPLOAD_UBOOT_ADDRESS + 0x40000 #else #define WEBFAILSAFE_UPLOAD_KERNEL_ADDRESS WEBFAILSAFE_UPLOAD_UBOOT_ADDRESS + 0x20000 @@ -915,7 +924,8 @@ #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) +#elif defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_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) @@ -989,7 +999,8 @@ //#define OFFSET_MAC_ADDRESS 0x000004 //#define OFFSET_MAC_ADDRESS2 0x000016 #elif defined(CONFIG_FOR_8DEVICES_CARAMBOLA2) || \ - defined(CONFIG_FOR_DRAGINO_V2) + defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_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 @@ -1011,6 +1022,7 @@ !defined(CONFIG_FOR_DLINK_DIR505_A1) && \ !defined(CONFIG_FOR_GS_OOLITE_V1_DEV) && \ !defined(CONFIG_FOR_DRAGINO_V2) && \ + !defined(CONFIG_FOR_MESH_POTATO_V2) && \ !defined(CONFIG_FOR_GL_INET) #define OFFSET_ROUTER_MODEL 0x00FD00 #endif @@ -1052,7 +1064,8 @@ #define PLL_IN_FLASH_DATA_BLOCK_OFFSET 0x00040000 #define PLL_IN_FLASH_DATA_BLOCK_LENGTH 0x00010000 #define PLL_IN_FLASH_MAGIC_OFFSET 0x0000FFF0 // last 16 bytes -#elif defined(CONFIG_FOR_DRAGINO_V2) +#elif defined(CONFIG_FOR_DRAGINO_V2) || \ + defined(CONFIG_FOR_MESH_POTATO_V2) /* * We will store PLL and CLOCK registers * configuration at the end of environment diff --git a/u-boot/lib_mips/mips_linux.c b/u-boot/lib_mips/mips_linux.c index ec210e0..35558ce 100755 --- a/u-boot/lib_mips/mips_linux.c +++ b/u-boot/lib_mips/mips_linux.c @@ -119,7 +119,7 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]){ wasp_set_cca(); #endif -#if defined(CONFIG_FOR_DRAGINO_V2) +#if defined(CONFIG_FOR_DRAGINO_V2) || defined(CONFIG_FOR_MESH_POTATO_V2) // Restore WAN/LAN LEDs (BIT 3 and 7 in GPIO_FUNCTION_1) ar7240_reg_wr(AR7240_GPIO_FUNC, (ar7240_reg_rd(AR7240_GPIO_FUNC) | 0x88)); #endif -- 2.25.1