Tag Archives: Bare Metal

Using ELLCC For Mips Standalone With QEMU

NOTE: This is a very preliminary post which will be updated as I work through adding standalone support to ELLCC.

Build a simple program:

~/ellcc/bin/mips32r2sf-sa-ecc write.c

Make a bios image:

~/ellcc/bin/ecc-objcopy -S -j .reset --output-target binary a.out mips_bios.bin

The qemu command line:

~/ellcc/bin/qemu-system-mips -machine mips -bios ./mips_bios.bin -nographic -s -S

Starting gdb:

~/ellcc/bin/ecc-gdb
GNU gdb (GDB) 7.3.1
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
.
(gdb) target remote :1234
Remote debugging using :1234
0x00000000 in ?? ()
(gdb) set arch mips
The target architecture is assumed to be mips
(gdb) set endian big
The target is assumed to be big endian
(gdb) info regi
          zero       at       v0       v1       a0       a1       a2       a3
 R0   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
            t0       t1       t2       t3       t4       t5       t6       t7
 R8   00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
            s0       s1       s2       s3       s4       s5       s6       s7
 R16  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
            t8       t9       k0       k1       gp       sp       s8       ra
 R24  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
            sr       lo       hi      bad    cause       pc
      00400004 00000000 00000000 00000000 00000400 bfc00000 
           fsr      fir
      00000000 00000000 
(gdb) disas 0xbfc00000, 0xbfc00024
Dump of assembler code from 0xbfc00000 to 0xbfc00024:
=> 0xbfc00000:  lui     k0,0xbfc0
   0xbfc00004:  addiu   k0,k0,16
   0xbfc00008:  jr      k0
   0xbfc0000c:  nop
   0xbfc00010:  mfc0    k0,$12
   0xbfc00014:  0x7f5a04c0
   0xbfc00018:  beqz    k0,0xbfc00030
   0xbfc0001c:  nop
   0xbfc00020:  lui     k0,0x9d00
End of assembler dump.
(gdb)

The gdb commands (for cut and paste):

target remote :1234
set arch mips
set endian big
info regi
disas 0xbfc00000, 0xbfc00024