Supporting ZSUN Wifi Card Reader (16MB Flash, 64MB RAM, AR9331)

Yes, that is my question. Also not clear based upon the date that the parameters are for the Z-Sun.

Well it looks like I bricked it anyway. Got hooks on it (jumpered the missing resistor) and it wouldn't get a serial prompt. Additionally, the LED wouldn't light up anymore either, suggesting I really hosed it.

Perhaps I should invest in another, once there is a uboot mod that allows loading firmware off the SD Card to make fixing semi-bricks a bit easier...

1 Like

With many thanks to @maurer I've built a custom image with the imagebuilder. In addition to the base-image it contains the following additional packages:

  • luci-ssl
  • openvpn-openssl
  • travelmate (+ luci package)
  • nlbwmon (+ luci packge)
  • ip-full

This makes the Zsun a nice little road-warrior with always-on VPN for me. Without VPN I get around 15 Mbit of throughput, with VPN (256bit AES-CBC) around 7 Mbit. Excellent for most public Wifi networks :slight_smile:

You can download my image here: https://mega.nz/#!o3QWWaJZ!Yn3X6mZbFHmj5oQdWMaTa3mSvnbU-u9i9BzNrKo1DfI

2 Likes

I would like to build an image that has the possibility to read and automount sdcards that are inserted and then share them via samba, any suggestions on what packages I need and to actually do that with Imagebuilder?

cheers,
/J

I think at lease you need base-system -> block-mount and samba36-server

my 1 zsun also bricked after 17.01.04 upgrade, but i dont have hooks yet to see if really dead. The 17.01.01 update i used did not have the led configured properly

here what i added to 17.01.01 build to get led working

/etc/config/system

config led 'led_wifi_led'
      option name 'wifi'
      option sysfs 'zsun-sdreader:green:system'
      option trigger 'netdev'
      option mode 'link rx tx'
      option dev 'wlan0'

Thank you, that suggestion worked wonderfully.

However, I am having some problems mounting my sdcard. I could install block-mount and samba36-server just fine, but I am unsure of which kmods I need to be able to mount and read the file system on the sdcard. Its fat32 currently.

I did try the kmod-fs-exfat and -vfat, but they fail with some kernel mismatch error.

What to do?

Have you select kmod-fs-msdos & kmod-fs-vfat in kernel sub menu? You also need to refresh zsun with the new sysupgrade image whenever you make kernel setup change, as the kmod-*.ipk must match the the built kernel.

I did not. I tried this from within lede, installing packages from the software menu... but perhaps that is not the way to do it... or maybe the kernel have changed in snapshot since my image was built and that is why the mismatch occurs.

So you are saying I need to build this with the imagebuilder?
Iirc I tried that and failed as well, some similar error.

What does refreshing the sysupgrade image mean? I would imagine building something with imagebuilder automatically created a sysupgrade image, no?

I used normal lede git source and the patch for dirlede's post above to build the image, and using the same image and kernel modules packages under the bin folder, you can use user land packages from lede repos I guess, but you must use the same zsun custom-built kernel and kernel packages.

In case someone wants to do thing like I am trying, to build lede trunk image for zsun based on gdm85 and emeryth's patch, first git clone lede source master, make a local branch named zsun_master, then merge the patch and build from there as usual:

git checkout -b zsun_master master
git pull --no-ff https://github.com/gdm85/openwrt.git master

    remote: Counting objects: 72, done.
remote: Total 72 (delta 40), reused 40 (delta 40), pack-reused 32
展开对象中: 100% (72/72), 完成.
来自 https://github.com/gdm85/openwrt
 * branch                  master     -> FETCH_HEAD
自动合并 target/linux/ar71xx/image/legacy.mk
自动合并 target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
自动合并 target/linux/ar71xx/files/arch/mips/ath79/Makefile
自动合并 target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
自动合并 target/linux/ar71xx/config-4.4
自动合并 target/linux/ar71xx/base-files/lib/upgrade/platform.sh
自动合并 target/linux/ar71xx/base-files/lib/ar71xx.sh
自动合并 target/linux/ar71xx/base-files/etc/diag.sh
自动合并 target/linux/ar71xx/base-files/etc/board.d/02_network
Merge made by the 'recursive' strategy.
 target/linux/ar71xx/base-files/etc/board.d/02_network               |   3 ++
 target/linux/ar71xx/base-files/etc/diag.sh                          |   3 ++
 target/linux/ar71xx/base-files/etc/rc.button/BTN_1                  |   5 +++
 target/linux/ar71xx/base-files/etc/uci-defaults/99_zsun-enable-wifi |   7 +++++
 target/linux/ar71xx/base-files/lib/ar71xx.sh                        |   3 ++
 target/linux/ar71xx/base-files/lib/preinit/50_failsafe_wipe         |  11 +++++++
 target/linux/ar71xx/base-files/lib/upgrade/platform.sh              |   3 +-
 target/linux/ar71xx/config-4.4                                      |   1 +
 target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt           |  10 ++++++
 target/linux/ar71xx/files/arch/mips/ath79/Makefile                  |   1 +
 target/linux/ar71xx/files/arch/mips/ath79/mach-zsun-sdreader.c      | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 target/linux/ar71xx/files/arch/mips/ath79/machtypes.h               |   1 +
 target/linux/ar71xx/generic/profiles/zsun.mk                        |  17 ++++++++++
 target/linux/ar71xx/image/Makefile                                  |   7 +++++
 target/linux/ar71xx/image/legacy.mk                                 |   1 +
 target/linux/ar71xx/patches-4.4/415-mtd-m25p80-add-w25q128fw.patch  |  13 ++++++++
 16 files changed, 186 insertions(+), 1 deletion(-)
 create mode 100755 target/linux/ar71xx/base-files/etc/rc.button/BTN_1
 create mode 100644 target/linux/ar71xx/base-files/etc/uci-defaults/99_zsun-enable-wifi
 create mode 100644 target/linux/ar71xx/base-files/lib/preinit/50_failsafe_wipe
 create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-zsun-sdreader.c
 create mode 100644 target/linux/ar71xx/generic/profiles/zsun.mk
 create mode 100644 target/linux/ar71xx/patches-4.4/415-mtd-m25p80-add-w25q128fw.patch

In order to build it successfully, need to delete zsun.mk, and revert the changes in image/Makefile and legacy.mk. and add the patch image/generic.mk above in this thread like this:

diff --git a/target/linux/ar71xx/image/generic.mk b/target/linux/ar71xx/image/generic.mk
index 95265d1c0a..71b432cb23 100644
--- a/target/linux/ar71xx/image/generic.mk
+++ b/target/linux/ar71xx/image/generic.mk
@@ -1002,6 +1002,19 @@ define Device/bhr-4grv2
 endef
 TARGET_DEVICES += bhr-4grv2
 
+define Device/zsun-sdreader
+  DEVICE_TITLE := ZSUN WiFi SD Card Reader
+  BOARDNAME := ZSUN-SDREADER
+  ROOTFS_SIZE := 14912k
+  KERNEL_SIZE := 1216k
+  IMAGE_SIZE := 16128k
+  CONSOLE := ttyATH0,115200
+  MTDPARTS := spi0.0:64k(u-boot)ro,64k(u-boot-env)ro,14912k(rootfs),1216k(kernel),64k(nvram),64k(art),16128k@0x20000(firmware)
+  IMAGES := sysupgrade.bin
+  IMAGE/sysupgrade.bin = append-rootfs | pad-rootfs | pad-to $$$$(ROOTFS_SIZE) | append-kernel | check-size $$$$(IMAGE_SIZE)
+endef
+TARGET_DEVICES += zsun-sdreader
+
 define Device/wlr8100
   DEVICE_TITLE := Sitecom WLR-8100
   DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport kmod-usb3 \

What are some tricks to get kernel size down?

1 Like

Disable:
_Global build settings - Enable support for printk, Crash logging, Support for paging of anonymous memory (swap), Compile the kernel with debug filesystem enabled, Compile the kernel with symbol tables information, Compile the kernel with debug information, Compile the kernel with SysRq support, Enable printk timestamps
_Kernel modules - Wireless Drivers - kmod-ath9k - Support for Ubiquiti Unify Outdoor+
_Kernel modules - Wireless Drivers - kmod-mac80211 - Export mac80211 internals in DebugFS
_Kernel modules - Wireless Drivers - kmod-ath - Force Atheros drivers to respect the user's regdomain settings, Enable DFS support

2 Likes

Hi, I also got a Zsun reader for doing experiments. I built my ROM and of course I managed to kill Zsun. I made a sysupgrade from the Polish Rom 15.05.
Fortunately, I managed to restore Zsun using python ubootwrite.
In order to better recover Zsun, I've built my own bootloader based on https://github.com/pepe2k/u-boot_mod
It works great, Zsun can be quickly restored using a serial line and Ymod download.
Here's the link.
https://mega.nz/#F!BnJChJAS!kK_QLnrnjGvBzxMdR9Ud-Q
I recommend that you first have this bootloader in Zsun when doing experiments.
Using bootloader and memory dump, I found that sysupgrade from Polish firmware 15.05, the kernel was badly written down. I'm going to investigate what happened and try to write my ROM using mtd write.
If I'm successful, the next step will be to change the flash memory map and increase the space for the kernel :grin:

*     U-Boot 1.1.4-e011cf70-dirty     *
*          Build: 2018-02-28          *
***************************************

  BOARD: ZSUN WiFi Card Reader
    SOC: AR9330 rev. 1
    CPU: MIPS 24Kc
    RAM: 64 MB DDR2 16-bit CL3-4-4-10
  FLASH: 16 MB Winbond W25Q128FW
    MAC: 00:03:7F:11:56:48
 CLOCKS: CPU/RAM/AHB/SPI/REF
         400/400/200/ 25/ 25 MHz

Hit any key to stop booting:  1 0

Booting image from 0x9FEB0000...

   Image name:    MIPS OpenWrt Linux-3.18.20
   Build date:    2016-01-12 16:31:21 UTC
   Architecture:  MIPS
   OS/image type: Linux Kernel
   Compression:   LZMA
   Data size:     1.1 MB (1165698 bytes)
   Load address:  0x80060000
   Entry point:   0x80060000

   Header CRC...  OK!
   Data CRC...    skipped

Stopping network... OK!
Uncompressing Kernel... OK!
Starting kernel...

[    0.000000] Linux version 3.18.20 (andrju@Phenom) (gcc version 4.8.3
1 Like

Success, running my firmware based on stable 17.01 :grin:

***************************************
*     U-Boot 1.1.4-e011cf70-dirty     *
*          Build: 2018-02-28          *
***************************************

  BOARD: ZSUN WiFi Card Reader
    SOC: AR9330 rev. 1
    CPU: MIPS 24Kc
    RAM: 64 MB DDR2 16-bit CL3-4-4-10
  FLASH: 16 MB Winbond W25Q128FW
    MAC: 00:03:7F:11:56:48
 CLOCKS: CPU/RAM/AHB/SPI/REF
         400/400/200/ 25/ 25 MHz

Hit any key to stop booting:  1 0

Booting image from 0x9FEB0000...

   Image name:    MIPS LEDE Linux-4.4.112
   Build date:    2018-03-01 00:39:14 UTC
   Architecture:  MIPS
   OS/image type: Linux Kernel
   Compression:   LZMA
   Data size:     1.2 MB (1215696 bytes)
   Load address:  0x80060000
   Entry point:   0x80060000

   Header CRC...  OK!
   Data CRC...    skipped

Stopping network... OK!
Uncompressing Kernel... OK!
Starting kernel...

Linux version 4.4.112 (eddie@eddie-ubuntu64) (gcc version 5.4.0 (LEDE GCC 5.4.0 r3833-8369cfa) ) #0 Thu Mar 1 00:39:14 2018
bootconsole [early0] enabled
CPU0 revision is: 00019374 (MIPS 24Kc)
SoC: Atheros AR9330 rev 1
Determined physical RAM map:
 memory: 04000000 @ 00000000 (usable)
Initrd not found or empty - disabling initrd
No valid device tree found, continuing without
Zone ranges:
  Normal   [mem 0x0000000000000000-0x0000000003ffffff]
Movable zone start for each node
Early memory node ranges
  node   0: [mem 0x0000000000000000-0x0000000003ffffff]
Initmem setup node 0 [mem 0x0000000000000000-0x0000000003ffffff]
Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line:  board=ZSUN-SDREADER mtdparts=spi0.0:64k(u-boot)ro,64k(u-boot-env)ro,14912k(rootfs),1216k(kernel),64k(nvram),64k(art),16000k@0x40000(myfirmware),192k@0x00000(myuboot)  console=ttyATH0,115200 rootfstype=squashfs,jffs2 noinitrd
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Writing ErrCtl register=00000000
Readback ErrCtl register=00000000
Memory: 60488K/65536K available (2963K kernel code, 153K rwdata, 404K rodata, 312K init, 196K bss, 5048K reserved, 0K cma-reserved)
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:51
Clocks: CPU:400.000MHz, DDR:400.000MHz, AHB:200.000MHz, Ref:25.000MHz
clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 9556302233 ns
sched_clock: 32 bits at 200MHz, resolution 5ns, wraps every 10737418237ns
Calibrating delay loop... 265.42 BogoMIPS (lpj=1327104)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 256 (order: -1, 3072 bytes)
NET: Registered protocol family 16
MIPS: machine is ZSUN WiFi SD Card Reader
Can't analyze schedule() prologue at 80067054
clocksource: Switched to clocksource MIPS
NET: Registered protocol family 2
TCP established hash table entries: 1024 (order: 0, 4096 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
Crashlog allocated RAM at address 0x3f00000
squashfs: version 4.0 (2009/01/31) Phillip Lougher
jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler deadline registered (default)
Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
ar933x-uart: ttyATH0 at MMIO 0x18020000 (irq = 11, base_baud = 1562500) is a AR933X UART
console [ttyATH0] enabled
console [ttyATH0] enabled
bootconsole [early0] disabled
bootconsole [early0] disabled
m25p80 spi0.0: found w25q128fw, expected m25p80
m25p80 spi0.0: w25q128fw (16384 Kbytes)
8 cmdlinepart partitions found on MTD device spi0.0
Creating 8 MTD partitions on "spi0.0":
0x000000000000-0x000000010000 : "u-boot"
0x000000010000-0x000000020000 : "u-boot-env"
0x000000020000-0x000000eb0000 : "rootfs"
mtd: device 2 (rootfs) set to be root filesystem
1 squashfs-split partitions found on MTD device rootfs
0x000000240000-0x000000eb0000 : "rootfs_data"
0x000000eb0000-0x000000fe0000 : "kernel"
0x000000fe0000-0x000000ff0000 : "nvram"
0x000000ff0000-0x000001000000 : "art"
0x000000040000-0x000000fe0000 : "myfirmware"
0x000000000000-0x000000030000 : "myuboot"
libphy: ag71xx_mdio: probed
ag71xx-mdio.1: Found an AR7240/AR9330 built-in switch
eth0: Atheros AG71xx at 0xba000000, irq 5, mode:GMII
NET: Registered protocol family 10
NET: Registered protocol family 17
bridge: automatic filtering via arp/ip/ip6tables has been deprecated. Update your scripts to load br_netfilter if you need this.
8021q: 802.1Q VLAN Support v1.8
VFS: Mounted root (squashfs filesystem) readonly on device 31:2.
Freeing unused kernel memory: 312K
init: Console is alive
init: - watchdog -
kmodloader: loading kernel modules from /etc/modules-boot.d/*
kmodloader: done loading kernel modules from /etc/modules-boot.d/*
init: - preinit -
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
mount_root: jffs2 not ready yet, using temporary tmpfs overlay
urandom-seed: Seed file not found (/etc/urandom.seed)
procd: - early -
procd: - watchdog -
procd: - watchdog -
procd: - ubus -
random: ubusd: uninitialized urandom read (4 bytes read, 14 bits of entropy available)
random: ubusd: uninitialized urandom read (4 bytes read, 14 bits of entropy available)
random: ubusd: uninitialized urandom read (4 bytes read, 14 bits of entropy available)
random: ubusd: uninitialized urandom read (4 bytes read, 14 bits of entropy available)
random: ubusd: uninitialized urandom read (4 bytes read, 14 bits of entropy available)
random: ubusd: uninitialized urandom read (4 bytes read, 14 bits of entropy available)
random: ubusd: uninitialized urandom read (4 bytes read, 14 bits of entropy available)
procd: - init -
Please press Enter to activate this console.
kmodloader: loading kernel modules from /etc/modules.d/*
ip6_tables: (C) 2000-2006 Netfilter Core Team
Loading modules backported from Linux version wt-2017-01-31-0-ge882dff19e7f
Backport generated by backports.git backports-20160324-13-g24da7d3c
ip_tables: (C) 2000-2006 Netfilter Core Team
nf_conntrack version 0.5.0 (950 buckets, 3800 max)
xt_time: kernel timezone is -0000
PPP generic driver version 2.4.2
NET: Registered protocol family 24
ieee80211 phy0: Atheros AR9330 Rev:1 mem=0xb8100000, irq=2
kmodloader: done loading kernel modules from /etc/modules.d/*
random: jshn: uninitialized urandom read (4 bytes read, 18 bits of entropy available)
random: jshn: uninitialized urandom read (4 bytes read, 18 bits of entropy available)
random: jshn: uninitialized urandom read (4 bytes read, 18 bits of entropy available)
jffs2_scan_eraseblock(): End of filesystem marker found at 0x0
jffs2_build_filesystem(): unlocking the mtd device... done.
jffs2_build_filesystem(): erasing all blocks after the end marker... 
device eth0 entered promiscuous mode
IPv6: ADDRCONF(NETDEV_UP): br-lan: link is not ready
IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
device wlan0 entered promiscuous mode
IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
br-lan: port 2(wlan0) entered forwarding state
br-lan: port 2(wlan0) entered forwarding state
IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
br-lan: port 2(wlan0) entered forwarding state
random: nonblocking pool is initialized
done.
jffs2: notice: (882) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
1 Like

nice work! :grinning:
Increase the space for the kernel would be a very nice move too :yum:

still running with image prepared for flash image with new memory layout :grin:

10 cmdlinepart partitions found on MTD device spi0.0
Creating 10 MTD partitions on "spi0.0":
0x000000000000-0x000000010000 : "u-boot"
0x000000010000-0x000000020000 : "u-boot-env"
0x000000020000-0x000000eb0000 : "rootfs"
mtd: device 2 (rootfs) set to be root filesystem
1 squashfs-split partitions found on MTD device rootfs
0x000000390000-0x000000eb0000 : "rootfs_data"
0x000000eb0000-0x000000fe0000 : "kernel"
0x000000fe0000-0x000000ff0000 : "nvram"
0x000000ff0000-0x000001000000 : "art"
0x000000000000-0x000000030000 : "newuboot"
0x000000030000-0x000000040000 : "newubootenv"
0x000000040000-0x000000240000 : "newkernel"
0x000000240000-0x000000fe0000 : "newrootfs"

Hi, Eddiecz,
Would you like to consider a PR for uboot-mod?
or push the change to your fork repo?

At this time no, work is not yet complete, i'm working on uboot with Zsun SD card recovery, then you will not need a serial port.

4 Likes