Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Can't open uart in uClinux with MMU

Hi~

Right now, I am using uClinux with MMU.

My system have 3 uart, however, My system can't see all uarts.

He always show 2.

Moreover, in ternimal, it shows I have this device, but I can't open it.

http://i37.tinypic.com/ifx405.jpg

This picture is my setting about uart

http://i36.tinypic.com/244tu0x.jpg

Is there any other select I need to change.

Do I need to change config.c inside arch/nios2/board folder?

Thanks in advance for your help.

Tingming

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Kazu:

    I don't get it, why I need /dev/ttyS2 and S3?

    I have 3 uart in my system, but it only show 2.

    And I can't open (ttyS0 and ttyS1) in software.

    Thank you very much for reply me.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    --- Quote Start ---

    I don't get it, why I need /dev/ttyS2 and S3?

    I have 3 uart in my system, but it only show 2.

    And I can't open (ttyS0 and ttyS1) in software.

    --- Quote End ---

    Please check that your UART names are well-defined in the file 'nios2-linux/linux-2.6/arch/nios2/kernel/config.c', and if not, please modify it. In default, those must be 'UART0. 'UART1', 'UART2' and 'UART3'.

    
    /*
     *    Altera UART
     */
    static struct altera_uart_platform_uart nios2_uart_platform = {# if defined(UART0_BASE) || defined(UART_BASE)
     # ifdef UART0_BASE
        {
         .mapbase = UART0_BASE,
         .irq = UART0_IRQ,
         .uartclk = UART0_FREQ,
         },
     # else
        {
         .mapbase = UART_BASE,
         .irq = UART_IRQ,
         .uartclk = UART_FREQ,
         },
     # endif# endif# ifdef UART1_BASE
        {
         .mapbase = UART1_BASE,
         .irq = UART1_IRQ,
         .uartclk = UART1_FREQ,
         },# endif# ifdef UART2_BASE
        {
         .mapbase = UART2_BASE,
         .irq = UART2_IRQ,
         .uartclk = UART2_FREQ,
         },# endif# ifdef UART3_BASE
        {
         .mapbase = UART3_BASE,
         .irq = UART3_IRQ,
         .uartclk = UART3_FREQ,
         },# endif
        {},
    };
    
    And UART devices are probed in the function 'altera_uart_probe' of the file 'nios2-linux/linux-2.6/drivers/serial/altuart.c'.

    
    static int __devinit altera_uart_probe(struct platform_device *pdev)
    {
        struct altera_uart_platform_uart *platp = pdev->dev.platform_data;
        struct uart_port *port;
        int i;
        for (i = 0;
             ((i < CONFIG_SERIAL_ALTERA_UART_MAXPORTS) && (platp.mapbase));
             i++) {
            port = &altera_uart_ports.port;
            port->line = i;
            port->type = PORT_ALTERA_UART;
            port->mapbase = platp.mapbase;
            port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE);
            port->iotype = SERIAL_IO_MEM;
            port->irq = platp.irq;
            port->uartclk = platp.uartclk;
            port->ops = &altera_uart_ops;
            port->flags = ASYNC_BOOT_AUTOCONF;
            uart_add_one_port(&altera_uart_driver, port);
        }
        return 0;
    }
    
    Please debug it by 'printk', if necessry. Anyway you must distinguish your UART devices by major and minor numbers, so you need /dev/ttyS2 and /dev/ttyS3 after your 4 UARTs are probed successfully.

    Kazu
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Kazu~

    Thank you very much!

    My UART (S0 S1)can work already.

    Now, I am trying to make S2 work.

    I use mknod /dev/ttyS2 c 4 66, and my ttyS2 can work now

    I didn't change config.c files, so I can't use my UART.

    Thank you again for solving my problems.

    TingMing.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    Thanks in advance if you can shine light to the UART problem I am having. Like the problem you are having, I can't open the port or communicate to it, and I have name all my port with 'UART0. 'UART1', 'UART2' and 'UART3' in my QSYS and my device tree DTS file. The uClinux ver 3.1 boot up detect there is a UART with correct base address and irq:

    ttyAL0 at MMIO 0x8100160 (irq =5) is a Altera UART

    ttyAL1 at MMIO 0x8100180 (irq =6) is a Altera UART

    ttyAL2 at MMIO 0x8100200 (irq =7) is a Altera UART

    ttyAL3 at MMIO 0x8100220 (irq =8) is a Altera UART

    ttyAL4 at MMIO 0x8100240 (irq =9) is a Altera UART

    ttyAL5 at MMIO 0x8100260 (irq =10) is a Altera UART

    The /dev have ttyAL0 in it, but not none of the other ports. I'm able to open and communicate with ttyAL0, but none other port. Is there something I have to do specially for the device tree or driver I have to change? I did look at the altera_uart.c and can't figure out the problem.

    --- Quote Start ---

    Hi,

    Please check that your UART names are well-defined in the file 'nios2-linux/linux-2.6/arch/nios2/kernel/config.c', and if not, please modify it. In default, those must be 'UART0. 'UART1', 'UART2' and 'UART3'.

    
    /*
     *    Altera UART
     */
    static struct altera_uart_platform_uart nios2_uart_platform = {# if defined(UART0_BASE) || defined(UART_BASE)
     # ifdef UART0_BASE
        {
         .mapbase = UART0_BASE,
         .irq = UART0_IRQ,
         .uartclk = UART0_FREQ,
         },
     # else
        {
         .mapbase = UART_BASE,
         .irq = UART_IRQ,
         .uartclk = UART_FREQ,
         },
     # endif# endif# ifdef UART1_BASE
        {
         .mapbase = UART1_BASE,
         .irq = UART1_IRQ,
         .uartclk = UART1_FREQ,
         },# endif# ifdef UART2_BASE
        {
         .mapbase = UART2_BASE,
         .irq = UART2_IRQ,
         .uartclk = UART2_FREQ,
         },# endif# ifdef UART3_BASE
        {
         .mapbase = UART3_BASE,
         .irq = UART3_IRQ,
         .uartclk = UART3_FREQ,
         },# endif
        {},
    };
    
    And UART devices are probed in the function 'altera_uart_probe' of the file 'nios2-linux/linux-2.6/drivers/serial/altuart.c'.

    
    static int __devinit altera_uart_probe(struct platform_device *pdev)
    {
        struct altera_uart_platform_uart *platp = pdev->dev.platform_data;
        struct uart_port *port;
        int i;
        for (i = 0;
             ((i < CONFIG_SERIAL_ALTERA_UART_MAXPORTS) && (platp.mapbase));
             i++) {
            port = &altera_uart_ports.port;
            port->line = i;
            port->type = PORT_ALTERA_UART;
            port->mapbase = platp.mapbase;
            port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE);
            port->iotype = SERIAL_IO_MEM;
            port->irq = platp.irq;
            port->uartclk = platp.uartclk;
            port->ops = &altera_uart_ops;
            port->flags = ASYNC_BOOT_AUTOCONF;
            uart_add_one_port(&altera_uart_driver, port);
        }
        return 0;
    }
    
    Please debug it by 'printk', if necessry. Anyway you must distinguish your UART devices by major and minor numbers, so you need /dev/ttyS2 and /dev/ttyS3 after your 4 UARTs are probed successfully.

    Kazu

    --- Quote End ---