Unlike many of the examples I have seen, the following tutorial makes very few
assumptions about your level of expertise with FreeBSD or its command-line interface.
With reasonable attention to detail, you should be able to achieve similar results,
or transpose this example to suit your needs for a different target board.
First some notes/assumptions about the working environment, based on my configuration:
# pkg_add -r bash
$ screen /dev/cu.PL2303-00001AFD 115200
$ su Password: # id dbeattie uid=502(dbeattie) gid=20(staff) groups=20(staff),0(wheel)
All my work is being done in a folder named '/opt', which is made group-writable and therefore I can do anything as the normal user. The following assumes that your normal user is a member of group 'staff'. If that is not the case, adjust the group name for the following 'chgrp' command.
# mkdir -p /opt/usr # chgrp -R staff /opt # chmod -R g+w /optAlso required is a functional TFTP server. On FreeBSD, that's usually as simple as adding one line to /etc/rc.conf:
inetd_enable="YES"...and defining the folder location to serve up in /etc/inetd.conf:
tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /opt/tftpboot tftp dgram udp6 wait root /usr/libexec/tftpd tftpd -l -s /opt/tftpbootNote that the server points to a location inside '/opt'.
# pkg_add -r fastest_cvsup
The inline version below assumes the USA. For other countries, try running it externally:
fastest_cvsup -q -c all... or use a specific country code as argument to '-c'.
Now, back to the normal user, and let's get going!
# exit $ mkdir -p /opt/9stable $ cd /opt/9stable $ echo "*default host=`fastest_cvsup -q -c us`" > ./9stable.supfile $ cat >> ./9stable.supfile << EOF # *default host=cvsup4.us.freebsd.org *default base=/opt/9stable/var/db *default prefix=/opt/9stable/usr *default tag=RELENG_9 *default release=cvs delete use-rel-suffix *default compress src-all # ports-all EOFCreate the working folders, and pull in the source code.
$ mkdir -p /opt/9stable/usr $ mkdir -p /opt/9stable/var/db $ csup ./9stable.supfileThis last command can take a long time, even hours, depending on your network speed. (And I usually walk away, and relax for a while.)
Let's begin the build...
$ export MAKEOBJDIRPREFIX=/opt/9stable/obj $ cd /opt/9stable/usr/src $ make ARCH=arm TARGET_ARCH=arm buildworld $ make ARCH=arm TARGET_ARCH=arm KERNCONF=AT91SAM9260EK buildkernelThis will also take some time -- especially the 'buildworld'.
$ su Password: # echo $MAKEOBJDIRPREFIX /opt/9stable/obj # #[ Clean out DESTDIR if needed; must do a few special things based on file modes and existence of dot files ] # find /opt/tftpboot | xargs chflags -R noschg # chmod -R u+w /opt/tftpboot/* # rm -rf /opt/tftpboot/* # find /opt/tftpboot/ -type f -exec rm {} \;
# mkdir -p /opt/tftpboot # make TARGET=arm TARGET_ARCH=arm KERNCONF=AT91SAM9260EK installkernel DESTDIR=/opt/tftpboot 2>&1 | tee ./installkernel-log.txt # make TARGET=arm TARGET_ARCH=arm KERNCONF=AT91SAM9260EK installworld DESTDIR=/opt/tftpboot 2>&1 | tee ./installworld-log.txt # du -sh /opt/tftpboot/ 238M /opt/tftpboot/
#[ Careful with this...; first two prompts I chose 'l' for delete/link, last 3 answered 'y' for yes ] # mergemaster -m /opt/9stable/usr/src/etc -D /opt/tftpboot -i -A arm 2>&1 | tee ./mergemaster-log.txt # du -sh /opt/tftpboot/ 243M /opt/tftpboot/Create the mount table
# echo "# Device Mountpoint FStype Options Dump Pass#" > /opt/tftpboot/etc/fstab # echo "/dev/mmcsd0s1 / ufs rw 0 0" >> /opt/tftpboot/etc/fstab # cat /opt/tftpboot/etc/fstabCreate default configuration, including host name, DHCP, SSH time client:
# echo "hostname=arm9freebsd.hytherion.local" > /opt/tftpboot/etc/rc.conf # echo "ifconfig_ate0=\"DHCP\"" >> /opt/tftpboot/etc/rc.conf # echo "sshd_enable=\"YES\"" >> /opt/tftpboot/etc/rc.conf # echo "ntpd_enable=\"YES\"" >> /opt/tftpboot/etc/rc.conf # echo "ntpdate_enable=\"YES\"" >> /opt/tftpboot/etc/rc.conf # echo "ntpdate_hosts=\"in.pool.ntp.org\"" >> /opt/tftpboot/etc/rc.conf # cat /opt/tftpboot/etc/rc.confWe must also set up the target SD card to receive the root file system. The following assumes a USB-based SD/MMC card reader which appears on the FreeBSD build machine as /dev/da0
# ls -lt /dev/da* crw-r----- 1 root operator 0, 97 Jul 21 21:55 /dev/da0 # dd if=/dev/zero of=/dev/da0 bs=1k count=100 # fdisk -BI /dev/da0 ******* Working on device /dev/da0 ******* fdisk: invalid fdisk partition table found # ls -lt /dev/da* crw-r----- 1 root operator 0, 97 Jul 21 21:56 /dev/da0 crw-r----- 1 root operator 0, 94 Jul 21 21:56 /dev/da0s1 # newfs /dev/da0s1 /dev/da0s1: 14825.6MB (30362784 sectors) block size 32768, fragment size 4096 using 21 cylinder groups of 740.00MB, 23680 blks, 47360 inodes. super-block backups (for fsck -b #) at: 192, 1515712, 3031232, 4546752, 6062272, 7577792, 9093312, 10608832, 12124352, 13639872, 15155392, 16670912, 18186432, 19701952, 21217472, 22732992, 24248512, 25764032, 27279552, 28795072, 30310592 # mkdir -p /mnt/usbmc # mount /dev/da0s1 /mnt/usbmc/ # mount | grep da0s1 /dev/da0s1 on /mnt/usbmc (ufs, local) # #[ confirm free space available on the mounted SD card partition] # df -h /mnt/usbmc Filesystem Size Used Avail Capacity Mounted on /dev/da0s1 14G 8.0k 13G 0% /mnt/usbmc # #[ now get a copy of everything as a root file system into the SD card partition] # tar -cf - -C /opt/tftpboot/ . | tar -xvpf - -C /mnt/usbmc/ # #VERY IMPORTANT -- UNMOUNT IT PROPERLY: # umount /mnt/usbmc # #[ Final check of the file system; should report 'FILE SYSTEM IS CLEAN' ] # fsck -t ufs /dev/da0s1. . . now, insert the SD card into AT91SAM9260-EK slot, underside, and power up into U-Boot (assumed in DataFlash already)
RomBOOT > U-Boot 1.3.4 (Mar 9 2010 - 19:30:19) DRAM: 64 MB NAND: 256 MiB DataFlash:AT45DB642 Nb pages: 8192 Page Size: 1056 Size= 8650752 bytes Logical address: 0xD0000000 Area 0: D0000000 to D00041FF (RO) Bootstrap Area 1: D0004200 to D00083FF Environment Area 2: D0008400 to D0041FFF (RO) U-Boot Area 3: D0042000 to D0251FFF Kernel Area 4: D0252000 to D083FFFF FS In: serial Out: serial Err: serial Net: macb0 macb0: Starting autonegotiation... macb0: Autonegotiation complete macb0: link up, 100Mbps full-duplex (lpa: 0x45e1) Hit any key to stop autoboot: 0 U-Boot>
Your device IP address and server IP (host machine) address may be different; make adjustments to the following U-Boot command:
U-Boot> setenv ipaddr 192.168.0.116 ; setenv serverip 192.168.0.115 ; tftpboot 0x20000000 boot/kernel/kernel; go 0x200000E0... and away it goes, booting up. Note that this is the system's very first boot, so it also creates the SSH keys and likely does a few extra things for its first time.
U-Boot> setenv ipaddr 192.168.0.116 ; setenv serverip 192.168.0.115 ; tftpboot 0x20000000 boot/kernel/kernel; go 0x200000E0 macb0: link up, 100Mbps full-duplex (lpa: 0x45e1) Using macb0 device TFTP from server 192.168.0.115; our IP address is 192.168.0.116 Filename 'boot/kernel/kernel'. Load address: 0x20000000 Loading: ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ############### done Bytes transferred = 12617505 (c08721 hex) ## Starting application at 0x200000E0 ... KDB: debugger backends: ddb KDB: current backend: ddb Copyright (c) 1992-2012 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD is a registered trademark of The FreeBSD Foundation. FreeBSD 9.1-PRERELEASE #0: Sat Jul 21 21:08:16 MDT 2012 dbeattie@freebsd02vm.hytherion.local:/opt/9stable/obj/arm.arm/opt/9stable/usr/src/sys/AT91SAM9260EK arm CPU: ARM926EJ-S rev 5 (ARM9EJ-S core) DC enabled IC enabled WB enabled LABT 8KB/32B 4-way Instruction cache 8KB/32B 4-way write-back-locking-C Data cache real memory = 67108864 (64 MB) avail memory = 52916224 (50 MB) CONFIG: invalid hint 'hint.ohci.at=asb' CONFIG: invalid hint 'hint.ohci.maddr=0x00500000' atmelarm0:on motherboard at91sam92600: on atmelarm0 at91_pmc0: mem 0xdffffc00-0xdffffcff irq 1 on atmelarm0 at91_pmc0: Primary: 18432000 Hz PLLA: 198 MHz CPU: 198 MHz MCK: 99 MHz at91_wdt0: mem 0xdffffd40-0xdffffd4f irq 1 on atmelarm0 at91_wdt0: Watchdog disabled! (Boot ROM?) at91_rst0: mem 0xdffffd00-0xdffffd0f irq 1 on atmelarm0 at91_rst0: Reset cause: Power On. at91_pit0: mem 0xdffffd30-0xdffffd39 irq 1 on atmelarm0 Timecounter "AT91SAM9 timer" frequency 6208000 Hz quality 1000 at91_pio0: mem 0xdffff400-0xdffff5ff irq 2 on atmelarm0 at91_pio0: ABSR: 0x3e400c3b OSR: 0 PSR:0xc00002c4 ODSR: 0 at91_pio1: mem 0xdffff600-0xdffff7ff irq 3 on atmelarm0 at91_pio1: ABSR: 0 OSR: 0 PSR:0xc03f3f0f ODSR: 0 at91_pio2: mem 0xdffff800-0xdffff9ff irq 4 on atmelarm0 at91_pio2: ABSR: 0x800 OSR: 0x4800 PSR:0xfbcf ODSR: 0x4800 at91_twi0: mem 0xdffac000-0xdffaffff irq 11 on atmelarm0 iicbus0: on at91_twi0 setting cwgr to 0x11110 iic0: on iicbus0 at91_mci0: mem 0xdffa8000-0xdffabfff irq 9 on atmelarm0 mmc0: on at91_mci0 uart0: mem 0xdffff200-0xdffff3ff irq 1 on atmelarm0 uart0: console (115200,n,8,1) uart1: mem 0xdffb0000-0xdffb3fff irq 6 on atmelarm0 uart2: mem 0xdffb4000-0xdffb7fff irq 7 on atmelarm0 uart3: mem 0xdffb8000-0xdffbbfff irq 8 on atmelarm0 uart4: mem 0xdffd0000-0xdffd3fff irq 23 on atmelarm0 uart5: mem 0xdffd4000-0xdffd7fff irq 24 on atmelarm0 uart6: mem 0xdffd8000-0xdffdbfff irq 25 on atmelarm0 ate0: mem 0xdffc4000-0xdffc7fff irq 21 on atmelarm0 miibus0: on ate0 ukphy0: PHY 0 on miibus0 ukphy0: none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto ate0: Ethernet address: 3a:1f:34:08:54:54 ohci0: mem 0xdfc00000-0xdfcfffff irq 20 on atmelarm0 usbus0 on ohci0 Timecounters tick every 10.000 msec usbus0: 12Mbps Full Speed USB v1.0 ugen0.1: at usbus0 uhub0: on usbus0 mmcsd0: 14GB at mmc0 25.0MHz/4bit/1-block Root mount waiting for: usbus0 uhub0: 2 ports with 2 removable, self powered Root mount waiting for: usbus0 ugen0.2: at usbus0 run0: <1.0> on usbus0 run0: MAC/BBP RT3070 (rev 0x0200), RF RT3020 (MIMO 1T1R), address 00:05:7b:67:03:a8 Trying to mount root from ufs:/dev/md0 []... Mounting from ufs:/dev/md0 failed with error 22. Trying to mount root from ufs:/dev/mmcsd0s1 []... warning: no time-of-day clock registered, system time will not be set accurately Setting hostuuid: 9c1d6de3-d3ba-11e1-a71e-3a1f34085454. Setting hostid: 0xeb1f5905. Entropy harvesting: interrupts ethernet point_to_point kickstart. Starting file system checks: Mounting local file systems:. Setting hostname: arm9freebsd.hytherion.local. ate0: link state changed to UP Starting Network: lo0 ate0. lo0: flags=8049 metric 0 mtu 16384 options=600003 inet 127.0.0.1 netmask 0xff000000 ate0: flags=8843 metric 0 mtu 1500 options=80008 ether 3a:1f:34:08:54:54 media: Ethernet autoselect (100baseTX ) status: active Starting devd. Starting dhclient. DHCPDISCOVER on ate0 to 255.255.255.255 port 67 interval 6 DHCPOFFER from 192.168.0.1 DHCPREQUEST on ate0 to 255.255.255.255 port 67 DHCPACK from 192.168.0.1 bound to 192.168.0.116 -- renewal in 302400 seconds. Generating host.conf. Creating and/or trimming log files. Starting syslogd. ELF ldconfig path: /lib /usr/lib /usr/lib/compat Setting date via ntp. 22 Jul 18:05:21 ntpdate[683]: step time server 122.166.117.103 offset 46791.876386 sec Clearing /tmp (X related). Updating motd:. Starting ntpd. Generating public/private rsa1 key pair. Your identification has been saved in /etc/ssh/ssh_host_key. Your public key has been saved in /etc/ssh/ssh_host_key.pub. The key fingerprint is: 20:28:6f:68:2c:0f:d1:ed:bc:fa:a2:a9:ca:22:de:25 root@arm9freebsd.hytherion.local The key's randomart image is: +--[RSA1 1024]----+ | | | . o | |o o o . | |.= o . . | |+oo o S | |o+ . | | .E.. | |+.o.o | |@+.+. | +-----------------+ Generating public/private dsa key pair. Your identification has been saved in /etc/ssh/ssh_host_dsa_key. Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub. The key fingerprint is: 24:4b:e9:d5:38:00:6e:93:f5:c2:ae:b5:60:14:ef:3e root@arm9freebsd.hytherion.local The key's randomart image is: +--[ DSA 1024]----+ | o.o | | . * + o | | * B * . | | o * * . | | o * S | | . = . | | . E | | . | | | +-----------------+ Generating public/private rsa key pair. Your identification has been saved in /etc/ssh/ssh_host_rsa_key. Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub. The key fingerprint is: cf:fa:34:96:0e:63:d4:0a:65:31:47:bc:e3:dd:51:b6 root@arm9freebsd.hytherion.local The key's randomart image is: +--[ RSA 2048]----+ | ooo | | +. o| | o . o.| | o .o .E | | . S..o . . | | o +... . | | = B | | . B . | | ..o | +-----------------+ Generating public/private ecdsa key pair. Your identification has been saved in /etc/ssh/ssh_host_ecdsa_key. Your public key has been saved in /etc/ssh/ssh_host_ecdsa_key.pub. The key fingerprint is: 5f:41:67:e7:5b:e7:43:a3:88:15:16:ec:1b:89:5f:88 root@arm9freebsd.hytherion.local The key's randomart image is: +--[ECDSA 256]---+ | .+o o .| | .o.o o | | +.+ o+| | Eo=.oo.=| | S...=. o.| | . + .| | . | | | | | +-----------------+ Starting sshd. Starting cron. Starting background file system checks in 60 seconds. Sun Jul 22 18:07:57 UTC 2012 FreeBSD/arm (arm9freebsd.hytherion.local) (ttyu0) login: _ FreeBSD/arm (arm9freebsd.hytherion.local) (ttyu0) login: root Jul 22 21:43:24 arm9freebsd login: ROOT LOGIN (root) ON ttyu0 FreeBSD 9.1-PRERELEASE (AT91SAM9260EK) #0: Sat Jul 21 21:08:16 MDT 2012 Welcome to FreeBSD! Before seeking technical support, please use the following resources: o Security advisories and updated errata information for all releases are at http://www.FreeBSD.org/releases/ - always consult the ERRATA section for your release first as it's updated frequently. o The Handbook and FAQ documents are at http://www.FreeBSD.org/ and, along with the mailing lists, can be searched by going to http://www.FreeBSD.org/search/. If the doc package has been installed (or fetched via pkg_add -r lang-freebsd-doc, where lang is the 2-letter language code, e.g. en), they are also available formatted in /usr/local/share/doc/freebsd. If you still have a question or problem, please take the output of `uname -a', along with any relevant error messages, and email it as a question to the questions@FreeBSD.org mailing list. If you are unfamiliar with FreeBSD's directory layout, please refer to the hier(7) manual page. If you are not familiar with manual pages, type `man man'. Edit /etc/motd to change this login announcement. root@arm9freebsd:/root # top -b last pid: 1176; load averages: 0.07, 0.02, 0.00 up 0+03:43:31 21:46:56 12 processes: 1 running, 11 sleeping Mem: 8600K Active, 9444K Inact, 8644K Wired, 13M Buf, 25M Free Swap: PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND 1141 root 1 16 0 10108K 2532K pause 0:00 0.05% csh 758 root 1 40 0 11460K 1960K select 0:05 0.00% ntpd 779 root 1 40 0 11400K 2160K select 0:02 0.00% sendmail 786 root 1 8 0 9796K 1252K nanslp 0:00 0.00% cron 670 root 1 40 0 9736K 1280K select 0:00 0.00% syslogd 818 root 1 8 0 10648K 1924K wait 0:00 0.00% login 782 smmsp 1 16 0 11400K 1932K pause 0:00 0.00% sendmail 1176 root 1 40 0 10176K 1864K RUN 0:00 0.00% top 521 root 1 50 0 9736K 980K select 0:00 0.00% dhclient 776 root 1 42 0 13392K 1820K select 0:00 0.00% sshd 576 _dhcp 1 40 0 9736K 940K select 0:00 0.00% dhclient 577 root 1 40 0 12356K 388K select 0:00 0.00% devd root@arm9freebsd:/root # file `which cc` /usr/bin/cc: ELF 32-bit LSB executable, ARM, version 1 (FreeBSD), statically linked, for FreeBSD 9.0 (900506), stripped root@arm9freebsd:/root # mount /dev/mmcsd0s1 on / (ufs, local) devfs on /dev (devfs, local) root@arm9freebsd:/root # df -h Filesystem Size Used Avail Capacity Mounted on /dev/mmcsd0s1 14G 243M 12G 2% / devfs 1.0k 1.0k 0B 100% /dev root@arm9freebsd:/root # uname -a FreeBSD arm9freebsd.hytherion.local 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #0: Sat Jul 21 21:08:16 MDT 2012
dbeattie@freebsd02vm.hytherion.local:/opt/9stable/obj/arm.arm/opt/9stable/usr/src/sys/AT91SAM9260EK arm root@arm9freebsd:/root # _
root@arm9freebsd:/root # shutdown -p now Shutdown NOW! shutdown: [pid 1339] root@arm9freebsd:/root # *** FINAL System shutdown message from root@arm9freebsd.hytherion.local *** System going down IMMEDIATELY Jul 22 23:20:49 arm9freebsd shutdown: power-down by root: System shutdown time has arrived Stopping cron. Stopping sshd. Waiting for PIDS: 776. Stopping ntpd. Stopping devd. Writing entropy file:. Terminated . Jul 22 23:21:24 arm9freebsd syslogd: exiting on signal 15 Waiting (max 60 seconds) for system process `vnlru' to stop...done Waiting (max 60 seconds) for system process `bufdaemon' to stop...done Waiting (max 60 seconds) for system process `syncer' to stop... Syncing disks, vnodes remaining...0 done Syncing disks, buffers remaining... 7 7 6 6 6 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 Final sync complete Uptime: 5h18m9s The operating system has halted. Please press any key to reboot.
Also, you're welcome to visit my home page.