This is hardly a theoretical question as many have done this, albeit there's very little information on the underlying processes.

I'm developing a custom MIPS-based processor on which I would like to run Ubuntu. I'm quite baffled as to what to do next after you've designed the instruction set and the computer architecture itself. I need to be able to run a kernel and OS but how does it all tie in?

At the moment I'm researching into designing a compiler for the Linux kernel to generate the appropriate assembly language. Is that a good way to go? What do I need to do after that?


2 Answers 2


On the architecture side, you need more than an instruction set and a computer architecture. You also need to have:

  • A CPU in some form (emulator, FPGA, silicon…).
  • A way of booting that processor: a way of getting the operating system into the memory that the processor runs at boot time. Most processors boot to code stored in ROM which either switches on some kind of flash memory and branches to it, or which loads some code from some storage media into RAM and branches to it. The next stage is an OS bootloader.
  • Some peripherals — at a minimum, RAM, some kind of storage controller, and some input/output devices.

On the software side, you will need:

  • A compiler. Since you're using the MIPS architecture, any existing compiler targetting MIPS should be sufficient. If your instruction set extends the basic MIPS instruction set (e.g. with extra registers), you may need to extend the assembler accordingly.
  • A kernel. Linux for MIPS already exists. You'll have to add support for what you customized in your architecture: boot, MMU, …
  • Drivers. You'll need to write drivers for all the pieces of computer architecture that you didn't take off-the-shelf.
  • A bootloader. There are usually things in the bootloader that are very architecture-specific, but you can probably add the requisite support to an existing bootloader, e.g. by adding a machine definition to U-Boot.
  • And that's about all. Once you have a kernel and bootloader, userland programs should just work. Patch the kernel and bootloader from an existing distribution, cross-compile it on your PC, and install. Ubuntu doesn't support MIPS, but Debian does (mips or mipsel depending on endianness).
  • Really succinct, @giles. Quick question, though. So basically is this the right sequence of operations: a small piece of code stored somewhere on the processor calls the OS bootloader which fires up the OS?? Does that mean the kernel isn't called directly.ie. is it merely a dependency for the OS??
    – xupv5
    Nov 24, 2012 at 15:05
  • 1
    @xupv5 Yes, ROM/EEPROM → U-Boot/Milo/… → kernel is the usual sequence (if you're lucky: many architectures have more steps). Something has to load the kernel into memory. The initial code is not stored on the processor itself but in a separate ROM or flash memory (which may be inside the same silicon package). If you're not familiar with that process, I recommend playing with an existing emulator or board first (e.g. with Qemu). Nov 24, 2012 at 15:10

Whow, you've got yourself into a lot of work I suppose (It sounds like a many-year-project if you ask me). You're not actually going to do all that, right?

Yes, the next step would be to write (or better: port) some sort of compiler (I guess first you want to use a cross-compiler from your current PC).

I' guess that porting an existing compiler (as gcc) might be the easier task (it supports many architectures already, however I've never done something like that, maybe the GCC internals docs will help you).

After you've got your compiler up and running I'd go with trying out some basic microcontroller-like programs (e.g. letting a led on one of the data ports flash, etc.) and some testing programs just to see if everything's working as expected.

The next step could be implementing a boot loader that will ultimately load your kernel. I don't know if your architecture is going to use a BIOS/EFI or something similar, but that's another thing to consider when designing a boot loader.

After that, it's time to get to the kernel. Start with a minimal kernel config and try to get it up and running. You'll need to port the kernel to your architecture (which includes configuring all the arch-dependent header files, writing modules to access your hardware, a serial driver so that you can access the shell, etc.), again a rather extensive process.

Btw.: I hope your architecture has a memory mapping unit or you'll run into some serious trouble later (if it hasn't look into µClinux which is able to run a mmu-less kernel but I seriously doubt that you'd be able to run a full desktop-OS).

You might want to have a look at the android or OpenWRT kernel which both are running on embedded devices.

Once the kernel is ported (many years from now if you're trying to do that on your own), you'll continue with the userland. I'd start with porting busybox, the compiler and then some basic unix tools like openssh, cron, etc.

After that (assuming you've already got a working GPU attached to your system) you'd have to write a GPU driver and try to get the X server (or its replacement wayland). Keep in mind that you will need to implement 2D/3D acceleration to get the Ubuntu desktop up and running.

Finally, the task is to port as many ubuntu packages as possible to your platform.

So to conclude: You've just spent a lot of your time developing your own CPU architecture, but you're just right at the start of getting a full-blown linux distribution to run on it. I hope you're just writing a book about the process and are not going to actually do it, because you're getting yourself into a serious load of work for the next years.

However, I hope I could give you a brief look into the process (and I hope I didn't miss anything important). Good luck.

  • 1
    GCC already supports MIPS. Depending on how much the architecture has been customized, it may work out of the box or may need a few extra assembler instructions. Nov 24, 2012 at 14:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .