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?


To have any chance of getting this ported you first need GCC to be able to produce the object code for your target CPU, the kernel was written using GCC and we also assume that GCC is used to build a lot of the user space applications too.

You then also need to write the architecture specific parts in the kernel for your CPU and platform. If you have based your CPU on existing MIPS designs then this makes life a little bit easier, for example the virtual memory management handling may already exist for your target CPU if you are lucky, however you may need to write this from scratch if it is a new design.

If you are writing your own compiler then you need to make it support all the GCC specific extensions which the kernel supports, and there are quite a few. It is most probably easier to port GCC than write your own from scratch.

Porting the kernel is the first step, but for a new CPU you need to think about how you will design the way user space does system calls into the kernel and you will need to write a system call hander for the kernel and also the user space C library system call shims too. You will find that there is a tremendous amount of effort required just to get to the point where you are able to get the user space first process init running. You will then need to cross compile all the core libraries and utilities just to get a basic system booting. It's non-trivial. The first step is to be able to build tools like busybox that give you a minimally set of Linux tools to be able to get a shell running with a minimal set of tools to interact with the system.

Back in the days of the 2.2 kernel I ported Linux and busybox to a new architecture (a VLIW media processor) as part of a research project (which got canned) and it took about a year to get to the point where I could boot the kernel, run init and start up busybox on a serial TTY. And this was not counting the effort to get a stable toolchain. Just be warned, it can take some effort.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.