From owner-freebsd-current@FreeBSD.ORG Sun May 20 17:47:12 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DC8071065670; Sun, 20 May 2012 17:47:12 +0000 (UTC) (envelope-from kientzle@freebsd.org) Received: from monday.kientzle.com (99-115-135-74.uvs.sntcca.sbcglobal.net [99.115.135.74]) by mx1.freebsd.org (Postfix) with ESMTP id 6398B8FC0A; Sun, 20 May 2012 17:47:12 +0000 (UTC) Received: (from root@localhost) by monday.kientzle.com (8.14.4/8.14.4) id q4KHl4XH024645; Sun, 20 May 2012 17:47:04 GMT (envelope-from kientzle@freebsd.org) Received: from [192.168.2.143] (CiscoE3000 [192.168.1.65]) by kientzle.com with SMTP id zrrqp4c7e8vdsu47r7dr52umjs; Sun, 20 May 2012 17:47:04 +0000 (UTC) (envelope-from kientzle@freebsd.org) From: Tim Kientzle Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Date: Sun, 20 May 2012 10:47:04 -0700 Message-Id: To: freebsd-current FreeBSD , arm@freebsd.org Mime-Version: 1.0 (Apple Message framework v1257) X-Mailer: Apple Mail (2.1257) Cc: Subject: Customizing ubldr build... X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 May 2012 17:47:13 -0000 In order to fully automate building SD images for Beaglebone, I'm trying to come up with a clean way to tailor the ubldr build. I think I've come up with a good way to do this and would appreciate any = feedback. First, here's the (somewhat simplified) script that builds and installs = ubldr (this is going into the beaglebsd.sh script I've been working on): cd /usr/src buildenv=3D`make TARGET_ARCH=3Darm TARGET_CPUTYPE=3Darm buildenvvars` cd sys/boot eval $buildenv make obj eval $buildenv make UBLDR_LOADADDR=3D0x80100000 all cd arm/uboot eval $buildenv make DESTDIR=3D${DESTDIR} BINDIR=3D NO_MAN=3Dtrue = install The key issue is the physical load address, which differs among boards. My idea is to allow specifying this at build time through a make variable UBLDR_LOADADDR. The Makefile for sys/boot/arm/uboot passes this down into a dynamically-built loader script. Here's a summary of the changes I'm proposing to sys/boot/arm/uboot/Makefile: +UBLDR_LOADADDR?=3D 0x1000000 =20 LDFLAGS=3D -nostdlib -static +LDFLAGS+=3D -T ldscript.generated LDFLAGS+=3D -T ${.CURDIR}/ldscript.${MACHINE_CPUARCH} =20 +${PROG}: ldscript.generated + +ldscript.generated:: + echo "UBLDR_LOADADDR =3D ${UBLDR_LOADADDR};" > = ldscript.generated And now the standard loader script can simply use the symbol instead of a hard-coded value: Index: ldscript.arm =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ldscript.arm (revision 235597) +++ ldscript.arm (working copy) @@ -5,7 +5,7 @@ SECTIONS { /* Read-only sections, merged into text segment: */ - . =3D 0x1000000 + SIZEOF_HEADERS; + . =3D UBLDR_LOADADDR + SIZEOF_HEADERS; .interp : { *(.interp) } .hash : { *(.hash) } .dynsym : { *(.dynsym) } This seems to work pretty well for me, except for one odd point: the make dependencies cause ubldr to get relinked on every build. (This can be fixed in the usual way.) If anyone sees a better way to handle this, I'd much appreciate the = input. Cheers, Tim