Reading time: 4 – 6 minutes

Migration in actionPhoto by: lilit

I’ve recently been “forced” to move my desktop from Windows to Linux again. Basically my current desktop “decided” it won’t support Windows anymore, and any attempt to start it ends up in a BSOD, and I just got fed-up of trying to get it to work.

In fact, all of my development at home is done on Linux anyway, and I was just using windows as my dummy operating system, and using virtualization with my development environment. move to Linux works just as well.

As usual the move to Ubuntu 10.4 was a breeze, and I didn’t even have to download any of the drivers for things like graphics card, wireless or external hard-drives. everything worked straight away.

However, after I started to play with my “new” box, I noticed that my external serial ports were not working properly. They were passing the right signal and voltage, but somehow not being able to receive any feedback.

I use serial ports for RS-232 protocol a lot with my pic programming, and although I could simply use a Serial-to-USB cable, I find that it’s just an extra layer, and you could easily blow your USB module should you do anything wrong.

PCI card to two serial portsThe device I’m using is a PCI card that gives me two serial ports. I got it off eBay for a couple of pounds, and so far it has been working flawlessly.

Its communication is a lot faster than via USB, as I’m connected directly to the motherboard, therefore, no “middle-man” is used during the process.

As described previously, it started to malfunction after I moved on to Ubuntu, and even after I installed the correct driver that accompanies it, I would still not be able to download anything to my pic. the error I was getting was:

Verification error – 0×00 transmitted but 0xFFFFFF80 received at byte 1

After some research, I found out that  the driver that comes with the board, does little or nothing to make sure it works properly on Linux, and I would  have to make sure the board was properly “initiated” once the operating system loaded up.

A quick Google brought me to this. This guy gives a whole explanation of all the inner-workings and reasons why thigs aren’t working, and he happens to also be using the same board as I am.

He also mentions that you can list all the available COM ports on your system by issuing the following command on terminal:

setserial -g /dev/ttyS*

This was returning:

/dev/ttyS0, UART: undefined, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: undefined, Port: 0x1108, IRQ: 18
/dev/ttyS2, UART: undefined, Port: 0x1100, IRQ: 18
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3

The software I use to program my pic micro-controller was able to detect it, on /dev/ttyS0, so that’s what I needed to get working for now.

on the website mentioned above, the guy mentions he was able to get everything working by issuing the following command:

sudo setserial /dev/ttyS[YOUR-PORT_HERE] uart 16550A

I then issued it for each of my ports, and got everything to work fine.

sudo setserial /dev/ttyS0 uart 16550A
sudo setserial /dev/ttyS1 uart 16550A

Now, when I run setserial -g /dev/ttyS*, I get:

/dev/ttyS0, UART: 16550A, Port: 0xe800, IRQ: 22
/dev/ttyS1, UART: 16550A, Port: 0xe400, IRQ: 22
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3

Next step was add this to my /etc/rc.local so it runs on startup, and everything is fine again.

I know this is slightly off-topic, but I thought it might be of help to somebody in the future.

Be Sociable, Share!

10 Responses to “Getting serial ports to work on Linux”

  1. If you start using Linux, normally you don’t want to switch back to Windows. It used to be a Problem, that there have been missing Software on Linux, but now after all this years there is a Solution or Software for every desire on Linux. This plattform improoved so much, that you can use it now for almost everything. So I will never go back to Windows. Long live Linux! :-)

  2. Stephen says:

    Just installed a card similar to yours, checked with

    # setserial -g /dev/ttyS[0123]
    /dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
    /dev/ttyS1, UART: undefined, Port: 0×1040, IRQ: 169

    didn’t look good, googled and found your fix
    Problem to solution in 2 minutes, thanks

  3. Marcos Placona says:

    Very glad my blog post helped you Stephen.

  4. RawthiL says:

    Thanks a lot, I’ve been weeks trying to make my Boarduino work untill I found this!

  5. Marcos Placona says:

    That’s very good news. Glad it worked out for you.

    Cheers

  6. Sam says:

    Hi can you please give me the command to add it in to startup
    its my first week with Ubuntu
    thank you

  7. Karst says:

    Please let me know how to get it rc.local.
    What do I have to fill in.
    Just as Sam new in this.

    Thanks in advance

  8. Sergio says:

    Hi, try to do that but got this:
    setserial /dev/ttyS0 uart 16550A
    ->Cannot set serial info: Device or resource busy ???

    any help please, thanks!

  9. saurabh says:

    hhey,,you are the mannnnnnnnnnnnnn bro,,
    solved my problemmmmmmm..

    thnx a tonnn!!

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>