Toolchain

From MoxieWiki

Jump to: navigation, search

Contents

Toolchain Usage and Status

The toolchain for the moxie architecture consists of ports of the following tools:

  • the GNU assembler, linker and binary utilities
  • GCC, the GNU Compiler Collection
  • GDB, the GNU Debugger, including a port of the GDB simulator to the moxie architecture
  • Qemu, the Open Source Processor Emulator
  • Newlib, a C library for bare-metal embedded software development

All GNU software is configured to use the moxie-elf target name.

Ports of these tools are maintained in the MoxieDev repository.

What follows are notes on the usage and status of each component.

The GNU assembler, linker and binary utilities

These tools are completely functional. They produce, examine and manipulate ELF binaries.

GCC, the GNU Compiler Collection

The moxie GCC port supports C and C++ only. If you are using newlib, you will need to specify the appropriate BSP by way of a linker script.

$ moxie-elf-gcc -o hello.x hello.c -Tsim.ld
$ moxie-elf-run hello.x
Hello, World!

The sim.ld linker script identifies the GDB sim BSP, whereas qemu.ld is used to target the default qemu board.

There are no processor specific flags for this port.

GDB, the GNU Debugger

The moxie port of GDB is currently capable of connecting to the GDB sim or qemu, loading a program, stepping through it, setting breakpoints and examining variables. Calls to the inferior (calling function from the GDB command line) has not been implemented yet. Here's an example of starting up the debugger on a simple program, connecting to the built-in simulator, and stepping through the code.

$ cat hello.c
#include <stdio.h> 

int main()
{
  puts("Hello World!");
  return 0;
}
$ moxie-elf-gcc -g -o hello.x hello.c
$ moxie-elf-gdb hello.x
GNU gdb (GDB) 6.8.50.20090307-cvs
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "--host=i686-pc-linux-gnu --target=moxie-elf".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
(gdb) target sim
Connected to the simulator.
(gdb) load
(gdb) b main
Breakpoint 1 at 0x119a: file hello.c, line 5.
(gdb) run
Starting program: /green/moxiedev/hello.x   

Breakpoint 1, main () at hello.c:5
5         puts("Hello World!");
(gdb) where
#0  main () at hello.c:5
(gdb) si
0x000011a0      5         puts("Hello World!");
(gdb) si
puts (s=0x54d0 "Hello World!")
    at ../../../../../../src/newlib/libc/stdio/puts.c:102
102     {
(gdb) si
0x0000132a in puts (s=0x54d0 "Hello World!")
    at ../../../../../../src/newlib/libc/stdio/puts.c:102
102     {
(gdb) info registers
$fp            0x1fffe0 0x1fffe0
$sp            0x1fffe0 0x1fffe0
$r0            0x54d0   21712
$r1            0x8      8
$r2            0x0      0
$r3            0x0      0
$r4            0x0      0
$r5            0x0      0
$r6            0x0      0
$r7            0x0      0
$r8            0x0      0
$r9            0x0      0
$r10           0x0      0
$r11           0x0      0
$r12           0x0      0
$r13           0xfffffff8       -8
$pc            0x132a   0x132a <puts+6>
(gdb)

Qemu, the Open Source Processor Emulator

The qemu port is partially functional. It does not yet support all moxie instructions, however, it is capable of simulating a simple "Hello World" example program.

 $ cat hello.c
 #include <stdio.h>
 
 int main()
 {
   puts ("Hello World!");
   return 0;
 }
 $ moxie-elf-gcc -o hello.x hello.c -Tqemu.ld
 $ ./qemu-system-moxie -nographic -kernel hello.x
 Hello World!
 qemu: fatal: Trying to execute code outside RAM or ROM at 0x00000000
 
 pc=0x00000000
 $fp=0x00000000 $sp=0x0000000c $r0=0x00000001 $r1=0x000055c4
 $r2=0x00000000 $r3=0x00000000 $r4=0x001ffff4 $r5=0x00000000
 $r6=0x00000000 $r7=0x00000000 $r8=0x00000000 $r9=0x00000000
 $r10=0x00000000 $r11=0x00000000 $r12=0x00000000 $r13=0xfffffff4
 Aborted

The failure at the end is because the simulator has "run off the end" of the program. We should really be simulating an operating system that doesn't end.

You can also debug program running on qemu with gdb. To do this, start qemu with the "-s -S" options, and connection to qemu from moxie-elf-gdb with "target remote localhost:1234".

Newlib, a C library for bare-metal embedded software development

Newlib (and libgloss) are both fully functional. The libgloss provides BSPs for both the GDB simulator (moxie-elf-run) and qemu.

Personal tools