aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ath79/image
diff options
context:
space:
mode:
authorChuanhong Guo <gch981213@gmail.com>2019-08-04 22:13:45 +0800
committerChuanhong Guo <gch981213@gmail.com>2019-08-08 21:00:59 +0800
commit4d5dae27419a6883484d0a051c653888d2042bca (patch)
treece20ef29c1780f67d9634996c7ded9f8f124d111 /target/linux/ath79/image
parent1d6368ee73a8a2c3ba1593fc4dd143f094f48520 (diff)
downloadupstream-4d5dae27419a6883484d0a051c653888d2042bca.tar.gz
upstream-4d5dae27419a6883484d0a051c653888d2042bca.tar.bz2
upstream-4d5dae27419a6883484d0a051c653888d2042bca.zip
ath79: add support for PISEN WMB001N
Specifications: - SoC: AR9341 - RAM: 64M - Flash: 16M - Ethernet: 1 * FE port - WiFi: ar934x-wmac - Sound: WM8918 DAC 1 * 3.5mm headphone jack 2 * RCA connectors for speakers 1 * SPDIF out - USB: 1 * USB2.0 port Flash instruction: Upload generated factory image via vendor's web interface. Notes: A. Audio stuff: 1. Since AR934x, all pins for peripheral blocks can be mapped to any available GPIOs. We currently don't have a PCM/I2S driver for AR934x so pinmux for i2s and SPDIF are bound to i2c gpio node. This should be moved into I2S node when a PCM/I2S driver is available. 2. The i2c-gpio node is for WM8918. DT binding for it can't be added currently due to a missing clock from I2S PLL. B. Factory image: Image contains a image header and a tar.gz archive. 1. Header: A 288 byte header that has nothing to do with appended tarball. Format: 0x0-0x7 and 0x18-0x1F: magic values 0x20: Model number string 0xFC: Action string. It's either "update" or "backup" 0x11C: A 1 byte checksum. It's XOR result of 0x8-0x11B Firmware doesn't care about the rest of the header as long as checksum result is correct. The same header is used for backup and update routines so the magic values and model number can be obtained by generating a backup bin and grab values from it. 2. Tarball: It contains two files named uImage and rootfs, which will be flashed into corresponding mtd partition. Writing a special utility that can only output a fixed binary blob is overkill so factory image header is placed under image/bin instead. C. LED The wifi led has "Wi-Fi" marked on the case but vendor's firmware used it as system status indicator. I did the same in this device support patch. D. Firmware Factory u-boot is built without 'savenv' support so it's impossible to change kernel offset. A 2MB kernel partition won't be enough in the future. OKLI loader is used here to migrate this problem: 1. add OKLI image magic support into uImage parser. 2. build an OKLI loader, compress it with lzma and add a normal uImage header. 3. flash the loader to where the original kernel supposed to be. 4. create a uImage firmware using OKLI loader. 5. flash the created firmware to where rootfs supposed to be. By doing so, u-boot will start OKLI loader, which will then load the actual kernel at 0x20000. The kernel partition is 2MB, which is too much for our loader. To save this space, "mtd-concat" is used here: 1. create a 64K (1 erase block) partition for OKLI loader and create another partition with the left space. 2. concatenate rootfs and this partition into a virtual flash. 3. use the virtual flash for firmware partition. Currently OKLI loader is flashed with factory image only. sysupgrade won't replace it. Since it only has one function and it works for several years, its unlikely to have some bugs that requires a replacement. Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
Diffstat (limited to 'target/linux/ath79/image')
-rw-r--r--target/linux/ath79/image/Makefile4
-rw-r--r--target/linux/ath79/image/bin/pisen_wmb001n_factory-header.binbin0 -> 288 bytes
-rw-r--r--target/linux/ath79/image/generic.mk29
3 files changed, 33 insertions, 0 deletions
diff --git a/target/linux/ath79/image/Makefile b/target/linux/ath79/image/Makefile
index 734f27e689..24768ef5e0 100644
--- a/target/linux/ath79/image/Makefile
+++ b/target/linux/ath79/image/Makefile
@@ -36,6 +36,10 @@ define Build/loader-okli
mv "$@.new" "$@"
endef
+define Build/append-loader-okli
+ cat "$(KDIR)/loader-$(word 1,$(1)).$(LOADER_TYPE)" >> "$@"
+endef
+
define Build/relocate-kernel
rm -rf $@.relocate
$(CP) ../../generic/image/relocate $@.relocate
diff --git a/target/linux/ath79/image/bin/pisen_wmb001n_factory-header.bin b/target/linux/ath79/image/bin/pisen_wmb001n_factory-header.bin
new file mode 100644
index 0000000000..99e1e8a2db
--- /dev/null
+++ b/target/linux/ath79/image/bin/pisen_wmb001n_factory-header.bin
Binary files differ
diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk
index abaf1a3e07..5127cfd510 100644
--- a/target/linux/ath79/image/generic.mk
+++ b/target/linux/ath79/image/generic.mk
@@ -58,6 +58,18 @@ define Build/nec-fw
mv $@.new $@
endef
+define Build/pisen_wmb001n-factory
+ -[ -f "$@" ] && \
+ mkdir -p "$@.tmp" && \
+ cp "$(KDIR)/loader-$(word 1,$(1)).uImage" "$@.tmp/uImage" && \
+ mv "$@" "$@.tmp/rootfs" && \
+ cp "bin/pisen_wmb001n_factory-header.bin" "$@" && \
+ $(TAR) -cp --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name \
+ $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
+ -C "$@.tmp" . | gzip -9n >> "$@" && \
+ rm -rf "$@.tmp"
+endef
+
define Device/seama
KERNEL := kernel-bin | append-dtb | relocate-kernel | lzma
KERNEL_INITRAMFS := $$(KERNEL) | seama
@@ -775,6 +787,23 @@ define Device/netgear_wndr3700v2
endef
TARGET_DEVICES += netgear_wndr3700v2
+define Device/pisen_wmb001n
+ ATH_SOC := ar9341
+ DEVICE_VENDOR := PISEN
+ DEVICE_MODEL := WMB001N
+ IMAGE_SIZE := 14080k
+ DEVICE_PACKAGES := kmod-i2c-core kmod-i2c-gpio kmod-usb2
+ LOADER_TYPE := bin
+ LOADER_FLASH_OFFS := 0x20000
+ COMPILE := loader-$(1).bin loader-$(1).uImage
+ COMPILE/loader-$(1).bin := loader-okli-compile
+ COMPILE/loader-$(1).uImage := append-loader-okli $(1) | pad-to 64k | lzma | uImage lzma
+ KERNEL := kernel-bin | append-dtb | lzma | uImage lzma -M 0x4f4b4c49
+ IMAGES += factory.bin
+ IMAGE/factory.bin := $$(IMAGE/sysupgrade.bin) | pisen_wmb001n-factory $(1)
+endef
+TARGET_DEVICES += pisen_wmb001n
+
define Device/pisen_wmm003n
$(Device/tplink-8mlzma)
ATH_SOC := ar9331