Bug 943 - Need a functional u-boot for mpc8315e-rdb (using factory now)
Summary: Need a functional u-boot for mpc8315e-rdb (using factory now)
Status: VERIFIED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 1.0
Hardware: mpc8315e-rdb ppc
: Medium normal
Target Milestone: 1.3
Assignee: Paul Gortmaker
QA Contact:
URL:
Whiteboard: (P4) O2 solves build, PRC hardware br...
Depends on:
Blocks:
 
Reported: 2011-03-31 15:08 UTC by Darren Hart
Modified: 2012-11-15 07:53 UTC (History)
7 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments
v2010.09 Build Failure: crc32.c:85:1: error: initializer element is not constant crc32.c:85:1: error: (near initialization for 'crc_table[0]') (38.22 KB, text/plain)
2011-03-31 15:08 UTC, Darren Hart
no flags Details
v2010.12 Build Failure: ehci-hcd.c:59:3: error: initializer element is not constant (85.01 KB, text/plain)
2011-03-31 15:12 UTC, Darren Hart
no flags Details
the patch to pass compilation (1.26 KB, patch)
2011-04-02 02:59 UTC, Qing He
no flags Details | Diff
updated patch to fix compilation (1.03 KB, patch)
2011-04-02 03:04 UTC, Qing He
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darren Hart 2011-03-31 15:08:25 UTC
We should be including u-boot in the mpc8315e-rdb images. v2010.09 is documented in README.hardware as the preferred version. However, neither this version, nor v2010.12, nor HEAD will compile with the 1.0 toolchain:

$ /opt/poky/1.0/sysroots/x86_64-pokysdk-linux/usr/bin/ppc603e-poky-linux/powerpc-poky-linux-gcc --version
powerpc-poky-linux-gcc (GCC) 4.5.1

Regardless of the version, gcc complains about the -Os option:
dvhart@doubt:u-boot.git$ make ARCH=powerpc CROSS_COMPILE=/opt/poky/1.0/sysroots/x86_64-pokysdk-linux/usr/bin/ppc603e-poky-linux/powerpc-poky-linux- MPC8315ERDB_config
awk '(NF && $1 !~ /^#/) { print $1 ": " $1 "_config; $(MAKE)" }' boards.cfg > .boards.depend
Generating include/autoconf.mk
cc1: error: Do not use -Os option if --enable-target-optspace is not set.
Generating include/autoconf.mk.dep
cc1: error: Do not use -Os option if --enable-target-optspace is not set.
Configuring for MPC8315ERDB board...

The following patch gets past this:

diff --git a/config.mk b/config.mk
index eb95093..374b262 100644
--- a/config.mk
+++ b/config.mk
@@ -151,7 +151,7 @@ ARFLAGS = crv
 endif
 RELFLAGS= $(PLATFORM_RELFLAGS)
 DBGFLAGS= -g # -DDEBUG
-OPTFLAGS= -Os #-fomit-frame-pointer
+OPTFLAGS= #-Os #-fomit-frame-pointer
 ifndef LDSCRIPT
 #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
 ifeq ($(CONFIG_NAND_U_BOOT),y)

The build failures for the three points in the git file follow as attachments.
Comment 1 Darren Hart 2011-03-31 15:08:59 UTC
Created attachment 126 [details]
v2010.09 Build Failure:
crc32.c:85:1: error: initializer element is not constant
crc32.c:85:1: error: (near initialization for 'crc_table[0]')
Comment 2 Darren Hart 2011-03-31 15:12:19 UTC
Created attachment 127 [details]
v2010.12 Build Failure: ehci-hcd.c:59:3: error: initializer element is not constant
Comment 3 Darren Hart 2011-03-31 15:14:17 UTC
I see that v2011.03 was released today. Building with the Poky 4.5.1 gcc results in the same error there as for v2010.12.
Comment 4 Qing He 2011-04-02 02:58:17 UTC
(In reply to comment #3)
> I see that v2011.03 was released today. Building with the Poky 4.5.1 gcc
> results in the same error there as for v2010.12.

It looks like the omission of -Os is fatal in this case.

cpu_to_le{16,32} are translated to swab family of functions, where in
include/linux/byteorder/swab.h, there is:
---
#if defined(__GNUC__) && (__GNUC__ >=2) && defined(__OPTIMIZE__)
#  define __swab16(x) \
(__builtin_constant_p((__u16)(x))? \
 ___swab16((x)) : \
 __fswab16((x)))
...
#else
#  define __swab16(x) __fswab16(x)
...
#endif /* OPTIMIZE */
---

So, when -Os is missing, __OPTIMIZE__ is not set, and cpu_to_le16 is translated to __fswab16(x) which is not constant foldable (f denotes function here).

I try to always define __swab16 (two underscores) to be ___swab16 (three underscores) in the above file, and the compilation passed this point (but linking still fails).
Comment 5 Qing He 2011-04-02 02:59:55 UTC
Created attachment 132 [details]
the patch to pass compilation

This patch fix the constant folding of cpu_to_le
Comment 6 Qing He 2011-04-02 03:04:48 UTC
Created attachment 133 [details]
updated patch to fix compilation
Comment 7 Darren Hart 2011-04-21 15:51:32 UTC
Please submit the patch to the list for review. Qing, can you please accept the bug as well?
Comment 8 Qing He 2011-04-21 20:10:25 UTC
(In reply to comment #7)
> Please submit the patch to the list for review. Qing, can you please accept the
> bug as well?

Darren, is the patch fix your problem? I've been waiting for response for a while.

This bug is against building external u-boot with 1.0 toolchain, which is exposed by a known limitation of ppc toolchain (lack of -Os). I'm not sure what do you want me to fix, the possibilities are:
1. building external u-boot
2. building u-boot recipe within yocto
3. fixing the toolchain limitation

However,
1. the fix is for external u-boot, which is not part of yocto (thus not fixable). I thought you met the build failure in the middle of u-boot enabling for mpc8315e-rdb, am I missing anything?
2. if this is the case, please be clear in the description and include the error message generated by "bitbake u-boot". Also, if u-boot is not current included in mpc8315e-rdb images (and not buildable), I doubt whether it should be target for 1.0 point release.
3. I don't know the exact reason why -Os is disabled on ppc, but that needs a separate bug.

So, can you please clarify?
Comment 9 Darren Hart 2011-04-25 23:33:09 UTC
Qing, the goal would be to apply your patch to the u-boot recipe in oe core and see if it builds. If so, this addresses the bug as reported. If not, it may be we need to refresh our u-boot recipe as well to a newer version to get u-boot to build for the mpc within poky.
Comment 10 Qing He 2011-04-26 02:16:08 UTC
(In reply to comment #9)
> Qing, the goal would be to apply your patch to the u-boot recipe in oe core and
> see if it builds. If so, this addresses the bug as reported. If not, it may be
> we need to refresh our u-boot recipe as well to a newer version to get u-boot
> to build for the mpc within poky.

got it. Thank you.
I remember that the build still failed at some later stage after applying the patch to solve constant initializer patch.

Saul, is u-boot enabled in the mpc8315e-rdb in the 1.0? If not, it seems not suitable for targeting point release.
Comment 11 Darren Hart 2011-04-26 07:59:08 UTC
(In reply to comment #10)

> Saul, is u-boot enabled in the mpc8315e-rdb in the 1.0? If not, it seems not
> suitable for targeting point release.

It is not. Getting it for 1.1 should be fine. This is a feature add for mpc, not purely a bug fix.
Comment 12 Darren Hart 2011-04-27 19:43:00 UTC
This is not required for 1.0. The stock u-boot for this board seems to be capable of booting the linux-yocto kernel specified for this board. Retargeted to 1.1.
Comment 13 Shane Wang 2011-05-06 00:02:43 UTC
Transfer to Liming to debug on ppc.
Comment 14 Liming Wang 2011-05-11 22:59:33 UTC
anyone can provide info how to compile u-boot for mpc8315-rdb successfully using 4.5.1 poky gcc? all patches in this thread don't resolve the building issues.
Comment 15 Liming Wang 2011-05-12 00:18:25 UTC
OK, no patch used here. Using O2 instead of Os can build the u-boot successfully.
I have tested "v2010.12" version on mpc8315e-rdb, it works well. The boot message:

U-Boot 2010.12-dirty (May 12 2011 - 13:43:46) MPC83XX

Reset Status: Software Hard, External/Internal Soft, External/Internal Hard

CPU:   e300c3, MPC8315E, Rev: 1.2 at 400 MHz, CSB: 133.333 MHz
Board: Freescale MPC8315ERDB Rev 1.0
I2C:   ready
DRAM:  128 MiB (DDR2, 32-bit, ECC off, 266.667 MHz)
FLASH: 8 MiB
NAND:  32 MiB
*** Warning - bad CRC, using default environment

PCIE0: No link
PCIE1: No link
In:    serial
Out:   serial
Err:   serial
Net:   eTSEC0, eTSEC1
Hit any key to stop autoboot:  0
Comment 16 Liming Wang 2011-05-12 00:30:47 UTC
But the bad news is that after I reboot the board, the board can't boot now. I think some part of hardware initializing failed on the board. Previous success is that I used "reset" command to reboot the board after I re-flash the u-boot to the latest version.
We need more time to test this case. But we need jtag to re-flash the board first.
Comment 17 Darren Hart 2011-05-16 15:40:33 UTC
Moving to 1.1 M4. It is possible we'll just drop u-boot entirely for this board and suggest users use the known-to-be-working u-boot that ships with the board.
Comment 18 Darren Hart 2011-05-26 15:33:30 UTC
Move to post 1.1 as it works as is with factory u-boot.
Comment 19 Paul Gortmaker 2012-08-13 18:11:59 UTC
I believe this can be marked as resolved, as of this commit:

commit 15b96762f1862057c16f0a453c77bb1a0688692d
Author: Paul Gortmaker <paul.gortmaker@windriver.com>
Date:   Thu Jul 19 20:01:55 2012 -0400

    mpc8315: build u-boot v2012.04 by default.
Comment 20 Richard Purdie 2012-08-16 14:57:54 UTC
Mark as resolved as mentioned by Paul
Comment 21 Yi Zhao 2012-11-15 07:53:27 UTC
Verified with 1.3 danny branch.
gitinfo: 27af23e65f63b41962a7cfddba9e9372d5212396