Index: target/linux/ramips/files/arch/mips/ralink/rt305x/Kconfig
===================================================================
--- target/linux/ramips/files/arch/mips/ralink/rt305x/Kconfig	(revision 31541)
+++ target/linux/ramips/files/arch/mips/ralink/rt305x/Kconfig	(working copy)
@@ -12,6 +12,11 @@
 	select RALINK_DEV_GPIO_BUTTONS
 	select RALINK_DEV_GPIO_LEDS
 
+config RT305X_MACH_ALL0239_3G
+	bool "Allnet ALL0239-3G support"
+	select RALINK_DEV_GPIO_BUTTONS
+	select RALINK_DEV_GPIO_LEDS
+
 config RT305X_MACH_W502U
 	bool "ALFA Networks W502U board support"
 	select RALINK_DEV_GPIO_BUTTONS
Index: target/linux/ramips/files/arch/mips/ralink/rt305x/Makefile
===================================================================
--- target/linux/ramips/files/arch/mips/ralink/rt305x/Makefile	(revision 31541)
+++ target/linux/ramips/files/arch/mips/ralink/rt305x/Makefile	(working copy)
@@ -14,6 +14,7 @@
 obj-$(CONFIG_RT305X_MACH_ARGUS_ATP52B)	+= mach-argus-atp52b.o
 obj-$(CONFIG_RT305X_MACH_BC2)		+= mach-bc2.o
 obj-$(CONFIG_RT305X_MACH_ALL0256N)	+= mach-all0256n.o
+obj-$(CONFIG_RT305X_MACH_ALL0239_3G)	+= mach-all0239-3g.o
 obj-$(CONFIG_RT305X_MACH_DIR_300_REVB)	+= mach-dir-300-revb.o
 obj-$(CONFIG_RT305X_MACH_ESR_9753)	+= mach-esr-9753.o
 obj-$(CONFIG_RT305X_MACH_F5D8235_V2)    += mach-f5d8235-v2.o
Index: target/linux/ramips/files/arch/mips/ralink/rt305x/mach-all0239-3g.c
===================================================================
--- target/linux/ramips/files/arch/mips/ralink/rt305x/mach-all0239-3g.c	(revision 0)
+++ target/linux/ramips/files/arch/mips/ralink/rt305x/mach-all0239-3g.c	(revision 0)
@@ -0,0 +1,98 @@
+/*
+ *  Allnet ALL0239-3G board support
+ *
+ *  Copyright (C) 2011 Massimo Vellucci <vemax78@gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <asm/mach-ralink/machine.h>
+#include <asm/mach-ralink/dev-gpio-buttons.h>
+#include <asm/mach-ralink/dev-gpio-leds.h>
+#include <asm/mach-ralink/rt305x.h>
+#include <asm/mach-ralink/rt305x_regs.h>
+
+#include "devices.h"
+
+#define ALL0239_3G_GPIO_LED_USB		8
+#define ALL0239_3G_GPIO_LED_3G		11
+#define ALL0239_3G_GPIO_LED_CONNECT	12
+#define ALL0239_3G_GPIO_LED_WPS		14
+
+#define ALL0239_3G_GPIO_BUTTON_RESET	10
+#define ALL0239_3G_GPIO_BUTTON_CONNECT	7
+#define ALL0239_3G_GPIO_BUTTON_WPS	0
+
+#define ALL0239_3G_KEYS_POLL_INTERVAL	20
+#define ALL0239_3G_KEYS_DEBOUNCE_INTERVAL	(3 * ALL0239_3G_KEYS_POLL_INTERVAL)
+
+static struct gpio_led all0239_3g_leds_gpio[] __initdata = {
+	{
+		.name		= "all0239-3g:green:usb",
+		.gpio		= ALL0239_3G_GPIO_LED_USB,
+		.active_low	= 1,
+	}, {
+		.name		= "all0239-3g:green:3g",
+		.gpio		= ALL0239_3G_GPIO_LED_3G,
+		.active_low	= 1,
+	}, {
+		.name		= "all0239-3g:green:connect",
+		.gpio		= ALL0239_3G_GPIO_LED_CONNECT,
+		.active_low	= 1,
+	}, {
+		.name		= "all0239-3g:green:wps",
+		.gpio		= ALL0239_3G_GPIO_LED_WPS,
+		.active_low	= 1,
+	}
+};
+
+static struct gpio_keys_button all0239_3g_gpio_buttons[] __initdata = {
+	{
+		.desc		= "reset",
+		.type		= EV_KEY,
+		.code		= KEY_RESTART,
+		.debounce_interval = ALL0239_3G_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= ALL0239_3G_GPIO_BUTTON_RESET,
+		.active_low	= 1,
+	}, {
+		.desc		= "connect",
+		.type		= EV_KEY,
+		.code		= KEY_CONNECT,
+		.debounce_interval = ALL0239_3G_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= ALL0239_3G_GPIO_BUTTON_CONNECT,
+		.active_low	= 1,
+	}, {
+		.desc		= "wps",
+		.type		= EV_KEY,
+		.code		= KEY_WPS_BUTTON,
+		.debounce_interval = ALL0239_3G_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= ALL0239_3G_GPIO_BUTTON_WPS,
+		.active_low	= 1,
+	}
+};
+
+static void __init all0239_3g_init(void)
+{
+	rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
+
+	rt305x_register_flash(0);
+
+	rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
+	rt305x_register_ethernet();
+	ramips_register_gpio_leds(-1, ARRAY_SIZE(all0239_3g_leds_gpio),
+				  all0239_3g_leds_gpio);
+	ramips_register_gpio_buttons(-1, ALL0239_3G_KEYS_POLL_INTERVAL,
+				     ARRAY_SIZE(all0239_3g_gpio_buttons),
+				     all0239_3g_gpio_buttons);
+	rt305x_register_wifi();
+	rt305x_register_wdt();
+	rt305x_register_usb();
+}
+
+MIPS_MACHINE(RAMIPS_MACH_ALL0239_3G, "ALL0239_3G", "Allnet ALL0239-3G",
+	     all0239_3g_init);
Index: target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h
===================================================================
--- target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h	(revision 31541)
+++ target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h	(working copy)
@@ -56,6 +56,7 @@
 	RAMIPS_MACH_WR6202,		/* Accton WR6202 */
 	RAMIPS_MACH_XDXRN502J,          /* unknown XDX-RN502J */
 	RAMIPS_MACH_UR_336UN,		/* UPVEL ROUTER */
+	RAMIPS_MACH_ALL0239_3G,		/* Allnet ALL0239-3G */
 
 	/* RT3662 based machines */
 	RAMIPS_MACH_RT_N56U,		/* Asus RT-N56U */
Index: target/linux/ramips/image/Makefile
===================================================================
--- target/linux/ramips/image/Makefile	(revision 31541)
+++ target/linux/ramips/image/Makefile	(working copy)
@@ -159,9 +159,11 @@
 mtd_dir300b1_rootfs_part_size=2949120
 define BuildFirmware/DIR300B1
 	$(call BuildFirmware/Generic,$(1),$(2),board=$(3) $(call mkmtd/phys,$(mtdlayout_dir300b1)),$(mtd_dir300b1_kernel_part_size),$(mtd_dir300b1_rootfs_part_size))
-	mkwrgimg -s $(4) -d /dev/mtdblock/2 \
-		-i $(call sysupname,$(1),$(2)) \
-		-o $(call imgname,$(1),$(2))-factory.bin
+	if [ -e "$(call sysupname,$(1),$(2))" ]; then \
+		mkwrgimg -s $(4) -d /dev/mtdblock/2 \
+			-i $(call sysupname,$(1),$(2)) \
+			-o $(call imgname,$(1),$(2))-factory.bin; \
+	fi
 endef
 
 define BuildFirmware/DIR300B1/initramfs
@@ -192,6 +194,15 @@
 	$(call BuildFirmware/GENERIC_8M/initramfs,$(1),fonera20n,FONERA20N,ttyS1,57600,phys)
 endef
 
+define BuildFirmware/ALL0239_3G
+	$(call BuildFirmware/GENERIC_8M,$(1),all0239_3g,ALL0239_3G,ttyS1,57600,phys)
+	$(call BuildFirmware/Edimax,$(1),all0239_3g,RSDK,NL1T,0x50000,0xc0000)
+endef
+
+define BuildFirmware/ALL0239_3G/initramfs
+	$(call BuildFirmware/GENERIC_8M/initramfs,$(1),all0239_3g,ALL0239_3G,ttyS1,57600,phys)
+endef
+
 mtdlayout_nw718=192k(u-boot)ro,128k(config)ro,64k(factory)ro,896k(kernel),2816k(rootfs),3712k@0x60000(firmware)
 kernel_size_nw718=917504
 rootfs_size_nw718=2883584
@@ -335,6 +346,10 @@
 	$(call Image/Build/Template/$(fs_squash)/$(1),FONERA20N)
 endef
 
+define Image/Build/Profile/ALL0239_3G
+	$(call Image/Build/Template/$(fs_squash)/$(1),ALL0239_3G)
+endef
+
 define Image/Build/Profile/FREESTATION5
 	$(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_8M,freestation5,FREESTATION5,ttyS1,115200,phys)
 endef
@@ -428,6 +443,7 @@
 ifeq ($(CONFIG_RALINK_RT305X),y)
 define Image/Build/Profile/Default
 	$(call Image/Build/Profile/ALL0256N,$(1))
+	$(call Image/Build/Profile/ALL0239_3G,$(1))
 	$(call Image/Build/Profile/ARGUS_ATP52B,$(1))
 	$(call Image/Build/Profile/BC2,$(1))
 	$(call Image/Build/Profile/DIR300B1,$(1))
Index: target/linux/ramips/rt305x/config-3.3
===================================================================
--- target/linux/ramips/rt305x/config-3.3	(revision 31541)
+++ target/linux/ramips/rt305x/config-3.3	(working copy)
@@ -97,6 +97,7 @@
 # CONFIG_RALINK_RT3883 is not set
 CONFIG_RAMIPS_WDT=y
 CONFIG_RT305X_MACH_ALL0256N=y
+CONFIG_RT305X_MACH_ALL0239_3G=y
 CONFIG_RT305X_MACH_ARGUS_ATP52B=y
 CONFIG_RT305X_MACH_BC2=y
 CONFIG_RT305X_MACH_DIR_300_REVB=y
Index: target/linux/ramips/base-files/lib/ramips.sh
===================================================================
--- target/linux/ramips/base-files/lib/ramips.sh	(revision 31541)
+++ target/linux/ramips/base-files/lib/ramips.sh	(working copy)
@@ -50,6 +50,9 @@
 	*"Allnet ALL0256N")
 		name="all0256n"
 		;;
+	*"Allnet ALL0239-3G")
+		name="all0239_3g"
+		;;
 	*"ARC FreeStation5")
 		name="freestation5"
 		;;
Index: target/linux/ramips/base-files/lib/upgrade/platform.sh
===================================================================
--- target/linux/ramips/base-files/lib/upgrade/platform.sh	(revision 31541)
+++ target/linux/ramips/base-files/lib/upgrade/platform.sh	(working copy)
@@ -15,6 +15,7 @@
 
 	case "$board" in
 	all0256n | \
+	all0239_3g | \
 	bc2 | \
 	dir-300-b1 | \
 	dir-600-b1 | \
Index: target/linux/ramips/base-files/lib/preinit/06_set_iface_mac
===================================================================
--- target/linux/ramips/base-files/lib/preinit/06_set_iface_mac	(revision 31541)
+++ target/linux/ramips/base-files/lib/preinit/06_set_iface_mac	(working copy)
@@ -25,6 +25,7 @@
                 ifconfig eth0 hw ether $mac 2>/dev/null
                 ;;
 	all0256n |\
+	all0239_3g |\
 	hw550-3g |\
 	nbg-419n |\
 	omni-emb |\
Index: target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
===================================================================
--- target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom	(revision 31541)
+++ target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom	(working copy)
@@ -49,6 +49,7 @@
 		;;
 
 	all0256n | \
+	all0239_3g | \
 	argus-atp52b | \
 	bc2 | \
 	esr-9753 | \
Index: target/linux/ramips/base-files/etc/uci-defaults/leds
===================================================================
--- target/linux/ramips/base-files/etc/uci-defaults/leds	(revision 31541)
+++ target/linux/ramips/base-files/etc/uci-defaults/leds	(working copy)
@@ -51,6 +51,10 @@
 	fonera20n)
 		set_usb_led "fonera20n:amber:usb"
 		;;
+	all0239_3g)
+		set_usb_led "all0239-3g:green:usb"
+		set_wifi_led "rt2800pci-phy0::radio"
+		;;
 	hw550-3g)
 		set_usb_led "hw550-3g:green:usb"
 		;;
