Hacking Build your own dongle (Research and development thread)

Wierd_w

Well-Known Member
OP
Member
Joined
May 12, 2018
Messages
406
Trophies
0
Age
41
XP
651
Country
United States
This is the R&D thread. This is for people who want to know the nitty gritty of making their own dongle from sources, and has my thoughts through each stage of my process.
The user-friendly "Do this, this, this and this" tutorial will come after.

Disclaimer out of the way-- Here we go.


_________GREAT BIG EDIT____________

Ok. First up, the zsun is a "much soldering required" solution. My garbage hands are too shaky to even try this again. However, it will require an external power supply of some kind as the NX does not supply voltage on the USB voltage rail when in RCM mode. This means that in addition to the soldering hack to disable the card-reader and pass the port directly to the SOC, you will need some kind of battery. The contact points are tiny. VERY tiny. A small fraction of a millimeter tiny.

For these reasons, I recommend going with a platform that is much easier to work with. Currently, there are 2 major choices:

1) Fusee-lede based injectors

This is a flashable image for the "unbranded" A5-V11 hardware platform. This hardware is mostly known as something along the lines of "3G router 150m" and the like.. It comes in multiple hardware revisions, and two major form factors. One of the form factors is "without battery", while the other contains a useful battery and a power switch.

They look like this, respectively:

WITHOUT BATTERY
A76H_130772749067521634gQnztpligk.jpg


WITH BATTERY
New-Portable-Battery-Inbuilt-3G-Wifi-Router.jpg_350x350.jpg


There are now at least 5 builds of flashable images for this hardware that verious people have built. All are based on the initial modified lede instructions and injector code supplied by Retr0id. (read further into the thread, or search for 'fusee-lede')

***CAUTION***
This hardware has many many many internal hardware variations! While this is in theory a "cheap, solderless, and mostly painless" off-the-shelf solution, the factory of origin is still unknown, there is no known means to identify which internal hardware variant you are getting when you buy one, and there are several reports of bricked devices which likely stem from this hardware non-uniformity.

This same code-base is meant for just about any router or device that openWRT or LEDE supports, so it can be built for more devices than can be counted. The targeted platform for the project was the cheap chinese "3g router" specified however. It can be built for a very wide assortment of devices that support openwrt/lede, as long as the device has a USB2 port that can do host-mode.


PROS:
--SOLDERLESS
--INEXPENSIVE
--COMES WITH NICE INJECTION MOLDED HOUSING
--CAN PERFORM ANCILLARY FUNCTIONS (local file server, DNS host, Wifi bridge, etc.)

CONS:
--HARDWARE ROULETTE
--SLOW (Device takes ~30 seconds to boot itself before it can perform injections)

2)
Trinket M0 based injector(s)

These are devices based around the Adafruit Trinket M0, and Feather M0. The hardware is very uniform, as Adafruit does not screw around. This requires soldering, but the work of building the binary image for these microcontrollers has already been completed. The solder points are nice through-holes (aside from the USB port, but you can use solderless solutions on those.) and the skill needed to perform the work is significantly reduced from that needed for the zsun. The feather M0 has built-in battery charge logic, and a convenient JST battery connector. Ninoh_fox gets the credits for building the first functioning unit. Several variations of this offering have appeared in various youtube videos of internalized modchips for the NX console, as the trinket M0 is already very small, and is very fast.

PROS:
--RELIABLE, CONSISTENT HARDWARE SOURCE
--FAST (Ready to inject in just a few milliseconds.)
--CAN BE INTERNALIZED
--NICE THROUGH-HOLE SOLDER POINTS
--VERY SMALL

CONS:
--REQUIRES SOLDERING
--MORE EXPENSIVE (in total) THAN FUSEE-LEDE
--LACKS SHELL
--LACKS BATTERY



-----------------
For posterity, here is the remainder of the original post.

First an old post from another discussion topic so it does not get lost--

I was really hoping to not have to do surgery on the dongle, but looking closely at the pictures of the PCB from the hacking documents/research, I am going to have to.

There will need to be some slight soldering modifications to the device so that host mode data pins are exposed through the port. This sadly means sacrificing either the ability for the device to read the sdcard slot, or for the device to function as an sdcard reader for the host. I am going to elect sacrificing the ability for the device to read the sdcard slot. (Picking option 1 below.)

The reasoning is simple:

The designers included a 2 output select highspeed switch (that is fully bidirectional), that (as currently wired), switches the SDCard reader's data pins between either the SoC's USB root hub, or the USB-A connector. (this means that as wired, the USB-A plug cannot talk to the host's root hub.)

We have two options:

1) (Make the USB-A interface become the item that gets switched)
De-solder the contact going into the highspeed switch where the SDCard interface board talks, and remove the 2 pin header from the daughter board
Solder 2 patch wires into the header holes on the daughter board
Solder 2 patch wires onto the USB-A connector's D+ and D- contact pads
VERY CAREFULLY cut the traces on the motherboard that connect the SW1 D+ and D- pads of the highspeed switch to the USB-A interface
Run the USB-A patch wires into the switch's input header holes
Run the SDCard reader's patch wires into the teeeeeny tiny contact points of the surface mount switch's SW1 points. (Or look for testpoints on the PCB, and connect there.)

2) (Make the SoC host interface become the item that gets switched)
Hunt down contact points for the SoC's D+ and D- lines, and attach jumper wires
VERY CAREFULLY cut the traces after the SoC contact points we are using that lead to the switch
Desolder and remove the 2 pin header from the SDCard daughter board
Solder jumper wires to the header pin holes on the daughter board
Solder the SoC jumper wires to the switch input header pin holes
Solder the CardReader jumper wires to SW2 data pins (look for testpoints)

I think option 1 is less likely to have issues. (I dont have to hunt for as many test pads, and it should be easier to cut the traces) It will also allow the console to read the SDCard slot after the appropriate GPIO is asserted. Access to the RCM mode console is enabled because the highspeed switch is bidirectional, when the GPIO is low. The downside is that the SoC cannot see or use the card reader.

Option 2 allows the SoC to see the card reader, but denies the console access to the slot. It is also harder to pull off I think.


Given the issues I have faced trying to get a suitable bare image for the zsun built (due to small SPI flash, only 16mb), I think "candidate 2" I linked previously is a no-go, (Only 4mb SPI flash) even though it would be solderless. (has fully exposed host interface) I will look into other options that could be done that are fully solderless, but they are more expensive, and I am not made of money. (For the cost of 2 hardware test articles, I could buy a switch game and have much more fun.)[/QUOTE]


Addendum:

There's also the "Super easy" choice where we sacrifice both, by unsoldering the two pins to the SDcard reader, jumpering straight to the data pins on the port, and hooking nothing else up. That would make the GPIO toggle basically be "Host connected to port." and "Nothing connected." (actually, port connected to itself, so nothing.)

For simplicity, I will take this last option until I more completely explore this device.

----

And now for the fun part.

The dongle has arrived.

It's much smaller than I expected.

0518182348.jpg


Initial research:

Device comes stock with an ancient linux kernel, and hyper-minimal embedded linux userspace. (2.6.31 !! BLECH!!)
Device's USB driver is NOT baked into the kernel; It is loaded as a module.
Device's root file system is writable!? (No, it's NOT tmpfs! It's totally jffs2!)
Device has root access via hidden telnet on port 11880. Username: root Password: zsun1188

This means the option to just recompile ehci-hcd.ko with FoF's patch, and sideload python (without flashing openwrt) is possible, but I wont be doing that. (Already built openwrt, which while an old version, is much newer than this kernel. 3.xxx kernel.)

I have already dumped the partitions and backed them up. Going to attempt firmware update. (If I fail, I will solder serial console header on, and recover)
Wish me luck.
 
Last edited by Wierd_w,

Wierd_w

Well-Known Member
OP
Member
Joined
May 12, 2018
Messages
406
Trophies
0
Age
41
XP
651
Country
United States
Now then-- Compiling sources.

I am lazy, and grabbed this Emeryth guy's repo with git.

Once we start the building process (and get past the initial toolchain build, which takes FOR-EV-ER), we have to add FoF's patch to ehci-hcd.c in the linux kernel source

You can find the patch here:
https://github.com/fail0verflow/shofel2/blob/master/linux-ehci-enable-large-ctl-xfers.patch

You can do this manually (Like I did, since it is just a simple deletion) but you have to be fast before the compiler gets there.

You will also need to patch bzip2's make file, so that it can be built properly, otherwise the python package will break. You can find the needed patch here:
https://git.archive.openwrt.org/?p=...ff;h=6a69e3064bdfa320f85d730c8d017f69c0215f6b
 

Wierd_w

Well-Known Member
OP
Member
Joined
May 12, 2018
Messages
406
Trophies
0
Age
41
XP
651
Country
United States
Flashing images:

Emeryth's research is damn useful. He has found that there is a hidden upgrade utility in the stock firmware that is pretty hard to screw up. You can pull his flash update builder script here:
https://code.hackerspace.pl/informatic/zsun-fw-tools

I had some issues though. The firmware inside my zsun apparently does not expose the SMB share the auto-flasher uses. Instead, it has an HTTP PUT method based uploader through the web portal. I used that to upload the update file, then used the hidden telnet to move it to the correct location. Then I triggered the update by loading the magic URL.

Chaos Calmer now running on the zsun.


Next up, getting nano and python installed using ipkg. The built-in ssh daemon (dropbear) apparently does not like allowing connections over sftp. I DO however, have wget.
 

OllieD

Active Member
Newcomer
Joined
Dec 31, 2008
Messages
43
Trophies
1
XP
703
Country

Wierd_w

Well-Known Member
OP
Member
Joined
May 12, 2018
Messages
406
Trophies
0
Age
41
XP
651
Country
United States
if you were not aware this thread has some useful info on the zsun.

https://forum.lede-project.org/t/supporting-zsun-wifi-card-reader-16mb-flash-64mb-ram-ar9331/

I recovered one of these devices from a bad flash last weekend.

I can highly recommend Eddiecz's uboot mod:

https://mega.nz/#F!BnJChJAS!kK_QLnrnjGvBzxMdR9Ud-Q

ymodem upload over serial was way faster than uboot_write which kept failing for me.


Nice to know, but using the built-in flasher worked a treat. Already on Chaos Calmer.

@hippy dave The converter is now proven to supply power to the dongle. It boots fine. I have gotten nano and python (2.7 but hey... embedded device yo. I can also put python 3 if I need it.)

Next is hardware modification.
 
  • Like
Reactions: hippy dave

The Real Jdbye

*is birb*
Member
Joined
Mar 17, 2010
Messages
23,284
Trophies
4
Location
Space
XP
13,840
Country
Norway
If this works, you're going to make a lot of people happy.
Good luck with it.
I was thinking we would have to make something using a Teensy or something similar, which would be bigger and also would not come in a nice case, this would be a much better solution.

Also, how much does that dongle cost?
 

Wierd_w

Well-Known Member
OP
Member
Joined
May 12, 2018
Messages
406
Trophies
0
Age
41
XP
651
Country
United States
If this works, you're going to make a lot of people happy.
Good luck with it.
I was thinking we would have to make something using a Teensy or something similar, which would be bigger and also would not come in a nice case, this would be a much better solution.

Also, how much does that dongle cost?

Dongle + 2pack USB-C adapter block == 20$ from amazon with prime.

This thing can potentially do much more than a teensy. It is a 200mhz-ish SoC (MIPS), with 64mb of RAM and 16mb of SPI flash, with TWO hardware wifi controllers. This thing can run straight up Linux. (That's what OpenWRT is, essentially.)

This thing can download stuff from bittorrent, host a VPN tunnel, do all sorts of bells and whistles. Right now, I just want it to do the autoinjection payload thing.
 

The Real Jdbye

*is birb*
Member
Joined
Mar 17, 2010
Messages
23,284
Trophies
4
Location
Space
XP
13,840
Country
Norway
Dongle + 2pack USB-C adapter block == 20$ from amazon with prime.

This thing can potentially do much more than a teensy. It is a 200mhz-ish SoC (MIPS), with 64mb of RAM and 16mb of SPI flash, with TWO hardware wifi controllers. This thing can run straight up Linux. (That's what OpenWRT is, essentially.)

This thing can download stuff from bittorrent, host a VPN tunnel, do all sorts of bells and whistles. Right now, I just want it to do the autoinjection payload thing.
Sure, but for this purpose, none of that is needed or even useful. You could do all that on Switch Linux.
Price is decent though. A Teensy isn't going to be any cheaper either.
It'll be a good alternative to SX, once Atmosphere releases and there's a warez loader at least.
And the extra MicroSD could prove useful.
Got a link to where to buy this? I'm not going to buy one (at least not now) but I'm curious about this device and what exactly it is.
 
Last edited by The Real Jdbye,

Wierd_w

Well-Known Member
OP
Member
Joined
May 12, 2018
Messages
406
Trophies
0
Age
41
XP
651
Country
United States
Sure, but for this purpose, none of that is needed or even useful. You could do all that on Switch Linux.
Price is decent though. A Teensy isn't going to be any cheaper either.
It'll be a good alternative to SX, once Atmosphere releases and there's a warez loader at least.
And the extra MicroSD could prove useful.
Got a link to where to buy this? I'm not going to buy one (at least not now) but I'm curious about this device and what exactly it is.

Indeed. Speaking of the shell-- it opens VERY easily. Insert a razor blade into the small crease near the bottom, and gently lever it. It is basically a sleeve over the plastic bottom plug, and all the parts slide apart fairly easily with the right motivation.

JESUS is this thing tiny inside. I hope I can solder this small.
 

The Real Jdbye

*is birb*
Member
Joined
Mar 17, 2010
Messages
23,284
Trophies
4
Location
Space
XP
13,840
Country
Norway
Indeed. Speaking of the shell-- it opens VERY easily. Insert a razor blade into the small crease near the bottom, and gently lever it. It is basically a sleeve over the plastic bottom plug, and all the parts slide apart fairly easily with the right motivation.

JESUS is this thing tiny inside. I hope I can solder this small.
Bonus points if you can integrate the OTG adapter into the device :)
 

TheSynthax

Well-Known Member
Member
Joined
Apr 29, 2018
Messages
220
Trophies
0
XP
509
Country
United States
Arrived at the same time, but have not tested that yet.
Have you considered deconstructing this adapter, removing the SD port, USB plug, etc. and placing it in your Switch? Could untether the exploit by flipping a bit somewhere in the bootloader to corrupt it, forces RCM every boot and a custom payload could switch between stock, CFW, Linux boot based on holding vol- or vol+ or something similar.
 

Wierd_w

Well-Known Member
OP
Member
Joined
May 12, 2018
Messages
406
Trophies
0
Age
41
XP
651
Country
United States
Have you considered deconstructing this adapter, removing the SD port, USB plug, etc. and placing it in your Switch? Could untether the exploit by flipping a bit somewhere in the bootloader to corrupt it, forces RCM every boot and a custom payload could switch between stock, CFW, Linux boot based on holding vol- or vol+ or something similar.


To be perfectly honest, my hands shake terribly from years of abuse doing computer work. (Carpal tunnel for the lose.) Soldering is not my finest skill. I will leave it at that.

I am much more proficient with the embedded linux software side of things. As such, the less I have to solder things tinier than .5mm (which is how tiny the contacts on this thing are! ERGH!! I feel like I am about to try soldering a surface mount finger-landing type IC by hand! I dont have a clamp rig either!) the better!

I am quite happy to have the adapter piggy backed on the dongle. As is, I am going to remove the SD-Card daughter board as carefully and slowly as I can, remove the 2 pin header (which is tiny as shit!), and do a direct wire to the USB data pins. Then I will carefully put the daughter board back on. (It has the 3v regulator and some other goodies on it, so I kinda need it.)

If some other people in our merry band of cut-throats and villains has extra special soldering skills, and wants to use my software to make and sell these thing, I am totally down with that. First is the proof of concept though.
 
  • Like
Reactions: leproos

TheSynthax

Well-Known Member
Member
Joined
Apr 29, 2018
Messages
220
Trophies
0
XP
509
Country
United States
To be perfectly honest, my hands shake terribly from years of abuse doing computer work. (Carpal tunnel for the lose.) Soldering is not my finest skill. I will leave it at that.

I am much more proficient with the embedded linux software side of things. As such, the less I have to solder things tinier than .5mm (which is how tiny the contacts on this thing are! ERGH!! I feel like I am about to try soldering a surface mount finger-landing type IC by hand! I dont have a clamp rig either!) the better!

I am quite happy to have the adapter piggy backed on the dongle. As is, I am going to remove the SD-Card daughter board as carefully and slowly as I can, remove the 2 pin header (which is tiny as shit!), and do a direct wire to the USB data pins. Then I will carefully put the daughter board back on. (It has the 3v regulator and some other goodies on it, so I kinda need it.)

If some other people in our merry band of cut-throats and villains has extra special soldering skills, and wants to use my software to make and sell these thing, I am totally down with that. First is the proof of concept though.
Just bought one to experiment with internalization, will report back later on. I'll check back here on your progress!

Edit: I wonder if that would interfere with docked mode in any way, or drain the Switch measurably faster. Probably not, but worth considering.
 
Last edited by TheSynthax,

Retr0id

Active Member
Newcomer
Joined
Apr 12, 2018
Messages
33
Trophies
0
Age
54
XP
441
Country
United Kingdom
I just ordered one of these things: https://www.ebay.co.uk/itm/381347616902 (£10 shipped)
It has an on-board battery, and usb host mode out-of-the box.

It is also well documented on the openwrt wiki: https://wiki.openwrt.org/toh/unbranded/a5-v11 (See the bottom of the page)

So in theory, this thing just needs a minor firmware/software change and then it's ready to go!

This undercuts TX in price, is equally user-friendly, and has way more potential features! (Wi-Fi payload updates anyone? )

Edit: just found another listing for only £8: https://www.ebay.co.uk/itm/282771298892
 
Last edited by Retr0id,

Wierd_w

Well-Known Member
OP
Member
Joined
May 12, 2018
Messages
406
Trophies
0
Age
41
XP
651
Country
United States
I just ordered one of these things: https://www.ebay.co.uk/itm/381347616902 (£10 shipped)
It has an on-board battery, and usb host mode out-of-the box.

It is also well documented on the openwrt wiki: https://wiki.openwrt.org/toh/unbranded/a5-v11 (See the bottom of the page)

So in theory, this thing just needs a minor firmware/software change and then it's ready to go!

This undercuts TX in price, is equally user-friendly, and has way more potential features! (Wi-Fi payload updates anyone? )

Edit: just found another listing for only £8: https://www.ebay.co.uk/itm/282771298892


The problem with that one is the flash is too small.

AND-- I just totally hoosiered the zsun trying to solder something so damn tiny, with shaky assed hands, a shitty soldering iron that had the tip melting off in just a few minutes from rosin core solder, and my abysmally bad luck. (There is a reason I try not to solder anything, and it is because I am all fucking thumbs at it.)

I will look for a solder-free alternative platform that has immediate host mode access, and has a decent amount of flash.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    SylverReZ @ SylverReZ: @AncientBoi, My friend passed away 3 days ago. :( +1