Skip navigation.
Home
The QNX Community Portal

View topic - Unable to launch Uart serial driver

Unable to launch Uart serial driver

For discussion of realtime and/or embedded programming.

Unable to launch Uart serial driver

Postby Anant Pai » Tue Apr 11, 2017 12:30 pm

Hi,

We are working on porting QNX to a custom ARM Cortex A7 board. We are facing trouble while launching the serial driver through the build script.
In the build script we launch the driver with the following command
devc-pl011Uart -e -S -F -b115200 -c51200000 -u3 0x50020000,59
waitfor /dev/ser3
reopen /dev/ser3
display_msg Reopen done

The reopen command succeeds and we get the display print on console.
There after the shell hangs indefinitely and does not execute any shell commands correctly.
We observe from JTAG debugger that we consistently get Receive interrupts whenever we input something from the host and the input is processed by tty
to be echoed back on console. However the given input is not processed by the shell.

Do we need to enable/configure something specific in Startup, Build script to enable the TTY layer to work consistently.
Can somebody please help in resolving this issue.

Regards
Anant
Anant Pai
Active Member
 
Posts: 19
Joined: Wed Mar 01, 2017 2:25 pm

Re: Unable to launch Uart serial driver

Postby Tim » Tue Apr 11, 2017 2:46 pm

Anant,

I'm not 100% clear on what your trying to accomplish. Are you wanting to be able to use the serial port to be able to enter commands to the shell?

If you post the rest of your build script that will help answer what's configured incorrectly.

Tim
Tim
Senior Member
 
Posts: 1392
Joined: Wed Mar 10, 2004 12:28 am

Re: Unable to launch Uart serial driver

Postby Anant Pai » Tue Apr 11, 2017 3:22 pm

Tim,

Yes we are trying to use the serial port to enter commands to the shell.
Below are the set of observations.

On board power on i see the following logs on console.
Loading IFS...done
alloc_syspage_memory: syspage size:000008c8 _syspage_ptr:a079a000
callout_io_map: mapping paddr:48e01000 returns:fc405000
callout_io_map: mapping paddr:48e02000 returns:fc406000
callout_io_map: mapping paddr:50020000 returns:fc408000
callout_io_map: mapping paddr:50020000 returns:fc409000
callout_io_map: mapping paddr:50020000 returns:fc40a000

System page at phys:a079a000 user:fc404000 kern:fc404000
Starting next program at vfe05e02c
cpu_startnext: cpu0 -> fe05e02c
------------------------------------------------
Welcome to QNX Neutrino 6.6.0
slog launched
pipe launched
Serial Driver Launching...
Reopen done


The Shell on bootup hangs at this point. I get the prompt only if i enter Ctrl+C character.

Once i get the prompt i am able to enter characters but the shell does not process them Instead i see the same input being printed twice on console.


# pidin
pidin



###########################################################################
##
## QNX Neutrino 6.6 on the (ARMv7 Cortex-A7 core) Board
##
###########################################################################
##
## SUPPORTED DEVICES:
## UART, I2C, SPI
##
###########################################################################
##
## NOTES:
##
###########################################################################

###########################################################################
## START OF BUILD SCRIPT
###########################################################################
[image=0xA0000000]
[+keeplinked]
[virtual=armle-v7,raw] .bootstrap = {
# Options specific to this BSP:
# Increase or decrease the verbosity level
startup -v
#######################################################################
## PATH set here is the *safe* path for executables.
## LD_LIBRARY_PATH set here is the *safe* path for libraries.
## i.e. These are the paths searched by setuid/setgid binaries.
## (confstr(_CS_PATH...) and confstr(_CS_LIBPATH...))
#######################################################################

PATH=/proc/boot:/bin:/usr/bin:/sbin:/usr/sbin:/usr/lib:/etc
LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll:/usr/lib:/etc procnto

#PATH=/proc/boot procnto -ae
}

[+script] .script = {

procmgr_symlink ../../proc/boot/libc.so.3 /usr/lib/ldqnx.so.2
TZ=EDT5EST

display_msg ------------------------------------------------
display_msg Welcome to QNX Neutrino 6.6.0

#Start some common servers
slogger &
display_msg slog launched
pipe &
display_msg pipe launched
#devc-pty
display_msg Serial Driver Launching...
devc-serPl011 -e -S -F -b115200 -c51200000 -u3 0x50020000,59
#display_msg Serial Driver Launched
waitfor /dev/ser3
reopen /dev/ser3

display_msg Reopen done

#######################################################################
## These env variables are inherited by all the programs which follow
#######################################################################

SYSNAME=nto
TERM=qansi
HOME=/
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:/usr/photon/bin:/proc/boot
LD_LIBRARY_PATH=/lib:/usr/lib:/lib/dll:/opt/lib:/proc/boot

[+session] ksh &
#[+session] ksh /proc/boot/.console.sh &
#[+session] sh &
}

# Redirect console messages
[type=link] /bin/sh=/proc/boot/ksh
[type=link] /dev/console=/dev/ser3
[type=link] /tmp=/dev/shmem

#Shared libraries
libc.so
libz.so
libm.so
libmq.so
libcpp.so.5
libcpp-ne.so.5
librpc.so
devnp-steth-slx.so

###########################################################################
## uncomment for BLOCK device
###########################################################################
libcam.so
io-blk.so
cam-disk.so
fs-qnx6.so
fs-qnx4.so
fs-dos.so

# Executables
[data=c]
#[perms=+r,+x]
#Serial Driver
#devc-pl011Uart
devc-serPl011
#I2C Driver
i2c-stat
#I2C Driver Test App
i2c-test
devb-sdmmc-sdhci
#devc-serdebug

############################################################################
### General commands
############################################################################
ksh
io-pkt-v6-hc
nicinfo
ping
ftp
ifconfig
if_up
dhcp.client
arp
tcpdump
hogs
ls
pipe
pidin
slogger
syslogd
slogger2
sloginfo
cp
rm
slay
mv
grep
more
mount
uname
umount
waitfor
shutdown
sleep
getconf
setconf
dumper
chmod
fdisk
mkdosfs
devb-ram
cat
vi
use
mkdir
out32
in32
random
date
tar
gzip
gunzip
zcat
mq
ln
top
route
sync
dd
on
mqueue
devc-pty
env
/usr/bin/logout=logout
/usr/bin/ps=ps
/usr/bin/nice=nice
/usr/bin/find=find
/usr/bin/touch=touch
Last edited by Anant Pai on Mon Apr 24, 2017 11:48 am, edited 1 time in total.
Anant Pai
Active Member
 
Posts: 19
Joined: Wed Mar 01, 2017 2:25 pm

Re: Unable to launch Uart serial driver

Postby Tim » Tue Apr 11, 2017 6:23 pm

Anant,

Your file certainly looks OK at a quick glance.

What program are you using on the other side (Hyperterminal, Putty or something else)?

Tim
Tim
Senior Member
 
Posts: 1392
Joined: Wed Mar 10, 2004 12:28 am

Re: Unable to launch Uart serial driver

Postby Anant Pai » Wed Apr 12, 2017 5:05 am

Tim,

Thanks for your support.

We are using TeraTerm at the host machine with the following line configuration 115200 8-N-1.
The serial port on board is a Serial over USB using FTDI chip connected to a ARM PL011 UART IP.

We are able to observe the following through the debugger.

On entering a character on console Rx Interrupt is triggered.
The Rx handler passes the input character to TTY layer via tti call.
The TTY layer processes it and echoes it back through tto call. (This is confirmed by the character appearing on console.)

However when we press Enter after entering a command the characters previously entered are echoed back again through a call to tto.
We are unable to figure out why the call to tto happens again and who calls it.

Regards
Anant
Anant Pai
Active Member
 
Posts: 19
Joined: Wed Mar 01, 2017 2:25 pm

Re: Unable to launch Uart serial driver

Postby Tim » Wed Apr 12, 2017 2:01 pm

Anant,

I wonder if you just need to set your terminal type directly on the serial port. This talks about terminal types over serial
http://www.qnx.com/developers/docs/6.3. ... /char.html

If you add the 'stty' command to your build image you can run it and see what mode your in.

stty </dev/ser3

Alternatively you can just try and set it and hope that's the problem.

stty term=qansi </dev/ser3

You may also need to adjust the options you are passing to your serial driver.

Tim
Tim
Senior Member
 
Posts: 1392
Joined: Wed Mar 10, 2004 12:28 am

Re: Unable to launch Uart serial driver

Postby maschoen » Thu Apr 13, 2017 3:42 am

I could be wrong about this, but it seems like you are assuming that the boot script is being processed by an "sh" shell. I don't think this is the case. Typically what I've seen to accomplish what you want is something like this.

...
display_msg Reopen done
esh

Where "esh" is a "small" shell that QNX provides.
maschoen
QNX Master
 
Posts: 2644
Joined: Wed Jun 25, 2003 5:18 pm

Re: Unable to launch Uart serial driver

Postby Anant Pai » Thu Apr 13, 2017 4:01 pm

Tim,

Thanks for your help so far.
To run the stty i need the shell to accept the commands which is not the case here.

Maschoen,

Thanks for your help the change from ksh to esh helped us progress.
If we change the shell to esh i get the shell prompt.
I made the following change to my build script.
[+session] PATH=/proc/boot esh &

[type=link] /bin/sh=/proc/boot/esh
[type=link] /dev/console=/dev/ser3


With the above changes i am able to launch the shell, but the shell is very slow it takes about a minute for any command to execute.
Some control characters like backspace still don't work.

I am a little curious about this change how does changing to esh alter the behavior so much.
http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/utilities/e/esh.html says it is for memory constrained systems.
Some of the reference BSPs i referred like beaglebone use the ksh to launch their shell.

Regards
Anant Pai
Anant Pai
Active Member
 
Posts: 19
Joined: Wed Mar 01, 2017 2:25 pm

Re: Unable to launch Uart serial driver

Postby Anant Pai » Thu Apr 13, 2017 4:52 pm

Hi,

I have attached my UART source code here for reference.
uartDrv.zip
Pl011 Uart Driver
(24.23 KiB) Downloaded 80 times


Regards
Anant
Anant Pai
Active Member
 
Posts: 19
Joined: Wed Mar 01, 2017 2:25 pm

Re: Unable to launch Uart serial driver

Postby maschoen » Thu Apr 13, 2017 5:31 pm

The fact that is works but is slow suggests contention. Put pidin in the image and run it. Look for processes that are in READY mode, especially those at or the same or higher priority than esh. You could also try to bump esh to a higher priority to see if that helps.

If something is running free (in READY mode all the time) that could be a problem.
maschoen
QNX Master
 
Posts: 2644
Joined: Wed Jun 25, 2003 5:18 pm

Re: Unable to launch Uart serial driver

Postby denkelly » Fri Apr 14, 2017 1:24 pm

I would be curious to know what this does...

startup-Auto_Talks -v

Any involvement with the uart?
denkelly
Senior Member
 
Posts: 161
Joined: Sat Aug 02, 2008 3:27 pm

Re: Unable to launch Uart serial driver

Postby Anant Pai » Wed Apr 19, 2017 3:59 pm

Hi All,

I was able to resolve the issue of slow command response to shell commands.
The issue was in my tto function where the exit condition for transmission of characters was incorrect.
With this fix we are able to launch the shell and execute commands by launching esh from the build script.
Some small issues still exist like for instance the TAB command does not work.

The shell works fine only if we use the esh if we use the ksh we are unable to launch the shell.

Do we need to set some path or environment variable in the build script to launch the ksh?

Thank you everyone for your support so far.

build.zip
Build script
(2.17 KiB) Downloaded 84 times


Regards
Anant Pai
Anant Pai
Active Member
 
Posts: 19
Joined: Wed Mar 01, 2017 2:25 pm

Re: Unable to launch Uart serial driver

Postby Tim » Wed Apr 19, 2017 5:32 pm

Maybe you need to add the -i option to make ksh interactive. Otherwise I believe it's just echoing what you type and not processing it as commands.

Tim
Tim
Senior Member
 
Posts: 1392
Joined: Wed Mar 10, 2004 12:28 am

Re: Unable to launch Uart serial driver

Postby Anant Pai » Sun Apr 23, 2017 4:41 pm

Hi Tim,

I have tried with ksh -i & option but no luck the behavior is still the same.

If i launch the esh -i & the shell is launched and the commands are processed.
But the following commands like Ctrl-Z and TAB do not work.
On entering Ctrl-Z to stop a process the shell hangs indefinitely(but Ctrl-C works fine when used to stop a process) and TAB does not throw any help with commands.

Is it something to do with terminal type?
Are there any limitations with using esh with respect to some commands like CTRL-Z, TAB.

# echo $TERM
qansi
# echo $SYSNAME
nto
# echo $SHELL
/bin/sh

Below is the stty output.
#stty -a
Name: /dev/ser3
Type: serial
Opens: 2

+hupcl
+cread
-clocal
+isig
+icanon
+iexten
+echo
+echoe
+echok
+echoke
+echonl
+echoctl
-noflsh
-ignbrk
+brkint
-ignpar
-parmrk
-istrip
-inlcr
-igncr
+icrnl
+imaxbel
+opost
+onlcr

-isflow
-osflow
-ihflow
-ohflow
intr=^C quit=^\ erase=^? kill=^U eof=^D eol=^- eol2=^- swtch=^-
start=^Q stop=^S susp=^Z dsusp=^- reprint=^- discard=^- werase=^- lnext=^V
min=01 time=00 fwd=^- login=^- pr1=^[ pr2=5B pr3=^- pr4=^-
sf1=^- sf2=^- sf3=^- sf4=^- left=44 right=43 up=41 down=42
ins=40 del=50 rub=^- can=^- home=48 end=59
par=none +inpck bits=8 stopb=1 baud=115200 rows=0,0


Regards
Anant Pai
Anant Pai
Active Member
 
Posts: 19
Joined: Wed Mar 01, 2017 2:25 pm

Re: Unable to launch Uart serial driver

Postby Tim » Mon Apr 24, 2017 1:45 pm

Anant,

CTRL-Z hanging the shell is expected behavior. This happens with ksh too. What really happens is that the shell exits and control passes back to your build file. There is nothing more to run in that file so it hangs.

If you need to recover from CTRL-Z and relaunch a shell of some kind I suggest you instead use tinit.
http://www.qnx.com/developers/docs/6.3. ... tinit.html

So instead of starting a shell in your build file you start tinit which runs forever and will launch shells for you (note you have to put your custom ttys file in your build and provide a path to it. In that ttys file you replace the /bin/login shown in the docs with /proc/boot/ksh).

Tim
Tim
Senior Member
 
Posts: 1392
Joined: Wed Mar 10, 2004 12:28 am

Next

Return to Realtime and Embedded

Who is online

Users browsing this forum: No registered users and 3 guests