From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24892 invoked by alias); 16 Aug 2006 14:13:52 -0000 Received: (qmail 24884 invoked by uid 22791); 16 Aug 2006 14:13:51 -0000 X-Spam-Check-By: sourceware.org Received: from wr-out-0506.google.com (HELO wr-out-0506.google.com) (64.233.184.231) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 16 Aug 2006 14:13:50 +0000 Received: by wr-out-0506.google.com with SMTP id 50so15286wri for ; Wed, 16 Aug 2006 07:13:48 -0700 (PDT) Received: by 10.67.105.19 with SMTP id h19mr348102ugm; Wed, 16 Aug 2006 07:13:47 -0700 (PDT) Received: by 10.66.222.10 with HTTP; Wed, 16 Aug 2006 07:13:47 -0700 (PDT) Message-ID: <4dd15d180608160713y33fbb16ewc1af1c5f8673cc8d@mail.gmail.com> Date: Wed, 16 Aug 2006 14:13:00 -0000 From: "David Ho" To: "eCos discuss list" In-Reply-To: <4dd15d180608100715g1344caa9h78801c04ddd52630@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4dd15d180608100715g1344caa9h78801c04ddd52630@mail.gmail.com> X-IsSubscribed: yes Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: [ECOS] Re: Serial port contention X-SW-Source: 2006-08/txt/msg00166.txt.bz2 > Has anyone come across this issue? Is there a good preventive measure > I can use to make sure there is no contention? This is what I do when I need to debug my system while my only serial port is being used. Stolen from a ppc board, all credits go to the originator(s). David --- commit 5b20c814009df6a19e63adc9058be47763e5496e Author: David Ho Date: Mon Aug 14 07:52:59 2006 -0400 Write diagnostics to RAM. diff --git a/packages/hal/arm/at91/var/current/src/hal_diag.c b/packages/hal/arm/at91/var/current/src/hal_diag.c index 73c4830..34a8c3f 100644 --- a/packages/hal/arm/at91/var/current/src/hal_diag.c +++ b/packages/hal/arm/at91/var/current/src/hal_diag.c @@ -65,6 +65,49 @@ #include #include // USART registers +#define CYGDBG_DIAG_BUF + +#ifdef CYGDBG_DIAG_BUF +// Keep diag messages in a buffer for later [re]display + +int enable_diag_uart = 0; +int enable_diag_buf = 1; +//static char diag_buf[40960*4]; +static char diag_buf[4096*4]; +static int diag_buf_ptr = 0; + +/** + * Turn this into a circular buffer - DKWH + */ +static void +diag_putc(char c) +{ + if (enable_diag_buf) { + diag_buf[diag_buf_ptr++] = c; + if (diag_buf_ptr == sizeof(diag_buf)) { + diag_buf_ptr--; + } + } +} + +/** + * Restore buffer after buffer dump - DKWH + */ +void +dump_diag_buf(int start, int len) +{ + int i; + enable_diag_uart = 1; + enable_diag_buf = 0; + if (len == 0) len = diag_buf_ptr; + diag_printf("\nDiag buf\n"); + for (i = start; i < len; i++) { + hal_diag_write_char(diag_buf[i]); + } + enable_diag_buf = 1; +} +#endif // CYGDBG_DIAG_BUF + //----------------------------------------------------------------------------- typedef struct { cyg_uint8* base; @@ -104,6 +147,12 @@ cyg_hal_plf_serial_putc(void *__ch_data, { cyg_uint8* base = ((channel_data_t*)__ch_data)->base; cyg_uint32 status, ch; + +#ifdef CYGDBG_DIAG_BUF + diag_putc(c); + if (!enable_diag_uart) return; +#endif // CYGDBG_DIAG_BUF + CYGARC_HAL_SAVE_GP(); do { -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss