NSLU2-Linux
view · edit · print · history

Why Add A Serial Port?

Because you can!! [IF you're careful at tight-space soldering around surface-mount components, and a lot of non-experts have been.]

There are two ways that you can connect a serial port to your NSLU2: you can plug a USB-to-Serial cable in to one of its USB ports, or you can open the case and make use of the internal serial port.

Using a USB-to-Serial cable will allow you to:

  • Interface to peripherals with RS232 ports.
  • Log in, if you run a getty process on the port.

See USB2Serial for more information about using these cables.

There are, however, some things that you can only do using the internal serial port. You can:

  • Access RedBoot and/or APEX, the boot-loaders - though you can also TelnetIntoRedBoot.
  • View kernel messages while the NSLU2 is booting.
  • See any kernel panics.

The rest of this page describes how to connect up your internal serial port.

Pinout of the J2 serial port

Pin 13.3V (pin 1 has a white stripe next to it)
Pin 2RXD (from serial terminal program to NSLU2)
Pin 3TXD (from NSLU2 to serial terminal program)
Pin 4GND

RXD and TXD are (LV)TTL signals (0V/3.3V), not RS-232 signals (+/-12V). This means that they cannot be connected directly to a PC serial port. Converters are discussed below.

Pin 1 is the left-hand pin.

NB: In the photo above, a set of header pins has been attached to J2. As sold, J2 consists only of a row of holes, filled with solder. First action for any of the methods below is to mount such a header (you didn't consider soldering your cable directly to the board, did you?). After that construct a cable to connect to this header using one of the methods below. As an easy starter one can cut a CDROM audio cable in two. That will give you a four pin connector with some wire to connect to. Alternately a flat cable header can be used.

Before soldering a header to the board (as opposed to separate wires), you should remove the solder from the holes. If you try to insert the header while the solder is still there, you would need to heat all holes simultaneously in order to push it through the board. Removing the solder can be done by soldering a wire to the hole (without adding extra solder) and removing it again, and possibly repeating this several times.

If you want to put the board back in the case after you connected the header, take care that it doesn't go too far through the board. If it does, it will push a bit at the case. This is enough to lock the power button in a way that prevents it being pushed.

By default, RedBoot, APEX and the Linux kernel all use 115200,8,N,1 settings.

Set DTR drop time to 0, and "modem has DCD line" to no.

Make sure that your terminal program does not send a modem init string and that you have set it to software flow control, not hardware.

RS232 connection without a kit

If you wish to construct a level converter from scratch and not buy a kit then a suitable level converter chip is the MAX3232 from Maxim/Dallas Semiconductor. In addition to the MAX3232, you will need five 0.1μF capacitors. The diagram to wire up the capacitors to the MAX3232 is available on the Maxim/Dallas Semiconductor page. You may be able to omit the capacitor between Vcc and GND, though doing so could increase noise.

Like here:

(Note that there are actually 2 level converters on this chip. Don't get the wiring wrong, or you put high voltages (+/-12V) on the board!

Photos of the steps to build such a level converter can be found here (in this case its built into a Diskstation 106): http://helgen.oinkzwurgl.org/diskstation/rs232/

A more friendly schematics can be found at http://www.bwalle.de/docs/nslu2-rs232.sch (EAGLE format, if you would like to edit) and http://www.bwalle.de/docs/nslu2-rs232.pdf (PDF format).

RS232 connection with a level-converter kit

A really good kit is the RS Link from jescab (Swedish...) RS-Link (page in Swedish but specs in english). Note that this converter is Max232-based and requires +5V to do it's magic, has points on board for adding external power. Connect TX on your board to "In" and RX to "Out" on the RS-Link.

If you wish to buy a kit then the CompSys A232DBH3v Max232 adapter kit (3V version) has been used with no problems. See Rod Whitby's guide for more details.

Another board that works is this one, from Italy: http://www.picbasic.it/interfacce/page2.html . The lead has the right pin-out for the NSLU2 connector.

Yet another board is this one: http://www.futurlec.com/Mini_RS232_TTL_3V.shtml. The connectors aren't particularly convenient, but it's very cheap. If you have access to 0.1" female headers and male test pins, this is probably the cheapest approach. This board will have two serial ports, so you can use the other one for your serial port APC UPS (if one of the not-so-smart variety). The pin-out is as follows below. Note that the DB9 connectors are assumed to be female (DTE), as opposed to male (DCE). Please see RS-232 Wiki for more details.

NSLU2 J2Futurlec TTL-side RS232-sideDB9
pin
1+VCC n/an/a
2RX0 RS232-0-RXD3
3TX0 RS232-0-TXD2
4GND RS232-0-GND5

Finally, NSLU2 RHS R128 (as viewing silk screen) is RX data only (TX is not present), connect this as follows:

NSLU2 R128Futurlec TTL-side RS232-sideDB9
pin
2RX1 RS232-1-RXD3
n/an/a RS232-1-GND5

Using a mobile phone data cable (DB9 serial port types)

Some mobile phone data cables are just level converters, and may be a good choice if you can get one more cheaply than the level converter kits described above. However, note that noise pick-up has been reported more often with these cables.

The Siemens S/C25, S/C/M35 and S/SL/ME/M45 phones all operate at 3.3V and the RS232 data cables are compatible. This cable is used on another embedded project. Take a look at: http://www.meshcube.org/meshwiki/ModifiedMobileSerCable (Dead link, use http://web.archive.org/web/20070820095200/http://www.meshcube.org/meshwiki/ModifiedMobileSerCable(approve sites) )

The cable should be powered from the DSub-side (PC/Terminal). The pins which are used are 1 (GND), 5(TX), 6(RX). The Siemens-Handy-connector is shown at http://www.hardwarebook.net/connector/cellular/siemens_c25_s25.html
If your cable is not powered from the DSub-side you have to connect pin 4 to J2 pin 1 (+3.3V).
For a no-name cable for Siemens labelled "880880-84501" "A801-2" "Made in China", (also S30880-S4501 A801-2 ) the BLACK wire is GND, the RED wire is needed for power, the YELLOW cable is data out (TX) and the GREEN cable is data in (RX)

You can also use Nokia DLR-3P data cable. Just cut off connector and wire RED to J2 pin 1 (+3.3V), GREEN to J2 pin 2 (RXD), GRAY to J2 pin 3 (TXD) and BLACK+SHIELD to J2 pin 4 (GND). Since this cable is normally powered by phone you need to connect J2 pin 1.

The Nokia DLR-3 cable is the same hardware, but older Windows95 driver software (which you don't need). I found my cable through Froogle for $2.00 US.

USB connection

Nokia DKU-5 and CA-42 clone cables are available widely, and cheaply (from US$4.00 or UKú2.50 including postage on EBay at time of writing). Instructions for identifying each pin are available at http://buffalo.nas-central.org/index.php/Use_a_Nokia_Serial_Cable_on_an_ARM9_Linkstation

FTDI sell a couple of reasonably cheap USB to 3v3 serial cables, part numbers TTL-232R-3V3 and TTL-232R-3V3-WE, which are known to work. The TTL-232R-3V3 has a 6 pin connector which can be used by swapping the pins to make it compatible with the NSLU2, while the -WE version has bare wires that you can connect up as you like. They are available from the FTDI Online Store.

Using a USB to TTL converter is nice because it seems to solve the floating RxD problem which prevents the NSLU2 from booting (see the section titled, "Serial port and picking-up mains: a word of caution" on this page). The following steps describe how to hook up the TTL-232R-3V3 6-pin connector to the NSLU2 4-pin serial port.

  1. Carefully remove the female pins from the TTL-232R-3V3 6-pin connector by lifting the black tabs that hold each pin in place. A small flat-head screwdriver or a razor blade works well.
  2. Connect the orange wire of the TTL-232R-3V3 to pin 2 of the NSLU2 serial port, the yellow wire to pin 3, and the black wire to pin 4. Don't connect pin 1 on the NSLU2, and the brown, green, and red wires of the TTL-232R-3V3. I reused the black 6-pin connector to hold the socket pins in place.

A USB based data cable for a mobile phone is another possibility. Most (if not all) of these cables are nothing more than an USB to serial port adapter, and as most mobile phone today are using 3.3V anyway they already have the right signal levels.

Most of the cheap cables are based on a Prolific PL2303 chipset (PL2303 datasheet ) which is supported under Windows (Driver Download) and Linux. A third party Nokia data cable for a 8000 series phone has been used with no problems. A data cables from the Siemens C25/35/45 works too. The cables from the old models (i.e. C25) costs a 2..3$.

A cheap($20) cable can be purchased at Radio Shack. The Future-Dial cables have a "dongle" in the middle that has the Prolific usb-serial chip.

See this hack-treo page, and nas-central.

Compatible Radio Shack (Future Dial) "Mobile Phone Data Cables":

   - LG Models 1200, VI5225, VX4500, VX4600, VX600
   - Audiovox Models 8200, 8500 and 8600
   - Nokia Models 3285 and 5185
   - Cable 22 (For Nokia 3100, 3200, 3585i, 3588 and others with Nokia 14-pin pop-port)

Installation of "Radio Shack Mobile Phone Data Cable for Nokia Models 3285 and 5185.", "Radio Shack Mobile Phone Data Cable for Audiovox Models 8200, 8500 and 8600.", "MobileAction MA-8710C for Siemens mobiles" and "Future Dial Cable 22"

  1. Open the connector that connects to the cell phone, You only need 3 wires, and these connect to J2.

    Below are a number of cables listed with a description of the colored wires that you need. Since clone cables might use different colors I recommend googling for the connector layout of the mobile phone you used and carefully pry the cable open (at the phone connector) and study the pinning/cabling.
    For Nokia 3285 and 5185 Cable:

    Pin 1 - NC
    Pin 2 - Orange
    Pin 3 - Red
    Pin 4 - Brown/Shield

    For Audiovox 8200, 8500 and 8600 Cable:
    Pin 1 - NC
    Pin 2 - Yellow
    Pin 3 - Orange
    Pin 4 - Shield

    For LG 1200 Cable:
    Pin 1 - NC
    Pin 2 - Red
    Pin 3 - Orange
    Pin 4 - Shield

    For Siemens MobileAction MA-8710C Cable:
    Pin 1 - NC
    Pin 2 - Red
    Pin 3 - Black
    Pin 4 - Shield

    For Future Dial Cable 22:
    Pin 1 - NC
    Pin 2 - Orange
    Pin 3 - White
    Pin 4 - Green & Shield (twisted together)

    For Nokia DKU-5 or CA-42 (WT048000317):
    This cable seems easier to get in Australia (I got mine off eBay.) There are generic versions available, so the colours might be different. You will probably need a multimeter to find the correct wires.

    From the USB/PC point of view:
    GND: White (maybe also Yellow)
    TX: Red
    RX: Blue (apparently not Green)

    Based on the picture above, it's easy to find RX and TX. Pin 7 of pl-2303 is GND, measure the resistance between pin 7 and GND can help identify GND.

    You can check these with a multimeter - the voltage between GND and TX is 3.3V, and the voltage sags slightly if you send a lot of data out over the port (e.g. by holding a key down in a terminal emulator.) You can also hook up a speaker between these two wires and it should click whenever you transmit a character/press a key.

    The voltage between GND and RX is about 2.5V. If you connect TX and RX together (join the Red and Blue wires) you should see anything you type echoed back to the screen (possibly appearing twice if you have local-echo enabled in your terminal emulator.) For me, this worked when I connected Red to either Blue or Green, but only Blue worked when connected to the WRT54G - nothing was received through the Green wire.

    Assuming your colours are the same as mine, then:

    Pin 1 - NC
    Pin 2 - Red
    Pin 3 - Blue
    Pin 4 - White

I had something a little different:

Pin 1 - NC
Pin 2 - white
Pin 3 - Green
Pin 4 - Red

Me three: Pin 1 - NC
Pin 2 - White
Pin 3 - Green
Pin 4 - Blue

FWIW, I found a discussion in a webforum using this (CA-42) class of cable as a hack for yetanother device. One of their number ("Tom") had taken it upon himself to buy many different samples from many sources with a goal of understanding why some cost $1.99 and some $19.99. What he found shocked him. While the most expensive (but not always) could be argued to be over-engineering, the crappiest (and not always the least expensive) were found to have 1/5 the number of components of even the "ordinary" cable. He concluded: avoid those with injection-molded USB ends (tell-tale sign is four small "holes" where the injection took place). Prefer instead those with the "snap-over" case on the USB end, which can be pried open with a small X-acto or screwdriver. His opinion was that if it's found on ebay, it's likely to be an injection-molded, read, inferior, version. I ordered a $6 one from YallStore? (through amazon, I think) which quite accidentally proved to be one of his "good" variety. The beauty of being able to pry open the cover is that you most likely, as in my case, see the circuit board connections, the colors of the conductors, and the labels: GND, Tx, Rx, Vcc. BTW, I paid for my good luck by having Our Fine Postal Service take upwards of 3 weeks to get it to me. Remember to Tip your Postal Employees.

To tie a bow in this:
dmesg | grep tty \# to find out what tty pops up when your slug shows up on your USB: in my case, /dev/ttyUSB0
sudo picocom -s 115200 -d 8 -p n /dev/ttyUSB0 # note much non-printable gibberish until the NSLU2 is powered on;
# when it's powered on, look for \'+\': Ctrl-C to interrupt as soon as you see the \'+\' or sit back and watch it boot and see why it fails
# (in my case: "no /dev/sda2" wtf???)

# Solder three wires from a ribbon cable to J2, pins 2, 3, 4. On the cell phone cable, cut off all but the three wires above. \[If you can open the cover at the USB, snip them inside and replace the cover.\]

  1. Carve a slot just below the power connector hole in the back panel that will allow you to insert the strain relief through the power supply hole and slip it down into place. [An alternative is to NOT run an exterior cable, but instead to take the case apart and connect the cable to the header only when things are so bad it's worth this effort to troubleshoot.]
  2. Run the cable through the power supply hole, and solder the other ends of the 3 wires to the phone data cable. You can shrink wrap, or tape the wires.
  3. Slide the strain relief down into the slot, and slide the board back into the case. The power supply socket will lock the strain relief in place.
  4. Plug the USB connector into your Linux box. Start minicom and set the port to /dev/ttyUSB0 115200 8N1. Power up and you will see a '+' printed. Ctrl+C will get a RedBoot prompt, or leave it alone and watch it boot.
  5. Windows users will need a Windows driver for the Prolific USB-to-Serial adaptor, available at the Prolific Technology Inc Download Site

If the phone connector can easily be opened (as in the case of my connector which I got from ebay), then you can probably even do without a multimeter. Just have a look at the pinout of the Nokia Pop-port, or this similar document with photos for the Buffalo NAS devices, and you can easily figure out which wire is connected to which pin.

Lemo, a Swiss company specialized in connectors, offers tiny, yet professional, connectors that can easily be added to the back panel of the slug, right below the power connector.

Read only connection without level conversion

When I bought an USB to RS232? TTL converter running with 5V by mistake, I didn't want to buy another one just to adjust the voltage. So I read about TTL and the specs said that even 5V TTL circuits would recognize voltage greater than 2.2V as a logic one. So the 3.3V on the NSLU2s? TXD will still be enough to allow the 5V TTL chip to read the signals. What I did was connecting the 5V VCC provided by USB to the VCC pin of the converter, both GNDs? (The one of the NSLU2 and the one of USB) to the GND pin and the NSLU2s? TXD pin directly to the converters RXD pin.

With this connection I can read all the output of the NSLU2, but of course I can't write anything. Maybe I will add a little circuit to convert the 5V TXD of the converter to 3.3V so the connection will be bidirectional. But for now read only is fairly enough to debug things.

Accessing the terminal

The NSLU2 configure his serial port at 115200 baud, with 8 bits of data, no parity (8N1) If you run a Linux a box, you can use the UUCP for talking to the nslu2 by the serial port:

 cu -l /dev/ttyS0 -s 115200 (for COM1).

If cu is giving you

 cu: open (/dev/ttyS0): Permission denied
cu: /dev/ttyS0: Line in use

even if running as root, you might want to check if /dev/ttyS0 is owned by uucp. If not do a chown uucp /dev/ttyS0

picocom is another simple terminal program:

 picocom -b 115200 /dev/ttyS0

If you run a windows box, you can use the HyperTerminal program located in accessory->Communication in the start menu. Or you can download uCon from: http://www.microcross.com/html/micromonitor.html (do a find for uCon). It's supposed to have better logging and more features. Or putty for its all-around goodie-ness.

Serial port and picking-up mains: a word of caution

Loose wires hanging off the serial connector can prevent the slug from booting properly. When this happens, the power LED stays orange and linux never boots. If a serial cable is plugged in and a serial terminal run, pressing enter will resume the booting process. This problem does not seem to occur with a TTL-232R-3V3 (see above) USB to TTL converter which makes sense, because the serial port of the NSLU2 is always connected to the FT232R IC which is used inside the cable.

This problem is caused by the mains being picked up by wire and injected into the RX pin as a 1.6V, 50Hz signal (measured with a scope).

There are two cases where this could be a problem:

  • Problem will occur when the serial cable is left unplugged at the PC end.
  • Problem can occur if the serial port is shifted to a connector at the back of the slug... and left unplugged.

This illustrates the second case: User drilled a hole under the power connector and fitted a 2.5mm stereo jack socket to bring the serial lines to the back. The NSLU2 will boot when the socket is used, but not when the serial cable is unplugged from the NSLU2. The 10cm cables between the socket and the PCB connector were causing the problem.

The following experiment was conducted to trace the problem:

  • NSLU2 booted normally when RX (pin 2) was connected to GND (pin 4).
  • NSLU2 booted normally when RX (pin 2) was connected to VCC (pin 1, via a 4.7K resistor).
  • NSLU2 didn't boot when a 10cm long twisted pair stub was connected between VCC and RX.

Connect a 3K resistor between pins one and two of the serial port pads on the SLUG and the problem will go away. Any TTL level driver can drive into 3K yet the resistance is low enough to prevent AC pick-up.

Acknowledgements

Thanks to paulbart, kju, m. allan noah, guidoz and Gerald L Clark.

---

You can find yet another example of serial port h/w implementation at http://p13r0.no-ip.info/g604t/RS232_howto.zip(approve sites)

To set the port free from the Linux prompt (in other words: to let my application use that serial port), I did this (tested on Unslung 6.10 only):

  • mv /dev/console /dev/console_original
  • mv /dev/ttyS0 /dev/ttyS0_original
  • mknod /dev/console c 1 3 (same maj/min of /dev/null)
  • mknod /dev/ttyS0 c 4 65 (same maj/min of /dev/ttyS1)
  • mknod /dev/COM1? c 4 64 (same maj/min of /dev/ttyS0_original)
  • chmod 644 /dev/console
  • chmod 644 /dev/ttyS0
  • chmod 644 /dev/COM1?

The "free" port is now /dev/COM1?


This page is password protected.

The password is "serialport". Let's see if that stops the automated wiki spam.