Adding Bluetooth Serial Port to Asus RT-N16

I am running DebWrt on my Asus RT-N16 and it works well. The only problem that I have is: in case I misconfigure something and the device is inaccessible via the network, I need to open the case then connect a serial port to fix it. Because the configuration is in USB, I don’t have to open the case very often, in most cases, I can unplug the USB disk, mount it in my Linux machine, try to fix the configuration, plug the USB again, restart the router, and hope that my fix works. Either way, both are such a hassle.

I could have added a serial port just like my DIR-300 mod, but I think it’s not the best solution. Because I still need to bring down my router, find my serial cable, plug it in and connect to it. I wish that the device has a Bluetooth capability, so I can connect to it (via Bluetooth serial port profile), fix any problem that it has, and without moving or plugging anything, and hopefully I don’t even need to restart the router and wait for it to boot.

So I bought a 7.32 USD bluetooth module from Aliexpress and installed it on my RT-N16. Some of you may think that it is a bad idea because Bluetooth interferes (somewhat) with WIFI, but I don’t plan to keep constant connection via Bluetooth, and when I do make the connection, the data that I am transferring is very small (maybe just several kilobytes per minutes). So far in my testing, when connected via Bluetooth, I didn’t notice any speed difference in WIFI transfer speed (even when transferring large files via WIFI) and typing furiously from my Bluetooth terminal. Asus RTN16 only supports 2.4 GHz, but If your router supports 5GHz, I think you should use that band to eliminate any possible interference.

Asus RT-N16 has a serial header ready to be connected (it even has labels on it, GND, RX, TX, VCC):

IMG_4476

But before plugging in the module, I need to set the speed of the Bluetooth serial module to 115200, because the default speed is 9600. To set up the Bluetooth serial module, we need to connect it to a computer via serial port (I am using Bus Pirate for this).

My version of Bluetooth module is H-C07, and for this version, the device doesn’t use \r or \n to terminate command, it just uses time out to end a command (a complete command must be received within few hundreds millisecond). Typing very-very quickly in your terminal won’t work, so just copy and paste the command from your text editor. The command needed to set the Bluetooth module to 115200 is “AT+BAUD8”. These Bluetooth modules usually don’t come with documentation, so you need to look on the internet for your specific version.

Bluetooth

One of the nice thing about Bluetooth is: it is accessible from non-PC devices. After connecting the cables, I can connect to my router using Android Bluetooth SPP

Using Bluetooth SPP as console on Android

One thing to note: the Bluetooth module needs time to initialize, so it can not be used for accessing the bootloader. To restart the router, I need to plug and unplug the power cable. So the Bluetooth module will lose its connection when I restart the device. By the time the Bluetooth module is ready, the bootloader has already passed and you will be in the middle of Linux booting.

If you really want to use the Bluetooth module to access the bootloader, you will either need a separate power source for the Bluetooth module, or make a special reset button for the router (that doesn’t involve unplugging and plugging the device, and doesn’t cut power to the Bluetooth module).

LocalBar: Install signed BAR files directly from PlayBook

I’ve reverse engineered the protocol used by blackberry-deploy to install apps file (BAR file) into the playbook. Then I made an app to Install signed BAR files directly from the playbook itself. You can find my work here:

http://yohan.es/playbook/localbar/

  • I am using https://localhost method. To put it simply: it works like other desktop installers that connect via network or USB, it sends commands to an HTTP service in the playbook. The only difference is that it works through the playbook itself.
  • It is possible that in the future RIM may block requests from localhost
  • I don’t have time to develop nice GUI for this, so I just use the basic GUI API that is accessible using NDK. For example: in the NDK there is a “login dialog” but no “password dialog”, so for the password dialog I use the “login dialog” that shows the “user” field (which I don’t need).
  • This works on OS 1.0.7 and on 2.0 (developer beta)
  • With this you can sort of OTA install through the playbook. From your PlayBook Just go to a website that has some bar files (for example this forum) , download it using the built in playbook browser, then run LocalBar to install the downloaded bar files.

EZ430-Chronos OTP

After wanting the EZ430 Chronos watch for a long time, I finally ordered one on Febuary 20th from TI eStore, and I got the watch on February 24th (Tax Free). So this is another stuff in my long list of “things to hack”.

I had a good idea to use my Ez430 Chronos as OTP generator for Google 2 factor authentication. Before my long weekend, I did my research on Thursday (24 February) and that time no one had implemented it. So I wrote a small modification to OpenChronos, and just before I finished my implementation on Sunday (I was quite busy during the long weekend helping to move our company’s office), I looked at Chronos Wiki again to find some links to the chronos documentation, and found out that Huan Truong has just implemented his version of OTP by modifying OpenChronos.

After learning that in his version the clock function doesn’t work yet (in his readme it says “THIS FIRMWARE CURRENTLY HAS A YET-TO-IMPLEMENT CLOCK FUNCTIONALITY, SO IT WONT DISPLAY TIME PROPERLY”), I decided to continue my implementation. My implementation doesn’t change the time logic so you can still use the stock Control Center provided by TI (Huan Troung changed the OpenChronos code to use epoch implementation, and he modified the control center) . Instead of replacing all algorithms to use timestamp, I use a simple mktime implementation to convert existing year/month/date data to unix timestamp.

After flashing the image to the watch, a new menu is added to the second line after “rFbSL”, it will show a heart icon and first 2 digits of the OTP (I will never buy a heart monitor for this watch so I use that icon just to show that I am in OTP mode). Pressing the “#” key for a few seconds will show the remaining 4 digits. Just for your information, enabling CONFIG_OTP adds 2914 bytes to the code size.

So here is my version of Google OTP (If many people are interested, I can put it in github):

http://tinyhack.com/files/OpenChronos-joe-otp.zip

I am too lazy to implement the “make config’, just edit otp.h with your key, and fill in the timezone offset (+N from UTC). You can get the key from base32 encoded string using codegen script that I made, for example:

bash$ python codegen.py pf xwqy lomvz wu 33f
\x79\x6f\x68\x61\x6e\x65\x73\x6a\x6f\x65

https://github.com/yohanes/OpenChronos

You can use make config to set your secret key in base32 (that means you can just copy paste from the auth code presented by Google), and you can set the timezone offset.

New Adventures

My last post was about 6 months ago. Now I am back with some new adventures. The first one is Jonathan, my first baby:

Jonathan

And the next one is BeagleBoard-xM from John Nicholls.

BeagleBoard-xM

About a month ago I found a promotion and got this free MSP430 USB development tool:

eZ430-F2013

It got me interested in MSP430 in general and bought some LaunchPad (only 4.30 usd each). My first project is to control the plug so i can plug and unplug BeagleBoard-xM through PC (so I can control it remotely via SSH). With this, I should be able to work on BeagleBoard remotely (like when I am in my room holding my baby boy).

LaunchPad MSP430

And I have updated the CNS21XX code in my gitorious repo with the latest head. Hopefully I can put the code to SVN HEAD in the near future.

D-LINK DIR-300 Serial Port and SD mod

The latest progress of my freeBSD port for CNS21XX and ThinkLink Hot-e was three weeks ago. The CNS21XX network driver and Hot-e network driver was completed. I haven’t touched anything since then because I had to work on weekends at the office. This weekend, I could have continued coding, but I don’t feel like coding, so I did a hardware project: adding serial port and SD card slot to my D-LINK DIR-300 that I bought April last year.

This is not a difficult project, I already added SD/MMC card to my WRT54GL about 2,5 years ago. The difference is that there isn’t much guide about the hardware part (which GPIO pins to solder), and the software part (how to activate the drivers). So here is a short guide to anyone who needs it. Note that I already installed OpenWRT Kamikaze using the guide from: OpenWRT site.
Continue reading “D-LINK DIR-300 Serial Port and SD mod”

ThinLinx Hot-e and CNS21XX

I am still fixing the Cavium Econa CNS11XX network driver with the guide from Pyun YongHyeon. He is guiding to make the network driver more robust. Unfortunately, we still don’t know why the driver is slower than the Linux version. The port is currently accessible through FreeBSD CVS at:

http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/arm/econa/

I asked in the freebsd-arm mailing list if anyone would like to donate me a CNS21XX device, and Stefan Bethke immediately offered me to buy one for me. I bought the device from dealextreme with the money donated to me. It took 9 days until it arrived.

Meanwhile John Nicolls from ThinkLinx sent me a Hot-e, a device based on AT91SAM9G20. I told him that I have received mr Stefan offer, but he said I can work on it anytime I want it. Since the Hot-e arrived earlier, I have managed to get it to boot. At first i was going to use the work from Sylvestre Gallon on at91sam9621(mailing list archive), but it turns out that it is not usable yet.

I have fixed the clock computation in at91_pmc.c, and currently writing a new timer driver (at91_pit.c), because the system timer device (at91_st.c) no longer exists in AT91SAM9G20. Currently the timer device is still not working properly, but I think I will be able to get it work this week.

When the CNS211XX LAN device finally arrived, I stopped the work for Hot-e for a while to test the new device. I bought a CA-42 cable to connect to it, but I can’t send anything to the device. I thought that the device was faulty, but turns out that the cable is faulty. I was disappointed because usually I used that type of cable (it is cheap only 132 baht or 4 usd). Fortunately I still have one MAX3232, and I can make my own cable.

I think porting CNS21XX will not be so difficult. I made some small adjustment for the serial port driver to make it show something. Memory mapping is different compared to CNS11XX, but that can easily be adjusted. The Interrupt controller is different, so I need to rewrite some parts. After it works, EHCI/OHCI was working fine. The network driver will need major adjustment (may be I will just write a new driver for this one), and the device doesn’t use CFI for Flash, it uses SPI, so I will need to write a driver for SPI bus.

For CNS11XX and CNS21XX You can see my progress in this wiki page:
http://wiki.freebsd.org/FreeBSDcns11xx

STR9104/CNS1104 FreeBSD Port Progress

Returning from Indonesia, I continued my Freebsd porting attempt to the Emprex NSD-100. So far it’s going quite well. I took the FA526 CPU support from NetBSD, I use the 8250 driver for the UART, and default EHCI driver. I got stuck for a while on the EHCI part until Hans Petter Selasky pointed me that there might a problem in the busdma/cache handling. With the EHCI part fixed, I can get to the userland, booting from USB stick.

The remaining drivers that needs to be written are the OHCI and network. The OHCI shouldn’t take too much time, but I think the network will take quite a long time.

I was planning to clean up, and release the code today, but I was busy with something else, so may be I will release the code in the next few days. For those of you who are curious about the boot log, here it is:
Continue reading “STR9104/CNS1104 FreeBSD Port Progress”

Optimizing Asus EEE 900A

I just got back from my vacation around Thailand, so I will start to update things (Wii homebrew, Symbian apps, blogs, etc) again. Well, may be starting next week, I have a dental surgery this weekend and may need to rest. Anyway, this time I want to post about optimizing EEE 900A.

My wife was happy with her Asus EEE 701, but she would like something better with the same size. We sold the old Asus 701 to my brother, and she bought Asus EEE 900A. Compared to EE PC 701, the EEE PC 900A has a faster processor (Intel Atom 1.6 ghz vs the 900 Mhz EEE), more memory (1 gb vs 512 mb), bigger disk space (16 gb vs 4 gb), higher resolution (1024 x 600 vs 840×400), and better graphic processors (Intel GMA 950 vs Intel GMA 900). The only problem is the 16 GB SSD is much slower than the EEE 701 4 GB SSD. You can really feel it when running almost any applications, especially the firefox browser.

My wife uses Windows XP on the new Asus. After reading several blog posts and many forums, the conclusion is: to make everything faster, try to reduce the number of disk access. Here is how to reduce the disk access in Windows XP:

Continue reading “Optimizing Asus EEE 900A”

WiiApple: Apple IIe Emulator for Wii

I just learned about developing applications on Wii 3 days ago. I was wondering what application should I make, and I noticed that there was no Apple II emulator for Wii yet. Apple IIe was my first computer, so I thought it will be fun to be able to emulate it on my Wii. AppleWin is a good Apple emulator, but it is very windows specific, fortunately someone already ported it to Linux using SDL, and the name is LinApple.

Someone already made an early SDL port to Wii, but it is missing threading support (which is needed by the emulator). After reading things at wiibrew.org and devkitpro.org, I decided to complete the threading part. The next problem is the input. I want to be able to write BASIC applications, so I decided that the SDL port must support keyboard input, someone already made LibWiikeyboard, so I can just plug it in SDL (actually this is a hack, to correctly handle SDL requirements, there are some things that needs to be changed, in LibWiikeyboard and in the SDL gamecube implementation).

Next part is the porting process itself. The difficult part is making sure all the endiannes conversion of 6502 (Apple II CPU) to Wii’s PowerPC is done correctly, because I don’t have a USB gecko to debug it. Currently the port works, but don’t expect too much from this first release. I can already play some games, but I haven’t tested many other things. Sound is not yet now supported.

Here are some screenshots (made using tvtime, captured through my USB TV Box)

This is the application that you can extract to your SD Card

http://tinyhack.com/wii/wiiapple/wiiapple.zip

Note: Latest version is available at: http://code.google.com/p/wiiapple

The plan is: Everytime I update the application, I will still use the same file name, you can look at http://tinyhack.com/wii/wiiapple/ to look for older releases.
You will need to install Homebrew Channel to use it.

And the source codes are available at:

http://tinyhack.com/wii/wiiapple/

Note: Latest source code is available at: http://code.google.com/p/wiiapple

Update:

version 0.0.2:

– Fixed text overlay
– Disable saving options (dangerous for now, because you might overwrite your files)

version 0.0.3:

– Sound support
– Fix joypad problem
– Invalid disk image will not freeze the emulator (in case of invalid disk, Master.dsk will be reloaded)

January 6, 2009 (0.0.4)
– new keyboard driver, now work with most USB keyboards
Note: I am still working on the keyboard issue (some USB keyboard still  doesn’t work). I think this is because the limitation of Libwiikeyboard that can only do control transfer instead of interrupt transfer. Now I have rewritten the SDL keyboard part with my own code (part was based on the code from Guitar Fun).

January 6, 2009 (0.0.5)
– Support Gamecube controller (Wiimote support is planned for next version)
– updated some bug in keyboard handling

January 7, 2009 (0.0.6)
– Increased gamecube joystick sensitivity
– Fixed (most) crashing issue

January 8, 2009 (0.0.7)
– Support Wiimote as Joystick (Press A button in Gamecube controller to switch to gamecube joypad)

note: Mac USB keyboard works.

Tips For Debian on Agestar

Chris (Whites11) and several others have pointed that the source code for a device similar to Agestar have been released by a German company (http://www.multicase.de/en/products/76/ns348s.html). I have not looked carefully at the source code of this one, but none of the people on the mailing list have got it working with networking enabled.

Kari Ahtiala who owned several NAS devices (SLUG, NCB3AST, NCH3AHT), said that you can just move your disk from NSLU (SLUG) to Agestar just fine:

Continue reading “Tips For Debian on Agestar”