WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Serial /dev/ttyAMA0  (Read 4658 times)

Offline mehstg

  • Newbie
  • *
  • Posts: 5
Serial /dev/ttyAMA0
« on: May 13, 2015, 07:16:15 PM »
Hi all

I am out of ideas now, hoping one of you will be able to help me. I have a python script that uses /dev/ttyAMA0 (the built in serial on the GPIO). I am unable to use it however as the system reports it is already in use.

I have removed the offending code from cmdline.txt on partition mmcblk01p1. I have also commented out the serial console line in bootlocal.sh.

I checked /etc/inittab for a reference to the serial device and there is nothing in there.....I am now out of ideas what else could be holding the port open.

Any ideas. I'm running piCore 6.x on a Armv6 pi.

Paul

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11519
Re: Serial /dev/ttyAMA0
« Reply #1 on: May 13, 2015, 08:37:40 PM »
Hi mehstg
Try:
Code: [Select]
fuser -m /dev/ttyAMA0That should return a list of process IDs. Then run:
Code: [Select]
psand check which process IDs match.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Serial /dev/ttyAMA0
« Reply #2 on: May 14, 2015, 01:50:35 AM »
By default serial terminal on ttyAMA0 is started in /opt/bootlocal.sh


Code: [Select]
# Start serial terminal.
/sbin/getty -L ttyAMA0 115200 vt100 &

Comment this line to disable. After editing do not forget to backup before reboot.
« Last Edit: May 14, 2015, 01:53:00 AM by bmarkus »
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline mehstg

  • Newbie
  • *
  • Posts: 5
Re: Serial /dev/ttyAMA0
« Reply #3 on: May 14, 2015, 02:28:43 AM »
Hi, as mentioned in my original post, I have commented the line out in bootlocal.sh already and rebooted.

Running fuser -m /dev/ttyAMA0 shows two PID's holding the terminal open. Both are labelled '-sh' when I run PS

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Serial /dev/ttyAMA0
« Reply #4 on: May 14, 2015, 04:00:46 AM »
On a stock piCore-6.1beta1 I get:

Code: [Select]
root@box:/home/tc# fuser /dev/ttyAMA0
21641

21641 root     /sbin/getty -L ttyAMA0 115200 vt100

Only getty is using serial line from /opt/bootlocal.sh no any other process.

« Last Edit: May 14, 2015, 04:02:22 AM by bmarkus »
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline mehstg

  • Newbie
  • *
  • Posts: 5
Re: Serial /dev/ttyAMA0
« Reply #5 on: May 14, 2015, 04:26:11 AM »
bootlocal.sh:
Code: [Select]
#!/bin/sh

/usr/local/bin/wifi.sh -a 2>&1 > /tmp/wifi.log

# Set CPU frequency governor to ondemand (default is performance)
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

# Load modules
/sbin/modprobe i2c-dev

# Start openssh daemon
/usr/local/etc/init.d/openssh start

# ------ Put other system startup commands below this line

cmdline.txt
Code: [Select]
dwc_otg.lpm_enable=0 console=tty1 root=/dev/ram0 elevator=deadline rootwait nortc loglevel=3 noembed
fuser:
Code: [Select]
tc@nixiePi:~$ fuser -m /dev/ttyAMA0
1581 1789

1581 tc       -sh
1789 tc       -sh

If that is the case bmarkus, I may do a re-install. I wonder if it is one of my extensions that is holding the serial line open. (I have wifi and python gpio installed)


Offline mehstg

  • Newbie
  • *
  • Posts: 5
Re: Serial /dev/ttyAMA0
« Reply #6 on: May 14, 2015, 04:29:50 AM »
A little more digging.....It appears it is the busybox terminal...almost like I had not commented it out in bootlocal.sh

Code: [Select]
tc@nixiePi:~$ lsof | grep 1581
1581 /bin/busybox /dev/tty1
1581 /bin/busybox /dev/tty1
1581 /bin/busybox /dev/tty1
1581 /bin/busybox /dev/tty
tc@nixiePi:~$ lsof | grep 1789
1789 /bin/busybox /dev/pts/0
1789 /bin/busybox /dev/pts/0
1789 /bin/busybox /dev/pts/0
1789 /bin/busybox /dev/tty

Offline mehstg

  • Newbie
  • *
  • Posts: 5
Re: Serial /dev/ttyAMA0
« Reply #7 on: May 15, 2015, 04:21:12 PM »
Just wanted to report back on this. Did a reinstall from scratch and all is working as expected.

thanks for your help