I originally asked this question on The Microchip Forums

I recently installed the MIPS QEMU emulator and tried implementing a simple function that hammers a character to the screen

#define UART_BASE 0x1F000900
#define UART_LSR 0x00000030


void print_char(char c)
{
    for(int i=0; i<1; i--)
    {
        *(volatile char *)(UART_BASE) = c;
    };
}

I thought maybe my UART address was incorrect, but according to the MIPS Malta manual I’m on the right track. I called the function here in src/init.c

extern void clear_bss(void);
extern void print_char(char);

void
init(void)
{
    char letter = 'h';
    clear_bss();
    print_char(letter);
    return;
}

My linker script seems fine as well

MEMORY
{
    ram (rwx) : ORIGIN = (0x8+0x01000000), LENGTH = 128M
    flash (rx) : ORIGIN = 0xbfc00000, LENGTH = 4M
}

SECTIONS
{
    .text : ALIGN(4)
    {
        KEEP(*(.ivt))
        *(.text*)
        . = ALIGN(4);
        _etext = .;
    }>flash


    .bss : ALIGN(4)
    {
        __bss_start = .;
        *(.bss)
        *(COMMON)
        __bss_end = .;
    }>ram
}

_stack = ORIGIN(ram)+LENGTH(ram)

After compilation I stripped the ELF headers and padded the binary to 4 megabytes. I then tried running it using qemu-system-mips -pflash bin/boot.bin -nographic -M malta

It compiles just fine. QEMU seemingly runs it just fine (minus a warning on auto-detecting formats.)

I need help figuring out what I’m doing wrong.

Thanks in advance.