public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "David Ho" <davidkwho@gmail.com>
To: "eCos discuss list" <ecos-discuss@ecos.sourceware.org>
Subject: [ECOS] Re: Serial port contention
Date: Wed, 16 Aug 2006 14:13:00 -0000	[thread overview]
Message-ID: <4dd15d180608160713y33fbb16ewc1af1c5f8673cc8d@mail.gmail.com> (raw)
In-Reply-To: <4dd15d180608100715g1344caa9h78801c04ddd52630@mail.gmail.com>

> 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 <davidho@nanometrics.ca>
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 <cyg/hal/hal_diag.h>

 #include <cyg/hal/var_io.h>             // 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

      reply	other threads:[~2006-08-16 14:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-10 14:15 [ECOS] " David Ho
2006-08-16 14:13 ` David Ho [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4dd15d180608160713y33fbb16ewc1af1c5f8673cc8d@mail.gmail.com \
    --to=davidkwho@gmail.com \
    --cc=ecos-discuss@ecos.sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).