Patchwork sparc: fix tftpboot.img build

login
register
mail settings
Submitter Robert Reif
Date June 19, 2009, 2:15 a.m.
Message ID <4A3AF4B6.60109@earthlink.net>
Download mbox | patch
Permalink /patch/28894/
State RFC
Delegated to: David Miller
Headers show

Comments

Robert Reif - June 19, 2009, 2:15 a.m.
David Miller wrote:
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Mon, 8 Jun 2009 21:20:43 +0200
>
>   
>> Kjetil Oftedal mentioned that piggyback_32 was failing
>> when building a sparc image.
>>
>> I tracked this down to the fact that the kernel no longer
>> provided an absolute symbol named "end".
>>
>> Commit 86ed40bd6fe511d26bb8f3fa65a84cb65c235366 ("sparc: unify sections.h")
>> renamed end to _end but failed to update piggyback_32.
>>
>> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
>> Cc: Kjetil Oftedal <oftedal@gmail.com>
>> Cc: Robert Reif <reif@earthlink.net>
>> ---
>>
>> This is not even build tested - but looks obvious.
>>     
>
> I don't even know how to build test this:
>
> davem@sunset:~/src/GIT/sparc-next-2.6$ make ARCH=sparc tftpboot.img
>   CHK     include/linux/version.h
>   CHK     include/linux/utsrelease.h
>   SYMLINK include/asm -> include/asm-sparc
>   CALL    scripts/checksyscalls.sh
> <stdin>:1519:2: warning: #warning syscall perf_counter_open not implemented
>   CHK     include/linux/compile.h
> make[1]: *** No rule to make target `arch/sparc/boot/piggyback', needed by `arch/sparc/boot/tftpboot.img'.  Stop.
> make: *** [tftpboot.img] Error 2
> davem@sunset:~/src/GIT/sparc-next-2.6$ 
>
>   
This patch gets piggyback_32.c compiling but there are other issues:


make[1]: *** No rule to make target `arch/sparc/boot/System.map', needed 
by `arch/sparc/boot/tftpboot.img'. Stop.
make[1]: *** Waiting for unfinished jobs....
HOSTCC arch/sparc/boot/piggyback_32
make: *** [tftpboot.img] Error 2

--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Julian Calaby - June 19, 2009, 2:18 a.m.
On Fri, Jun 19, 2009 at 12:15, Robert Reif<reif@earthlink.net> wrote:
> David Miller wrote:
>>
>> From: Sam Ravnborg <sam@ravnborg.org>
>> Date: Mon, 8 Jun 2009 21:20:43 +0200
>>
>>
>>>
>>> Kjetil Oftedal mentioned that piggyback_32 was failing
>>> when building a sparc image.
>>>
>>> I tracked this down to the fact that the kernel no longer
>>> provided an absolute symbol named "end".
>>>
>>> Commit 86ed40bd6fe511d26bb8f3fa65a84cb65c235366 ("sparc: unify
>>> sections.h")
>>> renamed end to _end but failed to update piggyback_32.
>>>
>>> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
>>> Cc: Kjetil Oftedal <oftedal@gmail.com>
>>> Cc: Robert Reif <reif@earthlink.net>
>>> ---
>>>
>>> This is not even build tested - but looks obvious.
>>>
>>
>> I don't even know how to build test this:
>>
>> davem@sunset:~/src/GIT/sparc-next-2.6$ make ARCH=sparc tftpboot.img
>>  CHK     include/linux/version.h
>>  CHK     include/linux/utsrelease.h
>>  SYMLINK include/asm -> include/asm-sparc
>>  CALL    scripts/checksyscalls.sh
>> <stdin>:1519:2: warning: #warning syscall perf_counter_open not
>> implemented
>>  CHK     include/linux/compile.h
>> make[1]: *** No rule to make target `arch/sparc/boot/piggyback', needed by
>> `arch/sparc/boot/tftpboot.img'.  Stop.
>> make: *** [tftpboot.img] Error 2
>> davem@sunset:~/src/GIT/sparc-next-2.6$
>>
>
> This patch gets piggyback_32.c compiling but there are other issues:

Looking at the code of piggyback_32.c and piggyback_64.c, there aren't
that many differences - I think that these could easily be merged into
a single file.

I'm at work at the moment, but I'll have a closer look tonight.

Thanks,
David Miller - June 19, 2009, 3:46 a.m.
From: Julian Calaby <julian.calaby@gmail.com>
Date: Fri, 19 Jun 2009 12:18:50 +1000

> Looking at the code of piggyback_32.c and piggyback_64.c, there aren't
> that many differences - I think that these could easily be merged into
> a single file.
> 
> I'm at work at the moment, but I'll have a closer look tonight.

Thanks for looking into this Julian.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
oftedal - June 20, 2009, 2:59 p.m.
On Thu, 18 Jun 2009, David Miller wrote:

> From: Julian Calaby <julian.calaby@gmail.com>
> Date: Fri, 19 Jun 2009 12:18:50 +1000
>
>> Looking at the code of piggyback_32.c and piggyback_64.c, there aren't
>> that many differences - I think that these could easily be merged into
>> a single file.
>>
>> I'm at work at the moment, but I'll have a closer look tonight.
>
> Thanks for looking into this Julian.
>

I tried the simple fix of piggyback_32 provided by Sam on a sun4m machine
using a kernel built from the sparc-next-2.6.git
It resulted in:
[   12.680000] RAMDISK: gzip image found at block 0
[   16.472000] VFS: Mounted root (ext2 filesystem) on device 1:0.
[   16.480000] Freeing unused kernel memory: 136k freed
[   16.488000] EXT2-fs error (device ram0): ext2_check_page: bad entry in direc0
[   16.500000] Warning: unable to open an initial console.
[   16.504000] Kernel panic - not syncing: No init found.  Try passing init= op.
[   16.508000] [f0257e1c : __stop_notes+0x1070/0x1dbc8 ] [f0011ab8 : _etext+0xf
[   16.532000] Press Stop-A (L1-A) to return to the boot prom

The filesystem mounts fine on a my buildbox.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Julian Calaby - June 21, 2009, 8:31 a.m.
On Fri, Jun 19, 2009 at 13:46, David Miller<davem@davemloft.net> wrote:
> From: Julian Calaby <julian.calaby@gmail.com>
> Date: Fri, 19 Jun 2009 12:18:50 +1000
>
>> Looking at the code of piggyback_32.c and piggyback_64.c, there aren't
>> that many differences - I think that these could easily be merged into
>> a single file.
>>
>> I'm at work at the moment, but I'll have a closer look tonight.
>
> Thanks for looking into this Julian.

Ok, the primary differences between the sparc64 and sparc32 piggyback tools are:
1. The sparc32 version has had some "endian fixes" applied to it back in 2000.
2. The sparc64 version performs an extra step and has some code work
in a slightly different way. (e.g. it goes straight to the HdrS
signature in the ELF header rather than searching for it like sparc32)
3. The (I assume) header is calculated slightly differently. (it uses
8191 for a constant in sparc64 and 4095 in sparc32)

I think that the bulk of the changes would fit under the umbrella of
"endian fixes", and would really like to get hold of the "endian fixes
for cross-compiles" patch from Pete Zaitcev <zaitcev@yahoo.com> (CC'd)
which was applied to arch/sparc/boot/piggyback.c (as it was at the
time) some time in 2000. The problem is that none of the git trees I
can find go back any further back than 2002-02-05.

This patch would probably apply to the sparc64 version without many
changes, and would probably make them almost identical apart from the
constant and extra step mentioned above.

I'd also really like to look at the history of this file before it was
renamed to piggyback_32.c, however this doesn't seem to be available
in any convenient, readily available form. There have been no
significant changes to it apart from Sam's sparc32 / 64 merge work
since the limit of the history I can find.

I'm going to try to mangle piggyback_64.c to match how piggyback_32.c
works as it's mostly abstracting some of the fancier casts into
functions, however I'm not sure which one reliably works, (I'm
guessing the *_64.c) so this is pretty much a shot in the dark for the
moment.

After that, I'll try to organise build tests here, but I don't
actually have a fully working 32 bit sparc machine to run these on.
... However, it doesn't have to run, just boot over the network, which
I'm all set up to do, so arguably if the kernel loads, that's success
... I'll have to think a bit more about that.

Thanks,
David Miller - June 21, 2009, 9:01 a.m.
From: Julian Calaby <julian.calaby@gmail.com>
Date: Sun, 21 Jun 2009 18:31:04 +1000

> 3. The (I assume) header is calculated slightly differently. (it uses
> 8191 for a constant in sparc64 and 4095 in sparc32)

Those constants are essentially "PAGE_SIZE - 1".

> I think that the bulk of the changes would fit under the umbrella of
> "endian fixes", and would really like to get hold of the "endian fixes
> for cross-compiles" patch from Pete Zaitcev <zaitcev@yahoo.com> (CC'd)
> which was applied to arch/sparc/boot/piggyback.c (as it was at the
> time) some time in 2000. The problem is that none of the git trees I
> can find go back any further back than 2002-02-05.

There is a history tree that goes back further at:

	git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git

> This patch would probably apply to the sparc64 version without many
> changes, and would probably make them almost identical apart from the
> constant and extra step mentioned above.

Yep.

> I'd also really like to look at the history of this file before it was
> renamed to piggyback_32.c, however this doesn't seem to be available
> in any convenient, readily available form. There have been no
> significant changes to it apart from Sam's sparc32 / 64 merge work
> since the limit of the history I can find.

These files haven't been touched seriously in many years.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sam Ravnborg - June 21, 2009, 9:56 a.m.
> 
> > I'd also really like to look at the history of this file before it was
> > renamed to piggyback_32.c, however this doesn't seem to be available
> > in any convenient, readily available form. There have been no
> > significant changes to it apart from Sam's sparc32 / 64 merge work
> > since the limit of the history I can find.
> 
> These files haven't been touched seriously in many years.

git log --follow arch/sparc/boot/piggyback_32.c is your friend.
Only patch is removal of CVS keywords.

	Sam

--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Julian Calaby - June 21, 2009, 11:19 a.m.
On Sun, Jun 21, 2009 at 19:01, David Miller<davem@davemloft.net> wrote:
> From: Julian Calaby <julian.calaby@gmail.com>
> Date: Sun, 21 Jun 2009 18:31:04 +1000
>
>> 3. The (I assume) header is calculated slightly differently. (it uses
>> 8191 for a constant in sparc64 and 4095 in sparc32)
>
> Those constants are essentially "PAGE_SIZE - 1".

Ah, they didn't really fit the 32 / 64 bit difference here, maybe I
can (eventually) pass them in from the Makefile, though I'm going to
have to tell the final tool whether it's 64 bit or not anyway, so
maybe it doesn't matter.

>> I think that the bulk of the changes would fit under the umbrella of
>> "endian fixes", and would really like to get hold of the "endian fixes
>> for cross-compiles" patch from Pete Zaitcev <zaitcev@yahoo.com> (CC'd)
>> which was applied to arch/sparc/boot/piggyback.c (as it was at the
>> time) some time in 2000. The problem is that none of the git trees I
>> can find go back any further back than 2002-02-05.
>
> There is a history tree that goes back further at:
>
>        git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git

It goes back to Feb 2002, that's where I ended up in my search, the
only change to arch/sparc/boot/piggyback.c is the initial import on
that date.

>> This patch would probably apply to the sparc64 version without many
>> changes, and would probably make them almost identical apart from the
>> constant and extra step mentioned above.
>
> Yep.

I've given up and am applying it manually. I'm currently trying to get
the Makefile to work properly.

>> I'd also really like to look at the history of this file before it was
>> renamed to piggyback_32.c, however this doesn't seem to be available
>> in any convenient, readily available form. There have been no
>> significant changes to it apart from Sam's sparc32 / 64 merge work
>> since the limit of the history I can find.
>
> These files haven't been touched seriously in many years.

I can see that =)

I'm wondering a little where Debian and Gentoo (my go-tos for sparc
distros) get their images from, but I guess "if it ain't broke, don't
fix it" applies to code too - I'm a little surprised that these
haven't bitrotted =)

(sorry for the reply condensing)

On Sun, Jun 21, 2009 at 19:56, Sam Ravnborg<sam@ravnborg.org> wrote:
>>
>> > I'd also really like to look at the history of this file before it was
>> > renamed to piggyback_32.c, however this doesn't seem to be available
>> > in any convenient, readily available form. There have been no
>> > significant changes to it apart from Sam's sparc32 / 64 merge work
>> > since the limit of the history I can find.
>>
>> These files haven't been touched seriously in many years.
>
> git log --follow arch/sparc/boot/piggyback_32.c is your friend.
> Only patch is removal of CVS keywords.

Exactly.

Thanks for the help!

Patch

diff --git a/arch/sparc/boot/Makefile b/arch/sparc/boot/Makefile
index 96041a8..5e2caeb 100644
--- a/arch/sparc/boot/Makefile
+++ b/arch/sparc/boot/Makefile
@@ -58,7 +58,7 @@  $(obj)/image: $(obj)/btfix.o FORCE
$(obj)/zImage: $(obj)/image
$(call if_changed,strip)

-$(obj)/tftpboot.img: $(obj)/piggyback $(obj)/System.map $(obj)/image FORCE
+$(obj)/tftpboot.img: $(obj)/piggyback_32 $(obj)/System.map $(obj)/image 
FORCE
$(call if_changed,elftoaout)
$(call if_changed,piggy)

HOSTCC arch/sparc/boot/piggyback_32
arch/sparc/boot/piggyback_32.c: In function ‘main’:
arch/sparc/boot/piggyback_32.c:84: warning: pointer targets in passing 
argument 1 of ‘fgets’ differ in signedness
arch/sparc/boot/piggyback_32.c:85: warning: pointer targets in passing 
argument 1 of ‘strlen’ differ in signedness
arch/sparc/boot/piggyback_32.c:85: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:85: warning: pointer targets in passing 
argument 1 of ‘strlen’ differ in signedness
arch/sparc/boot/piggyback_32.c:85: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:85: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:85: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:85: warning: pointer targets in passing 
argument 1 of ‘strlen’ differ in signedness
arch/sparc/boot/piggyback_32.c:85: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:85: warning: pointer targets in passing 
argument 1 of ‘strlen’ differ in signedness
arch/sparc/boot/piggyback_32.c:85: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:85: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:85: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:86: warning: pointer targets in passing 
argument 1 of ‘strtoul’ differ in signedness
arch/sparc/boot/piggyback_32.c:87: warning: pointer targets in passing 
argument 1 of ‘strlen’ differ in signedness
arch/sparc/boot/piggyback_32.c:87: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:87: warning: pointer targets in passing 
argument 1 of ‘strlen’ differ in signedness
arch/sparc/boot/piggyback_32.c:87: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:87: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:87: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:87: warning: pointer targets in passing 
argument 1 of ‘strlen’ differ in signedness
arch/sparc/boot/piggyback_32.c:87: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:87: warning: pointer targets in passing 
argument 1 of ‘strlen’ differ in signedness
arch/sparc/boot/piggyback_32.c:87: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:87: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:87: warning: pointer targets in passing 
argument 1 of ‘__builtin_strcmp’ differ in signedness
arch/sparc/boot/piggyback_32.c:88: warning: pointer targets in passing 
argument 1 of ‘strtoul’ differ in signedness
arch/sparc/boot/piggyback_32.c:98: warning: pointer targets in passing 
argument 1 of ‘ld4’ differ in signedness
arch/sparc/boot/piggyback_32.c:99: warning: pointer targets in passing 
argument 1 of ‘ld4’ differ in signedness
arch/sparc/boot/piggyback_32.c:99: warning: pointer targets in passing 
argument 1 of ‘ld4’ differ in signedness
arch/sparc/boot/piggyback_32.c:99: warning: pointer targets in passing 
argument 1 of ‘ld4’ differ in signedness
arch/sparc/boot/piggyback_32.c:110: warning: pointer targets in passing 
argument 1 of ‘ld2’ differ in signedness
arch/sparc/boot/piggyback_32.c:124: warning: pointer targets in passing 
argument 1 of ‘st4’ differ in signedness
arch/sparc/boot/piggyback_32.c:125: warning: pointer targets in passing 
argument 1 of ‘st4’ differ in signedness
arch/sparc/boot/piggyback_32.c:126: warning: pointer targets in passing 
argument 1 of ‘st4’ differ in signedness
arch/sparc/boot/piggyback_32.c:127: warning: pointer targets in passing 
argument 1 of ‘st4’ differ in signedness
make: *** [tftpboot.img] Error 2

This patch fixes the warnings but there are still more issues:

diff --git a/arch/sparc/boot/piggyback_32.c b/arch/sparc/boot/piggyback_32.c
index c9f500c..3f0f933 100644
--- a/arch/sparc/boot/piggyback_32.c
+++ b/arch/sparc/boot/piggyback_32.c
@@ -70,7 +70,7 @@  void die(char *str)
int main(int argc,char **argv)
{
static char aout_magic[] = { 0x01, 0x03, 0x01, 0x07 };
- unsigned char buffer[1024], *q, *r;
+ char buffer[1024], *q, *r;
unsigned int i, j, k, start, end, offset;
FILE *map;
struct stat s;