[ECOS] Re: diag_printf via serial port

Alexey Shusharin mrfinch@mail.ru
Fri Jun 1 12:27:00 GMT 2007

Sergei Gavrikov wrote:
 > Alexey, as far as I could understand, you try to busy one serial port
 > (UART0) by a triple work: for the debugging, for the diagnostic and for
 > the interrupt driven TTY mode, but that isn't possible.
 > You should use the second port on the board (D-Sub UART1) for TTY mode
 > (/dev/ser1) and using CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE option to point
 > what stdio output should appear there, i.e. printf() output (!diag)
 > shouldn't appear on /dev/ttydiag. By default, stdio output quite flows
 > via /dev/ttydiag.

Hello, Sergei

No, I don't use interrupt driven serial driver. On the contrary, I 
wouldn't use it. Did you try load and start application on Olimex 
LPC-E2294 via serial port?
As example I wrote a small test:

static void first_thread(CYG_ADDRESS data)
	diag_printf("\nWe should see this string\n");

void cyg_user_start(void)
     diag_printf("enter cyg_user_start()\n");

     cyg_thread_create(4, first_thread, (cyg_addrword_t) 0, "smalltest",
                       (void *)stack, STACKSIZE, &thread, &thread_obj);

     diag_printf("exit cyg_user_start()\n");

Then I connect via ethernet:

telnet 9000
Connected to (
Escape character is '^]'.
RedBoot> load smalltest.elf
Using default protocol (TFTP)
Entry point: 0x81010040, address range: 0x81010000-0x81016e60
RedBoot> go
enter cyg_user_start()
exit cyg_user_start()

We should see this string     <----- test work properly

Then I connect via serial port:

RedBoot> load -m xmodem 

CEntry point: 0x81010040, address range: 0x81010000-0x81016e60
xyzModem - CRC mode, 478(SOH)/0(STX)/0(CAN) packets, 1 retries
RedBoot> go
enter cyg_user_start()
exit cyg_user_start()

                              <----- I don't see test string

I found a bug in the variant layer of hal. It locates in 
cyg_hal_plf_serial_isr() (/hal/arm/lpc2xxx/var/current/src/hal_diag.c). 
This function handles UART interrupt but does't read UxIIR register in 
order to clear the interrupt flag. So, the cyg_hal_plf_serial_isr() 
calling never stops and prevents dsr and thread execution.

The test began working properly then I has added a read operation of 
UxIIR. I will send a patch to ecos-patches mailing list in a short time.

Best regards
Alexey Shusharin

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list