Most of this week has been devoted to finishing the house network setting up a workspace in the garage and using it. One of the things I have been trying to get off of my plate was to rebuild the transit tracker that we use to tell us when the next max is going downtown. In order to network from the house to the garage I have to navigate a super creepy crawl space and not get spider bitten or set up a wireless bridge. One of the OpwnWrt devices we bought to evaluate seemed perfect. The TP-Link TP-WR740.
Getting the OpenWrt operating system on the router is pretty much a matter of uploading the new firmare ( http://downloads.openwrt.org/attitude_adjustment/12.09-beta/ar71xx/generic/openwrt-ar71xx-generic-tl-wr740n-v4-squashfs-factory.bin) using the routers web based interface. Accessing the serial port required some surgery.
Once the serial was connected to the 4 pin connector I tested it with my ftdi.3.3v serial cable. Then I tried to see if the 3.3v tx signal was strong enough to be read by a sparkfun 5v serial lcd board I had on the bench. It wasn’t. If i had the parts for the 3.3v-5v boards i had fabbed last month (in particular the 74ahc125) then I would be done. So I looked around for what I could find. One of the documents I found on this was an app note from microchip called “3V Tips and Tricks” (http://ww1.microchip.com/downloads/en/DeviceDoc/chapter%208.pdf). As I was looking through it I went out to the garage and tried to see what I had that I could use. In a box labeled “chips and dips” I found a bunch of lm393 comparators that I had been packing around for over 10 years.
So I soldered an lm7805 to the dc coming in and the ground-plain started breadboarding.
I got no love from the resistor values provided by microchip so I put a pot in place opened a minicom connection to the serial on the router, held my hand on the g key, and rotated the pot until I got ggg’s on the lcd. Then I continued until I stopped getting characters. Then I centered the pot in between those places pulled it out and measured it with a multimeter. Which gave me the circuit below which I wired up bug style and embedded in hot glue.
There was still a little work to do. The OpenWrt luci system takes up a lot of space but makes trying things very easy. The command line tools aren’t bad but luci comes with most of the stock images which is ok. The thing that forced me to build a custom image was that the fact that the serial port starts up at 115200 baud rate and my lcd module didn’t support that. To make matters worse sending the boot messeges at 115200 created serial sequences that would corrupt the lcd module.
To get the baud rate to 9600 required me to:
- Upload the OpenWrt-ImageBuilder-ar71xx_generic-for-linux-i486.tar.bz2 to one of my linux machines.
- Find and replace parts of the Makefile where the console baud rate was hard coded. (target/linux/ar71xx/image/Makefile)
- “make image” with the correct target and any packages I wanted installed.
I also commented out the install luci part in the .config file at the top of the tree and added the trimet.lua script to a /scripts directory and which was magically added to my custom image (though not were I expected it to be).
make image PROFILE=TLWR740 PACKAGES="nano coreutils-stty coreutils-nohup monit lua luasocket" FILES="myscripts"
This created several images including one called bin/ar71xx/openwrt-ar71xx-generic-tl-wr740n-v4-squashfs-sysupgrade.bin
to install it i scp’d it to the /tmp/ partition of the router sshd into it and as root ran the command.
root@fatlink:~# sysupgrade -v openwrt-ar71xx-generic-tl-wr740n-v4-squashfs-sysupgrade.bin
where as the router flashed the image and rebooted.
A little tweeking on the startup scripts and we were done.
The transit tracker code from my previous post runs while the router is still doing its job as a hub and a wireless router.
Not bad for 20 bucks and what we had on hand.
- http://ww1.microchip.com/downloads/en/DeviceDoc/chapter%208.pdf (3v tricks ans tips)
- https://forum.openwrt.org/viewtopic.php?id=38419 (discussion of serial speed with links)
Impressive, Mr. Bond.
Nice job documenting.
Coming from you it means a lot.