Wed, 11 Sep 2013

Getting started with NetBSD on i.MX233 OLinuXino

Update: Tue, 8 Oct My work was committed to NetBSD -current tree so you can follow these instructions but please skip now unnecessary step "Apply my patch agains -current". Thanks! -Petri

NetBSD port is currently heavily under development so expect problems. I will keep my olinuxino.diff updated as I progress.

When I built with -m evbearmv5-el I wasn't able to enter multiuser mode for unknown reasons. Boot process got stuck at:

WARNING: no TOD clock present
WARNING: using filesystem time
WARNING: CHECK AND RESET THE DATE!
init path (default /sbin/init):
init: trying /sbin/init
Wed Sep 11 18:24:32 UTC 2013

So please build with -m evbarm.

Set some useful environment variables

export CVS_RSH="ssh"
# Lookup your local mirror from http://www.netbsd.org/mirrors/#anoncvs
export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
_DEV_ROOT="/work/nb"
export MAKEOBJDIRPREFIX="$_DEV_ROOT/obj"
export export MAKEVERBOSE=1
export MKUNPRIVED=yes
export TOOLDIR="$_DEV_ROOT/tooldir"
export DESTDIR="$_DEV_ROOT/destdir"
export RELEASEDIR="$_DEV_ROOT/release"
export MKMAINTAINERTOOLS=yes
export MKCROSSGDB=yes
export TMPDIR=/tmp
export PATH=${PATH}:"$_DEV_ROOT/tooldir/bin"

Populate your DEV_ROOT

$ mkdir -p ${DESTDIR}
$ mkdir ${MAKEOBJDIRPREFIX}
$ mkdir ${RELEASEDIR}
$ mkdir ${TOOLDIR}

Configure sane CVS defaults to your $HOME/.cvsrc

update -dPA
#update  -dP
rdiff   -u
diff    -uN
cvs     -q

Fetch NetBSD-current

$ cvs checkout src

Apply my patch against -current

$ wget http://www.asd.fi/~petri/blog/files/olinuxino.diff
$ cd src
$ patch -u < ../olinuxino.diff

Build tools, distribution, sets and kernel

# You can give -j <number of processes> to speed up the build on multicore machines
$ ./build.sh -m evbarm -u -U tools
$ ./build.sh -m evbarm -u -U distribution
$ ./build.sh -m evbarm -u -U sets
$ ./build.sh -m evbarm -u -U kernel=IMX23_OLINUXINO

Prepare SD card partitions

# fdisk -u /dev/sd0
Do you want to change our idea of what BIOS thinks? [n] n
Which partition do you want to change?: [none] 0
sysid: [0..255 default: 169] 83
start: [0..7580cyl default: 32, 0cyl, 0MB] 1MB
size: [0..7579cyl default: 15521792, 7579cyl, 7579MB] 16MB
bootmenu: [] SB
Which partition do you want to change?: [none] 1
sysid: [0..255 default: 169] 169
start: [0..7580cyl default: 32, 0cyl, 0MB] 17MB
size: [0..7563cyl default: 15489024, 7563cyl, 7563MB] <press enter>
bootmenu: [] NetBSD
Which partition do you want to change?: [none] <press enter>
install default bootfile instead? [n] n
Update the bootcode from /usr/mdec/mbr? [n]
Should we write new partition table? [n] y

After fdisk, your SD card partition table should look something like this

# fdisk /dev/sd0
...
Partition table:
0: DM6 Aux3 (sysid 83)
    bootmenu: SB
    start 2048, size 32768 (16 MB, Cyls 0-16)
        PBR is not bootable: All bytes are identical (0x00)
1: NetBSD (sysid 169)
    bootmenu: NetBSD
    start 34816, size 15489024 (7563 MB, Cyls 17-7579)
        PBR is not bootable: All bytes are identical (0x00)

I had to remove SD card USB adapter, remove the device file and reinsert the adapter. After this NetBSD was able to discover default disklabel for the drive.

# cd /dev
# rm sd0*
# ./MAKEDEV sd0

Now disklabel your NetBSD partition.

# disklabel -e sd0

I splitted 'f' partition to 128MB 'b' swap partition and gave rest of the space for root partition 'a'

After disklabel edit it looks like this:

# disklabel sd0
...
6 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a:  15226880     34816     4.2BSD      0     0     0  # (Cyl.     17 -   7451)
 b:    262144  15261696       swap                     # (Cyl.   7452 -   7579)
 c:  15489024     34816     unused      0     0        # (Cyl.     17 -   7579)
 d:  15523840         0     unused      0     0        # (Cyl.      0 -   7579)
 e:     32768      2048    unknown                     # (Cyl.      1 -     16)

Format your root partition. I guess you can use other than -O 1 option.

# newfs -O 1 /dev/rsd0a
/dev/rsd0a: 7435.0MB (15226880 sectors) block size 16384, fragment size 2048
        using 41 cylinder groups of 181.34MB, 11606 blks, 22912 inodes.
super-block backups (for fsck_ffs -b #) at:
32, 371424, 742816, 1114208, 1485600, 1856992, 2228384, 2599776, 2971168,
...............................................................................

Mount it to temporary location

# mount /dev/sd0a /mnt
# df -h /mnt
Filesystem         Size       Used      Avail %Cap Mounted on
/dev/sd0a          7.1G       2.0K       6.8G   0% /mnt

Extract at least etc.tgz and base.tgz to root partition

# tar zxpf /work/nb/release/evbarm/binary/sets/etc.tgz -C /mnt/
# tar zxpf /work/nb/release/evbarm/binary/sets/base.tgz -C /mnt/

Build device nodes

# cd /mnt/dev
# ./MAKEDEV all

Configure at /etc/rc.conf to have rc_configured=YES and your fstab

# cat /mnt/etc/fstab
/dev/ld0a       /       ffs     rw,log,noatime  1 1
/dev/ld0b       none    swap    sw,dp   0 0
ptyfs   /dev/pts        ptyfs   rw

Create boot image by copying kernel, bootloader and configuration to temporary location

$ cp /work/nb/obj/home/petri/dev/build_test/src/sys/arch/evbarm/compile/IMX23_OLINUXINO/netbsd.bin /tmp/
$ cp /work/nb/obj/home/petri/dev/build_test/src/sys/arch/evbarm/stand/bootimx23/bootimx23 /tmp/
$ cp sys/arch/evbarm/stand/bootimx23/bootimx23.bd /tmp/

Run elftosb

$ cd /tmp
$ nbelftosb -V -c bootimx23.bd -z -o bootimx23.sb
Boot Section 0x00000000:
  LOAD | adr=0x00000000 | len=0x00001010 | crc=0xbbfd93fe | flg=0x00000000
  LOAD | adr=0x00001010 | len=0x00000064 | crc=0xea2ad87e | flg=0x00000000
  FILL | adr=0x00001074 | len=0x0000000c | ptn=0x00000000
  CALL | adr=0x000001a8 | arg=0x00000000 | flg=0x00000000
  LOAD | adr=0x40000000 | len=0x00423880 | crc=0x62128975 | flg=0x00000000
  JUMP | adr=0x40000000 | arg=0x00000000 | flg=0x00000000

Now you have bootimx23.sb which you should transfer to boot partition

$ dd if=/dev/zero of=boot_partition.raw bs=512 count=4
$ dd if=bootimx23.sb of=boot_partition.raw ibs=512 seek=4 conv=sync,notrunc
# # 'e' partition holds bootable image on SD card
# dd if=boot_partition.raw of=/dev/sd0e

umount root filesystem

# umount /mnt
# # just to make sure :-)
# sync

...and insert SD card to your i.MX233/OLinuXino

Booting...done.
Press any key to drop into boot prompt...

NetBSD/evbarm (OLinuXino) booting ...
[ Kernel symbol table missing! ]
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 6.99.23 (IMX23_OLINUXINO) #0: Mon Sep 16 18:22:06 EEST 2013
        petri@babylon:/work/nb/obj/home/petri/dev/build_test/src/sys/arch/evbarm/compile/IMX23_OLINUXINO
total memory = 65536 KB
avail memory = 60092 KB
sysctl_createv: sysctl_create(machine_arch) returned 17
mainbus0 (root)
cpu0 at mainbus0 core 0: ARM926EJ-S rev 5 (ARM9EJ-S V5TEJ core)
cpu0: DC enabled IC enabled WB enabled EABT branch prediction enabled
cpu0: 16KB/32B 4-way L1 Instruction cache
cpu0: 16KB/32B 4-way write-back-locking-C L1 Data cache
apbh0 at mainbus0 base 0x80000000-0x8003ffff
icoll0 at apbh0 addr 0x80000000-0x80001fff
apbdma0 at apbh0 addr 0x80004000-0x80005fff
ssp0 at apbh0 addr 0x80010000-0x80011fff irq 15: SSP Block v3.0
sdmmc0 at ssp0
digctl0 at apbh0 addr 0x8001c000-0x8001dfff
pinctrl0 at apbh0 addr 0x80018000-0x80019fff: PIN MUX & GPIO
gpio0 at pinctrl0: 96 pins
apbx0 at mainbus0 base 0x80040000-0x8007ffff
timrot0 at apbx0 addr 0x80068020-0x8006803f irq 28
timrot1 at apbx0 addr 0x80068040-0x8006805f irq 29
apbdma1 at apbx0 addr 0x80024000-0x80025fff
plcom0 at apbx0 addr 0x80070000-0x80070fff irq 0
plcom0: txfifo disabled
plcom0: console
usbphy0 at apbx0 addr 0x8007c000-0x8007dfff: USB PHY v4.0
clkctrl0 at apbx0 addr 0x80040000-0x80041fff
ahb0 at mainbus0 base 0x80080000-0x800fffff
imxusbc0 at ahb0 addr 0x80080000-0x800bffff
ehci0 at imxusbc0
ehci0: i.MX USB Controller id=5 revision=65 HCI revision=0x100
ehci0: 1 host port, device capable, 5 endpoints
usb0 at ehci0: USB revision 2.0
uhub0 at usb0: i.MX EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
WARNING: module error: can't find builtin dependency `iic'
WARNING: module error: can't find builtin dependency `au8522'
WARNING: module error: can't find builtin dependency `iic'
WARNING: module error: can't find builtin dependency `iic'
WARNING: module error: can't find builtin dependency `iic'
WARNING: module error: can't find builtin dependency `iic'
ssp0: bus clock @ 24.000 MHz
ld0 at sdmmc0: <0x03:0x5344:SU02G:0x80:0x0466cd3c:0x0a2>
ld0: 1886 MB, 957 cyl, 64 head, 63 sec, 512 bytes/sect x 3862528 sectors
ld0: 4-bit width, bus clock 25.000 MHz
uhub1 at uhub0 port 1: vendor 0x05e3 USB2.0 Hub, class 9/0, rev 2.00/77.64, addr 2
uhub1: single transaction translator
boot device: ld0
root on ld0a dumps on ld0b
root file system type: ffs
WARNING: no TOD clock present
WARNING: using filesystem time
WARNING: CHECK AND RESET THE DATE!
Mon Sep 16 16:17:01 UTC 2013
Starting root file system check:
/dev/rld0a: file system is clean; not checking
swapctl: setting dump device to /dev/ld0b
swapctl: adding /dev/ld0b as swap device at priority 0
Starting file system checks:
Loaded entropy from /var/db/entropy-file.
Setting tty flags.
Setting sysctl variables:
ddb.onpanic: 1 -> 0
Starting network.
/etc/rc: WARNING: $hostname not set.
IPv6 mode: host
Configuring network interfaces:.
Adding interface aliases:.
Waiting for DAD completion for statically configured addresses...
Building databases: dev, utmp, utmpx, services.
Starting syslogd.
Mounting all filesystems...
Clearing temporary files.
Creating a.out runtime link editor directory cache.
Checking quotas: done.
Setting securelevel: kern.securelevel: 0 -> 1
swapctl: setting dump device to /dev/ld0b
Starting virecover.
Checking for core dump...
savecore: (null): kvm_openfiles: /netbsd: No such file or directory
Sep 16 16:17:36  savecore: (null): kvm_openfiles: /netbsd: No such file or directory
Starting local daemons:.
Updating motd.
/usr/sbin/postconf: warning: valid_hostname: empty hostname
/usr/sbin/postconf: fatal: unable to use my own hostname
Sep 16 16:18:00  postfix[316]: fatal: unable to use my own hostname
/etc/rc.d/postfix exited with code 1
Starting inetd.
Starting cron.
The following components reported failures:
    /etc/rc.d/postfix
See /var/run/rc.log for more information.
Mon Sep 16 16:18:04 UTC 2013

NetBSD/evbarm (Amnesiac) (console)

login: root
Sep 16 16:18:25  login: ROOT LOGIN (root) on tty console
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 6.99.23 (IMX23_OLINUXINO) #0: Mon Sep 16 18:22:06 EEST 2013

Welcome to NetBSD!

This system is running a development snapshot of the NetBSD operating system,
also known as NetBSD-current.  It is very possible that it has serious bugs,
regressions, broken features or other problems.  Please bear this in mind
and use the system with care.

You are encouraged to test this version as thoroughly as possible.  Should you
encounter any problem, please report it back to the development team using the
send-pr(1) utility (requires a working MTA).  If yours is not properly set up,
use the web interface at: http://www.NetBSD.org/support/send-pr.html

Thank you for helping us test and improve NetBSD.

Terminal type is vt100.
We recommend that you create a non-root account and use su(1) for root access.
#

posted at: 18:50 | path: /NetBSD | permanent link to this entry