Customizing ubldr build...

Tim Kientzle kientzle at
Sun May 20 17:47:13 UTC 2012

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 script I've been working on):

 cd /usr/src
 buildenv=`make TARGET_ARCH=arm TARGET_CPUTYPE=arm buildenvvars`
 cd sys/boot
 eval $buildenv make obj
 eval $buildenv make UBLDR_LOADADDR=0x80100000 all
 cd arm/uboot
 eval $buildenv make DESTDIR=${DESTDIR}  BINDIR=  NO_MAN=true 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

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?=	0x1000000
 LDFLAGS=	-nostdlib -static
+LDFLAGS+=	-T ldscript.generated
+${PROG}: ldscript.generated
+	echo "UBLDR_LOADADDR = ${UBLDR_LOADADDR};" > ldscript.generated

And now the standard loader script can simply use the symbol instead of
a hard-coded value:

 Index: ldscript.arm
 --- ldscript.arm	(revision 235597)
 +++ ldscript.arm	(working copy)
 @@ -5,7 +5,7 @@
    /* Read-only sections, merged into text segment: */
 -  . = 0x1000000 + 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.



More information about the freebsd-current mailing list