This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Clarification on serial port drivers


Am Donnerstag, den 20.05.2010, 19:06 +0300 schrieb Sergei Gavrikov: 
> To force a usage of /dev/ser0 or /dev/tty0 for printf() you must change
> this option.
> 
> Some example in bash (to use UART1)
> 
>    $ ecosconfig import /dev/stdin <<<$(echo 'cdl_option CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE {user_value "\"/dev/tty1\""};')
> 
> 
> Look your ecos.ecc and grep for ser? to get it. What application do you
> use? I hope that is examples/serial (good point to catch right DBG I/O).

I tried your suggestion, but this changes nothing at all.

I'm using a modified version of the serial example, that tries to print
using /dev/haldiag (works) and /dev/ser0 (-ENOENT). As a last step it
tries to write using printf.
In the beginning the source checks for CYGPKG_IO_SERIAL_ARM_NETX and
CYGPKG_IO_SERIAL_ARM_NETX_UART0 being defined, and in case it is not
raising an error (which is not the case, so the ecc seems to include
them). See the attached file.

So, I stepped a little bit more with my debugger an stopped in
cyg_io_lookup(). I investigated __DEVTAB__ and the only elements
are /dev/ttydiag and /dev/haldiag. No sign of /dev/ser0.

I'm not quite familiar with how and where each packages pull each other
in, but it seems as the netx_serial driver isn't pulled in properly. Any
way I can check that? How is the process of starting up the serial
devices?

Cheers,
Manuel

-- 
manuel@matronix.de
http://www.matronix.de
/* 
 * Written 1999-03-19 by Jonathan Larmour, Cygnus Solutions
 * This file is in the public domain and may be used for any purpose
 */

/* CONFIGURATION CHECKS */

#include <pkgconf/system.h>     /* which packages are enabled/disabled */
#ifdef CYGPKG_KERNEL
# include <pkgconf/kernel.h>
#endif
#ifdef CYGPKG_LIBC
# include <pkgconf/libc.h>
#endif
#ifdef CYGPKG_IO_SERIAL
# include <pkgconf/io_serial.h>
#endif

#ifndef CYGFUN_KERNEL_API_C
# error Kernel API must be enabled to build this example
#endif

#ifndef CYGPKG_LIBC_STDIO
# error C library standard I/O must be enabled to build this example
#endif

#ifndef CYGPKG_IO_SERIAL_HALDIAG
# error I/O HALDIAG pseudo-device driver must be enabled to build this example
#endif

#ifndef CYGPKG_IO_SERIAL_ARM_NETX
# error netX serial driver is not included
#else
#include <pkgconf/io_serial_arm_netx.h>
#endif

#ifndef CYGPKG_IO_SERIAL_ARM_NETX_UART0
# error netX UART0 not defined
#endif


/* INCLUDES */

#include <stdio.h>                      /* printf */
#include <string.h>                     /* strlen */
#include <cyg/kernel/kapi.h>            /* All the kernel specific stuff */
#include <cyg/io/io.h>                  /* I/O functions */
#include <cyg/hal/hal_arch.h>           /* CYGNUM_HAL_STACK_SIZE_TYPICAL */

#include <cyg/infra/diag.h>



/* DEFINES */

#define NTHREADS 1
#define STACKSIZE ( CYGNUM_HAL_STACK_SIZE_TYPICAL + 4096 )

/* STATICS */

static cyg_handle_t thread[NTHREADS];
static cyg_thread thread_obj[NTHREADS];
static char stack[NTHREADS][STACKSIZE];

/* FUNCTIONS */

static void simple_prog(CYG_ADDRESS data)
{
    cyg_io_handle_t handle;
    Cyg_ErrNo err;
    const char test_string[] = "serial example is working correctly!\n";
    cyg_uint32 len = strlen(test_string);

    diag_printf("Starting serial example\n");

    err = cyg_io_lookup( "/dev/haldiag", &handle );
    
    if (ENOERR == err) {
        diag_printf("Found /dev/haldiag. Writing string....\n");
        err = cyg_io_write( handle, test_string, &len );
        if (ENOERR == err) {
            diag_printf("I think I wrote the string. Did you see it?\n");
        }
    }

    err = cyg_io_lookup( "/dev/ser0", &handle );

    if (ENOERR == err) {
        diag_printf("Found /dev/ser0. Writing string....\n");
        err = cyg_io_write( handle, test_string, &len );
        if (ENOERR == err) {
            diag_printf("I think I wrote the string. Did you see it?\n");
        }
    }
    

    diag_printf("Serial example finished\n");
    printf("Serial example finished (printf)\n");
}

void cyg_user_start(void)
{
    cyg_thread_create(4, simple_prog, (cyg_addrword_t) 0, "serial",
                      (void *)stack[0], STACKSIZE, &thread[0], &thread_obj[0]);
    cyg_thread_resume(thread[0]);
}

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]