Sunday, January 10, 2010

HOWTO build NetBSD for ARM platform

HOWTO build NetBSD on Fedora Core 9

1. Downloading sources for a NetBSD stable branch

[ ]# mkdir -p /home/NetBSD/src
[ ]# cd /home/NetBSD/src
[ ]# ftp -i ftp.NetBSD.org

ftp> cd /pub/NetBSD/NetBSD-release-4-0/tar_files/src/
ftp> mget *.tar.gz
ftp> quit

2. Decompress all tarballs
Run the following bash script:
---------------------------------------------------------------
#!/bin/sh

mkdir -p /home/NetBSD/build

for file in *.tar.gz; do
echo "untar $file"
tar -xzf $file -C /home/NetBSD/build
done
---------------------------------------------------------------

3. Compile toolchain for ARM platform

[ ]# cd /home/NetBSD/build/src
[ ]# ./build.sh -m evbarm tools

patch for compile error
(1) vi /home/NetBSD/build/src/tools/compat/../../lib/libc/gen/glob.c
---------------------------------------------------------------
#ifndef ARG_MAX
#define ARG_MAX (sysconf(_SC_ARG_MAX))
#endif
---------------------------------------------------------------

4. apply patch file for XXXXXX platform

[ ]# cd /home/NetBSD/build/src
[ ]# patch -p0 < /home/NetBSD/xxxxxx.patch
[ ]# ./build.sh -m evbarm kernel=XXXXXX
[ ]# ls -al /home/NetBSD/build/src/sys/arch/evbarm/compile/obj/XXXXXX/netbsd

5. Build File System
[ ]# cd /home/NetBSD/build/src/

6. Build NetBSD (Binary)
[ ]# nbmakefs -s 10M ramdisk.img rootfs
[ ]# arm--netbsdelf-mdsetimage -sv netbsd ramdisk.img
[ ]# arm--netbsdelf-objcopy -S -O binary netbsd netbsd.bin


Resource:
[ ]# wget ftp://ftp.tw.netbsd.org/pub/NetBSD/iso/4.0/sourcecd-4.0.iso
[ ]# wget hftp://iso.tw.netbsd.org/pub/NetBSD/iso/4.0/evbarmcd-4.0.iso

Reference:
1. Porting NetBSD to a new ARM SoC
2. http://wiki.netbsd.se/How_to_create_bootable_NetBSD_image