Skip to contentSkip to conversation

Emulating MIPS -- please help!

DISCUSSION Chris Boot 5 participants 10 messages Mar 28, 2006 – Mar 30, 2006 MIPS

lore
Share & tools
lore

Chris Boot

author
#0 lore raw

Hi all,

I'm desperately trying to get a MIPS emulator running Linux, and while I've managed to get gxemul and (I think) qemu running, I can't for the life of me get them to (1) output anything or (2) use an initrd.

Can anyone post some instructions and, perhaps, a .config for 2.6.16 so I can get some output like kernel boot messages and a login screen?

I've got gxemul emulating code and running a kernel, which I can test by stopping emulation and stepping the code. Qemu seems to boot my qemu-specific kernel but I get no output and qemu appears to hang (won't take keyboard input). I can't seem to get either emulator to load my initrd, but that doesn't really matter at this stage since I can't see anything anyway (I have no idea how to using gxemul, and qemu refuses to load the image).

Something that could emulate a NEC VR41xx chip would be icing on the cake, but I'll take anything I can get at this stage.

Many thanks in advance,
Chris

Signature · 3 lines
Chris Boot
[email protected]
http://www.bootc.net/
#1 lore raw
Quoted 7 lines · Chris Boot

I've got gxemul emulating code and running a kernel, which I can test by stopping emulation and stepping the code. Qemu seems to boot my qemu-specific kernel but I get no output and qemu appears to hang (won't take keyboard input). I can't seem to get either emulator to load my initrd, but that doesn't really matter at this stage since I can't see anything anyway (I have no idea how to using gxemul, and qemu refuses to load the image).

For qemu, are you looking at its VGA window, or its serial console window? Should use the latter.

Signature · 2 lines
Daniel Jacobowitz
CodeSourcery
#2 lore raw
In reply to Chris Boot
Quoted 6 lines · Chris Boot

Hi all,

I'm desperately trying to get a MIPS emulator running Linux, and while I've managed to get gxemul and (I think) qemu running, I can't for the life of me get them to (1) output anything or (2) use an initrd.

Quoted 7 lines

Can anyone post some instructions and, perhaps, a .config for 2.6.16 so I can get some output like kernel boot messages and a login screen?

I've got gxemul emulating code and running a kernel, which I can test by stopping emulation and stepping the code. Qemu seems to boot my qemu-specific kernel but I get no output and qemu appears to hang (won't take keyboard input).

VGA support for qemu isn't there yet, use -nographics to get the serial console output.

Quoted 4 lines

I can't seem to get either emulator to load my
initrd, but that doesn't really matter at this stage since I can't see anything anyway (I have no idea how to using gxemul, and qemu refuses to load the image).

Current qemu confuses virtual and physical adresses when loading initrds, this and a bunch of other bugs are fixed in a set of patches I have. Note that these are work in progress, and may cause different bugs. Notably, the gcc4 support patch won't work on x86, and probably only on powerpc. It has, however, emulated IDE support, I use a self-compiled qemu kernel and a Debian/mips image to boot from, no ramdisk. The patchset is available at

http://people.debian.org/~ths/qemu-patches-bogus/

Use at your own risk.

Thiemo

#9 lore raw
In reply to Chris Boot

From: "Chris Boot" <[email protected]>

Quoted 1 line

Can anyone post some instructions and, perhaps, a .config for 2.6.16 so I can get some output like kernel boot messages and a login screen?

I've spent some time playing with GXEmul and Linux kernel. The Linux 2.4.x under GXEemul 0.3.8 works fine.
The UART, timer, VGA/pckbd and IDE are working.
You could find a precompiled 2.4 kernel with built-in ramdisk there:
http://www.nwpi.ru/~alec/mips/
One kernel is compiled with GCC2.9.6 while another with GCC 3.3.5. They shows different CPU frequency under emulator due to the tricky "loop optimization" in the GXEmul/mips.

You could use DISK-debian image with pivot_root also to get a mips/debian with glibc and GCC. Use a -di: option to attach an IDE disk image.

To run this kernels, use Malta mode:

$ ./gxemul -E evbmips -e malta vmlinux_2_4_32-malta-ide-pci-ramdisk.elf.gz

Wait a minute to fill GXEmul translation cache. PCI stuff in the GXEmul does not work (try lspci).

Unfortunately, I still can't get Linux 2.6.x working under GXEmul. The interrupt routines in the 2.6 was massively changed and this produces IRQ16 spurious interrupt infinity loop. It's reasonable difficult to find such sort of bugs.

--
-=AV=-

author
#3 lore raw
In reply to Thiemo Seufer

Hi there,

Quoted 31 lines · Thiemo Seufer
Quoted 6 lines · Chris Boot

Hi all,

I'm desperately trying to get a MIPS emulator running Linux, and while I've managed to get gxemul and (I think) qemu running, I can't for the life of me get them to (1) output anything or (2) use an initrd.

Quoted 7 lines

Can anyone post some instructions and, perhaps, a .config for 2.6.16 so I can get some output like kernel boot messages and a login screen?

I've got gxemul emulating code and running a kernel, which I can test by stopping emulation and stepping the code. Qemu seems to boot my qemu-specific kernel but I get no output and qemu appears to hang (won't take keyboard input).

VGA support for qemu isn't there yet, use -nographics to get the serial console output.

Quoted 4 lines

I can't seem to get either emulator to load my
initrd, but that doesn't really matter at this stage since I can't see anything anyway (I have no idea how to using gxemul, and qemu refuses to load the image).

Current qemu confuses virtual and physical adresses when loading initrds, this and a bunch of other bugs are fixed in a set of patches I have. Note that these are work in progress, and may cause different bugs. Notably, the gcc4 support patch won't work on x86, and probably only on powerpc. It has, however, emulated IDE support, I use a self-compiled qemu kernel and a Debian/mips image to boot from, no ramdisk. The patchset is available at

Quoted 3 lines

http://people.debian.org/~ths/qemu-patches-bogus/

Use at your own risk.

Thanks for all the help, I've now got a step further (I think) and get a few boot messages from 2.6.16, and it appears as though my initrd loads. However, it gets stuck early in the boot process:

bootc@arcadia nsfdb $ qemu-system-mips -kernel linux-2.6.16/arch/mips/boot/vmlinux.bin -nographic -initrd buildroot/rootfs.mips.squashfs(qemu) mips_r4k_init: load BIOS '/usr/share/qemu/mips_bios.bin' size 131072 Linux version 2.6.16 (bootc@arcadia) (gcc version 3.4.6) #9 Wed Mar 29 16:35:35 BST 2006
CPU revision is: 00018000
Determined physical RAM map:
memory: 08000000 @ 00000000 (usable)
Built 1 zonelists
Kernel command line: console=ttyS0
Primary instruction cache 2kB, physically tagged, 2-way, linesize 16 bytes.
Primary data cache 2kB, 2-way, linesize 16 bytes.
Synthesized TLB refill handler (19 instructions).
Synthesized TLB load handler fastpath (31 instructions).
Synthesized TLB store handler fastpath (31 instructions).
Synthesized TLB modify handler fastpath (30 instructions).
PID hash table entries: 1024 (order: 10, 16384 bytes)
Using 100.000 MHz high precision timer.
Console: colour dummy device 80x25
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 128480k/131072k available (907k kernel code, 2556k reserved, 172k data, 96k init, 0k highmem)
Mount-cache hash table entries: 512
Checking for 'wait' instruction... available.

At this stage it gets stuck and I have to kill qemu. Any ideas how to debug this? I've only applied the elf-loader patch since I was having trouble applying some of the others to my Ubuntu qemu 0.8.0.

Many thanks,
Chris

Signature · 3 lines
Chris Boot
[email protected]
http://www.bootc.net/
#4 lore raw

On Wed, Mar 29, 2006 at 04:47:23PM +0100, Chris Boot wrote:
[snip]

Quoted 9 lines

Dentry cache hash table entries: 32768 (order: 5, 131072 bytes) Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 128480k/131072k available (907k kernel code, 2556k reserved, 172k data, 96k init, 0k highmem)
Mount-cache hash table entries: 512
Checking for 'wait' instruction... available.

At this stage it gets stuck and I have to kill qemu. Any ideas how to debug this?

Familiar symptom, I fixed it but don't remember offhand which patch contains the fix. It was either related to TLB emulation or to kernel-mode/user-mode mismatch.

Quoted 2 lines

I've only applied the elf-loader patch since I was having trouble applying some of the others to my Ubuntu qemu 0.8.0.

The patches are for upstream CVS.

Thiemo

author
#5 lore raw
Quoted 9 lines · Thiemo Seufer

On Wed, Mar 29, 2006 at 04:47:23PM +0100, Chris Boot wrote:
[snip]

Quoted 7 lines

Dentry cache hash table entries: 32768 (order: 5, 131072 bytes) Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 128480k/131072k available (907k kernel code, 2556k reserved, 172k data, 96k init, 0k highmem)
Mount-cache hash table entries: 512
Checking for 'wait' instruction... available.

Quoted 6 lines
Quoted 2 lines

At this stage it gets stuck and I have to kill qemu. Any ideas how to debug this?

Familiar symptom, I fixed it but don't remember offhand which patch contains the fix. It was either related to TLB emulation or to kernel-mode/user-mode mismatch.

Well, I added a few more patches and it finally boots now, but it can't mount the root FS off the RAMDISK. I'm not sure if this is a side-effect of the previous initrd problem or what, but it feels good to be getting further...

Quoted 4 lines
Quoted 2 lines

I've only applied the elf-loader patch since I was having trouble applying some of the others to my Ubuntu qemu 0.8.0.

The patches are for upstream CVS.

Hmm, well I might give it a shot and see what happens. I'd rather stick with a stable version, but if it gets me somewhere it's probably worth it.

Thanks very much,
Chris

Signature · 3 lines
Chris Boot
[email protected]
http://www.bootc.net/
#6 lore raw
Quoted 14 lines · Chris Boot
Quoted 12 lines · Thiemo Seufer

On Wed, Mar 29, 2006 at 04:47:23PM +0100, Chris Boot wrote:
[snip]

Quoted 9 lines

Dentry cache hash table entries: 32768 (order: 5, 131072 bytes) Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 128480k/131072k available (907k kernel code, 2556k reserved, 172k data, 96k init, 0k highmem)
Mount-cache hash table entries: 512
Checking for 'wait' instruction... available.

At this stage it gets stuck and I have to kill qemu. Any ideas how to debug this?

Quoted 8 lines
Quoted 3 lines

Familiar symptom, I fixed it but don't remember offhand which patch contains the fix. It was either related to TLB emulation or to kernel-mode/user-mode mismatch.

Well, I added a few more patches and it finally boots now, but it can't mount the root FS off the RAMDISK. I'm not sure if this is a side-effect of the previous initrd problem or what, but it feels good to be getting further...

I was unable to boot userspace from initrd too. It was loaded to the wrong address or something. "Fixing" that didn't work either.

OTOH initramfs worked fine for me. Maybe you can live with that.

Domen

Quoted 19 lines
Quoted 5 lines
Quoted 3 lines

I've only applied the elf-loader patch since I was having trouble applying some of the others to my Ubuntu qemu 0.8.0.

The patches are for upstream CVS.

Hmm, well I might give it a shot and see what happens. I'd rather stick with a stable version, but if it gets me somewhere it's probably worth it.

Thanks very much,
Chris

Signature · 3 lines
Chris Boot
[email protected]
http://www.bootc.net/
#7 lore raw
Quoted 19 lines · Domen Puncer
Quoted 18 lines · Chris Boot
Quoted 15 lines · Thiemo Seufer

On Wed, Mar 29, 2006 at 04:47:23PM +0100, Chris Boot wrote:
[snip]

Quoted 9 lines

Dentry cache hash table entries: 32768 (order: 5, 131072 bytes) Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 128480k/131072k available (907k kernel code, 2556k reserved, 172k data, 96k init, 0k highmem)
Mount-cache hash table entries: 512
Checking for 'wait' instruction... available.

At this stage it gets stuck and I have to kill qemu. Any ideas how to debug this?

Familiar symptom, I fixed it but don't remember offhand which patch contains the fix. It was either related to TLB emulation or to kernel-mode/user-mode mismatch.

Quoted 7 lines
Quoted 4 lines

Well, I added a few more patches and it finally boots now, but it can't mount the root FS off the RAMDISK. I'm not sure if this is a side-effect of the previous initrd problem or what, but it feels good to be getting further...

I was unable to boot userspace from initrd too. It was loaded to the wrong address or something. "Fixing" that didn't work either.

It gets loaded to 0x80800000, feeding rd_start/rd_size derived from that address as kernel parameters should work.

Thiemo

author
#8 lore raw
Quoted 10 lines · Thiemo Seufer
Quoted 7 lines
Quoted 4 lines

Well, I added a few more patches and it finally boots now, but it can't mount the root FS off the RAMDISK. I'm not sure if this is a side-effect of the previous initrd problem or what, but it feels good to be getting further...

I was unable to boot userspace from initrd too. It was loaded to the wrong address or something. "Fixing" that didn't work either.

It gets loaded to 0x80800000, feeding rd_start/rd_size derived from that address as kernel parameters should work.

That does the trick! Thank you so much!

That made my day. Now for a few little fixups and my experiment is a success.

Chris

Boot messages:

bootc@arcadia nsfdb $ qemu-system-mips -kernel linux-2.6.16/arch/mips/boot/vmlinux.bin -nographic -initrd buildroot/rootfs.mips.squashfs -append "rd_start=0x80800000 rd_size=495616 console=ttyS0" (qemu) mips_r4k_init: load BIOS '/usr/share/qemu/mips_bios.bin' size 131072
Linux version 2.6.16 (bootc@arcadia) (gcc version 3.4.6) #9 Wed Mar 29 16:35:35 BST 2006
CPU revision is: 00018000
Determined physical RAM map:
memory: 08000000 @ 00000000 (usable)
Initial ramdisk at: 0x80800000 (495616 bytes)
Built 1 zonelists
Kernel command line: rd_start=0x80800000 rd_size=495616 console=ttyS0
Primary instruction cache 2kB, physically tagged, 2-way, linesize 16 bytes.
Primary data cache 2kB, 2-way, linesize 16 bytes.
Synthesized TLB refill handler (19 instructions).
Synthesized TLB load handler fastpath (31 instructions).
Synthesized TLB store handler fastpath (31 instructions).
Synthesized TLB modify handler fastpath (30 instructions).
PID hash table entries: 1024 (order: 10, 16384 bytes)
Using 100.000 MHz high precision timer.
Console: colour dummy device 80x25
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 121116k/131072k available (907k kernel code, 9920k reserved, 172k data, 96k init, 0k highmem)
Mount-cache hash table entries: 512
Checking for 'wait' instruction... available.
checking if image is initramfs...it isn't (bad gzip magic numbers); looks like an initrd
Freeing initrd memory: 484k freed
Squashfs 2.1-r2 (released 2004/12/15) (C) 2002-2004 Phillip Lougher
io scheduler noop registered (default)
Real Time Clock Driver v1.12ac
Software Watchdog Timer: 0.07 initialized. soft_noboot=0 soft_margin=60 sec (nowayout= 0)
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16450
RAMDISK driver initialized: 1 RAM disks of 1024K size 1024 blocksize
RAMDISK: squashfs filesystem found at block 0
RAMDISK: Loading 482KiB [1 disk] into ram disk... done.
VFS: Mounted root (squashfs filesystem) readonly.
Freeing unused kernel memory: 96k freed
Initializing random number generator... rm: unable to remove `/etc/random-seed': Read-only file system
urandom start: failed.
done.

Welcome to the Erik's uClibc development environment.

(none) login:

Signature · 3 lines
Chris Boot
[email protected]
http://www.bootc.net/