Question

I am trying to send/receive data over serial connection (GPIO UART pins) between a Raspberry Pi (B model, raspian wheezy) and an STM32F4 board.

To setup the serial port, i followed all the stepts found in several tutorials like: http://elinux.org/RPi_Serial_Connection#Preventing_Linux_using_the_serial_port

When failing to get a connection to the STM32F4 board, i read that you can test the serial port locally on the pi if you just connect the TX, RX pins off the pi to eachother and it should just repeat the entered data in minicom.

sadly this does not work either.

The settings for ttyAMA0 in files 'cmdline' and 'inittab' are ok. (like described in many tutorials)

and allso tried auto configuration scrips from https://github.com/lurch/rpi-serial-console

Connecting RX to the TX pin on rpi directly does not give any output in minicom. I allso tried with a python script that repeats given input. Nothing seems to work, i'm kind of lost here.

Minicom start command should be correct(tried with different baud rates):

root@raspberrypi:/home/jef# minicom -b 9600 -o -D /dev/ttyAMA0

OPTIONS: I18n
Compiled on Apr 28 2012, 19:24:31.
Port /dev/ttyAMA0

On the bottom of minicom it allways shows status offline:

CTRL-A Z for help |  9600 8N1 | NOR | Minicom 2.6.1  | VT102 |      Offline

When checking available serial ports with python nothinig is swown:

python -m serial.tools.list_ports
no ports found

User is in dailout group so that should not be the issue(tried as root and non root):

root@raspberrypi:/home/jef# id
uid=0(root) gid=0(root) groups=0(root),20(dialout),1001(indiecity)

Verification that serial port is not used by getty anymore:

root@raspberrypi:/home/jef# ps aux | grep getty
root      2809  0.0  0.1   3740   804 tty1     Ss+  10:36   0:00 /sbin/getty --noclear 38400 tty1
root      2810  0.0  0.1   3740   804 tty2     Ss+  10:36   0:00 /sbin/getty 38400 tty2
root      2811  0.0  0.1   3740   804 tty3     Ss+  10:36   0:00 /sbin/getty 38400 tty3
root      2812  0.0  0.1   3740   804 tty4     Ss+  10:36   0:00 /sbin/getty 38400 tty4
root      2813  0.0  0.1   3740   804 tty5     Ss+  10:36   0:00 /sbin/getty 38400 tty5
root      2814  0.0  0.1   3740   804 tty6     Ss+  10:36   0:00 /sbin/getty 38400 tty6
root      3129  0.0  0.1   2012   624 pts/0    S+   11:57   0:00 grep getty

i checked for other apps using ttyAMA0, allso nothing:

root@raspberrypi:/home/jef# ps aux | grep ttyAMA0
root      3125  0.0  0.1   2012   628 pts/0    S+   11:56   0:00 grep ttyAMA0

users has correct rights to access serial port:

root@raspberrypi:/home/jef# ls -l /dev/ttyAMA0
crw-rw---T 1 root dialout 204, 64 Dec 25 11:53 /dev/ttyAMA0

Is there anything i missed? I read about 20 different tutorials and blogs on how to setup the serial port and i can't fond what causes this. Could you give me some advice i could look for please.

Was it helpful?

Solution 2

I have an Arduino connected to my Raspberry Pi serial port via a level shifter (3.3v to 5v) and was also having issues with minicom. I could receive the output from the Arduino in minicom but I couldn't get anything to send no matter what settings I tried. I also had exactly the same problem with minicom using the Arduino plugged in to the USB (/dev/ttyUSB0).

In the end I resorted to using the basic python serial console, install pyserial using pip (pip install pyserial) and execute the following command:

python -m serial.tools.miniterm -p /dev/ttyAMA0 -e

OTHER TIPS

I just went through something similar today. I had to set minicom to disable hardware control and the looping worked for me, as well as cross connecting 2 Raspis together over UARTs.

Also, I use 115200 buad rate on my TTYAMA0 connection string minicom -b 115200 -o -D /dev/ttyAMA0

Alt A

Z

O

Serial Port Setup [enter]

F toggles hardware flow control off

*Save those settings and anything you type should show up on the screen, but is actually being transmitted via uarts.

My minicom footer looks like this as well (just diff baud rate, but shows offline also but works)

CTRL-A Z for help |115200 8N1 | NOR | Minicom 2.5 | VT102 | Offline

Good Luck!

You can run a simple test by putting this sketch on your Arduino:

#define SERIAL_BAUD 115200

void setup() {

  //Init serial connection
  Serial.begin(SERIAL_BAUD);
  Serial.setTimeout(1);

}

void loop() {

  if ( Serial.available() ) {
    byte type = Serial.read();
    Serial.write(type);
  }

}

And wire it up using the following diagram:

Wiring Arduino to Raspberry Pi

Note: make sure you don't connect a usb cable to the Arduino. It will be powered by the Raspberry Pi.

Note: the Raspberry Pi runs on 3.3V so you must be sure that anything you connect to it is running 3.3V or has a level shifter. See more information about level shifters here. (go down to the Logic voltage levels section) Sparkfun has some basic level shifters (with schematics) here if you want to learn more.

You can then install and run screen. Screen is a dead simple way of connecting to a serial port.

apt-get install screen

Then run the following:

screen /dev/ttyAMA0 115200

The screen will show up blank. But, when you start typing you will notice that the characters you're writing are getting looped back to your terminal.

Note: If the screen is still blank you should double check the connections (power led on the Arduino is a good thing to check).

When in doubt you can see my whole example here.

Thankt for the tips guys. I tried them, but they didn't resolve the issue It seems that the raspberry pi UART port is shortcutted. I connect it to another raspberry pi (model A) that i borrowed and the B model just returned all sent characters that i sent with the A model without displaying them locally.

I have purchased a new model B and tested the AURT port and it is working as it should.

Allthough the STM32F4 board i purchased should allso be 3.3V it seems to have broken my raspi UART at some point (or never worked at all). I will now use a LLC anyway when i test again with the STM32F4 board just to make sure i dont blow anything up.

Thx again for the tips!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top