# GXemul: Raspberry Pi emulation

Back to the index.

The Raspberry Pi emulation is not working yet. This page contains preliminary instructions for how to start debugging NetBSD, FreeBSD, or HelenOS.

### NetBSD/raspberrypi:

This doesn't work yet.

Starting point for development:

See http://wiki.netbsd.org/ports/evbarm/raspberry_pi/ for more info on NetBSD.

To start debugging/development:

1. Download something similar to:

       	http://nyftp.netbsd.org/pub/NetBSD-daily/HEAD/201310032210Z/evbarm/binary/kernel/netbsd-RPI.gz

2. `gxemul -tviK -E rpi netbsd-RPI.gz`

TODO: Everything.

    GXemul> u
    <kernel_text>
    c00081e0:  e10f1000	mrs	r1,CPSR
    c00081e4:  e166f001	msr	SPSR_sx,r1
    c00081e8:  e28f1048	add	r1,pc,#0x48
    c00081ec:  e8912106	ldmia	r1,{r1,r2,r8,sp}
    c00081f0:  ee0d8f90	mcr	15,0,r8,cr13,cr0,4

    It starts up in kernel_text, which is in NetBSD usr/src/sys/arch/arm/arm32/locore.S:

    ENTRY_NP(kernel_text)

    ASENTRY_NP(start)
            mrs     r1, cpsr                /* fetch CPSR value */
            msr     spsr_sx, r1             /* set SPSR[23:8] to known value */

            adr     r1, .Lstart
            ldmia   r1, {r1, r2, r8, sp}    /* Set initial stack and */

    #if defined(TPIDRPRW_IS_CURCPU) || defined(TPIDRPRW_IS_CURLWP)
            mcr     p15, 0, r8, c13, c0, 4
    #endif
    #if defined(TPIDRPRW_IS_CURLWP)
            ldr     r8, [r8, #L_CPU]        /* r8 needs curcpu in it */
    #endif

            mov     r4, #0
    #ifdef _ARM_ARCH_DWORD_OK
            mov     r5, #0
    #endif

Also useful for testing:

    https://github.com/raspberrypi/firmware/blob/master/boot/kernel.img
    gxemul -tvK -E rpi 0x00000000:kernel.img

### FreeBSD:

Dummy mode so far.

FreeBSD sd card image:

    http://www.db.net/downloads/bsd-pi-250580M.img.xz
    # Extract the kernel from the second (2) slice' first partition (a):
    mdconfig -a -t vnode -f bsd-pi-250580M.img
    mount /dev/md0s2a /mnt/
    cp /mnt/boot/kernel/kernel* .
    umount /mnt
    mdconfig -d -u 0
    gxemul -tK -E rpi kernel

### HelenOS/rpi:

The Raspberry Pi mode in GXemul is just a dummy so far.

These instructions are used as a reminder for me when I wish to experiment with the HelenOS kernel:

1. Download the HelenOS kernel:

       	http://www.helenos.org/releases/HelenOS-0.7.2-arm32-raspberrypi.bin

2. Start GXemul using the following command line:

         	gxemul -VE rpi -tv 0x8000:0x40:0x8000:HelenOS-0.7.2-arm32-raspberrypi.bin