[En-Nut-Discussion] Early printf Capability
Harald Kipp
harald.kipp at egnite.de
Tue Mar 7 21:16:16 CET 2006
GDB on the command line is probably something for
people with a lot of time to create scripts.
After completely failing to setup Eclipse, I tried
Insight again with success (for ARM). Finally I found
out, that GDB will not really help with the optimization
problem (Nut/OS fails when compiled with optimization).
So I get back to the old method of printing out debug
lines. However, Nut/OS fails in a very early stage.
Here's how to setup stdout very early, even before the heap
exists. This sample had been added to arch/arm/dev/at91init.c
(CVS HEAD). Apart from the hardware initialization, an AVR
version will not differ much.
#include <dev/debug.h>
#include <stdio.h>
struct __iobuf {
int iob_fd; /*!< \internal Associated file, device or socket
descriptor. */
u_short iob_mode; /*!< \internal Access mode, see fcntl.h. */
u_char iob_flags; /*!< \internal Status flags. */
int iob_unget; /*!< \internal Unget buffer. */
};
struct __iobuf dbg;
/*!
* \brief AT91 specific initialization.
*/
void McuInit(void)
{
/* Set the vector. */
outr(AIC_SPU, (unsigned int)SpuriousEntry);
/* Enable UART clock. */
outr(PS_PCER, _BV(US0_ID));
/* Disable GPIO on UART tx/rx pins. */
outr(PIO_PDR, _BV(14) | _BV(15));
/* Reset UART. */
outr(US0_CR, US_RSTRX | US_RSTTX | US_RXDIS | US_TXDIS);
/* Disable all UART interrupts. */
outr(US0_IDR, 0xFFFFFFFF);
/* Clear UART counter registers. */
outr(US0_RCR, 0);
outr(US0_TCR, 0);
/* Set UART baud rate generator register. */
outr(US0_BRGR, 0x28);
/* Set UART mode to 8 data bits, no parity and 1 stop bit. */
outr(US0_MR, US_CHMODE_NORMAL | US_CHRL_8 | US_PAR_NO | US_NBSTOP_1);
/* Enable UART receiver and transmitter. */
outr(US0_CR, US_RXEN | US_TXEN);
__iob[1] = &dbg;
dbg.iob_fd = (int)((uptr_t)(* devDebug0.dev_open) (&devDebug0, "", 0, 0));
}
More information about the En-Nut-Discussion
mailing list