diff --git a/target/linux/ipq806x/base-files/etc/board.d/01_leds b/target/linux/ipq806x/base-files/etc/board.d/01_leds
index 977b3b104ebb3e7bf12d210b76265a790562bc03..13717672682d94ee90c654658620fb7daebbbf6c 100755
--- a/target/linux/ipq806x/base-files/etc/board.d/01_leds
+++ b/target/linux/ipq806x/base-files/etc/board.d/01_leds
@@ -26,6 +26,11 @@ r7800)
 	ucidef_set_led_netdev "wan" "WAN" "${board}:white:wan" "eth0"
 	ucidef_set_led_ide "esata" "eSATA" "${board}:white:esata"
 	;;
+fritz4040)
+	ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan" "phy0tpt" "phy1tpt"
+	ucidef_set_led_netdev "wan" "WAN" "$board:green:wan" "eth1"
+	ucidef_set_led_switch "lan" "LAN" "${board}:green:lan" "switch0" "0x1e"
+	;;
 nbg6817)
 	ucidef_set_led_wlan "wlan2g" "WLAN2G" "$board:amber:wifi2g" "phy1tpt"
 	ucidef_set_led_wlan "wlan5g" "WLAN5G" "$board:amber:wifi5g" "phy0tpt"
diff --git a/target/linux/ipq806x/base-files/etc/board.d/02_network b/target/linux/ipq806x/base-files/etc/board.d/02_network
index 52bb1629f7ba14f8799121a0c4437c1ef9a35da4..36e0fb3a0eb051e32a447234f00103194471745a 100755
--- a/target/linux/ipq806x/base-files/etc/board.d/02_network
+++ b/target/linux/ipq806x/base-files/etc/board.d/02_network
@@ -36,6 +36,11 @@ ea8500)
 	ucidef_set_interface_macaddr "lan" "$hw_mac_addr"
 	ucidef_set_interface_macaddr "wan" "$hw_mac_addr"
 	;;
+fritz4040)
+	ucidef_set_interfaces_lan_wan "eth0" "eth1"
+	ucidef_add_switch "switch0" \
+		"0@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
+	;;
 nbg6817)
 	hw_mac_addr=$(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
 	ucidef_add_switch "switch0" \
diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index 72c3ae88c2af7d5b20d9c5b2a34367380a58d322..652621247f47988413f8df17c0476e441658e93e 100644
--- a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -46,6 +46,21 @@ board=$(ipq806x_board_name)
 
 
 case "$FIRMWARE" in
+"ath10k/pre-cal-ahb-a000000.wifi.bin")
+	case "$board" in
+	fritz4040)
+		/usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
+		;;
+	esac
+	;;
+"ath10k/pre-cal-ahb-a800000.wifi.bin")
+	case "$board" in
+	fritz4040)
+		/usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
+		;;
+	esac
+	;;
+
 "ath10k/cal-pci-0000:01:00.0.bin")
 	case $board in
 	c2600)
diff --git a/target/linux/ipq806x/base-files/lib/ipq806x.sh b/target/linux/ipq806x/base-files/lib/ipq806x.sh
index a8b909ac04870740d75de1a5a8c8b144a9e7fd95..348a3a89516884a6f8f6a9cccfc5474ab662ddea 100644
--- a/target/linux/ipq806x/base-files/lib/ipq806x.sh
+++ b/target/linux/ipq806x/base-files/lib/ipq806x.sh
@@ -17,6 +17,9 @@ ipq806x_board_detect() {
 	*"AP148")
 		name="ap148"
 		;;
+	*"4040")
+		name="fritz4040"
+		;;
 	*"C2600")
 		name="c2600"
 		;;
diff --git a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh
index c3741f9ff242cddb3c185c2f638c7b4dff781e1b..89702850fca9a6a2234beec71019a53b5f2aeeac 100644
--- a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh
@@ -42,6 +42,9 @@ platform_do_upgrade() {
 		MTD_CONFIG_ARGS="-s 0x200000"
 		default_do_upgrade "$ARGV"
 		;;
+	*)
+		default_do_upgrade "$ARGV"
+		;;
 	esac
 }
 
diff --git a/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq4019-fritz4040.dts b/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq4019-fritz4040.dts
index fdd565c2eaeac195edc9a1e15c41b6f8419db8a3..1bd5b512c8cc61b2c4e5991ca7a0727909e2631f 100644
--- a/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq4019-fritz4040.dts
+++ b/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq4019-fritz4040.dts
@@ -272,7 +272,7 @@
 				read-only;
 			};
 			partition11@2A0000 {
-				label = "image"; /* firmware */
+				label = "firmware";
 				reg = <0x002A0000 0x01C60000>;
 			};
 			partition12@1f00000 {
diff --git a/target/linux/ipq806x/image/Makefile b/target/linux/ipq806x/image/Makefile
index 70c8056d906bc89372cd978994866ef1cddfd38a..8091d9951a511814af5500384674d983c2cc0145 100644
--- a/target/linux/ipq806x/image/Makefile
+++ b/target/linux/ipq806x/image/Makefile
@@ -5,8 +5,6 @@ include $(INCLUDE_DIR)/image.mk
 
 UBIFS_OPTS = -m 2048 -e 124KiB -c 4096 -U -F
 
-KERNEL_LOADADDR := 0x42208000
-
 define Image/Prepare
 	$(CP) $(LINUX_DIR)/vmlinux $(KDIR)/$(IMG_PREFIX)-vmlinux.elf
 endef
@@ -30,6 +28,7 @@ define Device/Default
 	KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
 	KERNEL_INITRAMFS_PREFIX := $$(IMG_PREFIX)-$(1)-initramfs
 	KERNEL_PREFIX := $$(IMAGE_PREFIX)
+	KERNEL_LOADADDR = 0x42208000
 	SUPPORTED_DEVICES = $$(BOARD_NAME)
 	IMAGE/sysupgrade.tar = sysupgrade-tar | append-metadata
 endef
@@ -46,6 +45,12 @@ define Device/FitImage
 	KERNEL_NAME := Image
 endef
 
+define Device/FitImageLzma
+	KERNEL_SUFFIX := -fit-uImage.itb
+	KERNEL = kernel-bin | lzma | fit lzma $$(DTS_DIR)/$$(DEVICE_DTS).dtb
+	KERNEL_NAME := Image
+endef
+
 define Device/UbiFit
 	KERNEL_IN_UBI := 1
 	IMAGES := nand-factory.ubi nand-sysupgrade.tar
@@ -165,6 +170,20 @@ define Device/EA8500
 	DEVICE_PACKAGES := ath10k-firmware-qca99x0
 endef
 
+define Device/FRITZ4040
+	$(call Device/FitImageLzma)
+	DEVICE_DTS := qcom-ipq4019-fritz4040
+	KERNEL_LOADADDR := 0x80208000
+	BLOCKSIZE := 4k
+	PAGESIZE := 256
+	BOARD_NAME := fritz4040
+	DEVICE_TITLE := AVM Fritz!Box 4040
+	IMAGE_SIZE := 29753344
+	IMAGES = sysupgrade.bin
+	IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata
+	DEVICE_PACKAGES := kmod-usb-phy-qcom-ipq4019 ipq-wifi-fritz4040 fritz-tools u-boot-fritz4040
+endef
+
 define Device/R7500
 	$(call Device/DniImage)
 	DEVICE_DTS := qcom-ipq8064-r7500
@@ -231,6 +250,7 @@ define Device/VR2600v
 	IMAGE/sysupgrade.bin := pad-extra 512 | append-kernel | pad-to $$$${KERNEL_SIZE} | append-rootfs | pad-rootfs | append-metadata
 endef
 
-TARGET_DEVICES += AP148 AP148-legacy C2600 D7800 DB149 EA8500 R7500 R7500v2 R7800 NBG6817 VR2600v
+TARGET_DEVICES += AP148 AP148-legacy C2600 D7800 DB149 EA8500 FRITZ4040 R7500 \
+		  R7500v2 R7800 NBG6817 VR2600v
 
 $(eval $(call BuildImage))