USB and U-Boot from source

As recently described,
I have pulled the sources from git://git.denx.de/u-boot-ti.git and
applied all patches that had been posted here.

The U-Boot works fine - except one thing. The USB port does not work
under Linux (lsusb remains empty). And this on both, C2 and C4 boards.
But board detection and CPU frequency settings (BogoMIPS in /proc/
cpuinfo) work fine.

Then, I tried the precompiled U-Boot binary from
http://www.angstrom-distribution.org/demo/beagleboard/ And that works
fine.

So I tried to compile that one myself and took the sources from the
subdirectory u-boot and applied the patches - and that one also works
well.

But it is just a snapshot not connected to GIT so I am not really
happy because it is a "currently works but will not get latest
features" version.

Finally I tried to fix all diffs in the files that have been patched
for the C4 board - but it still fails.

So my questions to those who have successfully built U-Boot (koen?
Khasim?):

a) what are the differences between git://git.denx.de/u-boot-ti.git
and
http://www.angstrom-distribution.org/demo/beagleboard/u-boot/git_git.denx.de.u-boot-ti.git_a5cf522a91ba479d459f8221135bdb3e9ae97479.tar.gz
b) why are the patches not the same (there appears e.g. to be a
difference in twl4030_pmrecv_vsel_cfg()
c) what is the exact procedure to pull sources from some GIT and apply
the patches (or is there a GIT repository where the patches are
already applied?)

Many thanks,
Nikolaus

While looking deeper into the code I found that

void twl4030_pmrecv_vsel_cfg(u8 vsel_reg, u8 vsel_val,
        u8 dev_grp, u8 dev_grp_sel)

is defined only in

drivers/power/twl4030.c

But there is no matching header file. So the parameters may be passed
s 32 bit ints instead of 8 bit as expected by the function.

The strange thing is that it appears to be missing in both (patched)
versions.

I also can't find a header file for void prcm_config_720mhz(void);
This is a smaller problem.

BR,
Nikolaus

No ideas? Did nobody besides me try to build a U-Boot from sources and
published patches?

No ideas? Did nobody besides me try to build a U-Boot from sources and
published patches?

Have you seen http://code.google.com/p/beagleboard/wiki/BeagleboardRevCValidationv3?

I'm a bit reluctant to point people to there right now as I think
there shouldn't be any v2/v3 pages. I think Khasim misunderstood me
entirely (we should have only one validation process, period).
http://code.google.com/p/beagleboard/wiki/BeagleBoardDiagnostics is
meant to be the place to go for the validation process, but folks got
the crazy idea of creating new versions instead of fixing the old one.

Of course, when these crazy forks are removed, they should all
eventually point back to
http://code.google.com/p/beagleboard/wiki/BeagleBoardDiagnostics.

Anyway, the published patches you are looking for are at
gitorious.org/beagleboard-default-u-boot/beagle_uboot_revc4.

> No ideas? Did nobody besides me try to build a U-Boot from sources and
> published patches?

Have you seenhttp://code.google.com/p/beagleboard/wiki/BeagleboardRevCValidationv3?

I'm a bit reluctant to point people to there right now as I think
there shouldn't be any v2/v3 pages. I think Khasim misunderstood me
entirely (we should have only one validation process, period).http://code.google.com/p/beagleboard/wiki/BeagleBoardDiagnosticsis
meant to be the place to go for the validation process, but folks got
the crazy idea of creating new versions instead of fixing the old one.

Of course, when these crazy forks are removed, they should all
eventually point back tohttp://code.google.com/p/beagleboard/wiki/BeagleBoardDiagnostics.

Anyway, the published patches you are looking for are at
gitorious.org/beagleboard-default-u-boot/beagle_uboot_revc4.

I just went back and read the discussion logs and it looks like all of
this has already been discussed. If you look at the patches, you'll
notice several include the pointers to the e-mails where they were
submitted to the mainline. The effort to get them accepted in the
mainline continues.

Are you sure that is not a kernel thing? What's your kernel boot up
log? How about your root fs?

Thanks for responding!

I think I have followed all the mails showing the patches and followed
the discussions. But nevertheless, I am missing some bits and the
patches and their base doesn't look complete to me. I get a warning
about twl4030_pmrecv_vsel_cfg() and can't find it in any include
header.

Thanks also for the pointer to again different sources at
http://code.google.com/p/beagleboard/wiki/BeagleboardRevCValidationv3
I will compare them next to find out why there are such discrepancies.
This may also help Khasim to push the patches to the mainstream...

So is there anybody who has really compiled U-Boot for a C4 board from
source who can help me to find the missing bit?

Anyway, the published patches you are looking for are at
gitorious.org/beagleboard-default-u-boot/beagle_uboot_revc4.

Yes, I already have these patches and applied them.

BTW: I can't clone the repository you have linked. Can someone check
that please?

$ git clone git://gitorious.org/beagleboard-default-u-boot/beagle_uboot_revc4.git
Initialized empty Git repository in /Users/hns/test/
beagle_uboot_revc4/.git/
remote: Counting objects: 105712, done.
remote: Compressing objects: 100% (18537/18537), done.
remote: Total 105712 (delta 86565), reused 105712 (delta 86565)
Receiving objects: 100% (105712/105712), 30.41 MiB | 1.36 MiB/s, done.
Resolving deltas: 100% (86565/86565), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.

This is already covered on the BeagleboardRevCValidationv3 page. Do
'git checkout origin/newbranch'.

Khasim, it seems the referenced tag does not exist?

The same kernel&rootfs combination works with the U-Boot binary but
not with the one compiled from the sources - as it should. I.e. I can
switch the uboot.bin back and forth on the first partition of the SD
card and make it work/not work. The logs are all the same (except
version number of my U-Boot of course).

So I assume I am missing something in patching U-Boot so that my
uboot.bin is different.

And since U-Boot generally works (e.g. recognizes the C4 board, sets
Clock to 720 MHz), I suspect that it is not my toolchain but something
with patches.

The reason why I am trying to compile it myself is twofold:
* learning how U-Boot works
* make some additions to U-Boot for a special expansion board

>> Anyway, the published patches you are looking for are at
>> gitorious.org/beagleboard-default-u-boot/beagle_uboot_revc4.

> Yes, I already have these patches and applied them.

> BTW: I can't clone the repository you have linked. Can someone check
> that please?

> $ git clone git://gitorious.org/beagleboard-default-u-boot/beagle_uboot_revc4.git
> Initialized empty Git repository in /Users/hns/test/
> beagle_uboot_revc4/.git/
> remote: Counting objects: 105712, done.
> remote: Compressing objects: 100% (18537/18537), done.
> remote: Total 105712 (delta 86565), reused 105712 (delta 86565)
> Receiving objects: 100% (105712/105712), 30.41 MiB | 1.36 MiB/s, done.
> Resolving deltas: 100% (86565/86565), done.
> warning: remote HEAD refers to nonexistent ref, unable to checkout.

This is already covered on the BeagleboardRevCValidationv3 page. Do
'git checkout origin/newbranch'.

I just did not even come to that point to switch branches.

Khasim, it seems the referenced tag does not exist?

I also found that the second link at
http://code.google.com/p/beagleboard/wiki/BeagleboardRevCValidationv3#Sources
is also broken (on the original Wiki - not here because I did a
copy&paste and mailing systems are restoring):

Sources for above listed binaries can be found here,

x-loader : http://gitorious.org/x-load-omap3/mainline commit: 037a8ed45e9ecfffacfaab0b7a713fdde56d155a
u-boot : http://git.gitorious.org/beagleboard-default-u-boot/beagle_uboot_revc4.git branch: newbranch commit:3f6a11d8a37f11bef4611345b3d3fe38cc086a17

(Example: git-checkout origin/newbranch)

I still get

$ git clone git://gitorious.org/beagleboard-default-u-boot/beagle_uboot_revc4.git
...
warning: remote HEAD refers to nonexistent ref, unable to checkout.

Please can somebody fix that?

I still get

$ git clone git://gitorious.org/beagleboard-default-u-boot/beagle_uboot_revc4.git
...
warning: remote HEAD refers to nonexistent ref, unable to checkout.

Please can somebody fix that?

You should still be able to do 'git-checkout origin/newbranch'. Can
you confirm that works?

I doubt that the HEAD reference will be fixed before we manage to get
the patches accepted upstream. If it lingers for another week or so,
I'll see if we can just copy newbranch to master.

I still get

$ git clone git://gitorious.org/beagleboard-default-u-boot/beagle_uboot_revc4.git
...
warning: remote HEAD refers to nonexistent ref, unable to checkout.

Please can somebody fix that?

You should still be able to do 'git-checkout origin/newbranch'. Can
you confirm that works?

I just verified that this does work (the clone error was a bit disconcerting,
but at least one can get at the data with the explicit checkout)

Ah, doing this after the failed git clone appears to work. I had tried
it in a fresh directory...

Ok,
now I can cross-compile a working U-Boot from sources! And, with this
U-Boot, USB works. So I now can diff/rebase/merge why my U-Boot
version does not work.

Short instructions:

1. git clone git://gitorious.org/beagleboard-default-u-boot/beagle_uboot_revc4.git
(currently fails with a warning and leaves an empty repository
2. cd beagle_uboot_revc4
3. git checkout origin/newbranch
4. export CROSS_COMPILE=....
5. make omap3_beagle_config && make all

To compile on Mac OS X you need (besides a working cross-toolchain)
these patches:

diff --git a/config.mk b/config.mk
index cb1c4af..119c5a9 100644
--- a/config.mk
+++ b/config.mk
@@ -65,7 +65,7 @@ HOSTSTRIP = strip

ifeq ($(HOSTOS),darwin)
HOSTCC = cc
-HOSTCFLAGS += -traditional-cpp
+#HOSTCFLAGS += -traditional-cpp
HOSTLDFLAGS += -multiply_defined suppress
else
HOSTCC = gcc
diff --git a/include/compiler.h b/include/compiler.h
index e602cce..e532336 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -48,6 +48,9 @@ extern int errno;
# include <byteswap.h>
#elif defined(__MACH__)
# include <machine/endian.h>
+#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#define __BIG_ENDIAN BIG_ENDIAN
+#define __BYTE_ORDER BYTE_ORDER
typedef unsigned long ulong;
typedef unsigned int uint;
#endif
diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index 7b26920..0b24378 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -23,12 +23,21 @@
  */

/* Required to obtain the getline prototype from stdio.h */
-#define _GNU_SOURCE
+//#define _GNU_SOURCE

#include "mkimage.h"
#include <image.h>
#include "kwbimage.h"

+ssize_t getline(char **lineptr, size_t *n, FILE *stream)
+{
+ if(!*lineptr)
+ *lineptr=malloc(*n=512);
+ if(fgets(*lineptr, *n, stream) == NULL)
+ return -1;
+ return strlen(*lineptr);
+}

Final [self reply]:

Ok,
now I can cross-compile a working U-Boot from sources! And, with this
U-Boot, USB works. So I now can diff/rebase/merge why my U-Boot
version does not work.

I have tracked down my problem to the MUX settings. If I use the
original ones, USB works (but not my expansion board). I still have to
find the one in conflict, but the general problem is solved. Thanks to
all who did help!

And, I have now understood why this warning is NOT (yet?) harmful:

beagle.c: In function 'misc_init_r':
beagle.c:143: warning: implicit declaration of function
'twl4030_pmrecv_vsel_cfg'
beagle.c:152: warning: implicit declaration of function
'prcm_config_720mhz'

The reason that gcc warns is that both functions are NOT defined in
twl4030.h. But one function is void prcm_config_720mhz(void). So no
problem anyway.

More problematic is that

void twl4030_pmrecv_vsel_cfg(u8 vsel_reg, u8 vsel_val,
        u8 dev_grp, u8 dev_grp_sel)

is missing. This should define the function as having 4 parameters
which are 8 bit unsigned. But since int and u8 are passed in 32 bit
wide registers on the ARM processor, they have the same layout as if
they are called with int parameters. And int parameters are what gcc
assumes if there is a implicit declaration of function. So it is a bug
that is fortunately not harmful.

Nevertheless, I suggest that the file twl4030.h is fixed.