FreeBSD

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(Required tools: Simplify compiling steps, add config.h generation)
 
(29 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Interested in using FreeBSD on the Neo1973 or as a Host OS? Get in touch with mn -at- bsdgroup.de and andrew -at- fubar.geek.nz, they are currently exploring what to do about this.
+
<b>FreeBSD is NOT ready to be used on the Neo Freerunner or Neo 1973, do not try unless you know what you are doing and are able to help porting. It will only get to single user mode with a very cut down root filesystem.</b>
 +
 
 +
Interested in using FreeBSD on the Neo1973 or as a Host OS? Get in touch with andrew -at- fubar.geek.nz, they are currently exploring what to do about this.
  
  
Line 6: Line 8:
  
 
=== Required tools ===
 
=== Required tools ===
You will need a copy of mkimage from u-boot. To build it fetch a copy of u-boot, cd to the tools directory and build it manually:
+
You will need:
cc -I../include -c ../lib_generic/crc32.c
+
# mkimage from u-boot. It's available in ports in devel/u-boot
cc -I../include -c mkimage.c
+
# makefs from ports in sysutils/makefs
cc -o mkimage mkimage.o crc32.o
+
If config.h is missing you can build one by using
+
gmake CC=/usr/bin/true gta01bv3_config
+
in the u-boot directory (you must have applied the patches for u-boot from openmoko)
+
  
You will also need a copy of Qemu-neo1973. Hints on building it are avaliable from [[Talk:OpenMoko under QEMU|this page.]]
+
==== Qemu ====
 +
To build Qemu on FreeBSD to test and develop FreeBSD on the Neo's:
 +
# Use subversion to checkout https://svn.openmoko.org/trunk/src/host/qemu-neo1973
 +
# In gnokiigsm/device.h comment out the declaration for device_read and device_write, see [[Talk:Openmoko under QEMU#FreeBSD_and_Qemu...]]
 +
# Edit Makefile.target, search for the line LIBS+=-lm and insert "-L/usr/lib" before "-lm"
 +
# If your running FreeBSD on an AMD64 edit x86_64.ld and remove all occurrences of ONLY_IF_RO and ONLY_IF_RW
 +
# Run ./configure --target-list=arm-softmmu and gmake
 +
# Edit openmoko/flash.sh to add kernel_image="/path/to/kernel.boot" between the calls to most_recent and where it prints the kernel image it will use
  
 
=== Building FreeBSD ===
 
=== Building FreeBSD ===
You will need to download http://fubar.geek.nz/files/freebsd/neo1973/neo1973-0.20070917.tar.bz2 and extract it over the FreeBSD src tree.
+
You will need to download http://fubar.geek.nz/files/freebsd/neo1973/neo-20080629.tar.bz2 to build FreeBSD for the Neo1973.
  
 
From the FreeBSD src tree run:
 
From the FreeBSD src tree run:
<code>
+
<pre>
make buildworld TARGET=arm TARGET_ARCH=arm TARGET_CPUTYPE=arm920t
+
make buildworld TARGET=arm TARGET_ARCH=arm TARGET_CPUTYPE=arm920t
make buildkernel TARGET=arm TARGET_ARCH=arm TARGET_CPUTYPE=arm920t KERNCONF=NEO1973
+
make installworld TARGET=arm TARGET_ARCH=arm TARGET_CPUTYPE=arm920t DESTDIR=/path/to/root/fs
gzip -9 usr/obj/path/to/kernel
+
</pre>
/path/to/mkimage -A arm -O freebsd -T kernel -C gzip -a 30008000 -e 30008000 -n "Kernel Image QT2410" -d /usr/obj/path/to/kernel.gz /usr/obj/same/path/kernel.boot
+
 
</code>
+
You will now need to trim down /path/to/root to remove things noot needed to test in single user mode
 +
<pre>
 +
makefs -B little /path/to/root.ufs /path/to/root/fs
 +
make buildkernel TARGET=arm TARGET_ARCH=arm TARGET_CPUTYPE=arm920t KERNCONF=NEO1973 -DNO_MODULES MFS_IMAGE=/path/to/root.ufs
 +
mkimage -A arm -O freebsd -T kernel -C none -a 30008000 -e 300080e0 -n "FreeBSD" -d /usr/obj/path/to/kernel /usr/obj/same/path/kernel.boot
 +
</pre>
  
 
You will now have a copy of FreeBSD that is able to be loaded by u-boot.
 
You will now have a copy of FreeBSD that is able to be loaded by u-boot.
  
 
=== Running FreeBSD ===
 
=== Running FreeBSD ===
From the qemu directory edit the openmoko/flash.sh and add the line
+
From the qemu directory run
<code>
+
<code>
kernel_image="/usr/obj/path/to/kernel.boot"
+
</code>
+
after the four "most_recent" lines.
+
 
+
Next run
+
<code>
+
 
  ./openmoko/download.sh
 
  ./openmoko/download.sh
 
  ./openmoko/flash.sh
 
  ./openmoko/flash.sh
</code>
+
</code>
  
 
This will fetch the required parts and create an image to run. They require you to have bash installed.
 
This will fetch the required parts and create an image to run. They require you to have bash installed.
  
 
Finally run qemu with
 
Finally run qemu with
<code>
+
<code>
  arm-softmmu/qemu-system-arm -M neo -m 130 -mtdblock openmoko/openmoko-flash.image -kernel openmoko/openmoko-kernel.bin -usb -show-cursor
+
  arm-softmmu/qemu-system-arm -M gta01 -m 130 -mtdblock openmoko/openmoko-flash.image -kernel openmoko/openmoko-kernel.bin -usb -show-cursor
</code>
+
</code>
  
 
It will display "Kernel loading..." with no further messages.
 
It will display "Kernel loading..." with no further messages.
 +
 +
You can append
 +
-serial telnet:localhost:1200,server
 +
to the qemu startup line to start a telnet server which represents the serial console, just
 +
telnet localhost 1200
 +
and qemu will go on with the startup process.
  
 
== Useful pages ==
 
== Useful pages ==
 
[[GTA02 Openness]]
 
[[GTA02 Openness]]
 +
 +
== Next steps ==
 +
* DMA
 +
* Drivers:
 +
** LCD
 +
** USB
 +
 +
== Using a Kernel Testimage ==
 +
Another method of getting the kernel into the neo is to use an image for the emulated sd card.
 +
I already have a file called sd.img ( dd'ed from a 32mb usb stick).
 +
cp /usr/obj/arm/usr/src/sys/NEO1973/kernel .
 +
/usr/obj/arm/usr/src/tmp/usr/bin/objcopy -O binary kernel
 +
sudo mdconfig -a -t vnode -f sd.img
 +
sudo mount_msdosfs /dev/md0s1 /mnt/tmp
 +
sudo cp kernel /mnt/tmp/
 +
sudo umount /mnt/tmp
 +
sudo mdconfig -d -u 0
 +
arm-softmmu/qemu-system-arm -M neo -m 130 -mtdblock openmoko/openmoko-flash.image -kernel openmoko/openmoko-kernel.bin -sd sd.img -usb -show-cursor -serial telnet:localhost:1200,server
 +
In another terminal:
 +
telnet localhost 1200
 +
mmcinit
 +
fatload mmc 0 0x30008000 kernel
 +
go 0x30008000
 +
And wait for the crash :)
 +
 +
== Kernel Constants ==
 +
* KERNVIRTADDR is the virtual address at which the kernel is loaded (and linked) (0xc0008000)
 +
* KERNPHYSADDR is the physical address at which the kernel is loaded (0x30008000)
 +
* PHYSADDR is the physical address of the RAM (0x30000000)
 +
* KERNBASE is the virtual address of the beginning of the kernel virtual address space (0xc0000000)
 +
* STARTUP_PAGETABLE_ADDR is a physical address, suitable for the very early pagetable we build in locore.S (0x30800000)
 +
* FLASHADDR is the address of the flash, virtual or physical depending on what the loader does (??)
 +
* LOADERRAMADDR the address at which the loader maps the RAM if we're running with the MMU enabled, and the physical address if not (??)
 +
 +
== Headers ==
 +
u-boot header size: 64 Bytes
 +
elf header size: ??
 +
 +
[[Category:Distributions]]

Latest revision as of 00:55, 29 April 2009

FreeBSD is NOT ready to be used on the Neo Freerunner or Neo 1973, do not try unless you know what you are doing and are able to help porting. It will only get to single user mode with a very cut down root filesystem.

Interested in using FreeBSD on the Neo1973 or as a Host OS? Get in touch with andrew -at- fubar.geek.nz, they are currently exploring what to do about this.


Contents

[edit] Running FreeBSD in Qemu-neo1973

A FreeBSD port is only ready for kernel developers.

[edit] Required tools

You will need:

  1. mkimage from u-boot. It's available in ports in devel/u-boot
  2. makefs from ports in sysutils/makefs

[edit] Qemu

To build Qemu on FreeBSD to test and develop FreeBSD on the Neo's:

  1. Use subversion to checkout https://svn.openmoko.org/trunk/src/host/qemu-neo1973
  2. In gnokiigsm/device.h comment out the declaration for device_read and device_write, see Talk:Openmoko under QEMU#FreeBSD_and_Qemu...
  3. Edit Makefile.target, search for the line LIBS+=-lm and insert "-L/usr/lib" before "-lm"
  4. If your running FreeBSD on an AMD64 edit x86_64.ld and remove all occurrences of ONLY_IF_RO and ONLY_IF_RW
  5. Run ./configure --target-list=arm-softmmu and gmake
  6. Edit openmoko/flash.sh to add kernel_image="/path/to/kernel.boot" between the calls to most_recent and where it prints the kernel image it will use

[edit] Building FreeBSD

You will need to download http://fubar.geek.nz/files/freebsd/neo1973/neo-20080629.tar.bz2 to build FreeBSD for the Neo1973.

From the FreeBSD src tree run:

make buildworld TARGET=arm TARGET_ARCH=arm TARGET_CPUTYPE=arm920t
make installworld TARGET=arm TARGET_ARCH=arm TARGET_CPUTYPE=arm920t DESTDIR=/path/to/root/fs

You will now need to trim down /path/to/root to remove things noot needed to test in single user mode

makefs -B little /path/to/root.ufs /path/to/root/fs
make buildkernel TARGET=arm TARGET_ARCH=arm TARGET_CPUTYPE=arm920t KERNCONF=NEO1973 -DNO_MODULES MFS_IMAGE=/path/to/root.ufs
mkimage -A arm -O freebsd -T kernel -C none -a 30008000 -e 300080e0 -n "FreeBSD" -d /usr/obj/path/to/kernel /usr/obj/same/path/kernel.boot

You will now have a copy of FreeBSD that is able to be loaded by u-boot.

[edit] Running FreeBSD

From the qemu directory run

./openmoko/download.sh
./openmoko/flash.sh

This will fetch the required parts and create an image to run. They require you to have bash installed.

Finally run qemu with

arm-softmmu/qemu-system-arm -M gta01 -m 130 -mtdblock openmoko/openmoko-flash.image -kernel openmoko/openmoko-kernel.bin -usb -show-cursor

It will display "Kernel loading..." with no further messages.

You can append

-serial telnet:localhost:1200,server

to the qemu startup line to start a telnet server which represents the serial console, just

telnet localhost 1200

and qemu will go on with the startup process.

[edit] Useful pages

GTA02 Openness

[edit] Next steps

  • DMA
  • Drivers:
    • LCD
    • USB

[edit] Using a Kernel Testimage

Another method of getting the kernel into the neo is to use an image for the emulated sd card. I already have a file called sd.img ( dd'ed from a 32mb usb stick).

cp /usr/obj/arm/usr/src/sys/NEO1973/kernel .
/usr/obj/arm/usr/src/tmp/usr/bin/objcopy -O binary kernel
sudo mdconfig -a -t vnode -f sd.img
sudo mount_msdosfs /dev/md0s1 /mnt/tmp
sudo cp kernel /mnt/tmp/
sudo umount /mnt/tmp
sudo mdconfig -d -u 0
arm-softmmu/qemu-system-arm -M neo -m 130 -mtdblock openmoko/openmoko-flash.image -kernel openmoko/openmoko-kernel.bin -sd sd.img -usb -show-cursor -serial telnet:localhost:1200,server

In another terminal:

telnet localhost 1200
mmcinit
fatload mmc 0 0x30008000 kernel
go 0x30008000

And wait for the crash :)

[edit] Kernel Constants

  • KERNVIRTADDR is the virtual address at which the kernel is loaded (and linked) (0xc0008000)
  • KERNPHYSADDR is the physical address at which the kernel is loaded (0x30008000)
  • PHYSADDR is the physical address of the RAM (0x30000000)
  • KERNBASE is the virtual address of the beginning of the kernel virtual address space (0xc0000000)
  • STARTUP_PAGETABLE_ADDR is a physical address, suitable for the very early pagetable we build in locore.S (0x30800000)
  • FLASHADDR is the address of the flash, virtual or physical depending on what the loader does (??)
  • LOADERRAMADDR the address at which the loader maps the RAM if we're running with the MMU enabled, and the physical address if not (??)

[edit] Headers

u-boot header size: 64 Bytes elf header size: ??

Personal tools

Interested in using FreeBSD on the Neo1973 or as a Host OS? Get in touch with mn -at- bsdgroup.de and andrew -at- fubar.geek.nz, they are currently exploring what to do about this.


Running FreeBSD in Qemu-neo1973

A FreeBSD port is only ready for kernel developers.

Required tools

You will need a copy of mkimage from u-boot. To build it fetch a copy of u-boot, cd to the tools directory and build it manually:

cc -I../include -c ../lib_generic/crc32.c
cc -I../include -c mkimage.c
cc -o mkimage mkimage.o crc32.o 

If config.h is missing you can build one by using

gmake CC=/usr/bin/true gta01bv3_config

in the u-boot directory (you must have applied the patches for u-boot from openmoko)

You will also need a copy of Qemu-neo1973. Hints on building it are avaliable from this page.

Building FreeBSD

You will need to download http://fubar.geek.nz/files/freebsd/neo1973/neo1973-0.20070917.tar.bz2 and extract it over the FreeBSD src tree.

From the FreeBSD src tree run:


make buildworld TARGET=arm TARGET_ARCH=arm TARGET_CPUTYPE=arm920t
make buildkernel TARGET=arm TARGET_ARCH=arm TARGET_CPUTYPE=arm920t KERNCONF=NEO1973
gzip -9 usr/obj/path/to/kernel
/path/to/mkimage -A arm -O freebsd -T kernel -C gzip -a 30008000 -e 30008000 -n "Kernel Image QT2410" -d /usr/obj/path/to/kernel.gz /usr/obj/same/path/kernel.boot

You will now have a copy of FreeBSD that is able to be loaded by u-boot.

Running FreeBSD

From the qemu directory edit the openmoko/flash.sh and add the line


kernel_image="/usr/obj/path/to/kernel.boot"

after the four "most_recent" lines.

Next run


./openmoko/download.sh
./openmoko/flash.sh

This will fetch the required parts and create an image to run. They require you to have bash installed.

Finally run qemu with


arm-softmmu/qemu-system-arm -M neo -m 130 -mtdblock openmoko/openmoko-flash.image -kernel openmoko/openmoko-kernel.bin -usb -show-cursor

It will display "Kernel loading..." with no further messages.

Useful pages

GTA02 Openness