Michael Schierl <[EMAIL PROTECTED]> writes:

> Eric W. Biederman schrieb:
>
>> Well reading through the relevant code would probably help, it
>> lists fairly clearly which subset of the kernel format I support.
>> Basically It must be at least protocol version 2.0 and it must
>> be a bzImage (not a zImage), and it must have all of the appropriate
>> magic numbers.  ISO linux and grub support older revisions of
>> the linux boot protocol.
>
> Hmm. Let's see.
>
> $ od -t x1z -w8 -Ax hello.bin
> 000000 eb fe 00 00 00 00 00 00  >........<
> 000008 00 00 00 00 00 00 00 00  >........<
> *
> 0001f0 00 01 00 00 00 00 00 00  >........<
> 0001f8 00 00 00 00 00 00 55 aa  >......U.<
> 000200 eb 55 48 64 72 53 04 02  >.UHdrS..<
> 000208 00 00 00 00 00 10 30 00  >......0.<
> 000210 00 01 00 00 00 00 00 00  >........<
> 000218 00 00 00 00 00 00 00 00  >........<
> *
> 000228 00 00 00 00 ff ff ff ff  >........<
> 000230 48 65 6c 6c 6f 4b 65 72  >HelloKer<
> 000238 6e 65 6c 20 31 2e 30 00  >nel 1.0.<
> 000240 48 65 6c 6c 6f 2c 20 77  >Hello, w<
> 000248 6f 72 6c 64 2c 20 30 78  >orld, 0x<
> 000250 78 78 78 78 21 0d 0a 8c  >xxxx!...<
> 000258 c8 8e d8 8e c0 b1 04 88  >........<
> 000260 e3 30 ff d3 e3 d2 eb 81  >.0......<
> 000268 c3 30 30 88 3e 50 00 88  >.00.>P..<
> 000270 1e 51 00 88 c3 30 ff d3  >.Q...0..<
> 000278 e3 d2 eb 81 c3 30 30 88  >.....00.<
> 000280 3e 52 00 88 1e 53 00 b4  >>R...S..<
> 000288 03 b7 00 cd 10 b8 01 13  >........<
> 000290 bb 17 00 b9 17 00 bd 40  >.......@<
> 000298 00 cd 10 fb eb fe 00 00  >........<
> 0002a0 00 00 00 00 00 00 00 00  >........<
> *
> 000400
>
>> int bzImage_probe(const char *buf, off_t len)
>> {
>>      struct x86_linux_header header;
>>      if (len < sizeof(header)) {
>>              return -1;
>>      }
>
> Length of my image is 1K, When looking over that struct, it looks like that
> struct is 32K long. Hmm? Looks strange to me. Must bzImages be at least 32K
> long?

That could be a bug.  I don't remember where that 32K limit came from.

>>      memcpy(&header, buf, sizeof(header));
>>      if (memcmp(header.header_magic, "HdrS", 4) != 0) {
>>              if (probe_debug) {
>>                      fprintf(stderr, "Not a bzImage\n");
>>              }
>>              return -1;
>>      }
>
> header_magic is offset 0x202 (if the comments in x86-linux.h are correct), and
> there is a "HdrS". So okay.
>
>>      if (header.boot_sector_magic != 0xAA55) {
>>              if (probe_debug) {
>>                      fprintf(stderr, "No x86 boot sector present\n");
>>              }
>>              /* No x86 boot sector present */
>>              return -1;
>>      }
>
> boot_sector_magic is 0x1FE, which is okay as well (at least on little endian
> machines).


>>      if (header.protocol_version < 0x0200) {
>>              if (probe_debug) {
>> fprintf(stderr, "Must be at least protocol version 2.00\n");
>>              }
>>              /* Must be at least protocol version 2.00 */
>>              return -1;
>>      }
>
> protocol_version is 0x0204. Ok as well.
>
>>      if ((header.loadflags & 1) == 0) {
>>              if (probe_debug) {
>>                      fprintf(stderr, "zImage not a bzImage\n");
>>              }
>>              /* Not a bzImage */
>>              return -1;
>>      }
>
> loadflags = 0x01, so (loadflags & 1) != 0. Okay as well..
>
>
>>      /* I've got a bzImage */
>
> Hmm. The only thing that is not okay is that my kernel is too small. Is that
> limitation of 32K documented somewhere...?

I don't recall.  If I can't find a good reason for it, that limit should
probably be fixed.

> Okay, I'll try to blow up my kernel a bit (with zeroes) and check if it helps.

Eric

_______________________________________________
fastboot mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/fastboot

Reply via email to