This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UART1

Other Parts Discussed in Thread: DM3730

Hi,

We are working on the DM3730 processor, using UART1 for communication on u boot(loop back test),it return only 64 bytes but our requirement is 1024 bytes.

We are able to read back all the 1024 Bytes of data at kernel.

Can anyone help us on solving this problem.

Regards

Vidya.

  • Hi Vidya,

    I would like to suggest you one quick workaround without view of your source - send the data of portions of 64 bytes. 

    BR

    Tsvetolin Shulev

  • Vidya,

    This is caused by the UART FIFO overflow. You've to wait before writing to the UART FIFO if the FIFO is full. There is a flag in the UART controller status registers for the same. The maximum UART FIFO size in DM37x is 64bytes. That's why you are able to see only 64bytes.

  • Hi Thomes,

    Thanks for reply.

    I am able to send more than 64 bytes through UART on the u-boot but facing issue on the receiving the more than 64 bytes data.

    On the kernel side i send as well as receive more than 64 bytes data properly but on u-boot 64 bytes data receive.

    Is any H/W restriction on the u-boot ?

    How could i receive more than 64 bytes data on the u-boot ?

    I tried similar register configuration which are given in the kernel.

    Please help me to solve this issue asap.

    Processor DM3730.

    Thanks,

    vidya

  • Vidya,

    There is no hardware restriction in u-boot. You've to poll for the fifo full bit in the UART status register and keep reading from the FIFO fast. In kernel this is performed in the kernel uart driver's interrupt handler.

  • Hi Thomas,

    Thanks for reply.

    I checked UART status register (LSR_REG) in u-boot source code, it is read register and returns

    0x61, 64 times and last one 0x60 on u-boot while receiving the FIFO data .

    I checked in TRM slicon revision 1.x

    0x60 comes when no data in the receive FIFO but i sent 1024 byte data in the FIFO.

    All registers values are same as default u-boot source package.

    What is the issue in receive FIFO polll mode ?

    Please help me to solve this issue.

    Thanks,

    Vidya





  • Vidya,

    Can you attach the source code files?

  • Hi Thomas,

    Thanks for reply.

    I am attaching two files.

    /*
     * COM1 NS16550 support
     * originally from linux source (arch/powerpc/boot/ns16550.c)
     * modified to use CONFIG_SYS_ISA_MEM and new defines
     */
    
    #include <config.h>
    #include <ns16550.h>
    #include <watchdog.h>
    #include <linux/types.h>
    #include <asm/io.h>
    
    #define UART_LCRVAL UART_LCR_8N1		/* 8 data, 1 stop, no parity */
    #define UART_MCRVAL (UART_MCR_DTR | \
    		     UART_MCR_RTS)		/* RTS/DTR */
    #define UART_FCRVAL (UART_FCR_FIFO_EN |	\
    		     UART_FCR_RXSR |	\
    		     UART_FCR_TXSR)		/* Clear & enable FIFOs */
    #ifdef CONFIG_SYS_NS16550_PORT_MAPPED
    #define serial_out(x, y)	outb(x, (ulong)y)
    #define serial_in(y)		inb((ulong)y)
    #elif defined(CONFIG_SYS_NS16550_MEM32) && (CONFIG_SYS_NS16550_REG_SIZE > 0)
    #define serial_out(x, y)	out_be32(y, x)
    #define serial_in(y)		in_be32(y)
    #elif defined(CONFIG_SYS_NS16550_MEM32) && (CONFIG_SYS_NS16550_REG_SIZE < 0)
    #define serial_out(x, y)	out_le32(y, x)
    #define serial_in(y)		in_le32(y)
    #else
    #define serial_out(x, y)	writeb(x, y)
    #define serial_in(y)		readb(y)
    #endif
    
    #ifndef CONFIG_SYS_NS16550_IER
    #define CONFIG_SYS_NS16550_IER  0x00
    #endif /* CONFIG_SYS_NS16550_IER */
    
    void NS16550_init(NS16550_t com_port, int baud_divisor)
    {
    	serial_out(CONFIG_SYS_NS16550_IER, &com_port->ier);
    #if (defined(CONFIG_OMAP) && !defined(CONFIG_OMAP3_ZOOM2)) || \
    					defined(CONFIG_AM33XX)
    	serial_out(0x7, &com_port->mdr1);	/* mode select reset TL16C750*/
    #endif
    	serial_out(UART_LCR_BKSE | UART_LCRVAL, (ulong)&com_port->lcr);
    	serial_out(0, &com_port->dll);
    	serial_out(0, &com_port->dlm);
    	serial_out(UART_LCRVAL, &com_port->lcr);
    	serial_out(UART_MCRVAL, &com_port->mcr);
    	serial_out(UART_FCRVAL, &com_port->fcr);
    	serial_out(UART_LCR_BKSE | UART_LCRVAL, &com_port->lcr);
    	serial_out(baud_divisor & 0xff, &com_port->dll);
    	serial_out((baud_divisor >> 8) & 0xff, &com_port->dlm);
    	serial_out(UART_LCRVAL, &com_port->lcr);
    #if (defined(CONFIG_OMAP) && !defined(CONFIG_OMAP3_ZOOM2)) || \
    					defined(CONFIG_AM33XX)
    
    #if defined(CONFIG_APTIX)
    	/* /13 mode so Aptix 6MHz can hit 115200 */
    	serial_out(3, &com_port->mdr1);
    #else
    	/* /16 is proper to hit 115200 with 48MHz */
    	serial_out(0, &com_port->mdr1);
    #endif
    #endif /* CONFIG_OMAP */
    }
    
    #ifndef CONFIG_NS16550_MIN_FUNCTIONS
    void NS16550_reinit(NS16550_t com_port, int baud_divisor)
    {
    	serial_out(CONFIG_SYS_NS16550_IER, &com_port->ier);
    	serial_out(UART_LCR_BKSE | UART_LCRVAL, &com_port->lcr);
    	serial_out(0, &com_port->dll);
    	serial_out(0, &com_port->dlm);
    	serial_out(UART_LCRVAL, &com_port->lcr);
    	serial_out(UART_MCRVAL, &com_port->mcr);
    	serial_out(UART_FCRVAL, &com_port->fcr);
    	serial_out(UART_LCR_BKSE, &com_port->lcr);
    	serial_out(baud_divisor & 0xff, &com_port->dll);
    	serial_out((baud_divisor >> 8) & 0xff, &com_port->dlm);
    	serial_out(UART_LCRVAL, &com_port->lcr);
    }
    #endif /* CONFIG_NS16550_MIN_FUNCTIONS */
    
    void NS16550_putc(NS16550_t com_port, char c)
    {
    	while ((serial_in(&com_port->lsr) & UART_LSR_THRE) == 0)
    		;
    	serial_out(c, &com_port->thr);
    
    	/*
    	 * Call watchdog_reset() upon newline. This is done here in putc
    	 * since the environment code uses a single puts() to print the complete
    	 * environment upon "printenv". So we can't put this watchdog call
    	 * in puts().
    	 */
    	if (c == '\n')
    		WATCHDOG_RESET();
    }
    
    #ifndef CONFIG_NS16550_MIN_FUNCTIONS
    char NS16550_getc(NS16550_t com_port)
    {
    	while ((serial_in(&com_port->lsr) & UART_LSR_DR) == 0) {
    #ifdef CONFIG_USB_TTY
    		extern void usbtty_poll(void);
    		usbtty_poll();
    #endif
    		WATCHDOG_RESET();
    	}
    	return serial_in(&com_port->rbr);
    }
    
    int NS16550_tstc(NS16550_t com_port)
    {
    	return (serial_in(&com_port->lsr) & UART_LSR_DR) != 0;
    }
    
    #endif /* CONFIG_NS16550_MIN_FUNCTIONS */
    

    8321.ns16550.h

    Changed UART registers values are :

    serial_out(UART_LCRVAL, &com_port->lcr);
    serial_out(0x10, &com_port->efr);
    serial_out(0x10, &com_port->ier);
    serial_out(0x30, &com_port->fcr);

    Overrun FIFO is not happening on u-boot to get more than 64 bytes data,

    also tried to multiple function calls to receive 64 bytes data but after 64 bytes it is breaking.

    Please Can you suggest me how to handle poll mode on u-boot to receive 1024 bytes data on u-boot.

    I am asking one more question regarding AES image ency and decry on ARM processor,

    downloaded the source file for Linux from this link :

    http://www.aescrypt.com/linux_aes_crypt.html

    On PC side not giving any issue in image ency as well as decry but when cross compiled and run the binary 

    then got "Error in iconv_open: Invalid argument".

    This error is coming from function

    int passwd_to_utf16(unsigned char *in_passwd,
                        int length,
                        int max_length,
                        unsigned char *out_passwd)

    from  password.c file.

    Please also suggest any idea to solve this issue.

    Thanks,

    Vidya

  • Vidya,

    Can you attach the code where you are calling uart APIs?

  • Hi Thomas,

    Thank you for reply.

    UART API functions to send and receive bytes  :

    static void send_packet_fp(unsigned int us_port_num, char *packet, int size) {
            int i = 0;

            while(size-- >  0)
                    NS16550_getc(us_port_num, packet[i++]);
    }

    and

    static int recv_packet_fp(unsigned int us_port_num, char *packet, int recv_count) {
            int i = 0, read_count = 0, ret_val;
            int payload;

            while(1) {
                    ret_val = NS16550_getc(us_port_num);    
                    read_count++;

                    if(ret_val == FP_TIME_OUT_ERR)
                            return FP_TIME_OUT_ERR;
                    packet[i] = ret_val;
                    i++;
                    if(read_count == RESPONSE_PKT_SIZE_WITHOUT_PAYLOAD) {
                            payload = packet[2] + packet[3] * 256;
                            if(payload == 0)
                                    break;
                            else
                                    continue;
                    }
                    if(read_count == recv_count)
                            break;
            }
            return read_count;

    }

    Receive function only receiving 64 bytes data on u-boot.

    Please suggest me to solve this issue.

    Thanks,

    Vidya




  • Vidya,

    I can see that you are calling NS16550_getc() function in both send and receive functions. Do you think this is right?

  • Hi Thomas,

    I want  to implement 'reset' command on the the u-boot so that system restart automatically.

    Can you help me to implement 'reset' command.

    Thanks,

    Vidya

  • Vidya,

    Is you previous query resolved? 

    Reset command can be implemented in multiple ways. 

    1. Use a watch dog timer to do a reset

    2. Jump to reset vector 0x0. This will not be a complete hardware reset.

    3. Check your board's schematics to see whether any GPIO lines are connected to a PMIC which can do a power cycle of the SoC?

  • Hi Thomas,

    Thanks for quick reply.

    No, i could not resolved my previous query.

    After "Hit any key to stop autoboot" i want to implement the 'reset'

    command so that system will reboot automatically.

    Can i implement the 'reset' command through

    system i/o function.

    Thanks,

    Vidya

  • Vidya,

    What is system I/O function? I've already given the ways to implement reset in my previous post.

  • Hi Thomas,

    In my  board's schematics PMIC lines are connected to the UART and watch dog timer can not be use.

    Can i implement like

    char cmd[6]="reset";

    if (system (cmd) == -1) {
                    fprintf (stderr, " system(%s) \n",
                                   cmd,);
    return 0;

    It is throwing error in u-boot compilation "undefined reference system".

    why can you help to solve this issue.

    Thanks,

    Vidya


  • Vidya,

    Please remember that you are working in u-boot. System is a standard library call, which is available in libc, and this will be applicable only when you are running n operating system. In u-boot there is no standard library available.