porting freebsd to at91sam9g45 ( SBC6045 board)

Aleksander Dutkowski adutkowski at gmail.com
Tue Jan 3 01:04:53 UTC 2012


hi!

Ive just come from linux world to FreeBSD and I have SBC6045 board
based on at91sam9g45 SoC so Ive decided to try and port FBSD on it ;)
I have quite good knowledge in x86 processor internals like paging,
protected mode etc, but I haven't been programing low level on arm
arch yet.

Somebody created port for SAM9G20EK, so I tried to compile and run it:

cd /usr/arm // my own copy from svn
export TARGET=arm
export TARGET_ARCH=arm
export MAKEOBJDIRPREFIX=/usr/arm/obj
make buildkernel KERNCONF=SAM9G20EK
make installkernel KERNCONF=SAM9G20EK DESTDIR=/arm-kernel  INSTALL_NODEBUG=t

file /arm-kernel/boot/kernel/kernel
kernel: ELF 32-bit LSB executable, ARM, version 1 (FreeBSD),
dynamically linked (uses shared libs), not stripped

And this is output from board's debug console:
----------------------------------------------------------------------------------------------
Start AT91Bootstrap...

U-Boot 1.3.4 (May 15 2011 - 11:23:14)

DRAM:  256 MB
## Unknown FLASH on Bank 1 - Size = 0x00000000 = 0 MB
Flash:  0 kB
NAND:  256 MiB
Error: 8 bit/pixel mode, but BMP has 32 bit/pixel
In:    serial
Out:   serial
Err:   serial
Net:   macb0
Hit any key to stop autoboot:  0
U-Boot> tftp 0x20000000 fbsd
macb0: Starting autonegotiation...
macb0: Autonegotiation complete
macb0: link up, 100Mbps full-duplex (lpa: 0x4de1)
Using macb0 device
TFTP from server 192.168.3.1; our IP address is 192.168.3.2
Filename 'fbsd'.
Load address: 0x20000000
Loading: #################################################################
         #################################################################
         #################################################################
         ###############################################################
done
Bytes transferred = 3775383 (399b97 hex)
U-Boot> go 0x200000C0
## Starting application at 0x200000C0 ...
----------------------------------------------------------------------------------------------
and it hangs - I can see that very early

Where did I get address 0x200000C0?
# readelf kernel -S | grep .text
[Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
[ 1] .text             PROGBITS        c00000c0 0000c0 239e30 00  AX  0   0 32

# readelf kernel -s | grep _start
[...]
461: c00000c0     0 FUNC    GLOBAL DEFAULT    1 _start
[...]

# cat /sys/arm/at91/std.sam9g20ek
makeoptions	KERNPHYSADDR=0x20000000
makeoptions	KERNVIRTADDR=0xc0000000
options		KERNPHYSADDR=0x20000000	
options		KERNVIRTADDR=0xc0000000

so, based on http://wiki.freebsd.org/FreeBSDAtmel, Ive changed
0x200000E0 to 0x200000C0

Ive put all of this code because maybe you'll find some mistakes. But
I am now researching info and can't tell how fbsd should be booted. I
have seen some code made by mr Rafal Jaworowski where he ran loader(8)
from u-boot and then kernel. Is this proper way today to boot fbsd on
arm? Because Ive researched, that my kernel file is only a plain
kernel, no boot0, boot2, nor loader. But maybe executing loader will
be easier?

-- 
regards
Aleksander Dutkowski


More information about the freebsd-arm mailing list