Best way to pass a compiler flag to UBOOT make files

2,013 views
Skip to first unread message

chromeboy

unread,
Sep 21, 2010, 2:14:18 AM9/21/10
to Chromium OS dev
Hi

I am trying to pass a build flag (either a CFLAG or CPPFLAG) to
UBOOT's build system.
All I am trying to do is to add a featurization to a part of the code
in UBOOT files in one file.

I did this by changing the ebuilds of interest:

Step 1)

diff --git a/sys-boot/u-boot/u-boot-2009.11.ebuild b/sys-boot/u-boot/u-
boot-2009.11.ebuild
+++ b/sys-boot/u-boot/u-boot-2009.11.ebuild
-inherit cros-workon toolchain-funcs
+inherit cros-workon toolchain-funcs flag-o-matic

-IUSE=""
+IUSE="qrdc_8660"

@@ -38,6 +38,11 @@ src_configure() {
src_compile() {
tc-getCC
tc-getSTRIP
+ use qrdc_8660 && {
+ export CFLAGS="-DBOARD_QRDC"
+ elog "CFLAGS is $CFLAGS \n"
+ }

diff --git a/sys-boot/u-boot/u-boot-9999.ebuild b/sys-boot/u-boot/u-
boot-9999.ebuild
+inherit cros-workon toolchain-funcs flag-o-matic
Similar changes were done in another ebuild as well.

Step 2) Corresponding change in the make.conf file

diff --git a/overlay-variant-st1q-8660/make.conf b/overlay-variant-
st1q-8660/make.conf
index d464ca4..3b81069 100644
--- a/overlay-variant-st1q-8660/make.conf
+++ b/overlay-variant-st1q-8660/make.conf
@@ -5,3 +5,4 @@ CHROMEOS_U_BOOT_CONFIG="chromeos_8660_recovery_config"
CHROMEOS_U_BOOT_VMLINUX_TEXT_BASE="0x40208000"
CHROMEOS_U_BOOT_TEXT_BASE="0x40100000"
APPSBOOT="emmc_appsboot.mbn"
+USE="qrdc_8660"

Step3) To verify the build system changes are taken into effect

With these changes, I verified the build dependency has been
confirmed:

(cros-chroot) pgargey@pgargey-linux ~/trunk/src/scripts $ emerge-
st1q_8660 --info u-boot
Portage 2.1.7.17-r12 (!/usr/local/portage/chromiumos//profiles/default/
linux/arm/10.0/chromeos/, gcc-4.4.3, unavailable, 2.6.28-18-generic
x86_64)
=================================================================
System Settings
=================================================================

CFLAGS="-O2 -pipe -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-
abi=softfp -I/build/st1q_8660/usr/include/ -I/build/st1q_8660/include/
-gstabs"
PORTDIR_OVERLAY="/usr/local/portage /usr/local/portage/chromiumos /
home/pgargey/trunk/src/overlays/overlay-st1q /home/pgargey/trunk/src/
overlays/overlay-variant-st1q-8660 /home/pgargey/trunk/src/private-
overlays/overlay-st1q-private /home/pgargey/trunk/src/private-overlays/
overlay-nochrome-st1q"
=================================================================
Package Settings
=================================================================

sys-boot/u-boot-9999 was built with the following:
USE="qrdc_8660"
CFLAGS="BOARD_QRDC"

>>> Attempting to run pkg_info() for 'sys-boot/u-boot-9999'
CROS_WORKON_SRCDIR="/home/pgargey/trunk/src/third_party/u-boot/files"
CROS_WORKON_PROJECT="u-boot"

Step 4)

With the above changes I expected the actual flag be available in the
common.h where I intended to use this flag.
But I am not seeing this flag defined there.

Any ideas?

thanks
PhaniG

chromeboy

unread,
Sep 21, 2010, 4:21:17 PM9/21/10
to Chromium OS dev
Spent some more time on this.
It appears that UBOOT build files (Makefiles) do not have a mechanism
to pass the CFLAGS directly from corresponding ebuilds.

We ended up with the following code change:

Patch 1) Modifying the config.mk file in the Uboot source tree so
that it does not over write CFLAGS and CPPFLAGS
Patch 2) Modifying the Makefile in the Uboot/files/tools directory
Patch 3) Change in the UBOOT ebuilds to pass the CFLAGS.

Obviously the second patch will need more clean up.
We just hard coded the second set of files to include -DQRDC_BOARD in
the CFLAGS and it worked

The third patch is obviously the change in the Uboot source files to
add the machine Id.

Let me clean up little bit and I will push some of these out later.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages