Today, When I connected my ARM9 development board with my laptop through picocom, I faced a peculiar error.

$ picocom -b 115200 /dev/ttyUSB0

picocom v1.4

port is : /dev/ttyUSB0
flowcontrol : none
baudrate is : 115200
parity is : none
databits are : 8
escape is : C-a
noinit is : no
noreset is : no
nolock is : no
send_cmd is : ascii_xfr -s -v -l10
receive_cmd is : rz -vv

Removing stale lock: /var/lock/LCK..ttyUSB0

FATAL: cannot lock /dev/ttyUSB0: File exists

After googling, I found solution for this.

Actually some process is using my serial port, which is interrupting me to connect the same for another process. Respective process id is present at /var/lock/LCK..ttyUSB0. Navigating to /var/lock/LCK..ttyUSB0 I found a number (process id) as 2850. But when I tried to figure out that process, nothing printed my all efforts were went vain.

$ ps 2850

PID TTY      STAT   TIME COMMAND

So I decided to kill that process. My bash reported as below.

$ sudo kill 2850

kill: No such process

Killing forcibly,

$ sudo kill -9 2850 

kill: No such process

Finally I decided to remove that file, so it may not cause any problem.

 $ sudo rm /var/lock/LCK..ttyUSB0 

As I expected, it worked for me.

$ picocom -b 115200 /dev/ttyUSB0 

picocom v1.4

port is : /dev/ttyUSB0
flowcontrol : none
baudrate is : 115200
parity is : none
databits are : 8
escape is : C-a
noinit is : no
noreset is : no
nolock is : no
send_cmd is : ascii_xfr -s -v -l10
receive_cmd is : rz -vv

Terminal ready
Embedded Artist 3250 Board
Build date: Sep 28 2010 11:43:41
Autoboot in progress, press any key to stop

U-Boot 2009.03-rc1-00014-g9950d48 (May 16 2012 – 04:45:53)

DRAM: 64 MB
NAND: 128 MiB
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
uboot>

Note : Proceed further by staying at /var/lock/

Moral of the story : When you try to connect any development board (or anything that can access serial port) with your system, a file named LCK..ttyUSBx (x – 0..9) is automatically generated at /var/lock/, which holds corresponding process id of Process which runs on using that port.

For me, using process id (16738) at /var/lock/LCK..ttyUSB0

 $ ps 16738

PID TTY STAT TIME COMMAND
16738 pts/0 S+ 0:00 picocom -b 115200 /dev/ttyUSB0

When I plug-out my board, it automatically deleted from /var/lock/.

Hence, reason for my actual problem was LCK..ttyUSB0 was not deleted previously. For Solution go back to top.

Enjoy..!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s