From owner-freebsd-arm@freebsd.org Sun May 22 18:55:16 2016 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 718B7B45A4E for ; Sun, 22 May 2016 18:55:16 +0000 (UTC) (envelope-from wwaites@tardis.ed.ac.uk) Received: from noether.irl.styx.org (noether.irl.styx.org [IPv6:2a00:d880:6:1a4::98dc]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "noether.irl.styx.org", Issuer "noether.irl.styx.org" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 00FC41C92 for ; Sun, 22 May 2016 18:55:15 +0000 (UTC) (envelope-from wwaites@tardis.ed.ac.uk) Received: by noether.irl.styx.org (Postfix, from userid 66) id 94D0119E36; Sun, 22 May 2016 18:55:12 +0000 (UTC) Received: from naartjie (localhost [127.0.0.1]) by naartjie (Postfix) with ESMTP id 37A3892D6F for ; Sun, 22 May 2016 18:54:00 +0000 (UTC) User-agent: mu4e 0.9.16; emacs 24.5.1 From: William Waites To: freebsd-arm Subject: Booting the Beaglebone Black from internal flash Date: Sun, 22 May 2016 18:53:59 +0000 Message-ID: <86zirhq5yw.fsf@naartjie.uucp> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 May 2016 18:55:16 -0000 I've gotten my BBB to boot and run off of its internal flash. It wasn't terribly difficult and maybe this is old news, but I had a lot of trouble finding instructions for how to do it. Here's what I did, in case it's useful. 1. Start from an image written to SD card. At the time of writing there seems to be a problem with the 11 images, but 10.3 works fine. 2. Delete any existing partitions from the internal flash, as well as the partition table so that we can start from scratch: gpart delete -i 2 mmcsd1 gpart delete -i 1 mmcsd1 gpart destroy mmcsd1 3. Create partitions similarly to the SD card: gpart create -s GPT mmcsd1 gpart add -t \!12 -b 63 -s 2M mmcsd1 gpart set -a active -i 1 mmcsd1 gpart add -t freebsd mmcsd1 gpart add -t freebsd-ufs mmcsd1s2 It is unclear if it is necessary or why to use a traditional disklabel here instead of just putting the freebsd-ufs directly in slice 2. 4. Create filesystems: newfs_msdos -F 12 /dev/mmcsd1s1 newfs -U -t /dev/mmcsd1s2a These filesystems do not (yet) have labels so they won't be magically found by the boot process. It does not appear to be possible to label them while there are other filesystems mounted with those labels. 5. Mount the filesystems: mount /dev/mmcsd1s2a /mnt mkdir -p /mnt/boot/msdos mount -t msdosfs /dev/mmcsd1s1 /mnt/boot/msdos 6. Copy the running system onto the internal flash: cd /boot/msdos; tar -cf - ./ | (cd /mnt/boot/msdos; tar -xpvf -) cd /; tar --one-file-system -cf - ./ | (cd /mnt; tar -xpvf -) This could alternatively be done by building from source, and installing with DESTDIR=/mnt or potentially using the distribution sets. Except perhaps for the early bootloader stages which come from the sysutils/u-boot-beaglebone port I believe. 7. Make sure that booting will proceed from the internal flash, because the default in u-boot is to use mmc 0 (the external SD card). echo 'fatdev=mmc 1' > /mnt/boot/msdos/uenv.txt 8. Halt the system, remove the SD card, boot into single user mode to label the disks. The kernel will not be able to find the root partition, and it needs to be specified as ufs:/dev/mmcsd0s2a when asked. glabel label MSDOSBOOT mmcsd0s1 glabel label rootfs mmcsd0s2a Notice that now the device is mmcsd0 and not mmcsd1. This is because of the way the numbering works which is slightly inconvenient. 9. Reboot and done. 9a. Not really, for me the kernel was still unable to find the filesystem with rootfs label, and I resorted to building a kernel with options ROOTDEVNAME=\"ufs:mmcsd0s2a\" The default in the BEAGLEBONE config is ufs:mmcsd0s2 which would probably have worked if not using BSD disklabels and putting the filesystem directly there (see #3). Is it a good idea to write this down in the wiki? Best wishes, -w ------------------------------------------------+------------------------ William Waites : School of Informatics Synthsys Centre for Mammalian Synthetic Biology : University of Edinburgh ------------------------------------------------+------------------------ The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.