Merge lp://staging/~mabac/linaro-image-tools/snowball-android-startfiles-hack into lp://staging/linaro-image-tools/11.11

Proposed by Mattias Backman
Status: Merged
Merged at revision: 493
Proposed branch: lp://staging/~mabac/linaro-image-tools/snowball-android-startfiles-hack
Merge into: lp://staging/linaro-image-tools/11.11
Prerequisite: lp://staging/~mabac/linaro-image-tools/fix-raw-partition-arguments
Diff against target: 507 lines (+321/-22)
3 files modified
linaro_image_tools/media_create/android_boards.py (+22/-0)
linaro_image_tools/media_create/boards.py (+27/-12)
linaro_image_tools/media_create/tests/test_media_create.py (+272/-10)
To merge this branch: bzr merge lp://staging/~mabac/linaro-image-tools/snowball-android-startfiles-hack
Reviewer Review Type Date Requested Status
Guilherme Salgado (community) Needs Fixing
Mathieu Poirier Pending
Review via email: mp+93430@code.staging.launchpad.net

Description of the change

Hi,

This branch adds Android support for the Snowball EMMC boot mode. We do this by assuming that the user has downloaded a special tarball with the startfiles and unpacked them to ./startupfiles. We could add this as a command line option but for now decided to not clutter the cli with an option that is specific to one board.

We also get the u-boot.bin from the boot partition, where it is unpacked from the boot tarball.

mpoirier: should I copy the u-boot-env file too? It's not in the overlay boot file I have now.

This change should not affect any other board than the Snowball and only when using l-a-m-c to create an image to flash to emmc.

Thanks,

Mattias

To post a comment you must log in.
Revision history for this message
Mattias Backman (mabac) wrote :

I've also added a delete_startupfiles flag so we can set wether to delete the files after dd:ing them. We want to delete them when we use l-m-c since the files have been copied to /boot on the target by the deb package. We don't want to leave them there.

In the l-a-m-c case the user has unpacked the files locally and does not want to have them deleted every time he runs l-a-m-c.

Revision history for this message
Mattias Backman (mabac) wrote :

> mpoirier: should I copy the u-boot-env file too? It's not in the overlay boot file I have now.

That is not needed so it will not be referenced in the startfiles.cfg provided by the boot overlay tarball.

Revision history for this message
Mattias Backman (mabac) wrote :

On Thu, Feb 16, 2012 at 10:39 PM, Mathieu Poirier <email address hidden> wrote:
> Good day,
>
> I tested your latest modifications and everything work perfectly.

Revision history for this message
Guilherme Salgado (salgado) wrote :
Download full text (9.4 KiB)

Hi Mattias,

I think it's not ideal to add two snowball-specific arguments to populate_raw_partition(), but I think it should be easy to get rid of them... see my suggestion below.

> === modified file 'linaro-android-media-create'
> --- linaro-android-media-create 2012-01-19 06:31:50 +0000
> +++ linaro-android-media-create 2012-02-16 15:27:17 +0000
> @@ -139,7 +139,8 @@
> board_config, media, args.image_size, args.boot_label,
> args.should_create_partitions, args.should_align_boot_part)
>
> - board_config.populate_raw_partition(args.device, BOOT_DIR)
> + board_config.populate_raw_partition(args.device, BOOT_DIR,
> + os.path.join(BOOT_DIR, 'boot'))
> populate_partition(BOOT_DIR + "/boot", BOOT_DISK, boot_partition)
> board_config.populate_boot_script(boot_partition, BOOT_DISK, args.consoles)
> with partition_mounted(boot_partition, BOOT_DISK):
>
> === modified file 'linaro_image_tools/media_create/android_boards.py'
> --- linaro_image_tools/media_create/android_boards.py 2012-02-16 15:27:17 +0000
> +++ linaro_image_tools/media_create/android_boards.py 2012-02-16 15:27:17 +0000
> @@ -161,8 +161,10 @@
> _userdata_len, sdcard_start)
>
> @classmethod
> - def populate_raw_partition(cls, media, boot_dir):
> - super(AndroidBoardConfig, cls).populate_raw_partition(media, boot_dir)
> + def populate_raw_partition(cls, media, boot_dir, config_files_dir,
> + delete_startupfiles=False):
> + super(AndroidBoardConfig, cls).populate_raw_partition(
> + media, boot_dir, config_files_dir, delete_startupfiles)
>
> @classmethod
> def install_boot_loader(cls, boot_partition, boot_device_or_file):
> @@ -231,6 +233,24 @@
> return '%s,%s,0xDA\n%s' % (
> loader_start, loader_len, command)
>
> + @classmethod
> + def populate_raw_partition(cls, media, boot_dir, config_files_dir,
> + delete_startupfiles=False):
> + # To avoid adding a Snowball specific command line option, we assume
> + # that the user already has unpacked the startfiles to ./startupfiles
> + local_config_dir = os.path.join('.', 'startupfiles')
> + assert os.path.exists(local_config_dir), "You need to unpack the "
> + "Snowball startupfiles to the directory 'startupfiles' in your current "
> + "working directory. See igloocommunity.org for more information."

This doesn't work as a multi-line string, you need to wrap it with
parentheses. And for bonus points you can indent them one extra level. :)

> + # We copy the u-boot files from the unpacked boot.tar.bz2
> + # and put it with the startfiles.
> + boot_files = ['u-boot.bin']
> + for boot_file in boot_files:
> + cmd_runner.run(['cp', os.path.join(boot_dir, 'boot', boot_file),

Ain't os.path.join(boot_dir, 'boot') the same as the new argument
(config_files_dir)? Maybe not for all boards?

> + local_config_dir], as_root=True).wait()
> + super(AndroidSnowballEmmcConfig, cls).populate_raw_partition(
> + ...

Read more...

review: Needs Fixing
498. By Mattias Backman

Start fixing review comments.

499. By Mattias Backman

Remove the new arguments to populate_raw_partition and get them from a class function instead. Add tests for populate_raw_partition.

500. By Mattias Backman

Revert the call from linaro-android-media-create.

Revision history for this message
Mattias Backman (mabac) wrote :
Download full text (10.1 KiB)

> Hi Mattias,
>
> I think it's not ideal to add two snowball-specific arguments to
> populate_raw_partition(), but I think it should be easy to get rid of them...
> see my suggestion below.

Thanks. I've changed that and added a class function that gives the new arguments. I've made the parent function raise an error since I believe it's an error to call this function from other than the two BoardConfigs for which it makes sense. (SnowballEmmcConfig and AndroidSnowballEmmcConfig.)

>
> > === modified file 'linaro-android-media-create'
> > --- linaro-android-media-create 2012-01-19 06:31:50 +0000
> > +++ linaro-android-media-create 2012-02-16 15:27:17 +0000
> > @@ -139,7 +139,8 @@
> > board_config, media, args.image_size, args.boot_label,
> > args.should_create_partitions, args.should_align_boot_part)
> >
> > - board_config.populate_raw_partition(args.device, BOOT_DIR)
> > + board_config.populate_raw_partition(args.device, BOOT_DIR,
> > + os.path.join(BOOT_DIR, 'boot'))
> > populate_partition(BOOT_DIR + "/boot", BOOT_DISK, boot_partition)
> > board_config.populate_boot_script(boot_partition, BOOT_DISK,
> args.consoles)
> > with partition_mounted(boot_partition, BOOT_DISK):
> >
> > === modified file 'linaro_image_tools/media_create/android_boards.py'
> > --- linaro_image_tools/media_create/android_boards.py 2012-02-16 15:27:17
> +0000
> > +++ linaro_image_tools/media_create/android_boards.py 2012-02-16 15:27:17
> +0000
> > @@ -161,8 +161,10 @@
> > _userdata_len, sdcard_start)
> >
> > @classmethod
> > - def populate_raw_partition(cls, media, boot_dir):
> > - super(AndroidBoardConfig, cls).populate_raw_partition(media,
> boot_dir)
> > + def populate_raw_partition(cls, media, boot_dir, config_files_dir,
> > + delete_startupfiles=False):
> > + super(AndroidBoardConfig, cls).populate_raw_partition(
> > + media, boot_dir, config_files_dir, delete_startupfiles)
> >
> > @classmethod
> > def install_boot_loader(cls, boot_partition, boot_device_or_file):
> > @@ -231,6 +233,24 @@
> > return '%s,%s,0xDA\n%s' % (
> > loader_start, loader_len, command)
> >
> > + @classmethod
> > + def populate_raw_partition(cls, media, boot_dir, config_files_dir,
> > + delete_startupfiles=False):
> > + # To avoid adding a Snowball specific command line option, we
> assume
> > + # that the user already has unpacked the startfiles to
> ./startupfiles
> > + local_config_dir = os.path.join('.', 'startupfiles')
> > + assert os.path.exists(local_config_dir), "You need to unpack the "
> > + "Snowball startupfiles to the directory 'startupfiles' in your
> current "
> > + "working directory. See igloocommunity.org for more information."
>
> This doesn't work as a multi-line string, you need to wrap it with
> parentheses. And for bonus points you can indent them one extra level. :)
>

Going for all the extra points I can get. ;) Fixed.

> > + # We copy the u-boot files from the unpacked boot.tar.bz2
...

501. By Mattias Backman

Undo line break and remove new arguments from another call.

Revision history for this message
Guilherme Salgado (salgado) wrote :

Wow, nice, lots of new tests! This looks quite good; the only comment I have is about snowball_config(chroot_dir), which has no docstring and return a two-tuple where one value is a hard-coded boolean so there's no way to know what it means. I'd prefer if the hard-coded value were in a class attribute and snowball_config(chroot_dir) returned just the path to the config dir, but having just a docstring on snowball_config() would be ok as well.

Revision history for this message
Mattias Backman (mabac) wrote :

On Mon, Feb 20, 2012 at 7:51 PM, Guilherme Salgado
<email address hidden> wrote:
> Wow, nice, lots of new tests!  This looks quite good; the only comment I have is about snowball_config(chroot_dir), which has no docstring and return a two-tuple where one value is a hard-coded boolean so there's no way to know what it means. I'd prefer if the hard-coded value were in a class attribute and snowball_config(chroot_dir) returned just the path to the config dir, but having just a docstring on snowball_config() would be ok as well.

I did the classproperty fix before merging.

Also mpoirier re-acked the change via email.

> --
> https://code.launchpad.net/~mabac/linaro-image-tools/snowball-android-startfiles-hack/+merge/93430
> You are the owner of lp:~mabac/linaro-image-tools/snowball-android-startfiles-hack.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches