this post was submitted on 19 Apr 2026
3 points (100.0% liked)

Learn Programming

2172 readers
1 users here now

Posting Etiquette

  1. Ask the main part of your question in the title. This should be concise but informative.

  2. Provide everything up front. Don't make people fish for more details in the comments. Provide background information and examples.

  3. Be present for follow up questions. Don't ask for help and run away. Stick around to answer questions and provide more details.

  4. Ask about the problem you're trying to solve. Don't focus too much on debugging your exact solution, as you may be going down the wrong path. Include as much information as you can about what you ultimately are trying to achieve. See more on this here: https://xyproblem.info/

Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient

founded 2 years ago
MODERATORS
 

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.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here