Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
jproberge
PostPosted: Jul 12, 2011 - 06:11 AM
Newbie


Joined: Mar 02, 2011
Posts: 19
Location: Montreal, Quebec, Canada

Hello!

Wow, I've been spending so much time on that issue lately and I haven't found anything that could help me on the forum. Please, help me Smile

Here's the situation: I updated Uboot and I used buildroot 2.3 to generate a new kernel with two more USARTs (ttyS1 and ttyS2) for my NGW100. I had no problems, I now have a new kernel that is working without any booting from SD-Card. I can see everything seems fine with my serial ports because after startup I get:

Quote:
~ # cat proc/tty/driver/atmel_serial
serinfo:1.0 driver revision:
0: uart:ATMEL_SERIAL mmio:0xFFE01000 irq:7 tx:1343 rx:0 RTS|DTR|DSR|CD|RI
1: uart:ATMEL_SERIAL mmio:0xFFE01400 irq:8 tx:0 rx:0 DSR|CD|RI
2: uart:ATMEL_SERIAL mmio:0xFFE01800 irq:9 tx:0 rx:0 DSR|CD|RI


And also, the following really sends the appropriate string to a remote terminal that is connected to /dev/ttyS0 (the tx count is also increasing):

Quote:

~ # echo "Test ttyS0" > dev/ttyS0


And by the way, I tested in the same way ttyS1 and ttyS2 and everything seems to work fine.

But now, here is the tricky part. When I try to compile any program that uses the serial port, it won't work at all. It won't send or receive anything. For example, I compiled this example from avrfreaks: http://www.avrfreaks.net/wiki/index.php/Documentation:Linux/Serial and it won't send or receive anything. I didn't forget to modify etc/inittab :

Quote:

# Inittab for the ATNGW100 development board
#
# Note: BusyBox init doesn't support runlevels. The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use sysvinit.
#
# Format for each entry: <id>:<runlevels>:<action>:<process>
#
# id == tty to run on, or empty for /dev/console
# runlevels == ignored
# action == one of sysinit, respawn, askfirst, wait, and once
# process == program to run

# Run the rcS script after kernel is booted.
::sysinit:/etc/init.d/rcS

# Run a shell on the first serial port. Comment out if you want a getty instead.
# ttyS0::respawn:-/bin/sh

# Run a shell on the g_serial port (USB gadget device)? This shell will spawn
# error message if the device is not connected.
#ttygserial::respawn:-/bin/sh

# Uncomment this to run a getty on the first serial port.
#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100

# Run a script on shutdown.
::shutdown:/etc/init.d/rcK


But still, it doesn't work. I know my programs are good and that they are supposed to work with at least ttyS0 because I was using them before the firmware upgrade and they were working properly. But now, nothing works, neither write() or read(), and tx count is not increasing when I run my programs.

Please, do any of you had an issue like that? Do you know anything about what I could do? I really need to fix that... I would be more than happy if anyone of you knows something that could help:)


Thank you so much!
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jproberge
PostPosted: Jul 13, 2011 - 03:18 AM
Newbie


Joined: Mar 02, 2011
Posts: 19
Location: Montreal, Quebec, Canada

More information about this problem, here's my dmesg:

Quote:

~ # dmesg
Linux version 2.6.27.6.atmel.1 (asalerno@ll2029476) (gcc version 4.2.2-atmel.1.1.3.buildroot.1) #1 Mon Jun 27 14:29:58 EDT 2011
CPU: AT32AP700x chip revision C
CPU: AP7 [01] core revision 0 (AVR32B arch revision 1)
CPU: MMU configuration: Shared TLB
CPU: features: dsp simd ocd perfctr java
CPU: Running at 140.000 MHz
Physical memory:
10000000-11ffffff
Reserved memory:
10000000-1018180f: Kernel code
10181810-102193e7: Kernel data
Exception vectors start at 90013000
CPU: Paging enabled
Node 0: start_pfn = 0x10000, low = 0x12000
On node 0 totalpages: 8192
free_area_init_node: node 0, pgdat 90205568, node_mem_map 9021c000
Normal zone: 8128 pages, LIFO batch:0
Node 0: mem_map starts at 9021c000
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 8128
Kernel command line: console=ttyS0 root=/dev/mtdblock1 rootfstype=jffs2
PID hash table entries: 128 (order: 7, 512 bytes)
avr32_comparator: irq 0, 140.000 MHz
console [ttyS0] enabled
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Memory: 30328k/30328k available (1466k kernel code, 2440k reserved, 111k data, 76k init)
SLUB: Genslabs=10, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Calibrating delay using timer specific routine.. 281.84 BogoMIPS (lpj=563689)
Mount-cache hash table entries: 512
net_namespace: 756 bytes
smc smc.0: Atmel Static Memory Controller at 0xfff03400
NET: Registered protocol family 16
pio0: base 0xffe02800, irq 13 chains 96..127
pio1: base 0xffe02c00, irq 14 chains 128..159
pio2: base 0xffe03000, irq 15 chains 160..191
pio3: base 0xffe03400, irq 16 chains 192..223
pio4: base 0xffe03800, irq 17 chains 224..255
pdc pdc.0: Atmel Peripheral DMA Controller enabled
at32_eic at32_eic.0: External Interrupt Controller at 0xfff00100, IRQ 19
at32_eic at32_eic.0: Handling 4 external IRQs, starting with IRQ 64
AVR32 AP Power Management enabled
tcb_clksrc: tc0 at 8.250 MHz
dw_dmac.0: DesignWare DMA Controller, 3 channels
Switched to high resolution mode on CPU 0
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 1024 (order: 1, 8192 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
TCP reno registered
NET: Registered protocol family 1
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
msgmni has been set to 59
io scheduler noop registered
io scheduler cfq registered (default)
atmel_usart.0: ttyS0 at MMIO 0xffe01000 (irq = 7) is a ATMEL_SERIAL
atmel_usart.1: ttyS1 at MMIO 0xffe01400 (irq = Cool is a ATMEL_SERIAL
atmel_usart.2: ttyS2 at MMIO 0xffe01800 (irq = 9) is a ATMEL_SERIAL
MACB_mii_bus: probed
eth0: Atmel MACB at 0xfff01800 irq 25 (00:04:25:1c:63:1c)
eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:01, irq=-1)
MACB_mii_bus: probed
eth1: Atmel MACB at 0xfff01c00 irq 26 (00:04:25:1c:63:1d)
eth1: attached PHY driver [Generic PHY] (mii_bus:phy_addr=1:03, irq=-1)
physmap platform flash device: 00800000 at 00000000
physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank
Amd/Fujitsu Extended Query Table at 0x0041
number of CFI chips: 1
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
RedBoot partition parsing not available
Using physmap partition information
Creating 3 MTD partitions on "physmap-flash.0":
0x00000000-0x00020000 : "u-boot"
0x00020000-0x007f0000 : "root"
0x007f0000-0x00800000 : "env"
atmel_spi atmel_spi.0: Atmel SPI Controller at 0xffe00000 (irq 3)
atmel_spi atmel_spi.0: Using bounce buffer at 0x24000000 len 4096
mtd_dataflash spi0.0: AT45DB642x (8448 KBytes) pagesize 1056 bytes
atmel_usba_udc atmel_usba_udc.0: MMIO registers at 0xfff03000 mapped at fff03000
atmel_usba_udc atmel_usba_udc.0: FIFO at 0xff300000 mapped at ff300000
at32ap700x_rtc at32ap700x_rtc.0: rtc core: registered at32ap700x_rtc as rtc0
at32ap700x_rtc at32ap700x_rtc.0: Atmel RTC for AT32AP700x at fff00080 irq 21
at32_wdt at32_wdt.0: AT32 WDT at 0xfff000b0, timeout 2 sec (nowayout=0)
atmel_mci atmel_mci.0: Atmel MCI controller at 0xfff02400 irq 28, 1 slots
Registered led device: sys
Registered led device: a
Registered led device: b
TCP cubic registered
Initializing XFRM netlink socket
NET: Registered protocol family 10
IPv6 over IPv4 tunneling driver
NET: Registered protocol family 17
NET: Registered protocol family 15
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
cpufreq: AT32AP CPU frequency driver
at32ap700x_rtc at32ap700x_rtc.0: setting system clock to 1970-01-01 00:00:00 UTC (0)
VFS: Mounted root (jffs2 filesystem).
Freeing init memory: 76K (90000000 - 90013000)
mmc0: new SD card at address e624
mmcblk0: mmc0:e624 SD512 495488KiB
mmcblk0: p1
JFFS2 write-buffering enabled buffer (1056) erasesize (8448)
eth0: link up (100/Full)
eth0: no IPv6 routers present
ip_tables: (C) 2000-2006 Netfilter Core Team
nf_conntrack version 0.5.0 (1024 buckets, 4096 max)
eth1: link up (100/Full)
warning: `proftpd' uses 32-bit capabilities (legacy support in use)
eth1: no IPv6 routers present
Node CRC 7698f808 != calculated CRC af531bbc for node at 004436e4
Node CRC def1f042 != calculated CRC b9d6792c for node at 00444194
Node CRC 22fa0e7a != calculated CRC 8143ea52 for node at 00444994
Node CRC bed26e22 != calculated CRC 8fe1dfee for node at 00445748
Node CRC 27d5ecc8 != calculated CRC 27adfff1 for node at 0044641c
Node CRC f4c988f5 != calculated CRC 8e2ea833 for node at 00446e70
Node CRC 2c8a2911 != calculated CRC 2c574976 for node at 00447714
Node CRC 50f487ff != calculated CRC 452b6803 for node at 0044814c
Node CRC 752423a2 != calculated CRC 759c7fc0 for node at 00448bdc
Node CRC ff1d9a61 != calculated CRC ff1dbb10 for node at 00449400
Node CRC f460130f != calculated CRC 28ec53ee for node at 0044a0fc
Node CRC 72a6c949 != calculated CRC fc8e47a2 for node at 0044ab7c
Node CRC be6b8ea6 != calculated CRC be8e08c3 for node at 0044b360
Node CRC c45a901a != calculated CRC 3e1f5f9b for node at 0044c118
Node CRC b6da2da2 != calculated CRC 08685640 for node at 0044cb5c
Node CRC 90761794 != calculated CRC 9076939b for node at 0044d600
Node CRC d0bfc610 != calculated CRC d08a0bd9 for node at 0044ddfc
Node CRC bb999b6a != calculated CRC 22fa0e7a for node at 004446e4
nmbd[372]: bus error at 00014e45 pc 2aaada3e sp 7fc76ba8 ecr 24
~ #


Any ideas about what's wrong?

In summary I can make ttyS0,1,2 work by writing normal Linux command like :
Quote:
~ # echo "test ttyS0" > dev/ttyS0

But when comes the time I try to do the same using a compiled c-program, it fails. Please help me Wink
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jproberge
PostPosted: Jul 13, 2011 - 06:58 AM
Newbie


Joined: Mar 02, 2011
Posts: 19
Location: Montreal, Quebec, Canada

Ok, sorry about all my posts but right now I'm doing nothing but trying to fix this. I've came up with a strange hypothesis about what might be wrong...

I compiled my current kernel using buildroot 2.3, and I'm developping my c-program with an avr32-studio that is linked with buildroot 3.0.

Do you think this could lead to some troubles? I'll try to link avr32-studio with buildroot 2.3 only and check what happens tomorrow. In the mean time, please post any comments or advices you have!

Aurevoir Smile
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jproberge
PostPosted: Jul 14, 2011 - 12:50 AM
Newbie


Joined: Mar 02, 2011
Posts: 19
Location: Montreal, Quebec, Canada

Ok, I finally tried avr32-studio with buildroot 2.3 only and I still cannot write to /dev/ttyS0 by c-programming.

Again, the only way I can send characters through the serial port is by typing standard linux commands like for instance:

Quote:
echo "testing serial port" > /dev/ttys0


At this point, I would really need some advices, ideas, hypotesis, or whatsoever. I think I tried everything I know... I want to buy some of the new NGW100 mkII, but I first need to show the capabilities of the current NGW100 to my boss. I'm not able to progress anymore. Please help.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
hce
PostPosted: Jul 14, 2011 - 04:47 PM
Raving lunatic


Joined: Jan 07, 2003
Posts: 4580
Location: Oslo, Norway

There is a howto interface serial ports written at http://tldp.org/HOWTO/Serial-Programming-HOWTO/

You are using avr32-linux-gcc as compiler, right?
 
 View user's profile Send private message  
Reply with quote Back to top
jproberge
PostPosted: Jul 14, 2011 - 06:03 PM
Newbie


Joined: Mar 02, 2011
Posts: 19
Location: Montreal, Quebec, Canada

Hello hce!

Thank you for your reply and also for the link. Unfortunately I already have read this howto almost completely and I still have no clue about what's going on. Yes I use avr32-linux-gcc for compiling my programs.

As I said, I can write to serial ports using echo "whatever string" > /dev/ttyS0 but my c-programs that were working before my firmware upgrade don't work anymore when it comes to sending string through ttyS0,1 or 2. In fact, I have two NGW100 boards: one with the old firmware (c-programs are working perfectly with serial port, but I only have one serial port and that's a problem) and one with the firmware upgraded (with which I'm now having trouble).

I will continue to work on that issue all day long, again, if anybody could help, please take a minute to reply. Thanks!
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jproberge
PostPosted: Jul 14, 2011 - 09:37 PM
Newbie


Joined: Mar 02, 2011
Posts: 19
Location: Montreal, Quebec, Canada

PROBLEM SOLVED!!

Oh my god, I'm so happy I finally found the solution. It surely would have been obvious for a lot of you guys, but not easy for me to find out!

The problem was related to hardware flow control. I think it was supported with my previous kernel and not supported anymore by my current kernel.

So here's what I did to fix this issue, I simply added the line
Quote:
newtio.c_cflag &= ~CRTSCTS
to my program (in the serial port configuration) to avoid hardware flow control and it worked! Smile

I still don't really get why CRTSCTS wasn't bothering while I was using my old kernel and is bothering now, but still, that was the cause of this trouble and I'm happy I finally solved it.

Thanks to everybody!

P.S.: By the way, just for curiosity, If anyone knows more about the reason why I was having troubles with CRTSCTS, I would be happy to learn more.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
hce
PostPosted: Jul 14, 2011 - 10:14 PM
Raving lunatic


Joined: Jan 07, 2003
Posts: 4580
Location: Oslo, Norway

Hardware flow control shouldn't be on by default. Weird...
 
 View user's profile Send private message  
Reply with quote Back to top
jproberge
PostPosted: Jul 18, 2011 - 04:25 PM
Newbie


Joined: Mar 02, 2011
Posts: 19
Location: Montreal, Quebec, Canada

hce, you're right.

Hardware flow control isn't on by default. I was putting it on because it wasn't behaving bad with my previous kernel, and also because the avrfreaks' Linux/serial wiki page suggests to put it on, as per example found at: [url] http://www.avrfreaks.net/wiki/index.php ... nux/Serial [/url]

Just by removing CRTSCTS or by adding
Quote:
newtio.c_cflag &= ~CRTSCTS
everything is just fine.

Thank you for your remark, maybe my last message wasn't clear enough about CRTSCTS' default status.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits