Re: Cannot boot from floppy disk

David Brownlee <[email protected]> Tue, 22 Apr 2014 20:44:10 +0100
Newsgroups gmane.os.netbsd.ports.bebox
Message-ID <CAGN_6pYMvYe+9FVjSXRJ1m9+-aqfD20vtA3Tff6ZOTeUb3F8yw@mail.gmail.com>
--001a11c331b60c670d04f7a6d7c6
Content-Type: text/plain; charset=UTF-8

On 22 Apr 2014 18:58, "Frank Wille" <[email protected]> wrote:
>
> On Mon, 21 Apr 2014 17:31:32 +0100
> David Brownlee <[email protected]> wrote:
>
> > > Now I'm trying to find out how the images are made. An nbmake-bebox in
> > > src/sys/arch/bebox/stand only creates "boot.elf" and the stripped
> > > "boot", which is also in ELF format. Who converts that into PEF format
> > > and puts it into the image?
> >
> > I suspect you want distrib/bebox... good hunting :)
>
> Right. I guess we have a problem with compiling on 64-bit architectures
> (I compiled on NetBSD/amd64).
>
> The BeOS PEF file header is in mkbootimage/pef.h defined as:
>
> ---8<---
> struct FileHeader
> {
>         unsigned long magic;
>         unsigned long fileTypeID;
>         unsigned long archID;
>         unsigned long versionNumber;
>         unsigned long dateTimeStamp;
>         unsigned long definVersion;
>         unsigned long implVersion;
>         unsigned long currentVersion;
>         unsigned short numSections;
>         unsigned short loadableSections;
>         unsigned long memoryAddress;
> };
>
> #define PEF_MAGIC 0x4A6F7921  /* Joy! */
> #define PEF_FILE  0x70656666  /* peff */
> #define PEF_PPC   0x70777063  /* pwpc */
> ---8<---

Bingo.  That was careless of someone :)  - I suspect the definition was
copied from BeOS or similar.

> I guess the types should be replaced by uint32_t and uint16_t to make it
> work, as the file header in my boot.fs image looks like that:
>
> 00006400  4a 6f 79 21 00 00 00 00  70 65 66 66 00 00 00 00
 |Joy!....peff....|
> 00006410  70 77 70 63 00 00 00 00  00 00 00 01 00 00 00 00
 |pwpc............|
>
> Note the empty 32-bit words between magic, fileTypeID and archID.
> That cannot work...

The good news is that it should be a simple fix, and that you are in the
perfect place to test the result :-p

--001a11c331b60c670d04f7a6d7c6
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<p dir=3D"ltr">On 22 Apr 2014 18:58, &quot;Frank Wille&quot; &lt;<a href=3D=
"mailto:[email protected]">[email protected]</a>&gt; wrote:<br>
&gt;<br>
&gt; On Mon, 21 Apr 2014 17:31:32 +0100<br>
&gt; David Brownlee &lt;<a href=3D"mailto:[email protected]">[email protected]</a>&gt=
; wrote:<br>
&gt;<br>
&gt; &gt; &gt; Now I&#39;m trying to find out how the images are made. An n=
bmake-bebox in<br>
&gt; &gt; &gt; src/sys/arch/bebox/stand only creates &quot;boot.elf&quot; a=
nd the stripped<br>
&gt; &gt; &gt; &quot;boot&quot;, which is also in ELF format. Who converts =
that into PEF format<br>
&gt; &gt; &gt; and puts it into the image?<br>
&gt; &gt;<br>
&gt; &gt; I suspect you want distrib/bebox... good hunting :)<br>
&gt;<br>
&gt; Right. I guess we have a problem with compiling on 64-bit architecture=
s<br>
&gt; (I compiled on NetBSD/amd64).<br>
&gt;<br>
&gt; The BeOS PEF file header is in mkbootimage/pef.h defined as:<br>
&gt;<br>
&gt; ---8&lt;---<br>
&gt; struct FileHeader<br>
&gt; {<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned long magic;<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned long fileTypeID;<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned long archID;<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned long versionNumber;<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned long dateTimeStamp;<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned long definVersion;<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned long implVersion;<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned long currentVersion;<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned short numSections;<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned short loadableSections;<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned long memoryAddress;<br>
&gt; };<br>
&gt;<br>
&gt; #define PEF_MAGIC 0x4A6F7921 =C2=A0/* Joy! */<br>
&gt; #define PEF_FILE =C2=A00x70656666 =C2=A0/* peff */<br>
&gt; #define PEF_PPC =C2=A0 0x70777063 =C2=A0/* pwpc */<br>
&gt; ---8&lt;---</p>
<p dir=3D"ltr">Bingo.=C2=A0 That was careless of someone :)=C2=A0 - I suspe=
ct the definition was copied from BeOS or similar. <br></p>
<p dir=3D"ltr">&gt; I guess the types should be replaced by uint32_t and ui=
nt16_t to make it<br>
&gt; work, as the file header in my boot.fs image looks like that:<br>
&gt;<br>
&gt; 00006400 =C2=A04a 6f 79 21 00 00 00 00 =C2=A070 65 66 66 00 00 00 00 =
=C2=A0|Joy!....peff....|<br>
&gt; 00006410 =C2=A070 77 70 63 00 00 00 00 =C2=A000 00 00 01 00 00 00 00 =
=C2=A0|pwpc............|<br>
&gt;<br>
&gt; Note the empty 32-bit words between magic, fileTypeID and archID.<br>
&gt; That cannot work...</p>
<p dir=3D"ltr">The good news is that it should be a simple fix, and that yo=
u are in the perfect place to test the result :-p<br></p>

--001a11c331b60c670d04f7a6d7c6--