11/13/2019 Openwrt Serial Port Programming Hardware
Welcome to LinuxQuestions.org, a friendly and active Linux Community.You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Today!Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.Are you new to LinuxQuestions.org? Visit the following links: If you have any problems with the registration process or your account login, please. Mesomorph pre workout. If you need to reset your password,.Having a problem logging in? Please visit to clear all LQ-related cookies.
Introduction to Linux - A Hands on GuideThis guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.to receive this Complete Guide absolutely free.
Figured this was more 'homebrew' than 'computers & SW'. Turns out Linksys WET54G routers have inside TTL level RS232 ports (probably for company production testing, and the hardware already inside one of the big chips anyway, so no real cost). OpenWRT is a set of 3rd party firmware people have written to enhance these routers, and one feature (you have to download and add the program) is the ability to drive an RS232 port via the ethernet network.The hardware end of things: crack open the router, and find JP2 (the one with ten holes):Pin 1: 3.3V Pin 2: 3.3VPin 3: Tx (ttyS1) Pin 4: Tx (ttyS0)Pin 5: Rx (ttyS1) Pin 6: Rx (ttyS0)Pin 7: NC Pin 8: NCPin 9: GND Pin 10: GNDabove fromYou want the ttyS1 pins. To protect these, solder a pair of 5V zener diodes' cathodes to these pins, and the anodes go to ground.
These signals are not true RS232 voltage levels, but are the TTL version (which look to be inverted, but are in the correct sense to directly feed the Icom's CIV line). I used a stereo headphone socket for these lines, as it fit easier in the back panel of the router, and this makes it not comparable with true RS232, which uses DB9 connectors.
In the headphone jack I shorted the Tx and Rx together, and this in turn goes to the Icom CIV jack on the back of my IC756Pro radio.The firmware part: seeOnce you get the router working with the openwrt firmware, you need to download the ser2net software package. Do this by going to the System tab, and then the software subtab. Then click the 'update lists' button. You may need to have the router be the master router, connected directly to your cable modem, to have it have access to the lists (it fetches these over the internet). Once you succeed you want the 'ser2net' one.
Download and install it, via the box just under the 'update lists' button.Go to the 'System' tab, and then the 'startup' subtab.with my router it wasAdd this line in the local startup box:ser2net -C '3031:raw:0:/dev/tts/1:19200 NONE 1STOPBIT 8DATABITS XONXOFF LOCAL -RTSCTS'Then reassign the openwrt router a static IP address (I used 192.168.1.203), then turn off the DHCP off, so you can use it as a secondary ethernet switch. Reboot it, and find it at this new IP address.Assuming you get this far you need PC software to tell your PC how to find this RS232 port.
One program is HW virtual serial port, at which is primarily intended for their products, though you can use it to do an OpenWRT serical port. Click the virtual serial port tab, enter the IP address you assigned the Openwrt router, the port number 3031, and pick a COM port (I used COM13) you want the PC to use to refer to the openwrt serial port.Okay, you can run a test. Using s terminal emulator like hyperterminal, have it connect to COM13, set the baud rate (bits per second) to 19200, data bits to 8, no parity, and stop bits to 1, and flow control to xon/xoff. Now short together the router's new serial port's Tx abd Rx pins together, and then in the terminal emulator program type in some random keystrokes. If it works, you shouls see what you type. If not, cuss for a while.Assuming success, then you can open 'commander' and go to the 'config' page and set the various parameters to match what we did.
![]()
And you should then be able to control your radio.Sounds fairly straightforward, but you'll probably spend a weekend fighting various computer stupidity to get it all working right, like I did.Logged.
Contents.Test FTDI chip with minicom Test Setup. MS14N-S with IoT firmware 4.2.2 loaded. FTDI to TTL module. Connect FTDI to MS14N-S 's external USB port. MS14N-S must have Internet connection to install packagesInstall Packages. Check if FTDI chip is see in Linux, run lsusb. And see FT232 chip as below:root@dragino-17be12:# lsusbBus 001 Device 003: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) ICBus 001 Device 002: ID 1a40:0101 Terminus Technology Inc.
4-Port HUBBus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub. Install Packages. Root@dragino-17be12:# wget https: //downloads.openwrt.org /chaoscalmer / 15.05 /ar71xx /generic /packages /packages /coreutils-stty8.23- 1ar71xx.ipk-2017-09-26 01: 31: 17- https: //downloads.openwrt.org /chaoscalmer / 15.05 /ar71xx /generic /packages /packages /coreutils-stty8.23- 1ar71xx.ipkResolving downloads.openwrt.org. 78.24.191.177Connecting to downloads.openwrt.org 78.24.191.177 : 443. Connected.HTTP request sent, awaiting response. Root@dragino-17be12:# cat luatest while 1 do -loop to get data and process serialin=io.open ( '/dev/ttyUSB0', 'r' ) -open serial port and prepare to read data from Serial while linenil do - read data from serial.
Openwrt Table Of Hardware![]()
line=serialin:read ( ) serialin:flush ( ) end print (line ) -print the data - -put your code here to process data- serialin:close ( ) line=nil -clear the line data end EOFThis will read the serial data from serial device and send it back to Linux console.
Most people get along without a serial console for their device because they're able to flash a working firmware the first time - or are able to apply various recovery methods - and do all their communicating with the device over a network. However, some bootloaders don't have a “really failsafe” network re-flash feature, making a serial console one of the few ways to recover from a “bad flash” or an error in a user's own configuration.Most devices supported by OpenWrt have or can be modified to have a serial port. These serial ports typically provide a console to the bootloader and, when the firmware has booted, a console to the running system. A console to the running system will let you correct a misconfigured network, for example. Console access to the bootloader will often allow one to fetch and flash new firmware and may be the only way to do so on some routers if the firmware is not functional.Enabling a serial port, if there is not one already available on the case, typically involves opening the case and basic soldering skills. The cost of components is relatively low; a 10-euro/dollar project if one uses “eBay-grade” parts (which are likely sufficient).
If one wishes a more permanent installation, mechanical skills in modifying the case may also be needed.About a Serial Port. Most routers come with an integrated into the and its pins are routed on the to allow debugging, firmware replacement or serial device connection (like modems).Typically, a router first starts its “permanent” which is responsible for the first steps of finding the OpenWrt firmware and starting OpenWrt running. During these early phases, the bootloader often gives information over the serial port and can respond to its own set of commands.
These commands are not “OpenWrt” commands, but ones pre-programmed into the bootloader. Details on these commands can often be found on the device-specific pages on the OpenWrt wiki.Once OpenWrt starts running, it is generally possible to enter failsafe mode with a terminal program attached to the serial port. Either in failsafe mode, or with OpenWrt running in normal mode, it is generally possible to enter commands the same way one would if using ssh over a network. As unpopulated holes in the PCB.For help with the latter two, see. But even if there is 9-pin D connector, beware the Voltage levels!
Sometimes by shortcutting some pins, connecting them to ground or to power you can change the serial mode. Some of them can help you to restore the bootloader since they allow you to write directly to memory or load something to ram through the serial connection, which can be useful for restoring a bootloader. Also if the original bootloader is password protected with this method you can replace it with a custom bootloader and bypass it.For example in the default mode is CFG 01, but changing to CFG 04 which is known as UART mode allows you to upload to ram through the serial connection and automatically execute a bootloader in ascii format through the serial connection.It is recommended that you don't try blindly to shortcut or connect to anything the pins as it can brick the device. Find documentation before doing anything.Voltage levels. Caution: Very few devices have standard +/- 12V serial ports, but in many OpenWrt-supported devices the serial ports operate at TTL voltage (sometimes 5V, most often 3.3V) levels, meaning you cannot use a standard serial or USB to serial cable: it will fry your board. Buy a USB- TTL dongle instead, it will still show up as serial port in your computer, but it will be able to safely communicate with your OpenWrt deviceIn order for the serial console to work, the logic levels on the wires should match those expected by your device. The first step therefore is to determine which voltage levels are required.
Often, you can find this documented on the OpenWrt wiki or elsewhere. If you can't determine the voltage based on a clear description in the OpenWrt page for your device or your own knowledge of electronics, you should probably stop here until you are reasonably certain of the voltage levels required.In case your device is using a TTL connection or what seems to be a TTL connection, you can try to find out by trial and error, at the risk of burning the USB- TTL dongle or to damage the OpenWrt device.Start by identifying the power wire (i.e. The wire carrying the 5V or 3.3 volt) and the ground pin with a multimeter on the 3-5 pin or holes in the board. The live pin should be labeled “1”, or “vcc” or have other signs that identify it as first pin.You can then proceed to connect the ground pin to your dongle, and then try to connect the other two pins (data pins) randomly and trying different serial settings on your terminal.Reversing Rx and Tx will not damage anything (it may will result in garbled text on your terminal), as long as the pins or holes are indeed a TTL port. If it is not a TTL port then you could probably damage your OpenWrt device, or (more commonly) burn the USB- TTL dongle.DO NOT under any circumstance connect the live pin (the 3.3 or 5V one) to your USB- TTL dongle as that could damage the dongle. It's not required in any dongle as they are USB-powered anyway and can auto-sense the data voltage.Talking and Listening. You will need a terminal emulation program on your computer, such as minicom, hyperterminal, etc.
Openwrt Flash Bootloader
The terminal emulation program needs to be configured to be compatible with your device, in particular, with regard to baud rate and flow control. If you are using only three wires (GND, TX, and RX) then hardware flow control should be turned off; you aren't using the pins (RTS and CTS) necessary for it to work. Rarely, the baud rate that the device expects might be different in the bootloader and the running firmware; if so, you'll need to modify the baud rate settings in your terminal emulator after the firmware boots up.Terminal software. If you get something like this during the bootcycle (output is garbled) 001f 2000-2008 Broadcom Corporation.Init ArenaInit Devs.This is?00020012?BCM4wXXLJ000200020735750 - 0x80)BSS: 0x80739790 - 0x804߇5.10The boot is CFEthen probably the GND is not connected (soldered?) well.
The router wont listen to any keyboard actions.After solving the problem output should look fine.Another possible cause for the garbled output is wrong serial port speed, try different settings, most common ones are 9600, 38400 and 115200 bps.Unable to send data. In order to interact with your device over its serial port, you need a minimum of three wires connected: a ground (GND); transmit (TX); and receive (RX). It is possible to get useful information about what is happening with only GND and RX, but in order to fix a problem you will usually also need TX. Your computer's TX should be connected to the device's RX, and your computer's RX should be connected to the device's TX. The computer's GND should connect the the device's GND.
That way, what you say will get heard by the device and what the device says will get heard by your computer. This is often called a “null-modem” configuration. If your computer has neither a serial port or a USB port, you are in trouble!These days, computer manufacturers are dropping, while USB ports are increasingly ubiquitous. Particularly if you need to TTL logic levels, USB is probably the way to go since you can get the right logic levels (the voltage) integrated in the USB- TTL converter.See for a variety of ways to make the physical connection from PC to router using homemade or commercial USB-serial and serial-serial cables.Serial port pinouts. If the serial port pinout is not shown on your model's devicepage, do a Google search. Most of the time, the serial port(s), if they exist, have already been documented by others.
If methods listed here are not enough for you, consider to go deeper readingFinding an UART on a router is fairly easy since it only needs 3 signals (without modem signaling) to work: GND, TX and RX (often accompanied by VCC). Try looking for a populated or unpopulated 4-pin header, which can be far from the SoC (signals are relatively slow) and usually with tracks on the top or bottom layer of the PCB, and connected to the TX and RX.Once found, you can easily check where is the GND, which is connected to the same ground layer than the power connector. The VCC should be fixed at 3.3V and connected to the supply layer; the TX is also at 3.3V level, but using a multimeter as an ohm-meter, if you find an infinite resistance between the TX and VCC pins, it means they're distinct signals (else, you'll need to find the correct TX or VCC pin). The RX and GND are by default at 0V, so you can check them using the same technique.If you don't have a multimeter, a simple trick that usually works is using a speaker or a LED to determine the 3.3V signals. Additionally, most PCB designers will draw a square pad to indicate pin number 1.Since your router is very likely to have its I/O pins working at 3.3V ( level voltage), you'll need or a level shifter such as a Maxim MAX232 to change the level from 3.3V to your computer level which is usually at 12V.Once the correct pins are found, just interface your level shifter with the device, and the serial port on the PC on the other side.
Most common baud rates for the off-the-shelf devices are 9600, 38400 and 115200 with 8-bits data, no parity, 1-bit stop.Piezoelectric buzzer method. Switch the multimeter to measure DC voltage on a scale greater than 10 but less than 100 volts. Meters vary, but you should be able to select a range greater than five volts. Place the black probe on the known ground point again, and with the router powered on, use the red probe to check the remaining pins of the port for steady 3.3V or 5V DC.
When you find it, that pin is likely to be the VCC connection. Note however that on some routers RX and VCC both have same voltage. One suggestion on how to distinguish them is to power off your device, and switch to continuity test if you have it(so that your mm would emit audible beep on near-zero ohms). VCC pin usually has a capacitor and shorting them would result in a very short beep once.
RX would not emit any beeps. It's easiest to find the router's TXD pin first, because all the console output from the boot process appears there. Measuring DC V with multimeter would easily point to TX pin as on output it would irregularly drop from 3.3 or 5 as console output occurs. If booting is long and produces a lot of output it would be easy to notice that even with a cheap multimeter.
![]()
Sometimes with a very brief output some multimeters' sampling points may come at the moments when there's no output so reboot it a few times to make sure. When you see an irregular drops, that's TX. Then you can connect the RXD pin of your level shifter to that router pin and re-start the router. You should have a terminal window connected to the serial port at the correct bitrate and parity, and you've connected the proper pin, you should see output data the router's startup process. If not, try another pin, restarting the router until you receive valid output.
Now you've located the serial port TXD connection. Anyway router TX and VCC are really one of the simpliest to find.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |