Skip to contentSkip to conversation

Initial support for the android bootimg filesystem.

PATCH In review Shea Levy 4 participants 11 messages Jan 26, 2016 – Feb 2, 2016

lore
Share & tools
lore

Shea Levy

author
#0 lore raw

PATCH v2 1/1 Initial support for the android bootimg filesystem.

Currently, the kernel and, if present, the ramdisk are made available as regular files.

---
 grub-core/Makefile.core.def    |   7 ++
 grub-core/fs/android_bootimg.c | 271 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 278 insertions(+)
 create mode 100644 grub-core/fs/android_bootimg.c
grub-core/Makefile.core.def +7 -0
index 0cc40bb..a726abd 100644
@@ -1231,6 +1231,13 @@ module = {
 };
 
 module = {
+  name = android_bootimg;
+  common = fs/android_bootimg.c;
+  cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
+  cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)';
+};
+
+module = {
   name = bfs;
   common = fs/bfs.c;
 };
grub-core/fs/android_bootimg.c new file +271 -0

271 lines not on this page · raw message

Signature · 1 line
2.7.0
#1 lore raw
Quoted 2 lines · Shea Levy

Currently, the kernel and, if present, the ramdisk are made available as regular files.

...

Quoted 17 lines
grub-core/fs/android_bootimg.c new file +17 -0
+
+struct boot_img_hdr
+{
+  uint8_t magic[BOOT_MAGIC_SIZE];
+
+  uint32_t kernel_size;
+  uint32_t kernel_addr;
+
+  uint32_t ramdisk_size;
+  uint32_t ramdisk_addr;
+
+  uint32_t second_size;
+  uint32_t second_addr;
+
+  uint32_t tags_addr;
+  uint32_t page_size;
+  uint32_t unused[2];

grub-core/fs/android_bootimg.c line 74

Quoted 10 lines
grub-core/fs/android_bootimg.c new file +10 -0
+
+  uint8_t name[BOOT_NAME_SIZE];
+
+  uint8_t cmdline[BOOT_ARGS_SIZE];
+
+  uint32_t id[8];
+
+  uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE];
+} GRUB_PACKED;
+

What is the use case for exposing it as filesystem in the first place? Dedicated android loader that reads them looks more logical.

Should this layout/content ever change in the future it will be near to impossible to modify without breaking unknown number of users relying on it; while simple

android hd1,msdos4

can transparently handle any forward and backward compatibility without impacting existing grub.cfg.

#2 lore raw

The main reason was that it wasn't clear how to easily reuse the code in the linux module to load the kernel and initrd; a secondary reason is to allow overriding the kernel command line or whatever provided in the bootimg. If there is a relatively straightforward path to fix the first one, though, I'm happy to do that and figure out ways to override later once the need actually arises, if ever.

~Shea

----- Original Message -----
From: "The development of GNU GRUB" <[email protected]> To:"The development of GNU GRUB" <[email protected]> Cc:"Shea Levy" <[email protected]>
Sent:Wed, 27 Jan 2016 10:22:34 +0300
Subject:Re: [PATCH v2] Initial support for the android bootimg filesystem.

Quoted 1 line · Shea Levy

Currently, the kernel and, if present, the ramdisk are made

available as

Quoted 1 line

regular files.

...

Quoted 17 lines
grub-core/fs/android_bootimg.c new file +17 -0
+
+struct boot_img_hdr
+{
+ uint8_t magic[BOOT_MAGIC_SIZE];
+
+ uint32_t kernel_size;
+ uint32_t kernel_addr;
+
+ uint32_t ramdisk_size;
+ uint32_t ramdisk_addr;
+
+ uint32_t second_size;
+ uint32_t second_addr;
+
+ uint32_t tags_addr;
+ uint32_t page_size;
+ uint32_t unused[2];

grub-core/fs/android_bootimg.c line 74

Quoted 10 lines
grub-core/fs/android_bootimg.c new file +10 -0
+
+ uint8_t name[BOOT_NAME_SIZE];
+
+ uint8_t cmdline[BOOT_ARGS_SIZE];
+
+ uint32_t id[8];
+
+ uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE];
+} GRUB_PACKED;
+

What is the use case for exposing it as filesystem in the first
place?
Dedicated android loader that reads them looks more logical.

Should this layout/content ever change in the future it will be near to impossible to modify without breaking unknown number of users relying on it; while simple

android hd1,msdos4

can transparently handle any forward and backward compatibility without impacting existing grub.cfg.

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw

Is it important that this go the "dedicated loader" route? It looks like quite a bit of work to abstract out the functionality of the "linux" and "initrd" commands in a way that enables reuse from other commands.

----- Original Message -----
From: [email protected]
To:"The development of GNU GRUB" <[email protected]> Cc:"Andrei Borzenkov" <[email protected]> Sent:Wed, 27 Jan 2016 04:53:07 -0800
Subject:Re: [PATCH v2] Initial support for the android bootimg filesystem.

The main reason was that it wasn't clear how to easily reuse the code
in the linux module to load the kernel and initrd; a secondary reason is to allow overriding the kernel command line or whatever provided in the bootimg. If there is a relatively straightforward path to fix the first one, though, I'm happy to do that and figure out ways to override later once the need actually arises, if ever.

~Shea

----- Original Message -----
From: "The development of GNU GRUB" <[email protected]> To:"The development of GNU GRUB" <[email protected]> Cc:"Shea Levy" <[email protected]>
Sent:Wed, 27 Jan 2016 10:22:34 +0300
Subject:Re: [PATCH v2] Initial support for the android bootimg filesystem.

Quoted 1 line · Shea Levy

Currently, the kernel and, if present, the ramdisk are made

available as

Quoted 1 line

regular files.

...

Quoted 17 lines
grub-core/fs/android_bootimg.c new file +17 -0
+
+struct boot_img_hdr
+{
+ uint8_t magic[BOOT_MAGIC_SIZE];
+
+ uint32_t kernel_size;
+ uint32_t kernel_addr;
+
+ uint32_t ramdisk_size;
+ uint32_t ramdisk_addr;
+
+ uint32_t second_size;
+ uint32_t second_addr;
+
+ uint32_t tags_addr;
+ uint32_t page_size;
+ uint32_t unused[2];

grub-core/fs/android_bootimg.c line 74

Quoted 10 lines
grub-core/fs/android_bootimg.c new file +10 -0
+
+ uint8_t name[BOOT_NAME_SIZE];
+
+ uint8_t cmdline[BOOT_ARGS_SIZE];
+
+ uint32_t id[8];
+
+ uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE];
+} GRUB_PACKED;
+

What is the use case for exposing it as filesystem in the first
place?
Dedicated android loader that reads them looks more logical.

Should this layout/content ever change in the future it will be near to impossible to modify without breaking unknown number of users relying on it; while simple

android hd1,msdos4

can transparently handle any forward and backward compatibility without impacting existing grub.cfg.

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#4 lore raw
Quoted 4 lines · On Fri, Jan 29, 2016 at 2:48 AM, <[email protected]> wrote:

Is it important that this go the "dedicated loader" route? It looks like quite a bit of work to abstract out the functionality of the "linux" and "initrd" commands in a way that enables reuse from other commands.

"It needs work" is rather weak argument against doing something.

Actually it is not that much work, at least for initial implementation. You could use "anonymous" files that are instantiated on the fly (see verify command for example how to do it); that needs minimal changes to linux/initrd to split out front end part that opens files. All further processing would then be shared.

Quoted 4 lines

The main reason was that it wasn't clear how to easily reuse the code in the linux module to load the kernel and initrd; a secondary reason is to allow overriding the kernel command line or whatever provided in the bootimg. If

Dealing with stored command line on grub shell level is not simpler due to fun with word splitting and quoting. Working with it in C would be easier. But here again is the question if we can treat Android as Linux. E.g. does Android support (or required to support) vga and mem parameters? If not, this part is obviously redundant.

Nothing prevents Android command from supporting extra kernel arguments that override stored command line.

Quoted 71 lines

there is a relatively straightforward path to fix the first one, though, I'm happy to do that and figure out ways to override later once the need actually arises, if ever.

~Shea

----- Original Message -----
From:
"The development of GNU GRUB" <[email protected]>

To:
"The development of GNU GRUB" <[email protected]>
Cc:
"Shea Levy" <[email protected]>
Sent:
Wed, 27 Jan 2016 10:22:34 +0300
Subject:
Re: [PATCH v2] Initial support for the android bootimg filesystem.

Quoted 2 lines · Shea Levy

Currently, the kernel and, if present, the ramdisk are made available as regular files.

...

Quoted 17 lines
grub-core/fs/android_bootimg.c new file +17 -0
+
+struct boot_img_hdr
+{
+ uint8_t magic[BOOT_MAGIC_SIZE];
+
+ uint32_t kernel_size;
+ uint32_t kernel_addr;
+
+ uint32_t ramdisk_size;
+ uint32_t ramdisk_addr;
+
+ uint32_t second_size;
+ uint32_t second_addr;
+
+ uint32_t tags_addr;
+ uint32_t page_size;
+ uint32_t unused[2];

grub-core/fs/android_bootimg.c line 74

Quoted 10 lines
grub-core/fs/android_bootimg.c new file +10 -0
+
+ uint8_t name[BOOT_NAME_SIZE];
+
+ uint8_t cmdline[BOOT_ARGS_SIZE];
+
+ uint32_t id[8];
+
+ uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE];
+} GRUB_PACKED;
+

What is the use case for exposing it as filesystem in the first place? Dedicated android loader that reads them looks more logical.

Should this layout/content ever change in the future it will be near to impossible to modify without breaking unknown number of users relying on it; while simple

android hd1,msdos4

can transparently handle any forward and backward compatibility without impacting existing grub.cfg.

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

author
#5 lore raw
Quoted 6 lines · Andrei Borzenkov
Quoted 4 lines · On Fri, Jan 29, 2016 at 2:48 AM, <[email protected]> wrote:

Is it important that this go the "dedicated loader" route? It looks like quite a bit of work to abstract out the functionality of the "linux" and "initrd" commands in a way that enables reuse from other commands.

Quoted 8 lines

"It needs work" is rather weak argument against doing something.

Actually it is not that much work, at least for initial implementation. You could use "anonymous" files that are instantiated on the fly (see verify command for example how to do it); that needs minimal changes to linux/initrd to split out front end part that opens files. All further processing would then be shared.

OK, will take this approach.

Quoted 6 lines
Quoted 5 lines

The main reason was that it wasn't clear how to easily reuse the code in the linux module to load the kernel and initrd; a secondary reason is to allow overriding the kernel command line or whatever provided in the bootimg. If

Quoted 6 lines

Dealing with stored command line on grub shell level is not simpler due to fun with word splitting and quoting. Working with it in C would be easier. But here again is the question if we can treat Android as Linux. E.g. does Android support (or required to support) vga and mem parameters? If not, this part is obviously redundant.

At least for android-x86 (the part I'm most familiar with), android is just a normal Linux as far as bootloading/command line is concerned.

Quoted 80 lines

Nothing prevents Android command from supporting extra kernel arguments that override stored command line.

Quoted 64 lines

there is a relatively straightforward path to fix the first one, though, I'm happy to do that and figure out ways to override later once the need actually arises, if ever.

~Shea

----- Original Message -----
From:
"The development of GNU GRUB" <[email protected]>

To:
"The development of GNU GRUB" <[email protected]>
Cc:
"Shea Levy" <[email protected]>
Sent:
Wed, 27 Jan 2016 10:22:34 +0300
Subject:
Re: [PATCH v2] Initial support for the android bootimg filesystem.

Quoted 2 lines · Shea Levy

Currently, the kernel and, if present, the ramdisk are made available as regular files.

...

Quoted 17 lines
grub-core/fs/android_bootimg.c new file +17 -0
+
+struct boot_img_hdr
+{
+ uint8_t magic[BOOT_MAGIC_SIZE];
+
+ uint32_t kernel_size;
+ uint32_t kernel_addr;
+
+ uint32_t ramdisk_size;
+ uint32_t ramdisk_addr;
+
+ uint32_t second_size;
+ uint32_t second_addr;
+
+ uint32_t tags_addr;
+ uint32_t page_size;
+ uint32_t unused[2];

grub-core/fs/android_bootimg.c line 74

Quoted 10 lines
grub-core/fs/android_bootimg.c new file +10 -0
+
+ uint8_t name[BOOT_NAME_SIZE];
+
+ uint8_t cmdline[BOOT_ARGS_SIZE];
+
+ uint32_t id[8];
+
+ uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE];
+} GRUB_PACKED;
+

What is the use case for exposing it as filesystem in the first place? Dedicated android loader that reads them looks more logical.

Should this layout/content ever change in the future it will be near to impossible to modify without breaking unknown number of users relying on it; while simple

android hd1,msdos4

Quoted 7 lines

can transparently handle any forward and backward compatibility without impacting existing grub.cfg.

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#6 lore raw

I actually think that both approaches have pros and cons. Can we settle on a design before plunging forward?
We should have feature parity between Android image and plain linux. I.a. it should be possible to replace or append initrd and command line. Doing this with a single command is tricky. Does bootimg come with a command line or is it just a bundle of Linux image and initrd? Have you considered making linux recognize androidimg and pull linux out of it? Adding
androidimg: alongside newc: syntax to initrd?

Quoted 132 lines · Shea Levy
Quoted 8 lines · Andrei Borzenkov
Quoted 6 lines · On Fri, Jan 29, 2016 at 2:48 AM, <[email protected]> wrote:

Is it important that this go the "dedicated loader" route? It looks like
quite a bit of work to abstract out the functionality of the "linux" and
"initrd" commands in a way that enables reuse from other commands.

Quoted 9 lines

"It needs work" is rather weak argument against doing something.

Actually it is not that much work, at least for initial implementation. You could use "anonymous" files that are instantiated on the fly (see verify command for example how to do it); that needs minimal changes to linux/initrd to split out front end part that opens
files. All further processing would then be shared.

OK, will take this approach.

Quoted 9 lines
Quoted 8 lines

The main reason was that it wasn't clear how to easily reuse the code in the
linux module to load the kernel and initrd; a secondary reason is to allow
overriding the kernel command line or whatever provided in the bootimg. If

Quoted 7 lines

Dealing with stored command line on grub shell level is not simpler due to fun with word splitting and quoting. Working with it in C would
be easier. But here again is the question if we can treat Android as Linux. E.g. does Android support (or required to support) vga and mem parameters? If not, this part is obviously redundant.

At least for android-x86 (the part I'm most familiar with), android is just a normal Linux as far as bootloading/command line is concerned.

Quoted 80 lines

Nothing prevents Android command from supporting extra kernel arguments that override stored command line.

Quoted 68 lines

there is a relatively straightforward path to fix the first one, though, I'm
happy to do that and figure out ways to override later once the need actually arises, if ever.

~Shea

----- Original Message -----
From:
"The development of GNU GRUB" <[email protected]>

To:
"The development of GNU GRUB" <[email protected]>
Cc:
"Shea Levy" <[email protected]>
Sent:
Wed, 27 Jan 2016 10:22:34 +0300
Subject:
Re: [PATCH v2] Initial support for the android bootimg filesystem.

Quoted 3 lines · Shea Levy

Currently, the kernel and, if present, the ramdisk are made available as
regular files.

...

Quoted 17 lines
grub-core/fs/android_bootimg.c new file +17 -0
+
+struct boot_img_hdr
+{
+ uint8_t magic[BOOT_MAGIC_SIZE];
+
+ uint32_t kernel_size;
+ uint32_t kernel_addr;
+
+ uint32_t ramdisk_size;
+ uint32_t ramdisk_addr;
+
+ uint32_t second_size;
+ uint32_t second_addr;
+
+ uint32_t tags_addr;
+ uint32_t page_size;
+ uint32_t unused[2];

grub-core/fs/android_bootimg.c line 74

Quoted 10 lines
grub-core/fs/android_bootimg.c new file +10 -0
+
+ uint8_t name[BOOT_NAME_SIZE];
+
+ uint8_t cmdline[BOOT_ARGS_SIZE];
+
+ uint32_t id[8];
+
+ uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE];
+} GRUB_PACKED;
+

What is the use case for exposing it as filesystem in the first place?
Dedicated android loader that reads them looks more logical.

Should this layout/content ever change in the future it will be near to impossible to modify without breaking unknown number of users relying on it; while simple

android hd1,msdos4

Quoted 7 lines

can transparently handle any forward and backward compatibility without impacting existing grub.cfg.

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#7 lore raw

29.01.2016 20:37, Vladimir 'phcoder' Serbinenko пишет:

Quoted 9 lines

I actually think that both approaches have pros and cons. Can we settle on a design before plunging forward?
We should have feature parity between Android image and plain linux. I.a. it should be possible to replace or append initrd and command line. Doing this with a single command is tricky. Does bootimg come with a command line or is it just a bundle of Linux image and initrd? Have you considered making linux recognize androidimg and pull linux out of it? Adding
androidimg: alongside newc: syntax to initrd?

As far as I understand this is single file that packs kernel, initrd and command line in one unit.

https://www.compulab.co.il/workspace/mediawiki/index.php5/Android:_Boot_image

I am not sure it is correct to treat it as free standing Linux kernel.

Quoted 142 lines · Shea Levy
Quoted 128 lines · Andrei Borzenkov
Quoted 8 lines · On Fri, Jan 29, 2016 at 2:48 AM, <[email protected]> wrote:
Quoted 6 lines

Is it important that this go the "dedicated loader" route? It looks like
quite a bit of work to abstract out the functionality of the "linux" and
"initrd" commands in a way that enables reuse from other commands.

Quoted 9 lines

"It needs work" is rather weak argument against doing something.

Actually it is not that much work, at least for initial implementation. You could use "anonymous" files that are instantiated on the fly (see verify command for example how to do it); that needs minimal changes to linux/initrd to split out front end part that opens
files. All further processing would then be shared.

OK, will take this approach.

Quoted 9 lines
Quoted 8 lines

The main reason was that it wasn't clear how to easily reuse the code in the
linux module to load the kernel and initrd; a secondary reason is to allow
overriding the kernel command line or whatever provided in the bootimg. If

Quoted 7 lines

Dealing with stored command line on grub shell level is not simpler due to fun with word splitting and quoting. Working with it in C would
be easier. But here again is the question if we can treat Android as Linux. E.g. does Android support (or required to support) vga and mem parameters? If not, this part is obviously redundant.

At least for android-x86 (the part I'm most familiar with), android is just a normal Linux as far as bootloading/command line is concerned.

Quoted 80 lines

Nothing prevents Android command from supporting extra kernel arguments that override stored command line.

Quoted 68 lines

there is a relatively straightforward path to fix the first one, though, I'm
happy to do that and figure out ways to override later once the need actually arises, if ever.

~Shea

----- Original Message -----
From:
"The development of GNU GRUB" <[email protected]>

To:
"The development of GNU GRUB" <[email protected]>
Cc:
"Shea Levy" <[email protected]>
Sent:
Wed, 27 Jan 2016 10:22:34 +0300
Subject:
Re: [PATCH v2] Initial support for the android bootimg filesystem.

Quoted 3 lines · Shea Levy

Currently, the kernel and, if present, the ramdisk are made available as
regular files.

...

Quoted 17 lines
(quoted diff) +17 -0
+
+struct boot_img_hdr
+{
+ uint8_t magic[BOOT_MAGIC_SIZE];
+
+ uint32_t kernel_size;
+ uint32_t kernel_addr;
+
+ uint32_t ramdisk_size;
+ uint32_t ramdisk_addr;
+
+ uint32_t second_size;
+ uint32_t second_addr;
+
+ uint32_t tags_addr;
+ uint32_t page_size;
+ uint32_t unused[2];

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+ uint8_t name[BOOT_NAME_SIZE];
+
+ uint8_t cmdline[BOOT_ARGS_SIZE];
+
+ uint32_t id[8];
+
+ uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE];
+} GRUB_PACKED;
+

What is the use case for exposing it as filesystem in the first place?
Dedicated android loader that reads them looks more logical.

Should this layout/content ever change in the future it will be near to impossible to modify without breaking unknown number of users relying on it; while simple

android hd1,msdos4

Quoted 7 lines

can transparently handle any forward and backward compatibility without impacting existing grub.cfg.

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#8 lore raw
In reply to Vladimir 'phcoder' Serbinenko

The bootimg contains a kernel, optional initrd, optional secondary payload (unused on x86 as far as I know), and kernel command line, as well as recommended load addresses for the kernel, initrd, secondary payload, and kernel tags (also unused on x86 as far as I know).

Making the linux command recognize it would be fine with me, if that is the preferred approach. Would we want to have the linux command load the kernel and the initrd load the ramdisk?

~Shea

----- Original Message -----
From: "Vladimir 'phcoder' Serbinenko" <[email protected]> To:"The development of GNU GRUB" <[email protected]> Cc:
Sent:Fri, 29 Jan 2016 17:37:52 +0000
Subject:Re: [PATCH v2] Initial support for the android bootimg filesystem.

I actually think that both approaches have pros and cons. Can we
settle on a design before plunging forward?
We should have feature parity between Android image and plain linux. I.a. it should be possible to replace or append initrd and command line. Doing this with a single command is tricky. Does bootimg come with a command line or is it just a bundle of Linux image and initrd? Have you considered making linux recognize androidimg and pull linux out of it? Adding androidimg: alongside newc: syntax to initrd?

Le ven. 29 janv. 2016 15:13, Shea Levy <[email protected] [1]> a écrit :

Quoted 2 lines · Andrei Borzenkov
Quoted 1 line · On Fri, Jan 29, 2016 at 2:48 AM,  <[email protected] [2]> wrote:

Is it important that this go the "dedicated loader" route? It

looks

Quoted 2 lines
Quoted 2 lines

like
quite a bit of work to abstract out the functionality of the

"linux"

Quoted 8 lines
Quoted 3 lines

and
"initrd" commands in a way that enables reuse from other commands.

"It needs work" is rather weak argument against doing something.

Actually it is not that much work, at least for initial implementation. You could use "anonymous" files that are

instantiated

Quoted 1 line

on the fly (see verify command for example how to do it); that

needs

Quoted 4 lines

minimal changes to linux/initrd to split out front end part that opens
files. All further processing would then be shared.

OK, will take this approach.

Quoted 5 lines
Quoted 5 lines

The main reason was that it wasn't clear how to easily reuse the code in the
linux module to load the kernel and initrd; a secondary reason is

to

Quoted 8 lines
Quoted 3 lines

allow
overriding the kernel command line or whatever provided in the bootimg. If

Dealing with stored command line on grub shell level is not simpler due to fun with word splitting and quoting. Working with it in C would
be easier. But here again is the question if we can treat Android

as

Quoted 1 line

Linux. E.g. does Android support (or required to support) vga and

mem

Quoted 2 lines

parameters? If not, this part is obviously redundant.

At least for android-x86 (the part I'm most familiar with), android
is
just a normal Linux as far as bootloading/command line is concerned.

Quoted 7 lines

Nothing prevents Android command from supporting extra kernel arguments that override stored command line.

Quoted 3 lines

there is a relatively straightforward path to fix the first one, though, I'm
happy to do that and figure out ways to override later once the

need

Quoted 20 lines
Quoted 20 lines

actually arises, if ever.

~Shea

----- Original Message -----
From:
"The development of GNU GRUB" <[email protected] [3]>

To:
"The development of GNU GRUB" <[email protected] [4]> Cc:
"Shea Levy" <[email protected] [5]>
Sent:
Wed, 27 Jan 2016 10:22:34 +0300
Subject:
Re: [PATCH v2] Initial support for the android bootimg filesystem.

Quoted 1 line
Quoted 1 line

On Tue, Jan 26, 2016 at 10:42 PM, Shea Levy <[email protected]

[6]>

Quoted 38 lines
Quoted 38 lines
Quoted 3 lines · wrote:

Currently, the kernel and, if present, the ramdisk are made available as
regular files.

...

Quoted 17 lines
(quoted diff) +17 -0
+
+struct boot_img_hdr
+{
+ uint8_t magic[BOOT_MAGIC_SIZE];
+
+ uint32_t kernel_size;
+ uint32_t kernel_addr;
+
+ uint32_t ramdisk_size;
+ uint32_t ramdisk_addr;
+
+ uint32_t second_size;
+ uint32_t second_addr;
+
+ uint32_t tags_addr;
+ uint32_t page_size;
+ uint32_t unused[2];

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+ uint8_t name[BOOT_NAME_SIZE];
+
+ uint8_t cmdline[BOOT_ARGS_SIZE];
+
+ uint32_t id[8];
+
+ uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE];
+} GRUB_PACKED;
+

What is the use case for exposing it as filesystem in the first place?
Dedicated android loader that reads them looks more logical.

Quoted 1 line
Quoted 1 line

Should this layout/content ever change in the future it will be

near

Quoted 13 lines
Quoted 5 lines

to impossible to modify without breaking unknown number of users relying on it; while simple

android hd1,msdos4

Quoted 7 lines

can transparently handle any forward and backward compatibility without impacting existing grub.cfg.

_______________________________________________
Grub-devel mailing list
[email protected] [7]
https://lists.gnu.org/mailman/listinfo/grub-devel [8]

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected] [9]
https://lists.gnu.org/mailman/listinfo/grub-devel [10]

_______________________________________________
Grub-devel mailing list
[email protected] [11]
https://lists.gnu.org/mailman/listinfo/grub-devel [12]

Links:
------
[1] mailto:[email protected]
[2] mailto:[email protected]
[3] mailto:[email protected]
[4] mailto:[email protected]
[5] mailto:[email protected]
[6] mailto:[email protected]
[7] mailto:[email protected]
[8] https://lists.gnu.org/mailman/listinfo/grub-devel
[9] mailto:[email protected]
[10] https://lists.gnu.org/mailman/listinfo/grub-devel
[11] mailto:[email protected]
[12] https://lists.gnu.org/mailman/listinfo/grub-devel

#9 lore raw

Any advice on how to move forward with this patch?

Thanks,
Shea

----- Original Message -----
From: [email protected]
To:"Vladimir 'phcoder' Serbinenko" <[email protected]>, "The development of GNU GRUB" <[email protected]>
Cc:
Sent:Fri, 29 Jan 2016 10:53:57 -0800
Subject:Re: [PATCH v2] Initial support for the android bootimg filesystem.

The bootimg contains a kernel, optional initrd, optional secondary
payload (unused on x86 as far as I know), and kernel command line, as well as recommended load addresses for the kernel, initrd, secondary payload, and kernel tags (also unused on x86 as far as I know).

Making the linux command recognize it would be fine with me, if that is the preferred approach. Would we want to have the linux command load the kernel and the initrd load the ramdisk?

~Shea

----- Original Message -----
From: "Vladimir 'phcoder' Serbinenko" <[email protected]> To:"The development of GNU GRUB" <[email protected]> Cc:
Sent:Fri, 29 Jan 2016 17:37:52 +0000
Subject:Re: [PATCH v2] Initial support for the android bootimg filesystem.

I actually think that both approaches have pros and cons. Can we
settle on a design before plunging forward?
We should have feature parity between Android image and plain linux. I.a. it should be possible to replace or append initrd and command line. Doing this with a single command is tricky. Does bootimg come with a command line or is it just a bundle of Linux image and initrd? Have you considered making linux recognize androidimg and pull linux out of it? Adding androidimg: alongside newc: syntax to initrd?

Le ven. 29 janv. 2016 15:13, Shea Levy <[email protected] [1]> a écrit :

Quoted 2 lines · Andrei Borzenkov
Quoted 1 line · On Fri, Jan 29, 2016 at 2:48 AM,  <[email protected] [2]> wrote:

Is it important that this go the "dedicated loader" route? It

looks

Quoted 2 lines
Quoted 2 lines

like
quite a bit of work to abstract out the functionality of the

"linux"

Quoted 8 lines
Quoted 3 lines

and
"initrd" commands in a way that enables reuse from other commands.

"It needs work" is rather weak argument against doing something.

Actually it is not that much work, at least for initial implementation. You could use "anonymous" files that are

instantiated

Quoted 1 line

on the fly (see verify command for example how to do it); that

needs

Quoted 4 lines

minimal changes to linux/initrd to split out front end part that opens
files. All further processing would then be shared.

OK, will take this approach.

Quoted 5 lines
Quoted 5 lines

The main reason was that it wasn't clear how to easily reuse the code in the
linux module to load the kernel and initrd; a secondary reason is

to

Quoted 8 lines
Quoted 3 lines

allow
overriding the kernel command line or whatever provided in the bootimg. If

Dealing with stored command line on grub shell level is not simpler due to fun with word splitting and quoting. Working with it in C would
be easier. But here again is the question if we can treat Android

as

Quoted 1 line

Linux. E.g. does Android support (or required to support) vga and

mem

Quoted 2 lines

parameters? If not, this part is obviously redundant.

At least for android-x86 (the part I'm most familiar with), android
is
just a normal Linux as far as bootloading/command line is concerned.

Quoted 7 lines

Nothing prevents Android command from supporting extra kernel arguments that override stored command line.

Quoted 3 lines

there is a relatively straightforward path to fix the first one, though, I'm
happy to do that and figure out ways to override later once the

need

Quoted 20 lines
Quoted 20 lines

actually arises, if ever.

~Shea

----- Original Message -----
From:
"The development of GNU GRUB" <[email protected] [3]>

To:
"The development of GNU GRUB" <[email protected] [4]> Cc:
"Shea Levy" <[email protected] [5]>
Sent:
Wed, 27 Jan 2016 10:22:34 +0300
Subject:
Re: [PATCH v2] Initial support for the android bootimg filesystem.

Quoted 1 line
Quoted 1 line

On Tue, Jan 26, 2016 at 10:42 PM, Shea Levy <[email protected]

[6]>

Quoted 38 lines
Quoted 38 lines
Quoted 3 lines · wrote:

Currently, the kernel and, if present, the ramdisk are made available as
regular files.

...

Quoted 17 lines
(quoted diff) +17 -0
+
+struct boot_img_hdr
+{
+ uint8_t magic[BOOT_MAGIC_SIZE];
+
+ uint32_t kernel_size;
+ uint32_t kernel_addr;
+
+ uint32_t ramdisk_size;
+ uint32_t ramdisk_addr;
+
+ uint32_t second_size;
+ uint32_t second_addr;
+
+ uint32_t tags_addr;
+ uint32_t page_size;
+ uint32_t unused[2];

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+ uint8_t name[BOOT_NAME_SIZE];
+
+ uint8_t cmdline[BOOT_ARGS_SIZE];
+
+ uint32_t id[8];
+
+ uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE];
+} GRUB_PACKED;
+

What is the use case for exposing it as filesystem in the first place?
Dedicated android loader that reads them looks more logical.

Quoted 1 line
Quoted 1 line

Should this layout/content ever change in the future it will be

near

Quoted 13 lines
Quoted 5 lines

to impossible to modify without breaking unknown number of users relying on it; while simple

android hd1,msdos4

Quoted 7 lines

can transparently handle any forward and backward compatibility without impacting existing grub.cfg.

_______________________________________________
Grub-devel mailing list
[email protected] [7]
https://lists.gnu.org/mailman/listinfo/grub-devel [8]

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected] [9]
https://lists.gnu.org/mailman/listinfo/grub-devel [10]

_______________________________________________
Grub-devel mailing list
[email protected] [11]
https://lists.gnu.org/mailman/listinfo/grub-devel [12]

Links:
------
[1] mailto:[email protected]
[2] mailto:[email protected]
[3] mailto:[email protected]
[4] mailto:[email protected]
[5] mailto:[email protected]
[6] mailto:[email protected]
[7] mailto:[email protected]
[8] https://lists.gnu.org/mailman/listinfo/grub-devel
[9] mailto:[email protected]
[10] https://lists.gnu.org/mailman/listinfo/grub-devel
[11] mailto:[email protected]
[12] https://lists.gnu.org/mailman/listinfo/grub-devel

#10 lore raw
In reply to Shea Levy

I think we should create a new loader(maybe separating common linux and android code into a lib) for this rather than a filesystem because it would simplify grub.cfg files.
Also in case we'll ever need to support 2ndloader(I'm like 99% sure this will never happen though) it would be easier to implement this in the android loader rather than adding another command for that.

Quoted 135 lines · Shea Levy
Quoted 7 lines · Andrei Borzenkov
Quoted 5 lines · On Fri, Jan 29, 2016 at 2:48 AM, <[email protected]> wrote:

Is it important that this go the "dedicated loader" route? It looks like quite a bit of work to abstract out the functionality of the "linux" and "initrd" commands in a way that enables reuse from other commands.

Quoted 9 lines

"It needs work" is rather weak argument against doing something.

Actually it is not that much work, at least for initial implementation. You could use "anonymous" files that are instantiated on the fly (see verify command for example how to do it); that needs minimal changes to linux/initrd to split out front end part that opens files. All further processing would then be shared.

OK, will take this approach.

Quoted 9 lines
Quoted 8 lines

The main reason was that it wasn't clear how to easily reuse the code in the
linux module to load the kernel and initrd; a secondary reason is to allow
overriding the kernel command line or whatever provided in the bootimg. If

Quoted 7 lines

Dealing with stored command line on grub shell level is not simpler due to fun with word splitting and quoting. Working with it in C would be easier. But here again is the question if we can treat Android as Linux. E.g. does Android support (or required to support) vga and mem parameters? If not, this part is obviously redundant.

At least for android-x86 (the part I'm most familiar with), android is just a normal Linux as far as bootloading/command line is concerned.

Quoted 81 lines

Nothing prevents Android command from supporting extra kernel arguments that override stored command line.

there is a relatively straightforward path to fix the first one, though,

Quoted 68 lines

I'm
happy to do that and figure out ways to override later once the need actually arises, if ever.

~Shea

----- Original Message -----
From:
"The development of GNU GRUB" <[email protected]>

To:
"The development of GNU GRUB" <[email protected]>
Cc:
"Shea Levy" <[email protected]>
Sent:
Wed, 27 Jan 2016 10:22:34 +0300
Subject:
Re: [PATCH v2] Initial support for the android bootimg filesystem.

Quoted 3 lines · Shea Levy

Currently, the kernel and, if present, the ramdisk are made available as regular files.

...

Quoted 18 lines
grub-core/fs/android_bootimg.c new file +17 -0
+
+struct boot_img_hdr
+{
+ uint8_t magic[BOOT_MAGIC_SIZE];
+
+ uint32_t kernel_size;
+ uint32_t kernel_addr;
+
+ uint32_t ramdisk_size;
+ uint32_t ramdisk_addr;
+
+ uint32_t second_size;
+ uint32_t second_addr;
+
+ uint32_t tags_addr;
+ uint32_t page_size;
+ uint32_t unused[2];

grub-core/fs/android_bootimg.c line 74

Quoted 10 lines
grub-core/fs/android_bootimg.c new file +10 -0
+
+ uint8_t name[BOOT_NAME_SIZE];
+
+ uint8_t cmdline[BOOT_ARGS_SIZE];
+
+ uint32_t id[8];
+
+ uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE];
+} GRUB_PACKED;
+

What is the use case for exposing it as filesystem in the first place? Dedicated android loader that reads them looks more logical.

Should this layout/content ever change in the future it will be near to impossible to modify without breaking unknown number of users relying on it; while simple

android hd1,msdos4

Quoted 8 lines

can transparently handle any forward and backward compatibility without impacting existing grub.cfg.

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel