Web hosting

Saturday, August 18, 2012

Funky Firmware

I've been examining my home network. Part of this process has obviously involved examining firmware upgrade options for embedded routers such as OpenWRT, DD-WRT, and Tomato. I have a Linksys WRT-54GL lying around but due to the flash constraints (it runs with 4MB flash and 8MB RAM) I've also been investigating other options (including hardware mods) and alternative hardware for a reasonable (sub-100). The hardware mods (such as USB, SD, Serial, etc...) aren't all that difficult. The main thing to take into consideration though is that this is the Internet. Information will vary in quality, people have slightly different hardware, and of course the way people communicate isn't always clear. Nonetheless, an SD card mod is very much a viable (and easy if you are a semi-decent solderer) option if you need more space for software installation (though indications of a short aren't exactly easy to decipher in the logs though).

Log entry with bad soldering job for SD mod.

[INFO] mmc_hardware_init: initializing GPIOs
[INFO] mmc_card_init: the period of a 380KHz frequency lasts 524 CPU cycles
[INFO] mmc_card_init: powering card on. sending 80 CLK
[INFO] mmc_card_init: 80 CLK sent in 43663 CPU cycles
[INFO] mmc_card_init: resetting card (CMD0)
[FATAL] mmc_card_init: invalid response from card: ff found, waiting for 01
[INFO] mmc_card_init: the period of a 380KHz frequency lasts 524 CPU cycles
[INFO] mmc_card_init: powering card on. sending 80 CLK
[INFO] mmc_card_init: 80 CLK sent in 43275 CPU cycles
[INFO] mmc_card_init: resetting card (CMD0)
[FATAL] mmc_card_init: invalid response from card: ff found, waiting for 01
[ERROR] mmc_init: got an error calling mmc_card_init: 01
[ERROR] mmc_check_media: change detected but was not able to initialize new card: ffffffff

Log entry with good soldering job for SD mod.

[INFO] mmc_hardware_init: initializing GPIOs
[INFO] mmc_card_init: the period of a 380KHz frequency lasts 524 CPU cycles
[INFO] mmc_card_init: powering card on. sending 80 CLK
[INFO] mmc_card_init: 80 CLK sent in 43646 CPU cycles
[INFO] mmc_card_init: resetting card (CMD0)
[INFO] mmc_card_init: doing initialization loop
[INFO] mmc_card_init: card inited successfully in 354 tries (10920782 CPU cycles).
[INFO] mmc_init: MMC/SD Card ID:
01 50 41 53 30 31 36 42 45 8a 16 3f b4 00 59 1f [INFO] Manufacturer ID   : 01
[INFO] OEM/Application ID: PA
[INFO] Product name      : S016B
[INFO] Product revision  : 4.5
[INFO] Product SN        : 3a529fb1
[INFO] Product Date      : 2005-9
[INFO] mmc_card_config: size = 14560, hardsectsize = 512, sectors = 29120
[WARN] mmc_init: hd_sizes=14560, hd[0].nr_sects=29120
[INFO] mmc_card_init: set_blocklen (CMD16) succeeded !
Partition check:
 mmca: p1


Along the way, I obviously found some interesting information about the hardware as well. One thing which surprised me though was how little exploration (it seemed that way to me) was done of the onboard voltages though. Some of the extraneous circuits out just didn't seem to be required. On my board alone there seemed to be stable sources for 2 (LEDs), ~3 (JTAG/Serial), 1.8, 5, 15 (DC Jack) volts around various areas of the board (with some clever programming and/or wiring you may also be able to extract decent/stable voltages from the Ethernet ports as well).

Please note that there is a difference in signalling/voltage between the onboard JTAG and standard RS-232 serial ports though. Note also, that while the difficulty of the solder job to create onboard serial/JTAG ports is trivial the USB job is can be extremely difficult if not well thought out or if you don't have adequate equipment on hand.


Note that if you end up using the Ritmo HL-340 USB to serial adapter you'll need the ch341 kernel module under Linux and the following driver for Windows 64 Bit (not included on the support CD that I received).

Bus 002 Device 004: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

[130081.190436] usb 3-1: new full speed USB device number 2 using uhci_hcd
[130081.349157] usb 3-1: New USB device found, idVendor=1a86, idProduct=7523
[130081.349171] usb 3-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[130081.349182] usb 3-1: Product: USB2.0-Ser!
[130081.467336] usbcore: registered new interface driver usbserial
[130081.467386] USB Serial support registered for generic
[130081.467474] usbcore: registered new interface driver usbserial_generic
[130081.467482] usbserial: USB Serial Driver core
[130081.480724] USB Serial support registered for ch341-uart
[130081.480788] ch341 3-1:1.0: ch341-uart converter detected
[130081.492731] usb 3-1: ch341-uart converter now attached to ttyUSB0
[130081.492825] usbcore: registered new interface driver ch341

I explored a number of options for a full router upgrade (but D-Link/Netcomm/NetGear were prime options simply because I had credit at my local Officeworks store). Here are some of the options. Note, that most on-line reviews of D-Link hardware seem to indicate that these are terrible devices in their normal guise/firmware configuration (they also seem to have a history of releasing bad first versions but solid subsequent revisions (read Amazon reviews)) but with better firmware they can make extremely good, inexpensive pieces of hardware.


Moreover, depending on your router choice you may be able to gain 3G backup capability (via USB modem).


Another choice of course is to simply turn a spare PC/laptop/netbook into a router and use a crossover cable to keep things going (laptop is obviously a decent choice since it basically has its own backup power system).


3G setup is actually fairly easy (depending on the modem) under Linux (I've seen and heard of bad things when it comes to many OEM software driver setups).
usb_modeswitch -v [Vendor ID] -p [Product ID] -R
nm-connection-editor (or some other network configuration utility).

Watch for some wierdness though. I had one system not being able to automatically pickup DNS setting from the ISP. I had to manually insert a rule.


While we're on the topic of firmware there does seem to be Open Source firmware projects for well known SSD's out there.


As you can see though, SSD reliability is still very much up in the air (across ALL manufacturers) though (keep backups, do your research, and so on.).


- as usual thanks to all of the individuals and groups who purchase and use my goods and services

Cleanup Operations

If you haven't already figured out already I often repair/investigate devices (for myself as well as on behalf of others) in my spare time. I was recently given an Acer Aspire One 531h, a Acer Aspire 1671 as well as a laptop that was running Vista in a foreign language. Let's start with the easy stuff. Language packs are easily handled via the following. Please note that while this may handle most dialogue within the operating system itself it doesn't deal with installed programs such as utilities, security, and other software.


The Aspire One and 1671 were much more difficult propositions. It was clear that they had previously been opened and were mis-diagnosed or had strange fixes applied to them. The 1671 was shutting down a few seconds after boot or would only boot when the battery had been charged for a little while. While opening it up:
- plastic pieces fell off after they had previously been broken and were inadequately put back (super/expoxy glue can work but is harder to use when dealing with thin plastics)
- there was glue where it shouldn't have been (super glue debonder helps here)
- the CPU wasn't locked down properly (there's a screw/lever mechanism for locking it in place normaly)
- it was clear that several screws were misplaced
- there were globs of heatsink compound everywhere, and so on...
It's clear that the previous person thought that the problem was entirely down to heat. By running a multimeter over the terminals of the DC jack it was clear that this wasn't the case though. The inner pin of the DC jack was losing contact with the mainboard which meant that only a trickle of charge was reaching the system with the result being unable to start the system or only being able to start it with an adequately charged battery (Unsurprisingly, it also had other issues such as a pirated version of Windows). On top of this, the trackpad seemed to be disabled by defaut after software re-installation?


Like the 1671, the One had many problems (the primary issue was the that no charge was reaching the system though):
- there was a break in the cable on the old AC adapter when you bent it. It also seemed to be a poorly made replacement (Lite-On branded but reviews seem to be poor on Amazon with similar problems reported, http://www.daniweb.com/hardware-and-software/pc-hardware/usb-devices-and-other-peripherals/threads/25588/synaptics-touchpad-suddenly-stopped-working) with the plug being slightly too large for the socket. Jigglng the plug made it work but it also exacerbated the problem with the DC jack. You were basically covering one problem with another and dismounting the pin in the DC jack (you can choose to either re-solder or replace)
- cable between mainboard and front LED lights had worn out contacts ('mended' by trimming a bit off the tip)
- there was a break in the connection between the internal wireless card and the attenna (re-soldered)
- the centre point on the DC jack was not connected properly to the mainboard (re-soldered)
- there was a break in the plastic on the right side panel (glue)
- numerous screws were misplaced (guess-timation)
- two charging pins to the battery were mis-aligned (bent back to shape)
- there was a massive break in an internal cable between the power switch and the mainboard (Alternatively, you can turn it on by shorting pins 2/3 of the relevant connector on the mainboard). After seeing the cost of the cable online and comparing it with the cost of device itself I half thought about (drilling holes or just swapping the switch for another existing port such as USB, Ethernet, etc... I've done it with phones before though but have 'sculpted' the switch rather than the case most of the time) using a small microswitch but obviously the solution wouldn't be elegant, light on power button wouldn't be perfect, etc...



- as usual thanks to all of the individuals and groups who purchase and use my goods and services

Monday, August 6, 2012

Space Saving

I've been running out of hard drive space. While I've upgraded I've also done a little bit of 'cleaning up' as well. Little did I know just how difficult this would be. With the recent increase in hard drive prices (due primarily to the Thailand floods) I (and others) have been looking at unusual sources. One of these has been purchasing portable hard drive expansion packs (hard drive and enclosures) that are on sale and removing the internal hard drive which often ends up being cheaper than purchasing the drive alone. Sounds simple, right? Not quite.

I tend to do some background on product purchases. In the past, this has held me in relatively good stead but with the advent of online marketing and reviews it seems as though everything has balanced out. Almost every single brand seems to have 'problems' and unless something is truly worthy it is unlikely to have a clean bill of health. In fact, a random sample of Amazon (and HDSentinel) reviews seemed to indicate that anywhere between 10-25% on average are dissatisfied with their purchase of electronic goods (anything from flash memory, hard drive, routers, to wireless network cards).


On top of this an increasing number of companies are locking down their hardware/software which means that modification can be difficult if not impossible. Obviously, there are issues relating to consistency, security, and so on. While some compromises I understand, other's I'm not so certain about. For instance, Clickfree actually have a microchip in their enclosures (warranty void if removed) which holds the key to being able to use the internal drive as a normal drive or as a 'Clickfree' drive. Toshiba have been attempting to draw more power than standard from USB ports for their external enclosures than standard. Seagate have been (depends on the age of the enclosure) using slightly larger than normal (12.5mm as opposed to 9.5mm height drives) in their enclosures which means you can't use them as a replacement for your internal hard drive. Western Digital have even altered their circuit boards so that instead of a generic SATA out interface that leads to a USB controller/interface card which then leads to your PC the circuit board is direct to USB (I never would have believed this had I now seen the pictures on HDDGuru). I've even seen accounts of HP using non-generic PCB's which basically encrypt the contents of your drive which mean that while your data is safe if it is removed from the drive in the advent of a failure it's difficult/impossble to recover your data without skilled aide. Firmware flashing of the requisite chip seems to be the only way around this without using a different enclosure.


Moreover, many firms are developing tamper proof enclosures that mean that opening them up is extremely difficult without causing damage to the enclosure themselves. The general consensus seems to be a combination of higher local ambient temperature and careful prying using thing pieces of plastic/metal is the best way.


While I've previously used SyncToy and other tools to run backups and syncronise drive contents I recently came across Syncback. Overall, it's just like many other backup tools. The thing I like about it is that it creates it's own backup logs (HTML format) instead of me having to create them.


Transcoding of media files seems like an extremely simple affair and I thought that many applications would be able to handle audio syncronisation issues easily by now but that's not the case. Whether I'm using CLI (ffmpeg) or GUI (HandBrake, FormatFactory, MediaCoder, Avidemux, etc...) based tools there doesn't seem a single tool that can transcode (at an acceptable level of quality) without extra input from the end user while maintaining sync without causing abberations in the transcoded file. The simplest option seems to be a mass transcode via MediaCoder/ffmpeg and then using the MediaInfo/Avidemux/VLC in order to re-sync/edit the transcoded file back to normal. This of course, raises other concerns.

ffmpeg -i out.ogg -itsoffset 4.267 -i out.ogg -map 1:0 -map 0:1 -ar 22050 video.flv


In my case, temperatures were exceeding acceptable limits/normal parameters which meants that it would automatically trigger system shutdown. Obviously, I've worked with CPU throttling applications (I even built one) previously though so using a combination of ThrottleStop, Open Hardware Monitor, and Process Lasso I've been able to slow things and maintain a more sustainable thermal environment.

If you've ever used a particular brand from Jaycar you'll notice that they have some quality control issues. Recently, I once purchased a mini microSD card reader but after noticing read errors from the device I returned it for another. I noticed the same thing again but this time decided to take a closer look. Apparently, they may have a dry solder problem with what appears to be an onboard crystal oscillator.


I also noticed similar read issues with another product (a USB to IDE/SATA convertor) from this particular brand. As soon as it hit the 1GB file mark of a certain file copy (this only seemed to occur on one particular file transfer) it seemed to silently fail (under Windows). There are accounts of the core chip not dealing with errors correctly (under reporting information during failure) and also incorrect/un-optimal implementations. I may explore this further if I have time but I'm still working on my 'Cloud and Internet Security' report.


- as usual thanks to all of the individuals and groups who purchase and use my goods and services

Wednesday, August 1, 2012

If Only Reading Were Easier...

I recently came into possession of a MiGear eBook Reader. It's not the best eBook device in the world but I got it for a price that was hard to refuse. One of the things I've discovered is that while it makes a great video/photo viewer and music playback device it's actual eBook reading capabilities needed a bit of work (the zoom function doesn't work particularly well in the default firmware which means that a lot of scrolling needs to be done because the fonts are too large or the words are too small because the there neds to be greater magnification).

Like others I've been exploring the full capabilities of the device and looking at modifying/changing the firmware to fully exploit it. The device itself is based on the Rockchip RK2738 which is often used in MP3/MP4 music devices with the rest of the device relying on inexpensive and readily available PC electronics. It is also used in many eBook readers as well which means that as long as the reader is based on the same chip you can chop and change as you like. Moreover, while it is possible for you to end up with an (inexpensive in this case) paperweight there are existing provisions to activate a recovery mode of sorts by shorting pins 29/30 on the flash chip (Based on what I've read and done it seems to be very hard to 'brick'. The product itself seems to be hobbled by the firmware than the hardware.).


Moreover, while you may end up with the wrong language they (the various firmware revisions) all seem to be based on the same core which means that even if you end up seeing strange characters you can almost always set it back to any arbitrary language. The irony though is that while there is a firmware update utility you need to tweak it (Hardware IDs which can be obtained from 'lsusb' under Linux and 'Device Manager' in Windows) in order to get things right.


There's clearly no 'perfect firmware' out there at the moment though. I've ended up using firmware from another Chinese clone which oddly enough had better hardware (more RAM, Flash memory, FM radio, TV-out, and also a larger battery) than my device. This led to be explore the actual data sheets, various PCBs, and SDKs for this chip. Most of the time the data sheets indicated that only minor modifications/additions needed to be made to add these capabilities (I actually thought about adding more flash memory from a USB flash drive after discovering the physical size of the chips on the board and in my flash drive were identical. Try to format the flash using NTFS and not FAT16/FAT32 as it will be more resistant against potential filesystem corruption. You'll know why if you've compared these filesystems on USB flash drives previously and have not ejected properly.). While there doesn't seem to be support for Android/Linux, Lexand seemed to have released a device that uses Android/Linux and is also based on the RK2738 (here's hoping someone uploads the firmware).


While there are SDKs out there development doesn't seem to be simple especially for the 27xx series. A lot of information has needed to be reverse engineered (Rockchips don't seem to be interested in Open Source development at the moment based on what I've read.) and even then there seems to have been measures taken to reduce the chances of end user tampering. Files have clearly been 'packed' and possibly encrypted with 28xx/29xx series also having similar protection.

Even viewing hidden partitions/backing up the actual firmware itself was a seeming mystery with many people just guessing at what the magical filename should be to make the partitions magically appear (I used the following command sequence to figure this out, 'strings RK2738.img | grep -i tag > tags'. Mine was 'HTC_E01.Tag' though this will obviously depend on you having a copy of the image in the first place.).

Moreover, unlike the 26xx series you can't just modify files on the hidden partitions itself. You need to unpack the image, modify the files, repack it and write the firmware to make the changes 'stick',

mkdir /media/ebook
mount -o loop BSTE102.img /media/ebook/
umount /media/ebook/

else you'll need to use something like WinRAR or WinImage under Windows.

With the firmware being relatively tedious or difficult to modify I wonder whether something like Rockbox/OpenInkpot are more viable options given time and your desired use for your device...

- as usual thanks to all of the individuals and groups who purchase and use my goods and services

Automated Audiobook Maker Script, Random Stuff, and More

- wanted to find a way to automated building of audiobooks. Built the following: https://sites.google.com/site/dtbnguyen/audiobook_maker-...