Zsun Wifi card reader is a tiny micro SD card reader with WiFi connectivity, and while people managed to access the device serial console a few months ago, the plan was to eventually run OpenWrt since it’s based on the popular Atheros AR9331 WiSoC combined with 64MB RAM and 16MB SPI Flash. It would also be one the smallest OpenWrt capable device with dimensions of 30 x 33 mm.
A team of Polish managed this feat, and have now posted instructions to install OpenWrt, as well as other documentation, for example a description of the board’s GPIOs.
There are four methods to flash OpenWrt:
- Solder on an Ethernet jack and flash from the original uboot (hard but safe)
- Reflash the bootloader from the original firmware to one that supports upload over serial (less soldering but fatal if you mess up)
- Reflash the firmware from the original firmware using mtd_write (easy but you have to do it right on the first try)
- Attach a programmer to the flash chip (impossible to mess up)
I’ll reproduce the method with mtd_write here, as although you may potentially brick your device, it’s the easiest (no hardware hack):
- Download OpenWrt for Zsun binary images
- Start a TFTP server on your computer. If you use a Linux computer, you can use dnsmasq as follows:
12sudo dnsmasq -p0 --enable-tftp --tftp-root=`pwd` -d --user=`whoami`# serves files off your current directory, remember to chmod o+r files you'd like to use - Login to the board, and download the necessary files to zsun’s /tmp directory:
123456789$ socat - TCP4:10.168.168.1:11880(none) login: rootPassword: zsun1188[...]# cd /tmp# tftp -g 10.168.168.100 -r openwrt-ar71xx-generic-zsun-sdreader-kernel.bin# tftp -g 10.168.168.100 -r openwrt-ar71xx-generic-zsun-sdreader-rootfs-squashfs.bin
You may also want to copy /sbin/mtd_write to /tmp, and kill all unnecessary process to be extra safe. - Now you can flash the firmware to “uImage” and “rootfs” partitions:
123456789101112131415# cat /proc/mtddev: size erasesize namemtd0: 00010000 00010000 "u-boot"mtd1: 00010000 00010000 "u-boot-env"mtd2: 00e90000 00010000 "rootfs"mtd3: 00130000 00010000 "uImage"mtd4: 00010000 00010000 "NVRAM"mtd5: 00010000 00010000 "ART"# mtd_write write openwrt-ar71xx-generic-zsun-sdreader-kernel.bin /dev/mtd3Unlocking /dev/mtd3 ...Writing from openwrt-ar71xx-generic-zsun-sdreader-kernel.bin to /dev/mtd3 ... [w]# mtd_write write openwrt-ar71xx-generic-zsun-sdreader-rootfs-squashfs.bin /dev/mtd2Unlocking /dev/mtd2 ...Writing from openwrt-ar71xx-generic-zsun-sdreader-rootfs-squashfs.bin to /dev/mtd2 ... [w]Bus error
“Bus error” looks like an error, but in this case it just indicates flashing is complete. - Restart the device, and after a longer than usual very first boot, you should have access to OpenWrt. Have fun 🙂
So once you’re done, what you can do with the device? Some ideas of the developers include just serving files over WiFi, using it as a WiFi AP/client/repeater, as the brain for an IoT project, mesh networking, PirateBox, mini Tor server, and more.
Zsun WiFi card reader can be purchased for as low as $10.99 on Banggood, and can be found on others shops for $11+ to about $15 such as DealExtreme, GearBest or Aliexpress.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress
Will try that now. Nice to hear! Will test if the SOIC can behave as master+client mode at the time.
What is the transfer speed when reading/writing to SD card?
What I would like to make is a networked SD card writer with integrated SD card MUX – switching SD card to the reader or to the target device. Something like this: http://www.linuxinternals.org/blog/2014/06/04/a-microsd-card-remote-switcher/
I have this with USB based writer already.
@Peter
If I understood correctly the circuit of the “MicroSD card switcher” you linked to, it is controlled via an FTDI cable. Maybe replacing the FTDI with an ESP8266 would make the job. Esp-link is supposed to replace the FTDI cable for AVR flashing, now I don’t know what the FTDI does in reality with that circuit, if it is a simple serial port console, then it is easy to replace with an ESP.
@zoobab
The switch program seems to use Bitbanging, so it will be more complicated to replace with an ESP, but the code seems to be very trivial.
so it’s not possible to change the host/device mode using only software as i understand? In which mode is the device by default? I thought it should be in device mode, why are they talking about disabling host mode by desoldering a resistor?
The SoC USB port cannot be connected to the USB plug without resoldering the connections.
USB plug | SoC USB port
………..|………|
………..V………V
………USB switch
……………|
……………V
……..SD card reader
She SoC USB port is soldered for host mode, since it needs to control the SD card reader.
@zoobab
This circuit is just an example. I have prototype build with TS3A27518E mux/demux. And it it working fine with USB card reader with write speed around 17 MB/s. Not as fast as it should probably because of bad prototyping.
But would be great if I could made ethernet device.
I would say ESP8266 would be way to slow.
@Peter
I meant replacing the FTDI with an ESP. I had a look at this solution to be able to reflash an SD card for a CI testbed for openwrt. The board was only booting from a flashed SD card.
@zoobab
Ok, I understand wrong then. You mean using ESP only to control switch.
Seems I’m using my prototype device in similar way as you. I have USB card reader, analog switches for SD card signals and one flat cable with SD card connector at the end. Something like this https://plus.google.com/+MichaelGebetsroither/posts/eS4VYkW7Jny?pid=5742485398778944786&oid=104422661029399872488
I’m using this design for devices which needs SD card to boot. It has external switch to control the flow (SD card to card reader or target device).
LAVA Validation Lab is using something similar but much more powerful (have the schematic from them).
@anon
So there is no way to control it by software? I can image this reader plugged into digital picture frame (has only USB input) serving photos. These photos can be “delivered” one per day from server, ex. openwrt’s cron on ZSun fires up the user script, switches card to wireless client (STA) and transfers pictures from server to sd card.
Zsun direct sells this through Amazon…
http://www.amazon.com/zsun%C2%AE-Memory-Reader-MicroSD-Flash/dp/B00UT1MC9W
Price is a bit higher, but if you’ve got Prime, it would be a good thing to add this to your list of suppliers since there’s no shipping costs involved.
@rufik
I would also like to do this. It must be possible for software to switch the card reader back and forth between the SoC and the USB plug, since the “Setcardworkmode” URL in the built-in firmware apparently does this, as described here: https://wiki.hackerspace.pl/projects:zsun-wifi-card-reader:factory-update
If someone could figure out how it does that, and port it to OpenWRT, I’d be happy.
(I don’t know if I’d actually use it with an always-on device like a digital picture frame, though, since it seems to get pretty warm when running.)
I lost WiFi connection during mtd_write to /dev/mtd2. I used telnet instead of socat, and did not kill any background programs… I don’t have any ESSID now, so I guess I’ll have to open it.
Oh, I wish I had seen this first: https://wiki.hackerspace.pl/projects:zsun-wifi-card-reader:factory-update
A easier and safer update method using Zsun own update procedure.
Nope, I don’t like ads. If you don’t either, you should stop plastering them all over your site. But, it doesn’t really matter. I choose to block ads, regardless of what you like.
By the way, I do not find this blog useful. But, since you asked about my preferences, I thought it was polite to answer your question.
Bye.
@Jean-Luc Aufranc (CNXSoft)
hi,
i had the same issue.
how did you recover the device?
thanks
@maurer
No. I decided not to spend time on it.