Skip to contentSkip to conversation

Need some help with auart on imx23

DISCUSSION Christian Jann 1 participant 3 messages Sep 10, 2013 – Sep 13, 2013 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

Hi, I could really need some help to get the second application uart working on my imx23 based board.

I've seen this message: http://article.gmane.org/gmane.linux.serial/9184/:
"But in mx23, the DMA has a bug(see errata:2836). We can not add the DMA support in mx23"

Hopefully there is only something wrong with my devicetree.

In arm/boot/dts/imx23-olinuxino.dts I've added:

auart1: serial@8006e000 {
pinctrl-names = "default";
pinctrl-0 = <&auart1_2pins_a>;
status = "okay";
};

And in arch/arm/boot/dts/imx23.dtsi I've added:

auart1_2pins_a: auart1-2pins@0 {
reg = <0>;
fsl,pinmux-ids = <

    0x00e0 /* MX23_PAD_GPMI_D14__GPMI_D14 */
    0x00f0 /* MX23_PAD_GPMI_D15__GPMI_D15 */
Quoted 1 line

;

fsl,drive-strength = <0>;
fsl,voltage = <1>;
fsl,pull-up = <0>;
};

I've adapted both from auart0 that was working on my OLinuXino.

The device /dev/ttyAPP1 is available and the serial getty should be configured correctly because I can use /dev/ttyAPP0 on my OLinuXino and I've configured it here in the same way. I can also eliminate a hardware problem because I have a working minimal example without OS where I can receive something on auart1.

Here is my current devicetree:

- http://www.jann.cc/_downloads/next-20130910_imx23.dtsi,
- http://www.jann.cc/_downloads/next-20130910_imx23-olinuxino.dts,
- http://www.jann.cc/_downloads/next-20130910.diff

It wasn't working in 3.9.4 and 3.10.11 too.

And my odyssey is documented here:

- http://www.jann.cc/2013/08/31/porting_linux_to_a_new_board.html#step-4-the-application-uart

I can use GDB to debug the kernel but I don't really know where to start, maybe something is broken in drivers/tty/serial/mxs-auart.c. Hopefully somebody could give me a hint what to do.

--
chris

#1 lore raw
Quoted 7 lines · On Tuesday 10 September 2013 12:26:32 you wrote:

Hi, I could really need some help to get the second application uart working on my imx23 based board.

I can use GDB to debug the kernel but I don't really know where to start, maybe something is broken in drivers/tty/serial/mxs-auart.c. Hopefully somebody could give me a hint what to do.

OK, receiving works, below you can see that I've received "Hello" one char at a time.

Quoted 114 lines

[chris@thinkpad linux-stable]$ arm-none-eabi-gdb vmlinux
GNU gdb (GNU Tools for ARM Embedded Processors) 7.4.1.20130312-cvs Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=i686-linux-gnu --target=arm-none-eabi". For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/chris/local/OLinuXino/imx23-olinuxino/kernel/linux-stable/vmlinux...d one. (gdb) c
The program is not being run.
(gdb) target remote :3333
Remote debugging using :3333
?? () at arch/arm/kernel/entry-armv.S:1132
1132 W(b) vector_rst
(gdb) c
Continuing.
WARNING! The target is already running. All changes GDB did to registers will be discarded! Waiting for target to halt. ^C
Program received signal SIGINT, Interrupt.
0xc0814728 in start_kernel () at init/main.c:480
480 while(wait_for_debugger);
(gdb) break mxs_auart_rx_char
Function "mxs_auart_rx_char" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n (gdb) break drivers/tty/serial/mxs-auart.c:mxs_auart_rx_char Function "mxs_auart_rx_char" not defined in "drivers/tty/serial/mxs-auart.c".
Make breakpoint pending on future shared library load? (y or [n]) n (gdb) break drivers/tty/serial/mxs-auart.c:703
Breakpoint 1 at 0xc02d7be0: file drivers/tty/serial/mxs-auart.c, line 703. (gdb) set var wait_for_debugger=0
(gdb) c
Continuing.

Breakpoint 1, mxs_auart_irq_handle (irq=<optimized out>, context=0xc3a27a00)
at drivers/tty/serial/mxs-auart.c:704 704 istat &=
~(AUART_INTR_RTIS | AUART_INTR_RXIS); (gdb) s
707 if (istat & AUART_INTR_TXIS) {
(gdb) s
708 mxs_auart_tx_chars(s);
(gdb) s
mxs_auart_tx_chars (s=s@entry=0xc3a27a00) at
drivers/tty/serial/mxs-auart.c:249 249 if
(auart_dma_enabled(s)) {
(gdb) s
auart_dma_enabled (s=<optimized out>) at drivers/tty/serial/mxs-auart.c:184
184 return s->flags & MXS_AUART_DMA_ENABLED;
(gdb) s
mxs_auart_tx_chars (s=s@entry=0xc3a27a00) at
drivers/tty/serial/mxs-auart.c:246 246 {
(gdb) delete breakpoints 1
(gdb) break drivers/tty/serial/mxs-auart.c:320
Breakpoint 2 at 0xc02d7c4c: file drivers/tty/serial/mxs-auart.c, line 320. (gdb) c
Continuing.

Breakpoint 2, mxs_auart_rx_chars (s=<optimized out>) at drivers/tty/serial/mxs-auart.c:367 367
mxs_auart_rx_char(s);
(gdb) delete breakpoints
Delete all breakpoints? (y or n) y
(gdb) break drivers/tty/serial/mxs-auart.c:321
Breakpoint 3 at 0xc02d7c54: file drivers/tty/serial/mxs-auart.c, line 321. (gdb) c
Continuing.

Breakpoint 3, mxs_auart_rx_char (s=0xc3a27a00) at
drivers/tty/serial/mxs-auart.c:321 321 stat =
readl(s->port.membase + AUART_STAT);
(gdb) list

316             int flag;
317             u32 stat;
318             u8 c;

319
320 c = readl(s->port.membase + AUART_DATA);
321 stat = readl(s->port.membase + AUART_STAT);
322
323 flag = TTY_NORMAL;
324 s->port.icount.rx++;
325
(gdb) p c
$3 = 72 'H'
(gdb) c
Continuing.

Breakpoint 3, mxs_auart_rx_char (s=0xc3a27a00) at
drivers/tty/serial/mxs-auart.c:321 321 stat =
readl(s->port.membase + AUART_STAT);
(gdb) p c
$4 = 101 'e'
(gdb) c
Continuing.

Breakpoint 3, mxs_auart_rx_char (s=0xc3a27a00) at
drivers/tty/serial/mxs-auart.c:321 321 stat =
readl(s->port.membase + AUART_STAT);
(gdb) p c
$5 = 108 'l'
(gdb) c
Continuing.

Breakpoint 3, mxs_auart_rx_char (s=0xc3a27a00) at
drivers/tty/serial/mxs-auart.c:321 321 stat =
readl(s->port.membase + AUART_STAT);
(gdb) p c
$6 = 108 'l'
(gdb) c
Continuing.

Quoted 6 lines

Breakpoint 3, mxs_auart_rx_char (s=0xc3a27a00) at
drivers/tty/serial/mxs-auart.c:321 321 stat =
readl(s->port.membase + AUART_STAT);
(gdb) p c
$7 = 111 'o'
(gdb)

All my sent characters and the login prompt (\r\r\nArch Linux 3.11.0- next-20130910-dirty (ttyAPP1)\r\n\r\nolinuxino login: ddHHe[AHelloWW) are in the tx buffer:

Quoted 31 lines

(gdb) delete breakpoints
Delete all breakpoints? (y or n) y
(gdb) break drivers/tty/serial/mxs-auart.c:285
Breakpoint 5 at 0xc02d7308: file drivers/tty/serial/mxs-auart.c, line 285. (gdb) c
Continuing.

Breakpoint 5, mxs_auart_tx_chars (s=0xc3a27a00) at
drivers/tty/serial/mxs-auart.c:285 285 if
(s->port.x_char) {
(gdb) p s->port.x_char
$8 = 0 '\000'
(gdb) list
280 }
281
282
283 while (!(readl(s->port.membase + AUART_STAT) &
284 AUART_STAT_TXFF)) {
285 if (s->port.x_char) {
286 s->port.icount.tx++;
287 writel(s->port.x_char,
288 s->port.membase + AUART_DATA);
289 s->port.x_char = 0;
(gdb) break drivers/tty/serial/mxs-auart.c:294
Breakpoint 6 at 0xc02d72c8: file drivers/tty/serial/mxs-auart.c, line 294. (gdb) n
292 if (!uart_circ_empty(xmit) &&
!uart_tx_stopped(&s->port)) { (gdb) n
293 s->port.icount.tx++;
(gdb) n

Quoted 9 lines

Breakpoint 6, mxs_auart_tx_chars (s=0xc3a27a00) at drivers/tty/serial/mxs-auart.c:294 294 writel(xmit->buf[xmit->tail],
(gdb) p xmit->buf[xmit->tail]
$10 = 87 'W'
(gdb) p xmit->buf
$9 = 0xc29cb000 "\r\r\nArch Linux 3.11.0-next-20130910-dirty (ttyAPP1)\r\n\r\nolinuxino login: ddHHe[AHelloWW" (gdb)

But I don't receive them:

Quoted 39 lines

(gdb) list
289 s->port.x_char = 0;
290 continue;
291 }
292 if (!uart_circ_empty(xmit) &&
!uart_tx_stopped(&s->port)) { 293
s->port.icount.tx++;
294 writel(xmit->buf[xmit->tail],
295 s->port.membase + AUART_DATA);
296 xmit->tail = (xmit->tail + 1) &
(UART_XMIT_SIZE - 1); 297 } else
298 break;
(gdb) n
293 s->port.icount.tx++;
(gdb) n
294 writel(xmit->buf[xmit->tail],
(gdb) n
296 xmit->tail = (xmit->tail + 1) &
(UART_XMIT_SIZE - 1); (gdb) n
283 while (!(readl(s->port.membase + AUART_STAT) &
(gdb) n

Breakpoint 5, mxs_auart_tx_chars (s=0xc3a27a00) at
drivers/tty/serial/mxs-auart.c:285 285 if
(s->port.x_char) {
(gdb) n
292 if (!uart_circ_empty(xmit) &&
!uart_tx_stopped(&s->port)) { (gdb) n
301 uart_write_wakeup(&s->port);
(gdb) n
303 if (uart_circ_empty(&(s->port.state->xmit)))
(gdb) n
304 writel(AUART_INTR_TXIEN,
(gdb) n
303 if (uart_circ_empty(&(s->port.state->xmit)))
(gdb) n
304 writel(AUART_INTR_TXIEN,
(gdb) n
310 if (uart_tx_stopped(&s->port))

Quoted 8 lines

(gdb) n
312 }
(gdb) n
uart_start (tty=tty@entry=0xc3b90000) at
drivers/tty/serial/serial_core.c:105
105 spin_unlock_irqrestore(&port->lock, flags);
(gdb) c
Continuing.

The line numbers are from next-20130910. Does somebody has an idea what could be broken?

--
chris

#2 lore raw
Quoted 4 lines · On Tuesday 10 September 2013 19:58:01 you wrote:
Quoted 3 lines · On Tuesday 10 September 2013 12:26:32 you wrote:

Hi, I could really need some help to get the second application uart working on my imx23 based board.

So I've finally solved the issue after reading Documentation/devicetree/bindings/pinctrl/fsl,mxs-pinctrl.txt again, the pinmux-ids were wrong.

Required subnode-properties:
- fsl,pinmux-ids: An integer array. Each integer in the array specify a pin with given mux function, with bank, pin and mux packed as below.

    [15..12] : bank number
    [11..4]  : pin number
    [3..0]   : mux selection

0000000000000000
[ ][ ][ ]
bank pin mux

0000000011100000 0x00e0 /* MX23_PAD_GPMI_D14__GPMI_D14 */ 0000000011110000 0x00f0 /* MX23_PAD_GPMI_D15__GPMI_D15 */
0b00001110 = 14
0b00001111 = 15

Looking at the datasheet, mux for auart should be 01:

0000000011100001 0x00e1 /* MX23_PAD_GPMI_D14__AUART2_TX */ 0000000011110001 0x00f1 /* MX23_PAD_GPMI_D15__AUART2_RX */

Before I haven't understood the exact functioning of fsl,pinmux-ids but now I've corrected arch/arm/boot/dts/imx23.dtsi:

auart1_2pins_a: auart1-2pins@0 {
reg = <0>;
fsl,pinmux-ids = <

    0x00e1 /* MX23_PAD_GPMI_D14__AUART2_TX */
    0x00f1 /* MX23_PAD_GPMI_D15__AUART2_RX */
Quoted 1 line

;

fsl,drive-strength = <0>;
fsl,voltage = <1>;
fsl,pull-up = <0>;
};

--
chris