Having fixed my ELF relocation issue, I've now got my basic kernel running quite well on the RPi - it seems that the "architecture independent" heap manager I wrote on x86 seems to work quite nicely on ARM.
I'm working on my UART debug interface now, and have got quite a lot of useful information, but there's an annoyance. I'm at 115200 baud and can see my console output. Data is being passed through an Arduino DUE which is transparent - passing data direct from one UART to another (and has been tested with other serial devices to test this - including my CubieTruck).
The problem is that the last 16-17 characters are not appearing on my terminal, when sent with my putc() function. If I send additional dummy characters to the UART transmit buffer at the end of transmission, I can see all the "real" output. Also, if I spin on a getc() function, this seems to cause the transmit to complete correctly. My code:
Code: Select all
inline char getc( void )
{
while ( (volatile uint32_t)readRegister(UartRegister::FR) & (1 << 4) ); // bit 4 == Rx Fifo Empty Flag
return (char)(readRegister(UartRegister::DR) && 0xFF);
}
inline void putc(uint8_t c)
{
while ( ((volatile uint32_t)readRegister(UartRegister::FR)) & (1 << 5) ) ; // bit 5 == Tx Fifo Full flag
writeRegister(UartRegister::DR, c);
}
Code: Select all
... // UART initialisation and write barrier
for(int i = 0; i < 4; ++i) uart0.puts("UART TEST");
uart0.puts("UART0 has been initialised.");
... // write barrier and GPIO initialisation
Code: Select all
UART TESTUART TESTUART TESTUART TESTUART0 has
Code: Select all
UART TESTUART TESTUART TESTUART TESTUART0 has been initialised.
Many thanks for any help,
Adam
EDIT: In fact, calling uart0.getc() *twice* seems to be enough to cause the tx to happen correctly. There must be some timing issue here that Ive missed...