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

I'm very sorry that you're having those issues with your Zsun-SD100, and from what you describe it seems that you have a bricked device.
I can only assume some kind of data corruption occurred while flashing the update image. Even though the instructions include a number of failsafes (like checking md5sum, remounting filesystems to read-only, using a tmp filesystem, ...) there's still a small chance of data corruption since we're overwriting the operating system that is running at that moment!

Recovering from this condition is not easy since it requires soldering on very small pads to have access to the device serial port, but I would suggest checking Emeryth's blog for more details.

Regarding your question about the recovery firmware, it's very much a standard OpenWrt firmware that has been slightly customized to:

  • Allow booting from a read-only MTD partition;
  • Execute the split firmware on the recovery partition instead of the default firmware partition (this is the kernel code responsible for splitting the image partition into the sub-partitions: kernel+rootfs+rootfs_data);
  • Use a memory filesystem instead of JFFS2 for the overlay.

The firmware to boot (main or recovery) is selected by the U-Boot bootloader during the initial seconds of plugin the device to the USB, by triggering its recovery script through the recovery button.

For the Zsun-SD100, U-Boot's recovery button is mapped to the state of the SD-Card:

  • SD-Card inserted: U-Boot sees it as recovery button NOT pressed;
  • SD-Card ejected: U-Boot sees it as recovery button pressed.

When you connect your device to the USB port, U-Boot initializes the hardware and then goes through the following checks:

  • If the recovery button is NOT pressed (SD-Card inserted) then it immediately boots the main firmware;
  • If the recovery button is pressed (SD-Card ejected), then it executes the recovery script:
    »» For 3 seconds, periodically check if the recovery button was released (SD-Card inserted), and if that happens then immediately boot the recovery firmware;
    »» If the recovery button was not released (SD-Card was not inserted) after those 3 seconds, then fallback to booting the main firmware.


Is there anyone else also having issues booting the recovery image but still with access to the main firmware? (if so, then please check the new section of the README file and follow its instructions to reflash the recovery image)

3 Likes

Would the patch for 19.07.0 also work on the 19.07.1 and 19.07.2 releases?

I assume you're talking about the Image Builder patch - no, it will not work for any other release other the one it was built for (it contains the compiled kernel for the Zsun-SD100).

You can grab the new patches for 19.07.1 and 19.07.2 from the GitHub repository.

2 Likes

How i can build custom image for this stick? Custom without recovery mod\partition

Let me start by saying that I strongly recommend you to leave the recovery partition on your device!

However, if you really want to go forward with your project without a recovery partition, you can use the patches from the GitHub repository with the following adjustments:

  • For the u-Boot patch (*), update the ap121.h file:
    • Adjust CONFIG_BOOTARGS:
      • Remove the recovery partition from mtdparts;
      • Increase firmware size to 16128k.
    • Remove the defines for the recovery script:
      • CFG_LOAD_ADDR_RECOVERY;
      • CONFIG_BOOTCOMMAND_RECOVERY;
      • CONFIG_ENV_BTN_RECOVERY_SCRIPT.
    • Change the size of WEBFAILSAFE_UPLOAD_LIMITED_AREA_IN_BYTES to (256 * 1024).
  • For the OpenWrt patch:
    • Change the ar9331_zsun_sd100.dts file:
      • Remove the recovery partition;
      • Increase the firmware partition size to 0xfc0000.
    • Change the generic.mk file:
      • Increase the IMAGE_SIZE to 16128k.

(*) Please note that you must flash a new u-Boot to your device to be able to use a recent OpenWrt version (due to the kernel size).

1 Like

start by saying that I strongly recommend

Thanks) I know what is very bad idea, but i have two zsun and if i brick adapter w\o recovery partition, i just flash dump from another adapter, just i need use flash in another style, and recovery just breack my idea.
P.S. Sorry for my bad english, i learn as possible in my situation....

How make from ONE PHYSICAL adapter - one virtual adapter that will look on the Internet and give the web page an owrt (i plane make it from tor hidden service which cant work from ISP NAT), the second adapter (virtual) for access from the LAN (if zsun will be unavailable from the Internet) in the access point mode and the third adapter, for working with networks (such as LANs and other) - i will make custom zsun, which will work as "passthrough" for working with several internal LANs via the Internet (in turn, of course) for my friend so that he doesn’t have to travel to the same buildings in different office several times (he’s just in poor health).

i make as you write and i get error:

Please setup your build environment as described here.

On my Arch Linux machine already installed all this packages - i successfully compile any openwrt images.
And original u-boot (with recovery partition) successfully compile any time.

If I'd have to guess, you didn't follow the instructions properly and also deleted the line (which must be kept!):

#undef CONFIG_CMD_HTTPD

Please be careful with the u-Boot changes, if you get a brick due to u-Boot failure then you cannot recover your device even if you soldered the pins for serial access!

Oh, sorry - I did not sleep all night, I think tight
https://pastebin.com/viZJk1Ur

You cannot edit the patch files directly without adjusting the offsets, otherwise you break the files.
Either manually change the files as described, or apply one of the following incremental patches after the original U-Boot patch:

Although the above patches compile successfully, I have not tested neither of the resulting binaries!

I flash Your version u-boot but it doesn't show anymore from serial port - 115200 8N1, rx to tx on com adapter, tx to rx. How activate it? I need restore owrt image on zsun.

As previously mentioned, I have not tested these non-recovery U-Boot versions but if it was patched, compiled and flashed correctly then the serial output should still be working - it's possible something went wrong there.

No, i install recovery version - w\o recovery just for future and not compiled yet.

If you have locked yourself out of your device without recovery and without serial access to U-Boot then I guess you have bricked your Zsun-SD100... =/

Unfortunately I can't help you with that situation, but perhaps someone else might have some suggestion.

I have soldered UART, but it inaccesible(. Can i flash spi flash without desoldering?

In this case it will be tricky, since the SPI flash is a QFN package. Maybe you can build something to make a contact to the pads.

The pre-compiled image for OpenWrt 19.07.3 (main firmware) and upgrade instructions are now available (link).

The documentation has also been updated with instructions on how to use the patches for the official OpenWrt Image Builder (link).

10 Likes