1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Tomato: serial port support ? /dev/tts/x

Discussion in 'Tomato Firmware' started by jenom, Jul 3, 2012.

  1. jenom

    jenom Networkin' Nut Member

    can someone who has TOMATO installed check, if in /dev there is a serial port listed :


    Thanks !
  2. koitsu

    koitsu Network Guru Member

    There is no /dev/tts on TomatoUSB. The Linux kernel is significantly older than that, thus the serial port devices are /dev/ttyS0 and /dev/ttyS1. Verification:

    root@gw:/tmp/home/root# ls -l /dev/ttyS*
    crw-r--r--    1 root     root        4,  64 Dec 31  1969 /dev/ttyS0
    crw-r--r--    1 root     root        4,  65 Dec 31  1969 /dev/ttyS1
    root@gw:/tmp/home/root# dmesg | grep -i serial
    Serial: 8250/16550 driver $Revision: 1.90 $ 2 ports, IRQ sharing disabled
    serial8250: ttyS0 at MMIO 0xb8000300 (irq = 8) is a 16550A
  3. jenom

    jenom Networkin' Nut Member

    thanks for the info
    so does it mean, both serial port ttyS0 and ttyS1 are there and available for any apps to use ?
  4. koitsu

    koitsu Network Guru Member

    Yes and no. Can you explain exactly what it is you're trying to do that involves the serial port header?
  5. jenom

    jenom Networkin' Nut Member

    rq-sssp-client needs a free second serial port to communicate (ttyS1)
    currently using openwrt/kamikaze with /dev/tts/1 (tts/0 is reserved by the system for a terminal)
    would like to give tomato a try, as long as there is a free serial port ( 0/1)
    also using a writable jffs file system, 1096 kb total, 632 kb used
  6. koitsu

    koitsu Network Guru Member

    I understand. The answer is then: it depends on the model of hardware you have. For example some routers have 2 serial ports, 1 which is intended for recovery CLI and some other bits (some kind of CFE I think) and sometimes has a 4-pin header on the motherboard, and the other which on many systems is on the PCI bus but doesn't actually have any solder points or headers on the router PCB. If the board has pin headers, you need to verify what the voltage is, as many boards require a MAX232 chip to normalise their voltage for PC use.

    If the model of router you have has a serial port header that's wired and routed to what should be /dev/ttyS1, then yes, it should work just fine in TomatoUSB. Otherwise my recommendation to you would be to consider something like a USB serial adapter that uses an FTDI chip (do not go with any other IC brand; FTDI makes reliable stuff and provides documentation to the open-source community). You might have to figure out how to build TomatoUSB yourself (to build the necessary USB serial drivers which you could modprobe I believe) in that case, but I would say it's doable.

    Otherwise overall I would have to say this kind of project might be better suited for something like OpenWRT running on something that's not just "generic consumer hardware". There are many vendors out there who make embedded systems that have one or more serial ports on them; a lot easier to deal with than proprietary hardware like, say, an Asus RT-N16. Generally speaking TomatoUSB is intended for generic end-users who just want a reliable router for their home network + have all the adjustments via GUI, not something more in-depth. OpenWRT provides something more technical/engineering-oriented.
  7. jenom

    jenom Networkin' Nut Member

    thanks for the reply
    my router is a WRT54G v3, it is already modified, and an external serial connector added
    (soldering points on the board, TTL to RS232 converter with MAX,etc...)
    as I have mentioned, it has a fully functional hardware setup....works fine with openwrt
    going to flash with tomato, and see what happens....?
    thanks again
  8. koitsu

    koitsu Network Guru Member

    Ah, the old WRT54G and friends. I wrote a document long ago of what to buy to wire the sucker up for serial. :)

    If I remember right, two pins on the connector are wired to RX/TX for ttyS0, and two pins on the connector are wired to RX/TX for ttyS1. This document seems to confirm it, but that's a WRT54GS, which is not necessarily the same as the WRT54G. ttyS0 is considered the serial console port + provides some degree of CFE. So using ttyS0 as a serial communications port with another device isn't a good idea; reboot the router, etc. and the device on the other end will get spurious data. I would say definitely use ttyS1.

    I think you've already figured this out though. :)

    The next problem with the serial ports is lack of hardware flow control (RTS/CTS). The end result is dropped characters across the wire when large amounts of data are sent or received (despite being 16550As with 16-byte FIFOs). The only solution for this is to use XON/XOFF within the program you're using, but that also sucks because it means bytes 0x11 (XON) and 0x13 (XOFF) can't be sent across the wire. All of this is confirmed here. In English: rq-sssp-client will need to support XON/XOFF flow control options within its configuration. If it doesn't, I wouldn't even bother trying this project. (Note: this is why any device that provides serial capability needs hardware flow control. It's amazing how many devices lack it. Utterly stupid...)

    Anyway, if it works fine with OpenWRT, I would say stick with that. It should work with TomatoUSB (assuming you change the serial device name string in rq-sssp-client.conf), but my comment about flow control still stands.

    Also remember that TomatoUSB doesn't operate off of JFFS -- there is no writeable flash-based filesystem. There are options to enable this in TomatoUSB, but there can be some dire consequences using it if you aren't careful. The general recommended solution for storage is to either use a CIFS/SMB share on your local network, or if you don't have one, use a USB flash drive -- except the WRT54G doesn't have a USB port. You can try dealing with the JFFS stuff in TomatoUSB if you want.
  9. jenom

    jenom Networkin' Nut Member

    How about the Tomato 1.28 version ?
    Does it support ttyS1 and has JFFS -- writeable flash-based filesystem ?
  10. koitsu

    koitsu Network Guru Member

    All TomatoUSB versions have serial driver support, to my knowledge.

    I believe JFFS support is in the official TomatoUSB firmware as well, but I'm not sure. I run Toastman's recent builds (specifically the VPN build). Meaning, in Toastman's builds, there's a JFFS menu where you can enable/disable it.

    But I think you might have misunderstood what I said. I'm saying that use of JFFS on TomatoUSB is one of those "you're on your own" things. I believe there are some repercussions from using it -- and the reason I don't has to do with concern over flash wearing out too much (yes, despite how the filesystem is designed). I simply use a CIFS/SMB share and keep my filesystems on TomatoUSB read-only (squashfs).

    The mtd partition layout on TomatoUSB is as follows (this is on an Asus RT-N16 -- your mileage may vary with other models):

    Flash device: 0x2000000 at 0x1c000000
    Creating 5 MTD partitions on "Physically mapped flash":
    0x00000000-0x00040000 : "pmon"
    0x00040000-0x01fe0000 : "linux"
    0x00127000-0x007a0000 : "rootfs"
    0x007a0000-0x01fe0000 : "jffs2"
    0x01fe0000-0x02000000 : "nvram"
    And actual filesystems:

    root@gw:/tmp/home/root# df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/root                 6592      6592         0 100% /
    tmpfs                    63500       208     63292   0% /tmp
    devfs                    63500         0     63500   0% /dev
    root@gw:/tmp/home/root# mount
    rootfs on / type rootfs (rw)
    /dev/root on / type squashfs (ro)
    proc on /proc type proc (rw)
    tmpfs on /tmp type tmpfs (rw)
    devfs on /dev type tmpfs (rw,noatime)
    sysfs on /sys type sysfs (rw)
    devpts on /dev/pts type devpts (rw)
  11. jenom

    jenom Networkin' Nut Member

    Just installed Tomato 1.28, enabled and mounted a JFFS2 file system (1024/700)​
    It has /dev/tts/0 and /dev/tts/1 , so I am good to go !​

    Copied a rq-sssp-client and libstdc++.so.6 into /root/...
    However, rq-sssp-client needs libstdc++.so.6 in a /lib/... location, but when I tried to make a symbolic link between the library file in /root/.... to the /lib/.... (ln -sf /root/existing /lib/new), got an error message: Read only file system! ------the /lib is not writable !​

    Is there any way to fix this problem ? remount file system? change permission ? different way to create link ?​

  12. koitsu

    koitsu Network Guru Member

    I already warned you of this exact situation in an earlier post, but from what I can tell you ignored what I wrote or thought I was bluffing? :)

    Use of JFFS on TomatoUSB does not make all filesystems writeable. Everything you do on the filesystem will be lost on reboot, barring the JFFS partition. Read the output from "mount" that I posted previously -- and read it slowly, pay very close attention.

    There is no real solution other than to place the library in question in the same directory as the executable (depends partially on ld.so, as well as how things were compiled/linked (e.g. ld -rpath flag)), or alternately you can make a script that sets/exports environment variable LD_LIBRARY_PATH to a location where the library resides prior to running the executable. It may or may not work.

    Now you understand exactly why I told you to stick with OpenWRT for what you're trying to do. It has a better overall shell-based environment for this sort of thing. This is not what TomatoUSB is focused on.

    The only other alternative would be to see if there is an official build as part of opkg which is part of the Entware project, which requires a proper /opt filesystem (either JFFS, CIFS/SMB, or whatever else). You can read how to go about all of that here: http://code.google.com/p/wl500g-repo/

    If there is not already a rq-sssp-client package for Entware, then you can build one yourself. There are instructions how to do that on the page I linked.
  13. jenom

    jenom Networkin' Nut Member

    This Tomato starts remind me of my past encounter with DDWRT, with its fancy GUI interface, but otherwise locked down to any attempt to turn it into something more useful.
    Thanks for the info on LD_LIBRARY_PATH.....I should give it a close look.
    Meanwhile, back to OpenWrt Kamikaze 8.2.09......it is totally open and worked for my special purpose !
    Thanks for all the replies !
  14. mstombs

    mstombs Network Guru Member

    How is wireless support in OpenWRT these days? It is cool booting to a Linux 3.3 kernel though I'm sure!
    OpenWRT does have versions where the filesystem can be a highly compressed squashfs-lzma readonly system but files can be overlaid with mini_fo (or something). You must be pretty restricted with what you can load onto a 4MB flash router though.

Share This Page