Merge lp:~angus-akkea/linaro-image-tools/Samsung-SMDKV310 into lp:linaro-image-tools/11.11
- Samsung-SMDKV310
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 295 |
Proposed branch: | lp:~angus-akkea/linaro-image-tools/Samsung-SMDKV310 |
Merge into: | lp:linaro-image-tools/11.11 |
Diff against target: |
1003 lines (+474/-150) (has conflicts) 2 files modified
linaro_media_create/boards.py (+299/-54) linaro_media_create/tests/test_media_create.py (+175/-96) Text conflict in linaro_media_create/boards.py |
To merge this branch: | bzr merge lp:~angus-akkea/linaro-image-tools/Samsung-SMDKV310 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guilherme Salgado (community) | Approve | ||
Loïc Minier (community) | Approve | ||
James Westby | Pending | ||
Review via email:
|
This proposal supersedes a proposal from 2011-03-02.
Commit message
Description of the change
Added back in the temp_dir logic I pulled out during the last merge
Fixed conflicts
Remove duplicates added during merge
Fix tests for me partition sizes
Merged in lp:~lool/linaro-image-tools/samsung-v310-v2
Adds a bunch of constants for the Samsung board
More comments
Adds a _dd method for all to use
Creates a boot_env dict for all to use
Added Loic's constant changes and comments
Changed bootargs and bootcmd methods to be used to create bootable_env
All all possible filesystem, bootagrs and bootcmd changes that are possible without functional VFAT in u-boot. Commented lines that should be used once FAT is functional.
More Loic recommendations
The SMDKv310 code now follows the recommended boot (FAT) and rootfs (EXT) partition scheme. BL1 , u-boot, the kernel and the initrd all load from the raw mmc offsets currently. Once my MMC issues are resolved I'll be able to load some of these from the FAT partition.
Update code based on Loic comments and fixed test cases
More changes to fix merge with sfdisk partition changes
Add support for Samsung SMDK V310 board
Use uses_fat_
Add make_flashable_env that will create a binary suitable to burn directly to flash for a u-boot environment.
add tests
One more minor change to set the bootm line correctly to mount the initrd
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
James Westby (james-w) wrote : Posted in a previous version of this proposal | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Guilherme Salgado (salgado) wrote : Posted in a previous version of this proposal | # |
Hi Angus,
I see some room for improvement here, but overall it looks good.
review needsfixing
On Thu, 2011-02-10 at 01:13 +0000, Angus Ainslie wrote:
> differences between files attachment (review-diff.txt)
> === modified file 'linaro_
> --- linaro_
> +++ linaro_
> @@ -29,9 +29,11 @@
> import os
> import re
> import tempfile
> +import struct
>
> from linaro_media_create import cmd_runner
> -
> +from binascii import hexlify
> +from binascii import crc32
Please combine these imports into just one line:
from binascii import (
crc32,
hexlify
)
>
> class BoardConfig(
> """The configuration used when building an image for a board."""
> @@ -55,6 +57,7 @@
> @classmethod
> def get_sfdisk_
> """Return the sfdisk command to partition the media."""
> +
Why did you add a blank line here?
> if cls.fat_size == 32:
> partition_type = '0x0C'
> else:
> @@ -201,6 +204,7 @@
> make_boot_
>
>
> +
And this one here?
> class BeagleConfig(
> uboot_flavor = 'omap3_beagle'
> _serial_tty = 'ttyO2'
> @@ -335,6 +339,68 @@
> cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
> make_uInitrd(
>
> +class SamsungConfig(
> + boot_env = [
> + 'baudrate=115200',
> + 'bootargs=
> + 'bootcmd=movi read kernel 40007000; movi read rootfs 41000000 600000; bootm 40007000',
> + 'bootdelay=3',
> + 'ethact=smc911x-0',
> + 'ethaddr=
> + 'gatewayip=
> + 'ipaddr=
> + 'netmask=
> + 'serverip=
We don't configure the network interface statically for any other board.
Is there any reason why we need to do so here?
> + 'stderr=serial',
> + 'stdin=serial',
> + 'stdout=serial'
> + ]
> +
> + @classmethod
> + def get_sfdisk_
> + # Create a one cylinder partition for fixed-offset bootloader data at
> + # the beginning of the image (size is 14 cylinder, so 115,146,752 bytes
> + # with the first sector for MBR).
You create two partitions here and not just the one for the bootloader
as the comment implies, right?
> + sfdisk_cmd = super(SamsungCo
As James pointed out, since you don't use the return value of the upcall
there's no need to upcall at all.
> + return ',14,0xDA\n,,,-'
> +
> + @classmethod
> + def _make_boot_
> + boot_dir, boot_script, boot_device_
> +
> + uboot_file = os.path.join(
> + chroot_dir, 'usr', 'lib', 'u-boot', 'smdkv310', 'u-boot.v310')
> + install_
> + make_uInitrd(
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
Thanks for looking at it, some comments inline.
On Thu, Feb 10, 2011 at 8:52 AM, Guilherme Salgado
<email address hidden> wrote:
> Review: Needs Fixing
> Hi Angus,
>
> I see some room for improvement here, but overall it looks good.
>
> review needsfixing
>
>>
>> class BoardConfig(
>> """The configuration used when building an image for a board."""
>> @@ -55,6 +57,7 @@
>> @classmethod
>> def get_sfdisk_
>> """Return the sfdisk command to partition the media."""
>> +
>
> Why did you add a blank line here?
>
>> if cls.fat_size == 32:
>> partition_type = '0x0C'
>> else:
>> @@ -201,6 +204,7 @@
>> make_boot_
>>
>>
>> +
>
> And this one here?
>
Adding the blank linaes wasn't intentional, I'll fix them.
>> class BeagleConfig(
>> uboot_flavor = 'omap3_beagle'
>> _serial_tty = 'ttyO2'
>> @@ -335,6 +339,68 @@
>> cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
>> make_uInitrd(
>>
>> +class SamsungConfig(
>> + boot_env = [
>> + 'baudrate=115200',
>> + 'bootargs=
>> + 'bootcmd=movi read kernel 40007000; movi read rootfs 41000000 600000; bootm 40007000',
>> + 'bootdelay=3',
>> + 'ethact=smc911x-0',
>> + 'ethaddr=
>> + 'gatewayip=
>> + 'ipaddr=
>> + 'netmask=
>> + 'serverip=
>
> We don't configure the network interface statically for any other board.
> Is there any reason why we need to do so here?
>
That was just a verbatim copy of the u-boot env I had on my board so I
could get the CRC calc in make_flashable_env correct. I'll remove the
network lines
>> + install_
>> +
>> +
>> +class SMDKV310Config(
>> + fat_size = 0
>> + extra_serial_opts = 'console=
>> + live_serial_opts = 'serialtty=ttyO2'
>> + kernel_addr = '0x40008000'
>> + initrd_addr = '0x40800000'
>> + load_addr = '0x40008000'
>> + kernel_suffix = 's5pv310'
>> + boot_script = 'boot.scr'
>> + extra_boot_
>> + 'root=/
>>
>> board_configs = {
>> 'beagle': BeagleConfig,
>> @@ -344,6 +410,7 @@
>> 'ux500': Ux500Config,
>> 'mx51evk': Mx51evkConfig,
>> 'overo': OveroConfig,
>> + 'smdkv310': SMDKV310Config,
>> }
>>
>>
>> @@ -359,6 +426,7 @@
>> '-n', name,
>> '-d', img_data,
>> img]
>> +
>> proc = cmd_runner.run(cmd, as_root=as_root, stdout=stdout)
>> proc.wait()
>> return proc.returncode
>> @@ -407,6 +475,25 @@
>> 'script', '0', '0', 'boot script', tmpfile, boot_script)
>>
>>
>> +def make_flashable_env( boot_env, env_file ) :
>
> This could be a @classmethod on SamsungConfig, no? That way you can get
> rid of the boot_env argument as you can get it from the class.
>
It could be but I thought th...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
You might need a:
from __future__ import with_statement
(we hope to complete a backport to Ubuntu 10.04 and hence we'd like to keep support for python2.5)
perhaps it's best to avoid "with" entirely
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Guilherme Salgado (salgado) wrote : Posted in a previous version of this proposal | # |
On Thu, 2011-02-10 at 16:34 +0000, Loïc Minier wrote:
> You might need a:
> from __future__ import with_statement
>
> (we hope to complete a backport to Ubuntu 10.04 and hence we'd like to keep support for python2.5)
We want to support python2.5 even though 2.6 is the default in Lucid?
If so, we'll have to add that import in a few other places because with
is already used in l-i-t.
>
> perhaps it's best to avoid "with" entirely
It's so cheap to make with work on 2.5 that I don't see why we'd want to
avoid it
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Guilherme Salgado (salgado) wrote : Posted in a previous version of this proposal | # |
On Thu, 2011-02-10 at 16:22 +0000, Angus Ainslie wrote:
[...]
> >> +class SamsungConfig(
> >> + boot_env = [
> >> + 'baudrate=115200',
> >> + 'bootargs=
> >> + 'bootcmd=movi read kernel 40007000; movi read rootfs 41000000 600000; bootm 40007000',
> >> + 'bootdelay=3',
> >> + 'ethact=smc911x-0',
> >> + 'ethaddr=
> >> + 'gatewayip=
> >> + 'ipaddr=
> >> + 'netmask=
> >> + 'serverip=
> >
> > We don't configure the network interface statically for any other board
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
A couple of other comments
On Thu, Feb 10, 2011 at 8:52 AM, Guilherme Salgado
<email address hidden> wrote:
>> + make_flashable_
>> + install_
>> +
>> + make_uImage(
>> + cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
>> + uImage_file = os.path.join(
>> + boot_dir, 'uImage')
>
> Would you mind changing make_uImage() to return the path of the file the
> image was written to? That way we don't have to guess its path here and
> risk getting it wrong.
>
make_uImage already returns the the result of _run_mkimage. There's
probable code that already relies on that return code. Should I make
it return a tuple or would you like it managed in some other way ?
>> + uInitrd_file = os.path.join(
>> + boot_dir, 'uInitrd')
>
> Would you mind changing make_uInitrd() to return the path of the file
> the initrd was written to? That way we don't have to guess its path
> here and risk getting it wrong.
>
Same as above
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Guilherme Salgado (salgado) wrote : Posted in a previous version of this proposal | # |
(previous message hit a bug in LP so my actual comments were not included. resending...)
On Thu, 2011-02-10 at 16:22 +0000, Angus Ainslie wrote:
[...]
> >> +class SamsungConfig(
> >> + boot_env = [
> >> + 'baudrate=115200',
> >> + 'bootargs=
> >> + 'bootcmd=movi read kernel 40007000; movi read rootfs 41000000 600000; bootm 40007000',
> >> + 'bootdelay=3',
> >> + 'ethact=smc911x-0',
> >> + 'ethaddr=
> >> + 'gatewayip=
> >> + 'ipaddr=
> >> + 'netmask=
> >> + 'serverip=
> >
> > We don't configure the network interface statically for any other board.
> > Is there any reason why we need to do so here?
> >
>
> That was just a verbatim copy of the u-boot env I had on my board so I
> could get the CRC calc in make_flashable_env correct. I'll remove the
> network lines
Oh, ok, is there anything else that would make sense to omit from the
default env?
>
> >> + install_
> >> +
> >> +
> >> +class SMDKV310Config(
> >> + fat_size = 0
> >> + extra_serial_opts = 'console=
> >> + live_serial_opts = 'serialtty=ttyO2'
> >> + kernel_addr = '0x40008000'
> >> + initrd_addr = '0x40800000'
> >> + load_addr = '0x40008000'
> >> + kernel_suffix = 's5pv310'
> >> + boot_script = 'boot.scr'
> >> + extra_boot_
> >> + 'root=/
> >>
> >> board_configs = {
> >> 'beagle': BeagleConfig,
> >> @@ -344,6 +410,7 @@
> >> 'ux500': Ux500Config,
> >> 'mx51evk': Mx51evkConfig,
> >> 'overo': OveroConfig,
> >> + 'smdkv310': SMDKV310Config,
> >> }
> >>
> >>
> >> @@ -359,6 +426,7 @@
> >> '-n', name,
> >> '-d', img_data,
> >> img]
> >> +
> >> proc = cmd_runner.run(cmd, as_root=as_root, stdout=stdout)
> >> proc.wait()
> >> return proc.returncode
> >> @@ -407,6 +475,25 @@
> >> 'script', '0', '0', 'boot script', tmpfile, boot_script)
> >>
> >>
> >> +def make_flashable_env( boot_env, env_file ) :
> >
> > This could be a @classmethod on SamsungConfig, no? That way you can get
> > rid of the boot_env argument as you can get it from the class.
> >
>
> It could be but I thought there might be other board that might want
> to create a flashable env so that's why I had it as a separate
> function
Fair enough.
>
> >>
> >> === modified file 'linaro_
> >> --- linaro_
> >> +++ linaro_
> >> @@ -81,7 +81,7 @@
> >> else:
> >> bootfs, rootfs = get_boot_
> >>
> >> - if should_
> >> + if should_
> >
> > I don't quite like the idea of abusing the fat_size to specify whether
> > or not to setup a vfat partition. I think a separate BoardConfig
> > attribute (uses_vfa...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
Some python challenges now
On Thu, Feb 10, 2011 at 8:52 AM, Guilherme Salgado
<email address hidden> wrote:
>> + env = ''
>> +
>> + for s in boot_env :
>> + for c in s :
>> + env += struct.pack( 'c', c )
>> + env += struct.pack( 'B', 0 )
>
> I think this could be written more concisely as
>
> struct.pack('B', 0).join(boot_env)
>
> ?
>
I changed this section to look like this
def make_flashable_env( boot_env, env_size, env_file ) :
struct.pack( 'B', 0 ).join( boot_env )
# pad the rest of the env for the CRC calc
while len( boot_env ) < (env_size - 4):
boot_env += struct.pack( 'B', 0)
crc = crc32(boot_env)
boot_env = struct.pack('<i', crc) + boot_env
with open(env_file, 'w') as fd:
fd.write( boot_env )
I now get and error while running it :
File "/usr/src/
line 483, in make_flashable_env
crc = crc32(boot_env)
TypeError: crc32() argument 1 must be string or read-only buffer, not list
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Guilherme Salgado (salgado) wrote : Posted in a previous version of this proposal | # |
On Thu, 2011-02-10 at 17:49 +0000, Angus Ainslie wrote:
> A couple of other comments
>
> On Thu, Feb 10, 2011 at 8:52 AM, Guilherme Salgado
> <email address hidden> wrote:
> >> + make_flashable_
> >> + install_
> >> +
> >> + make_uImage(
> >> + cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
> >> + uImage_file = os.path.join(
> >> + boot_dir, 'uImage')
> >
> > Would you mind changing make_uImage() to return the path of the file the
> > image was written to? That way we don't have to guess its path here and
> > risk getting it wrong.
> >
>
> make_uImage already returns the the result of _run_mkimage. There's
> probable code that already relies on that return code. Should I make
> it return a tuple or would you like it managed in some other way ?
I don't think there's any code currently using the return value of
make_uImage, but this is a very small and young codebase so if you don't
find anything using it, just change it.
>
> >> + uInitrd_file = os.path.join(
> >> + boot_dir, 'uInitrd')
> >
> > Would you mind changing make_uInitrd() to return the path of the file
> > the initrd was written to? That way we don't have to guess its path
> > here and risk getting it wrong.
> >
>
> Same as above
Ditto. ;)
--
Guilherme Salgado <https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Guilherme Salgado (salgado) wrote : Posted in a previous version of this proposal | # |
On Thu, 2011-02-10 at 17:57 +0000, Angus Ainslie wrote:
> Some python challenges now
>
> On Thu, Feb 10, 2011 at 8:52 AM, Guilherme Salgado
> <email address hidden> wrote:
> >> + env = ''
> >> +
> >> + for s in boot_env :
> >> + for c in s :
> >> + env += struct.pack( 'c', c )
> >> + env += struct.pack( 'B', 0 )
> >
> > I think this could be written more concisely as
> >
> > struct.pack('B', 0).join(boot_env)
> >
> > ?
> >
>
> I changed this section to look like this
>
> def make_flashable_env( boot_env, env_size, env_file ) :
> struct.pack( 'B', 0 ).join( boot_env )
Sorry, I wasn't clear. The above code will return a string but won't
change boot_env, so you need to assign the result of that to a variable
and use it instead of boot_env.
>
> # pad the rest of the env for the CRC calc
> while len( boot_env ) < (env_size - 4):
> boot_env += struct.pack( 'B', 0)
>
> crc = crc32(boot_env)
> boot_env = struct.pack('<i', crc) + boot_env
>
> with open(env_file, 'w') as fd:
> fd.write( boot_env )
>
> I now get and error while running it :
>
> File "/usr/src/
> line 483, in make_flashable_env
> crc = crc32(boot_env)
> TypeError: crc32() argument 1 must be string or read-only buffer, not list
>
--
Guilherme Salgado <https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
Wow, for some reason I thought lucid was 2.5, but it's 2.6; just ignore my previous comment
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
Forwarding a chat on this:
21:53 < lool> nytowl: I find the ethaddr worrying; init=/bin/bash is clearly bad too; console=ttySAC1 sounds like it should be handled like serialtty in the other boards
21:54 < lool> nytowl: do you actually need baudrate, bootdelay etc. in there or would the u-boot default be good enough?
21:55 < nytowl> lool, I don't like the ethaddr and bash either but I'd like network to work and init cause a kernel panic
21:55 < lool> nytowl: comment on "size is 14 cylinder" doesn't make sense anymore
21:55 < nytowl> I could probably get rid of baudrate and bootdelay
21:56 < lool> nytowl: I think we need a way to amend the cmdline; if we had this, you could just use this feature to override the default init while the kernel is broken
21:56 < lool> nytowl: (if you're tempted to provide this, submit it separately so that it can be merged separately)
21:56 < lool> nytowl: seek=1089 sounds like magic, where does it come from?
21:57 < lool> same question for seek=9281
21:57 < lool> or seek=33
21:57 < lool> I understand the seek=1 one though ;-)
21:57 < lool> and then there's this seek=65
21:57 < nytowl> Those are magic offsets that irom looks on the SD card for u-boot , uImage and initrd
21:57 < nytowl> I guess those should be commented :)
21:58 < lool> nytowl: uses_fat_
21:59 < nytowl> the boot_env is more than just the command line it is that flashable env I was talking to you about last week
21:59 < lool> nytowl: I think this board is substantially different and would warrant some deeper thoughts on how we should boot it and support it; where could I read about how it boots, which software
21:59 < nytowl> lool there's a little info in the wiki about those offsets
22:00 < nytowl> https:/
22:00 < lool> nytowl: My ideal documentation would be one which walks me through the various stages of the boot up to linux
22:01 < nytowl> lool that document doesn't exsist
22:01 < lool> nytowl: Is there some kind of technical reference manual for the SoC and some kind of user guide for the board?
22:02 < nytowl> lool, I have a data sheet for the SoC but no user guids
22:02 < lool> nytowl: test_smdkv310() says ,14,0xDA and then rootfs, but https:/
22:03 < nytowl> lool I fixed the sfdisk get command but forgot about the test
22:05 < lool> nytowl: It seems you have u-boot running and that it's loading kernel and initrd from mmc, so I presume it has mmc support; why wouldn't it be able to load uimage and uinitrd from a MMC
22:05 < lool> nytowl: Is the datasheet NDA? would I be able to get access to it?
22:06 < nytowl> lool, that was going to be step 2
22:06 < lool> nytowl: Is it from the datasheet that you found about these values?
22:06 < lool> nytowl: I think the l-i-t diff might be much smaller if you were using the same layout with vfat partition etc. as other boards
22:06 < nytowl> lool, now those values can from the BSP u-boot and discussions with Samsung
22:0...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
Hi Loic
some comments inline
On Mon, Feb 14, 2011 at 2:36 PM, Loïc Minier <email address hidden> wrote:
> Forwarding a chat on this:
>
> 21:53 < lool> nytowl: I find the ethaddr worrying; init=/bin/bash is clearly bad too; console=ttySAC1 sounds like it should be handled like serialtty in the other boards
> 21:54 < lool> nytowl: do you actually need baudrate, bootdelay etc. in there or would the u-boot default be good enough?
I removed the un-necessary varibales
> 21:55 < nytowl> lool, I don't like the ethaddr and bash either but I'd like network to work and init cause a kernel panic
> 21:55 < lool> nytowl: comment on "size is 14 cylinder" doesn't make sense anymore
> 21:55 < nytowl> I could probably get rid of baudrate and bootdelay
> 21:56 < lool> nytowl: I think we need a way to amend the cmdline; if we had this, you could just use this feature to override the default init while the kernel is broken
> 21:56 < lool> nytowl: (if you're tempted to provide this, submit it separately so that it can be merged separately)
The code I've added is a different way of creating a u-boot env. As
the Samsung v310 SMDK does not have any flash on board this is the
only way for me to store the env.
Are you saying you'd like me to override _get_boot_cmd or do you want
me to re-write it so it can deal with systems that don't use a FAT
partition.
> 21:56 < lool> nytowl: seek=1089 sounds like magic, where does it come from?
> 21:57 < lool> same question for seek=9281
> 21:57 < lool> or seek=33
> 21:57 < lool> I understand the seek=1 one though ;-)
> 21:57 < lool> and then there's this seek=65
> 21:57 < nytowl> Those are magic offsets that irom looks on the SD card for u-boot , uImage and initrd
> 21:57 < nytowl> I guess those should be commented :)
I've fixed these references
>
> 21:58 < lool> nytowl: uses_fat_
I needed some of the functionality provided by the partitioning
mechanism but I don't need a FAT partition. Once the MMC diver for the
Samsung kernel is fixed I should still be able to boot using just a
single EXT2/3 partition.
Is having a boot partition a requirement for using linaro-media-create ?
> 21:59 < nytowl> the boot_env is more than just the command line it is that flashable env I was talking to you about last week
> 21:59 < lool> nytowl: I think this board is substantially different and would warrant some deeper thoughts on how we should boot it and support it; where could I read about how it boots, which software
> starts from where etc.?
I've changed the way the board boots to closer follow the l-m-c way
but because of the MMC issues I can't finish the job. Are you
suggesting that I don't resubmit this for merge until those issues are
resolved ?
> 21:59 < nytowl> lool there's a little info in the wiki about those offsets
> 22:00 < nytowl> https:/
> 22:00 < lool> nytowl: My ideal documentation would be one which walks me through the various stages of the boot up to linux
> 22:01 < nytowl> lool that document doesn't exsist
>
I'll get the boot process documented on the wiki.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Guilherme Salgado (salgado) wrote : Posted in a previous version of this proposal | # |
On Mon, 2011-02-14 at 21:36 +0000, Loïc Minier wrote:
[...]
> 22:05 < lool> nytowl: It seems you have u-boot running and that it's loading kernel and initrd from mmc, so I presume it has mmc support; why wouldn't it be able to load uimage and uinitrd from a MMC
> partition instead of loading them from hardcoded MMC offsets?
> 22:05 < lool> nytowl: Is the datasheet NDA? would I be able to get access to it?
> 22:06 < nytowl> lool, that was going to be step 2
> 22:06 < lool> nytowl: Is it from the datasheet that you found about these values?
> 22:06 < lool> nytowl: I think the l-i-t diff might be much smaller if you were using the same layout with vfat partition etc. as other boards
> 22:06 < nytowl> lool, now those values can from the BSP u-boot and discussions with Samsung
> 22:07 < nytowl> lool, it would be but i wanted to get the board booting first and then start fixing things
Oh, I was assuming we couldn't use the same partition layout on this
board for some reason, but if we can then I really think we should aim
towards that instead of adding complexity to l-m-c just to remove it
later.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
On Wed, Feb 16, 2011 at 5:16 AM, Guilherme Salgado
<email address hidden> wrote:
> On Mon, 2011-02-14 at 21:36 +0000, Loïc Minier wrote:
> [...]
>> 22:05 < lool> nytowl: It seems you have u-boot running and that it's loading kernel and initrd from mmc, so I presume it has mmc support; why wouldn't it be able to load uimage and uinitrd from a MMC
>> partition instead of loading them from hardcoded MMC offsets?
>> 22:05 < lool> nytowl: Is the datasheet NDA? would I be able to get access to it?
>> 22:06 < nytowl> lool, that was going to be step 2
>> 22:06 < lool> nytowl: Is it from the datasheet that you found about these values?
>> 22:06 < lool> nytowl: I think the l-i-t diff might be much smaller if you were using the same layout with vfat partition etc. as other boards
>> 22:06 < nytowl> lool, now those values can from the BSP u-boot and discussions with Samsung
>> 22:07 < nytowl> lool, it would be but i wanted to get the board booting first and then start fixing things
>
> Oh, I was assuming we couldn't use the same partition layout on this
> board for some reason, but if we can then I really think we should aim
> towards that instead of adding complexity to l-m-c just to remove it
> later.
>
We can't use the same partition scheme on the Samsung board. It needs
some raw sectors for it's BL1 and u-boot env.
Is there some kind of requirement for having a boot/fat partition ?
Shouldn't having the fat partition be the exception instead of the rule ?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
On Wed, Feb 16, 2011, Angus Ainslie wrote:
> We can't use the same partition scheme on the Samsung board. It needs
> some raw sectors for it's BL1 and u-boot env.
We already create a non-FS data partition for mx51 which contains
u-boot (not the environment, but it's the same thing).
> Is there some kind of requirement for having a boot/fat partition ?
No; we're trying to use as much common layout across all boards as we
can as to avoid making the code more complex
> Shouldn't having the fat partition be the exception instead of the rule ?
I don't see why; it's more convenient to manipulate files with cp/mv
than dd-ing at specific offsets; also, managing the free space is
easier. I can also see this being useful for boot scripts, editing the
environment and more.
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
On Wed, Feb 16, 2011 at 7:52 AM, Loïc Minier <email address hidden> wrote:
> On Wed, Feb 16, 2011, Angus Ainslie wrote:
>> We can't use the same partition scheme on the Samsung board. It needs
>> some raw sectors for it's BL1 and u-boot env.
>
> We already create a non-FS data partition for mx51 which contains
> u-boot (not the environment, but it's the same thing).
>
So if I load BL1, env, and u-boot for the non-fs partiton that will be
acceptable ? I can then load the kernel from an ext partition.
>> Shouldn't having the fat partition be the exception instead of the rule ?
>
> I don't see why; it's more convenient to manipulate files with cp/mv
> than dd-ing at specific offsets; also, managing the free space is
> easier. I can also see this being useful for boot scripts, editing the
> environment and more.
>
I wasn't thinking use the raw device I was thinking a single rootfs
and boot partition, probably EXT. The question is more why are 2
partitions the default ?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
On Wed, Feb 16, 2011, Angus Ainslie wrote:
> So if I load BL1, env, and u-boot for the non-fs partiton that will be
> acceptable ?
That seems about right; ideally, if you could have u-boot on the first
partition that would be nicer.
Consider that it will be impossible for people to upgrade from this
boot layout to another one, so you're bound to support it "forever".
Linaro doesn't usually prioritize support for upgrading, but it's still
a good idea to consider it, especially if you take into account that
Linaro might be used as a base to build real products.
> I can then load the kernel from an ext partition.
Why ext and not vfat like the other ones?
> I wasn't thinking use the raw device I was thinking a single rootfs
> and boot partition, probably EXT. The question is more why are 2
> partitions the default ?
Because u-boot doesn't might not support the fancy rootfs scheme which
you need (e.g. btrfs, LVM...) and can't fsck; so it's easier to read
the initrd from a simple+solid fs (like vfat) and then have the initrd
do the heavy lifting, or have linux start the rootfs.
I bet you're going to ask about initrd next: I'd prefer if we keep
using initrd for all boards for pretty much the same reasons :-)
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
On Wed, Feb 16, 2011 at 8:26 AM, Loïc Minier <email address hidden> wrote:
> On Wed, Feb 16, 2011, Angus Ainslie wrote:
>> So if I load BL1, env, and u-boot for the non-fs partiton that will be
>> acceptable ?
>
> That seems about right; ideally, if you could have u-boot on the first
> partition that would be nicer.
>
Currently Bl1 doesn't support FAT. Samsungs u-boot doesn't either but
that's an easy fix.
> Consider that it will be impossible for people to upgrade from this
> boot layout to another one, so you're bound to support it "forever".
> Linaro doesn't usually prioritize support for upgrading, but it's still
> a good idea to consider it, especially if you take into account that
> Linaro might be used as a base to build real products.
>
Why would an upgrade be impossible ? If/when a FAT capable BL1 became
available it could be written to the MMC card, from u-boot, linux or
even a host computer.
>> I can then load the kernel from an ext partition.
>
> Why ext and not vfat like the other ones?
>
>> I wasn't thinking use the raw device I was thinking a single rootfs
>> and boot partition, probably EXT. The question is more why are 2
>> partitions the default ?
>
> Because u-boot doesn't might not support the fancy rootfs scheme which
> you need (e.g. btrfs, LVM...) and can't fsck; so it's easier to read
> the initrd from a simple+solid fs (like vfat) and then have the initrd
> do the heavy lifting, or have linux start the rootfs.
>
Well you got me on the fsck :)
>
> I bet you're going to ask about initrd next: I'd prefer if we keep
> using initrd for all boards for pretty much the same reasons :-)
>
No, enough religious debates for one day.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
On Wed, Feb 16, 2011, Angus Ainslie wrote:
> > Consider that it will be impossible for people to upgrade from this
> > boot layout to another one, so you're bound to support it "forever".
> > Linaro doesn't usually prioritize support for upgrading, but it's still
> > a good idea to consider it, especially if you take into account that
> > Linaro might be used as a base to build real products.
>
> Why would an upgrade be impossible ? If/when a FAT capable BL1 became
> available it could be written to the MMC card, from u-boot, linux or
> even a host computer.
I said it's impossible to upgrade the boot layout, as in to change to a
different boot layout (moving to having u-boot in vfat for instance).
Also, consider that your offsets are hardcoded forever and if you ever
need a larger BL1, u-boot or environment, you're screwed. Obviously
vfat has some limitations of its own.
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
On Wed, Feb 16, 2011 at 9:07 AM, Loïc Minier <email address hidden> wrote:
> On Wed, Feb 16, 2011, Angus Ainslie wrote:
>> > Consider that it will be impossible for people to upgrade from this
>> > boot layout to another one, so you're bound to support it "forever"
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Guilherme Salgado (salgado) wrote : Posted in a previous version of this proposal | # |
Hi Angus,
I think this looks quite good; I only have some minor changes to
suggest. I'd just like Loïc to have another look as he reviewed a
previous version of this branch and he may spot things that I've missed.
review needsfixing
On Thu, 2011-02-17 at 21:52 +0000, Angus Ainslie wrote:
> Angus Ainslie has proposed merging lp:~angus-akkea/linaro-image-tools/Samsung-SMDKV310 into lp:linaro-image-tools.
>
> Requested reviews:
> James Westby (james-w)
> Guilherme Salgado (salgado)
>
> For more details, see:
> https:/
>
> More Loic recommendations
>
> The SMDKv310 code now follows the recommended boot (FAT) and rootfs (EXT) partition scheme. BL1 , u-boot, the kernel and the initrd all load from the raw mmc offsets currently. Once my MMC issues are resolved I'll be able to load some of these from the FAT partition.
>
> Update code based on Loic comments and fixed test cases
> More changes to fix merge with sfdisk partition changes
>
>
> Add support for Samsung SMDK V310 board
> Use uses_fat_
> Add make_flashable_env that will create a binary suitable to burn directly to flash for a u-boot environment.
> add tests
> One more minor change to set the bootm line correctly to mount the initrd
> differences between files attachment (review-diff.txt)
> === modified file 'linaro_
> --- linaro_
> +++ linaro_
[...]
> @@ -419,6 +422,67 @@
> cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
> make_uInitrd(
>
> +class SamsungConfig(
> + boot_env = [
> + 'bootargs=
You could at least define a serial_tty attribute here (like in other
config classes) and use that here instead of hard-coding ttySAC1.
> + 'bootcmd=movi read kernel 40007000; movi read rootfs 41000000 600000;'
> + 'bootm 40007000 41000000',
> + 'ethact=smc911x-0',
> + 'ethaddr=
I think some of the lines above are longer than 79 chars?
> + ]
> +
> + @classmethod
> + def get_sfdisk_cmd(cls, should_
> + # Create a fixed-offset bootloader data at
> + # the beginning of the image (size is 214080 512 byte sectors
> + # with the first sector for MBR).
> + loader_start, loader_end, loader_len = align_partition(
> + 1, 214080, 1, PART_ALIGN_S)
> +
> + boot_start, boot_end, boot_len = align_partition(
> + loader_end + 1, BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
> +
> + # we ignore _root_end / _root_len and return a sfdisk command to
> + # instruct the use of all remaining space; XXX if we had some root size
> + # config, we could do something more sensible
> + root_start, _root_end, _root_len = align_partition(
> + boot_end + 1, ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Guilherme Salgado (salgado) wrote : Posted in a previous version of this proposal | # |
One thing I've missed...
On Thu, 2011-02-17 at 21:52 +0000, Angus Ainslie wrote:
> === modified file 'linaro_
> --- linaro_
> +++ linaro_
> @@ -29,9 +29,11 @@
> import os
> import re
> import tempfile
> +import struct
>
> from linaro_media_create import cmd_runner
> from linaro_
> +from binascii import crc32
>
> # Notes:
> # * geometry is currently always 255 heads and 63 sectors due to limitations of
> @@ -88,6 +90,7 @@
> mmc_option = '0:1'
> mmc_part_offset = 0
> fat_size = 32
> + uses_fat_
We don't need this any longer.
> === modified file 'linaro_
> --- linaro_
> +++ linaro_
> @@ -92,7 +92,7 @@
> else:
> bootfs, rootfs = get_boot_
>
> - if should_
> + if should_
Nor this
> print "\nFormating boot partition\n"
> proc = cmd_runner.run(
> ['mkfs.vfat', '-F', str(board_
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
On Thu, Feb 17, 2011, Angus Ainslie wrote:
> The SMDKv310 code now follows the recommended boot (FAT) and rootfs
> (EXT) partition scheme. BL1 , u-boot, the kernel and the initrd all
> load from the raw mmc offsets currently. Once my MMC issues are
> resolved I'll be able to load some of these from the FAT partition.
So overall, the diff is much smaller and it's getting closer to being
mergeable, thanks for your work; some comments below
> === modified file 'linaro_
> --- linaro_
> +++ linaro_
> @@ -419,6 +422,67 @@
> cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
> make_uInitrd(
>
> +class SamsungConfig(
> + boot_env = [
> + 'bootargs=
> + 'bootcmd=movi read kernel 40007000; movi read rootfs 41000000 600000;'
> + 'bootm 40007000 41000000',
> + 'ethact=smc911x-0',
> + 'ethaddr=
> + ]
> +
Why do we have root=/dev/mmcblk0p3 here and root=/dev/mmcblk0p2 in
extra_
booting. Same remark for init=/bin/bash.
console= should be inferred from a serialtty variable.
I don't think we should encode the default u-boot environment into
linaro-
ethact=smc911x-0 should go into u-boot's config for the board.
ethaddr= seems broken; this should be read from an EEPROM or should be
generated by u-boot or by the kernel once, and recorded (see what IGEP
or beagle xM do in u-boot + linux)
> + @classmethod
> + def get_sfdisk_cmd(cls, should_
> + # Create a fixed-offset bootloader data at
> + # the beginning of the image (size is 214080 512 byte sectors
> + # with the first sector for MBR).
> + loader_start, loader_end, loader_len = align_partition(
> + 1, 214080, 1, PART_ALIGN_S)
> +
> + boot_start, boot_end, boot_len = align_partition(
> + loader_end + 1, BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
> +
> + # we ignore _root_end / _root_len and return a sfdisk command to
> + # instruct the use of all remaining space; XXX if we had some root size
> + # config, we could do something more sensible
> + root_start, _root_end, _root_len = align_partition(
> + boot_end + 1, ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
> +
> + return '%s,%s,
> + loader_start, loader_len, boot_start, boot_len, root_start)
you're creating this partition layout:
<boot>
<root>
but I understand that the layout of data on the MMC is essentially:
+0 <partition table>
various stuff at fixed offsets:
+1 u-boot
+X kernel
+Y initrd
+4MiB <rootfs>
It would seem more sensible to me to have just a bootloader partition
and a rootfs partition (as long as your u-boot can't read ...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
On Fri, Feb 18, 2011, Loïc Minier wrote:
> the 16384 KiB are duplicated across:
> a) partition size constraints
> b) in this make_flashable_
> c) in install_
> please use some constants to compute partition offsets, dd args etc.
> from the same value
Also, some of these values are duplicated in the u-boot movi bootcmds
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
On Fri, Feb 18, 2011 at 7:58 AM, Loïc Minier <email address hidden> wrote:
> On Thu, Feb 17, 2011, Angus Ainslie wrote:
>> === modified file 'linaro_
>> --- linaro_
>> +++ linaro_
>> @@ -419,6 +422,67 @@
>> cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
>> make_uInitrd(
>>
>> +class SamsungConfig(
>> + boot_env = [
>> + 'bootargs=
>> + 'bootcmd=movi read kernel 40007000; movi read rootfs 41000000 600000;'
>> + 'bootm 40007000 41000000',
>> + 'ethact=smc911x-0',
>> + 'ethaddr=
>> + ]
>> +
>
> Why do we have root=/dev/mmcblk0p3 here and root=/dev/mmcblk0p2 in
> extra_boot_
> booting. Same remark for init=/bin/bash.
>
> console= should be inferred from a serialtty variable.
>
> I don't think we should encode the default u-boot environment into
> linaro-image-tools, but rather into u-boot. So things like
> ethact=smc911x-0 should go into u-boot's config for the board.
>
u-boot does not have the facility for creating a flashable environment
> ethaddr= seems broken; this should be read from an EEPROM or should be
> generated by u-boot or by the kernel once, and recorded (see what IGEP
> or beagle xM do in u-boot + linux)
>
>> + @classmethod
>> + def get_sfdisk_cmd(cls, should_
>> + # Create a fixed-offset bootloader data at
>> + # the beginning of the image (size is 214080 512 byte sectors
>> + # with the first sector for MBR).
>> + loader_start, loader_end, loader_len = align_partition(
>> + 1, 214080, 1, PART_ALIGN_S)
>> +
>> + boot_start, boot_end, boot_len = align_partition(
>> + loader_end + 1, BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
>> +
>> + # we ignore _root_end / _root_len and return a sfdisk command to
>> + # instruct the use of all remaining space; XXX if we had some root size
>> + # config, we could do something more sensible
>> + root_start, _root_end, _root_len = align_partition(
>> + boot_end + 1, ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
>> +
>> + return '%s,%s,
>> + loader_start, loader_len, boot_start, boot_len, root_start)
>
> you're creating this partition layout:
> <bootloader>
> <boot>
> <root>
> but I understand that the layout of data on the MMC is essentially:
> +0 <partition table>
> various stuff at fixed offsets:
> +1 u-boot
> +X kernel
> +Y initrd
> +4MiB <rootfs>
>
> It would seem more sensible to me to have just a bootloader partition
> and a rootfs partition (as long as your u-boot can't read from a vfat):
> <bootloader>
> <root>
>
During our previous email/irc exchange I suggested just such a layout.
You told me that a vfat boot partition...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
On Fri, Feb 18, 2011, Angus Ainslie wrote:
> >> + boot_env = [
> >> + 'bootargs=
> >> + 'bootcmd=movi read kernel 40007000; movi read rootfs 41000000 600000;'
> >> + 'bootm 40007000 41000000',
> >> + 'ethact=smc911x-0',
> >> + 'ethaddr=
> >> + ]
> > I don't think we should encode the default u-boot environment into
> > linaro-image-tools, but rather into u-boot. So things like
> > ethact=smc911x-0 should go into u-boot's config for the board.
> u-boot does not have the facility for creating a flashable environment
I'm not sure what you mean; I mean the default u-boot config for these
values should be in u-boot itself
> During our previous email/irc exchange I suggested just such a layout.
> You told me that a vfat boot partition was not a requirement but then
> went on give quite a number of good reasons why it should be there. So
> now that I've implemented why is the recommendation changing.
The recommendation is to create /and use/ a vfat partition layout, that
is actually put kernel and initrd in vfat and load them from there.
This should be possible, and in fact very very similar to mx5 boards,
except it's not done due to a but in u-boot. Creating a vfat partition
and not using it is not what I was suggesting; I was suggesting writing
only u-boot and u-boot environment to the bootloader partition and
writing kernel, initrd and boot script on the vfat boot partition -- as
done on mx5 boards.
> Currently I think this is a bug with my hardware and my hardware only.
> I hope to be receiving replacement hardware sometime next week. If the
> bug turns out to affect more than one board I will file a bug for it
Good news; we certainly want to add code to support a single broken
board though, so I guess the code should use a vfat partition and
u-boot should fatload kernel and initrd from it, if the non-broken
boards allow this.
> >> + @classmethod
> >> + def _make_boot_
> >> + boot_dir, boot_script, boot_device_
> >> + uboot_file = os.path.join(
> >> + chroot_dir, 'usr', 'lib', 'u-boot', 'smdkv310', 'u-boot.v310')
> >
> > I know it's a weird question, but why is the file suffix u-boot.v310?
> > Is it a special format that only the v310 supports?
> Yes this is a monolithic u-boot plus the BL1 I've been telling you
> about. The landing team is in the process of splitting BL1 and u-boot.
> Once this is done we'll be in a similar situation to the x-loader +
> u-boot boards.
Hmm ok
> >> + proc = cmd_runner.run([
> >> + "mv",
> >> + "%s" % tmpfile,
> >> + "%s" % env_file], as_root=True)
> >> + proc.wait()
> >
> > Why move the file in place instead of generating it directly at the
> > right location?
>
> If I try to generate it directly to the bootfs I get a permission error
Do you want to keep boot_env.flash on disk? It might have incorrect
ownership as a result of mv (might be owned by the user id of the
person running l-i-t); it's not actually a prob...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
On Fri, Feb 18, 2011 at 9:33 AM, Loïc Minier <email address hidden> wrote:
> On Fri, Feb 18, 2011, Angus Ainslie wrote:
>> >> + boot_env = [
>> >> + 'bootargs=
>> >> + 'bootcmd=movi read kernel 40007000; movi read rootfs 41000000 600000;'
>> >> + 'bootm 40007000 41000000',
>> >> + 'ethact=smc911x-0',
>> >> + 'ethaddr=
>> >> + ]
>> > I don't think we should encode the default u-boot environment into
>> > linaro-image-tools, but rather into u-boot. So things like
>> > ethact=smc911x-0 should go into u-boot's config for the board.
>> u-boot does not have the facility for creating a flashable environment
>
> I'm not sure what you mean; I mean the default u-boot config for these
> values should be in u-boot itself
>
The u-boot code is probably going to b shard with the c210 u-boot code
so I thought encoding some of these board specific values into the env
was less broken that hard coding them into u-boot.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
On Fri, Feb 18, 2011, Angus Ainslie wrote:
> The u-boot code is probably going to b shard with the c210 u-boot code
> so I thought encoding some of these board specific values into the env
> was less broken that hard coding them into u-boot.
I'm not saying that the env should not be able to override them, but
the default should be correct in u-boot to start with -- that is, if
the env isn't read, u-boot still does the right thing. I'm thinking of
it like booting a kernel with an empty cmdline.
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
On Fri, Feb 18, 2011 at 10:34 AM, Loïc Minier <email address hidden> wrote:
> I'm not saying that the env should not be able to override them, but
> the default should be correct in u-boot to start with -- that is, if
> the env isn't read, u-boot still does the right thing. I'm thinking of
> it like booting a kernel with an empty cmdline
As FAT support is currently not working for my u-boot/hardware this is
my way of overriding the env.
Is my merge going to be denied until FAT support is working ?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
On Fri, Feb 18, 2011, Angus Ainslie wrote:
> As FAT support is currently not working for my u-boot/hardware this is
> my way of overriding the env.
So with all other boards, we don't have any u-boot environment at all;
we just set bootcmd via a boot script. u-boot only uses its defaults
from the build-time config, which includes a bootcmd which loads a
boot.scr, and that boot.scr is generated by linaro-image-tools just to
set the kernel cmdline.
I understand that you can't have a boot script because you can't load
it from vfat, but I don't understand why we'd have to set all these
things in the u-boot environment instead of just having the u-boot
defaults be correct?
> Is my merge going to be denied until FAT support is working ?
Eh, I realize this is frustrating; I don't mind that we carry an
intermediate version which doesn't use FAT, but only if the root issues
are tracked and being worked on; if you say it's just your board which
has this issue, then certainly we should use FAT; right?
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
Hi,
@Angus: In lp:~lool/linaro-image-tools/samsung-v310, I've prepared some
changes on top of lp:~angus-akkea/linaro-image-tools/Samsung-SMDKV310.
This mainly reworks the partitioning to use just a bootloader partition
and compute offsets/lengths from a set of constants.
Could you take a look and consider merging it in your own branch? I
obviously can't test it, but it passes tests.
I have a new question with the current implementation: why dd the first
and last sectors of your u-boot file separately instead of dd-ing the
whole file and then replacing the environment?
Bye,
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
On Mon, Feb 21, 2011 at 4:55 PM, Loïc Minier <email address hidden> wrote:
> Hi,
>
> @Angus: In lp:~lool/linaro-image-tools/samsung-v310, I've prepared some
> changes on top of lp:~angus-akkea/linaro-image-tools/Samsung-SMDKV310.
> This mainly reworks the partitioning to use just a bootloader partition
> and compute offsets/lengths from a set of constants.
>
> Could you take a look and consider merging it in your own branch? I
> obviously can't test it, but it passes tests.
>
Sure, once I get my new board I'll be looking at the l-m-c code again.
> I have a new question with the current implementation: why dd the first
> and last sectors of your u-boot file separately instead of dd-ing the
> whole file and then replacing the environment?
>
Before I wrote the make_flashable_env method I chose not to overwrite
the env portion of the MMC card.
Angus
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
Hey Angus
I've started from your branch and:
* did a fake merge with mine as to have the history from my "use
constants for offsets" commits appear
* merged it with lp:linaro-image-tools as it was based on a slightly
older version and had some conflicts
* reworked it a bit, mostly to have less common code specifically for
Samsung; the biggest change is that I'm passing a boot_env dict
around _make_boot_files calls instead of the text of boot commands;
also, I've dropped the 4 MiB alignment of the bootloader partition as
to have it start at the beginning of the SD card
The current layout does create a boot partition (a vfat) but it's not
actually used for anything except to store uImage and uInitrd. I've
kept the boot.scr generation commented out as the contents of it were
completely unused, but it's easy to enable again when the FAT partition
is actually in use.
If you're ok with the changes, I'm ok to merge this the above new
branch(if other reviewers are ok as well).
Cheers,
Note for self: there are a couple of things I would like to do before
doing the final merge:
* replace "movi read kernel 40007000" with %(kernel_addr), but I don't
know whether movi accepts addresses prefixed with 0x
* add tests to some new functions like make_flashable_
install_
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
Hi Loic,
On Mon, Feb 28, 2011 at 6:59 PM, Loïc Minier <email address hidden> wrote:
> Note for self: there are a couple of things I would like to do before
> doing the final merge:
> * replace "movi read kernel 40007000" with %(kernel_addr), but I don't
> know whether movi accepts addresses prefixed with 0x
The board still boots fine if those constants are prefixed with '0x'
> * add tests to some new functions like make_flashable_
> install_
>
How would those be tested ? Write them out to a file and then do an md5sum ?
Angus
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
On Tue, Mar 01, 2011, Angus Ainslie wrote:
> The board still boots fine if those constants are prefixed with '0x'
Ok; in r317 of my branch the code is now using cls.kernel_addr and
initrd_addr. What's the 600000 value after rootfs?
> > * add tests to some new functions like make_flashable_
> > install_
> How would those be tested ? Write them out to a file and then do an md5sum ?
Functions like install_
the _dd function, or more simply with a Popen mock.
For make_flashable_
creating a dict from a binary environment, then checking with
unpack_
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
On Tue, Mar 1, 2011 at 8:02 AM, Loïc Minier <email address hidden> wrote:
> On Tue, Mar 01, 2011, Angus Ainslie wrote:
>> The board still boots fine if those constants are prefixed with '0x'
>
> Ok; in r317 of my branch the code is now using cls.kernel_addr and
> initrd_addr. What's the 600000 value after rootfs?
>
It's the size of the rootfs. I see another constant coming
--
Angus Ainslie <email address hidden>
Team Lead, Samsung Landing Team
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
On Tue, Mar 01, 2011, Angus Ainslie wrote:
> It's the size of the rootfs. I see another constant coming
The thing is that it doesn't match the size of the initrd in the
partition layout: I had computed SAMSUNG_
looking at the existing offsets from you older branch (which is exactly
100 MiB).
If 0x600000 bytes are enough, I just need to update
SAMSUNG_
instructions as well; does that make sense?
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
On Tue, Mar 01, 2011, Loïc Minier wrote:
> If 0x600000 bytes are enough, I just need to update
> SAMSUNG_
> instructions as well; does that make sense?
Angus, could you check out r318 in
lp:~lool/linaro-image-tools/samsung-v310-v2 ?
it moves to 6 MiB instead of 100 MiB; this reduces the image size
significantly. (It also prefixes the length with 0x)
I'm pretty sure our initrd are more than 6 MiB, so I suspect that this
will break, but that seems to point out a problem with the current movi
commands which are only 6 MiB when the initrd is actually longer, so
presumably initrd unpacking was failing?
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
On Tue, Mar 1, 2011 at 9:02 AM, Loïc Minier <email address hidden> wrote:
> On Tue, Mar 01, 2011, Angus Ainslie wrote:
>> It's the size of the rootfs. I see another constant coming
>
> The thing is that it doesn't match the size of the initrd in the
> partition layout: I had computed SAMSUNG_
> looking at the existing offsets from you older branch (which is exactly
> 100 MiB).
>
> If 0x600000 bytes are enough, I just need to update
> SAMSUNG_
> instructions as well; does that make sense?
>
The 100MiB is hardcoded into BL0 ( the ROM loader ) so I think that we
may nee 2 constants. One for the amount of space reserved for uinitrd
and one for how much we want to copy from there.
> --
> Loïc Minier
>
> https:/
> You are the owner of lp:~angus-akkea/linaro-image-tools/Samsung-SMDKV310.
>
--
Angus Ainslie <email address hidden>
Team Lead, Samsung Landing Team
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
On Tue, Mar 01, 2011, Angus Ainslie wrote:
> The 100MiB is hardcoded into BL0 ( the ROM loader ) so I think that we
> may nee 2 constants. One for the amount of space reserved for uinitrd
> and one for how much we want to copy from there.
Would it be too painful to copy the whole 100 MiB?
Or could we come to an agreement to use e.g. 30 MiB and set that in
both BL0 and linaro-image-tools movi commands?
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : Posted in a previous version of this proposal | # |
On Tue, Mar 1, 2011 at 9:56 AM, Loïc Minier <email address hidden> wrote:
> On Tue, Mar 01, 2011, Angus Ainslie wrote:
>> The 100MiB is hardcoded into BL0 ( the ROM loader ) so I think that we
>> may nee 2 constants. One for the amount of space reserved for uinitrd
>> and one for how much we want to copy from there.
>
> Would it be too painful to copy the whole 100 MiB?
>
IIRC that took the boot from seconds to minutes.
> Or could we come to an agreement to use e.g. 30 MiB and set that in
> both BL0 and linaro-image-tools movi commands?
>
If I understand correctly BL0 is burned into the SoC somehow so we
can't get source and it won't be changed.
I'll create 2 constants SAMSUNG_
SAMSUNG_
--
Angus Ainslie <email address hidden>
Team Lead, Samsung Landing Team
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : Posted in a previous version of this proposal | # |
review approve
I'm fine merging this; the two things I'd fix at merge time are:
On Tue, Mar 01, 2011, Angus Ainslie wrote:
> def _get_mlo_
> @@ -549,3 +730,41 @@
> proc = cmd_runner.run(
> ["cp", "-v", boot_script, "%s/boot.ini" % boot_disk], as_root=True)
> proc.wait()
> +
> + return "%s/boot.ini" % boot_disk
this (which I understand was requested by another reviewer in a prior
review); don't think the return value is used anywhere, so I'd rather
not have it
and the other thing is that I'd fix the relatively trivial conflicts
with tip
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Guilherme Salgado (salgado) wrote : | # |
Hi Angus,
This looks good in general, but there are some things which are not
clear to me and others which need changing. Once you're done with the
changes, just reply here and I'll have another look; there's no need to
re-submit the merge-proposal.
review needsfixing
On Wed, 2011-03-02 at 14:59 +0000, Angus Ainslie wrote:
[...]
> === modified file 'linaro_
> --- linaro_
> +++ linaro_
> @@ -27,9 +27,12 @@
> import glob
> import os
> import re
> +import tempfile
> +import struct
>
> from linaro_media_create import cmd_runner
> from linaro_
> +from binascii import crc32
This import should be together with the other ones from the standard
library.
>
> # Notes:
> # * geometry is currently always 255 heads and 63 sectors due to limitations of
> @@ -61,6 +64,44 @@
> # root partition; at least 50 MiB; XXX this shouldn't be hardcoded
> ROOT_MIN_SIZE_S = align_up(50 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
>
> +# Samsung v310 implementation notes
> +# * BL1 (SPL) is expected at offset +1s and is 32s long
> +# * BL2 (u-boot) is loaded at a raw MMC offset of +65s by BL1 which currently
> +# doesn't support FAT
> +# * the u-boot environment is at +33s and is 32s long (16 KiB)
> +# * currently, some hardware issues on certain boards causes u-boot to not be
> +# able to use FAT to load uImage and uInitrd (or boot.scr); as a temporary
> +# workaround, these are loaded from +1089s and +9281s respectively
> +# * hence we hardcode all offsets, make sure that the files aren't larger than
> +# their reserved spot, and create a bootloader partition from the first
> +# sector after MBR up to end of initrd
> +SAMSUNG_
> +SAMSUNG_
> +SAMSUNG_
> +SAMSUNG_
> +assert SAMSUNG_
> +assert SAMSUNG_
> + "BL1 expects u-boot environment to be 16 KiB")
> +SAMSUNG_
> +SAMSUNG_
> +assert SAMSUNG_
> + "BL1 expects BL2 (u-boot) to be 512 KiB")
> +SAMSUNG_
> +SAMSUNG_
> +assert SAMSUNG_
> + "BL2 (u-boot) expects uImage at +1089s")
> +assert SAMSUNG_
> + "BL2 (u-boot) expects uImage to be 4 MiB")
> +SAMSUNG_
> + SAMSUNG_
> +SAMSUNG_
> +SAMSUNG_
> +assert SAMSUNG_
> + "BL2 (u-boot) expects uInitrd at +9281s")
> +assert SAMSUNG_
> + "BL2 (u-boot) expects uInitrd to be 100 MiB")
> +assert SAMSUNG_
> + "Only c...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : | # |
Angus, Guilherme,
For some of the comments which I quote from Guilherme below, I'm the
original author of the change and am happy to provide fixes:
On Wed, Mar 02, 2011, Guilherme Salgado wrote:
> > - def _get_boot_cmd(cls, is_live, is_lowmem, consoles, rootfs_uuid):
> > - """Get the boot command for this board.
> > + def _get_bootcmd(cls):
> Since this doesn't take any arguments it'd be nicer if it was a property
> (you just have to decorate it with @classproperty instead of
> @classmethod). Would you mind doing that?
Makes sense to me
> > +def _dd(input_file, output_file, block_size=
> > + skip=None):
> Care to add a docstring to this function?
Ack
> > + boot_script_data = (
> > + "setenv bootcmd '%(bootcmd)s'\n"
> > + "setenv bootargs '%(bootargs)s'\n"
> > + "boot"
> > + % boot_env)
> The indentation here is one level off.
Ack
> > + # XXX need to check that the length of imx_file is smaller than
> > + # LOADER_MIN_SIZE_S
> Is it hard to do this or can we do it now? If there's any reason for
> not doing it now, would you mind filing a bug and putting a link to the
> bug here?
No; this wasn't properly done for other boards and when I realized this
I filed LP #722650; it was just distracting for me to do it
immediately.
> > +def install_
> > + # XXX need to check that the length of env_file is smaller than
> > + # SAMSUNG_
> > + _dd(env_file, boot_device_
> > + seek=SAMSUNG_
>
> Again, if there's any reason why we can't do the 3 checks above now,
> there should be bugs filed and a link to them here.
Same
> > +def install_
> > + # v310_file is a binary with the same layout as BL1 + u-boot environment +
> > + # BL2; write BL1 (SPL) piece first (SAMSUNG_
> > + # the file and +SAMSUNG_
> > + # piece (rest of the file starting at +(SAMSUNG_
> > + # SAMSUNG_
> > + # +(SAMSUNG_
>
> Care to convert this into a docstring? It'd also be nice if you could
> expand abbreviations like BL* and SPL the first time they're used.
Ok; BL0 is Samsung specific terminology for the first stage bootloader,
BL1 is the SPL (secondary program loader)
> > - 'sudo', 'dd', 'if=imx_file', 'of=boot_
> > - 'seek=1', 'conv=notrunc']
> > + 'sudo', 'dd', 'if=imx_file', 'of=boot_
> > + 'conv=notrunc', 'seek=2']
>
> Why are we using bs=512 and seek=2 in install_
> That surely isn't related to support for your board, is it?
Hmm I'm not sure where my other commit went, but this was preparation
to use the _dd() function which defaults to SECTOR_SIZE (512); this
makes install_
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Angus Ainslie (angus-akkea) wrote : | # |
James,
Do you have any more comments before I resubmit ?
Angus
On Wed, Mar 2, 2011 at 12:28 PM, Loïc Minier <email address hidden> wrote:
> Angus, Guilherme,
>
> For some of the comments which I quote from Guilherme below, I'm the
> original author of the change and am happy to provide fixes:
>
> On Wed, Mar 02, 2011, Guilherme Salgado wrote:
>> > - def _get_boot_cmd(cls, is_live, is_lowmem, consoles, rootfs_uuid):
>> > - """Get the boot command for this board.
>> > + def _get_bootcmd(cls):
>> Since this doesn't take any arguments it'd be nicer if it was a property
>> (you just have to decorate it with @classproperty instead of
>> @classmethod). Would you mind doing that?
>
> Makes sense to me
>
>> > +def _dd(input_file, output_file, block_size=
>> > + skip=None):
>> Care to add a docstring to this function?
>
> Ack
>
>> > + boot_script_data = (
>> > + "setenv bootcmd '%(bootcmd)s'\n"
>> > + "setenv bootargs '%(bootargs)s'\n"
>> > + "boot"
>> > + % boot_env)
>> The indentation here is one level off.
>
> Ack
>
>> > + # XXX need to check that the length of imx_file is smaller than
>> > + # LOADER_MIN_SIZE_S
>> Is it hard to do this or can we do it now? If there's any reason for
>> not doing it now, would you mind filing a bug and putting a link to the
>> bug here?
>
> No; this wasn't properly done for other boards and when I realized this
> I filed LP #722650; it was just distracting for me to do it
> immediately.
>
>> > +def install_
>> > + # XXX need to check that the length of env_file is smaller than
>> > + # SAMSUNG_
>> > + _dd(env_file, boot_device_
>> > + seek=SAMSUNG_
>>
>> Again, if there's any reason why we can't do the 3 checks above now,
>> there should be bugs filed and a link to them here.
>
> Same
>
>> > +def install_
>> > + # v310_file is a binary with the same layout as BL1 + u-boot environment +
>> > + # BL2; write BL1 (SPL) piece first (SAMSUNG_
>> > + # the file and +SAMSUNG_
>> > + # piece (rest of the file starting at +(SAMSUNG_
>> > + # SAMSUNG_
>> > + # +(SAMSUNG_
>>
>> Care to convert this into a docstring? It'd also be nice if you could
>> expand abbreviations like BL* and SPL the first time they're used.
>
> Ok; BL0 is Samsung specific terminology for the first stage bootloader,
> BL1 is the SPL (secondary program loader)
>
>> > - 'sudo', 'dd', 'if=imx_file', 'of=boot_
>> > - 'seek=1', 'conv=notrunc']
>> > + 'sudo', 'dd', 'if=imx_file', 'of=boot_
>> > + 'conv=notrunc', 'seek=2']
>>
>> Why are we using bs=512 and seek=2 in install_
>> That surely isn't related to support for your board, is it?
>
> Hmm I'm ...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Guilherme Salgado (salgado) wrote : | # |
On Wed, 2011-03-02 at 19:28 +0000, Loïc Minier wrote:
> Angus, Guilherme,
>
> For some of the comments which I quote from Guilherme below, I'm the
> original author of the change and am happy to provide fixes:
Cool, thanks Loïc.
> > > + # XXX need to check that the length of imx_file is smaller than
> > > + # LOADER_MIN_SIZE_S
> > Is it hard to do this or can we do it now? If there's any reason for
> > not doing it now, would you mind filing a bug and putting a link to the
> > bug here?
[...]
> > > - 'sudo', 'dd', 'if=imx_file', 'of=boot_
> > > - 'seek=1', 'conv=notrunc']
> > > + 'sudo', 'dd', 'if=imx_file', 'of=boot_
> > > + 'conv=notrunc', 'seek=2']
> >
> > Why are we using bs=512 and seek=2 in install_
> > That surely isn't related to support for your board, is it?
>
> Hmm I'm not sure where my other commit went, but this was preparation
> to use the _dd() function which defaults to SECTOR_SIZE (512); this
> makes install_
Well, you could just pass bs=1024 and seek=1 to the _dd() call in
install_
default bs (512) has the same effect?
--
Guilherme Salgado <https:/
- 308. By Angus Ainslie
-
fix review comments from salgado
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : | # |
On Wed, Mar 02, 2011, Guilherme Salgado wrote:
> Well, you could just pass bs=1024 and seek=1 to the _dd() call in
> install_
> default bs (512) has the same effect?
Yes; it's exactly the same thing; it was just a bit nicer to express
the offset in sectors (2) instead of absolute (1024) since dd works on
blocks which are by default of block_size=
--
Loïc Minier
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
James Westby (james-w) wrote : | # |
Nope, I'm happy with Loïc and Guilherme reviewing, and think we should
get this landed :-)
Thanks,
James
On Wed, 2 Mar 2011 12:47:17 -0700, Angus Ainslie <email address hidden> wrote:
> James,
>
> Do you have any more comments before I resubmit ?
>
> Angus
>
> On Wed, Mar 2, 2011 at 12:28 PM, Loïc Minier <email address hidden> wrote:
> > Angus, Guilherme,
> >
> > For some of the comments which I quote from Guilherme below, I'm the
> > original author of the change and am happy to provide fixes:
> >
> > On Wed, Mar 02, 2011, Guilherme Salgado wrote:
> >> > - def _get_boot_cmd(cls, is_live, is_lowmem, consoles, rootfs_uuid):
> >> > - """Get the boot command for this board.
> >> > + def _get_bootcmd(cls):
> >> Since this doesn't take any arguments it'd be nicer if it was a property
> >> (you just have to decorate it with @classproperty instead of
> >> @classmethod). Would you mind doing that?
> >
> > Makes sense to me
> >
> >> > +def _dd(input_file, output_file, block_size=
> >> > + skip=None):
> >> Care to add a docstring to this function?
> >
> > Ack
> >
> >> > + boot_script_data = (
> >> > + "setenv bootcmd '%(bootcmd)s'\n"
> >> > + "setenv bootargs '%(bootargs)s'\n"
> >> > + "boot"
> >> > + % boot_env)
> >> The indentation here is one level off.
> >
> > Ack
> >
> >> > + # XXX need to check that the length of imx_file is smaller than
> >> > + # LOADER_MIN_SIZE_S
> >> Is it hard to do this or can we do it now? If there's any reason for
> >> not doing it now, would you mind filing a bug and putting a link to the
> >> bug here?
> >
> > No; this wasn't properly done for other boards and when I realized this
> > I filed LP #722650; it was just distracting for me to do it
> > immediately.
> >
> >> > +def install_
> >> > + # XXX need to check that the length of env_file is smaller than
> >> > + # SAMSUNG_
> >> > + _dd(env_file, boot_device_
> >> > + seek=SAMSUNG_
> >>
> >> Again, if there's any reason why we can't do the 3 checks above now,
> >> there should be bugs filed and a link to them here.
> >
> > Same
> >
> >> > +def install_
> >> > + # v310_file is a binary with the same layout as BL1 + u-boot environment +
> >> > + # BL2; write BL1 (SPL) piece first (SAMSUNG_
> >> > + # the file and +SAMSUNG_
> >> > + # piece (rest of the file starting at +(SAMSUNG_
> >> > + # SAMSUNG_
> >> > + # +(SAMSUNG_
> >>
> >> Care to convert this into a docstring? It'd also be nice if you could
> >> expand abbreviations like BL* and SPL the first time they're used.
> >
> > Ok; BL0 is Samsung specific terminology for the first stage bootloader,
> > BL1 is the SPL (secondary program loader)
> >
> >> > - 'sudo', 'dd', 'if=imx_file', 'of=boot_
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Loïc Minier (lool) wrote : | # |
I've proposed merging lp:~lool/linaro-image-tools/samsung-v310-v3 into
lp:~angus-akkea/linaro-image-tools/Samsung-SMDKV310; see:
https:/
I think it addresses all issues; not all Samsung install() functions
are tested, but they are trivially identical to the mx5 one.
--
Loïc Minier
- 309. By Angus Ainslie
-
Merge in Guilherme suggestions for Loic's brnach
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Guilherme Salgado (salgado) wrote : | # |
Looks good to me, but there's a new conflict that needs to be resolved
Preview Diff
1 | === modified file 'linaro_media_create/boards.py' |
2 | --- linaro_media_create/boards.py 2011-03-03 13:44:11 +0000 |
3 | +++ linaro_media_create/boards.py 2011-03-05 19:28:12 +0000 |
4 | @@ -28,7 +28,13 @@ |
5 | import glob |
6 | import os |
7 | import re |
8 | -import tempfile |
9 | +<<<<<<< TREE |
10 | +import tempfile |
11 | +======= |
12 | +import tempfile |
13 | +import struct |
14 | +from binascii import crc32 |
15 | +>>>>>>> MERGE-SOURCE |
16 | |
17 | from linaro_media_create import cmd_runner |
18 | from linaro_media_create.partitions import SECTOR_SIZE |
19 | @@ -63,6 +69,44 @@ |
20 | # root partition; at least 50 MiB; XXX this shouldn't be hardcoded |
21 | ROOT_MIN_SIZE_S = align_up(50 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
22 | |
23 | +# Samsung v310 implementation notes |
24 | +# * BL1 (SPL) is expected at offset +1s and is 32s long |
25 | +# * BL2 (u-boot) is loaded at a raw MMC offset of +65s by BL1 which currently |
26 | +# doesn't support FAT |
27 | +# * the u-boot environment is at +33s and is 32s long (16 KiB) |
28 | +# * currently, some hardware issues on certain boards causes u-boot to not be |
29 | +# able to use FAT to load uImage and uInitrd (or boot.scr); as a temporary |
30 | +# workaround, these are loaded from +1089s and +9281s respectively |
31 | +# * hence we hardcode all offsets, make sure that the files aren't larger than |
32 | +# their reserved spot, and create a bootloader partition from the first |
33 | +# sector after MBR up to end of initrd |
34 | +SAMSUNG_V310_BL1_START = 1 |
35 | +SAMSUNG_V310_BL1_LEN = 32 |
36 | +SAMSUNG_V310_ENV_START = SAMSUNG_V310_BL1_START + SAMSUNG_V310_BL1_LEN |
37 | +SAMSUNG_V310_ENV_LEN = 32 |
38 | +assert SAMSUNG_V310_ENV_START == 33, "BL1 expects u-boot environment at +33s" |
39 | +assert SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, ( |
40 | + "BL1 expects u-boot environment to be 16 KiB") |
41 | +SAMSUNG_V310_BL2_START = SAMSUNG_V310_ENV_START + SAMSUNG_V310_ENV_LEN |
42 | +SAMSUNG_V310_BL2_LEN = 1024 |
43 | +assert SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, ( |
44 | + "BL1 expects BL2 (u-boot) to be 512 KiB") |
45 | +SAMSUNG_V310_UIMAGE_START = SAMSUNG_V310_BL2_START + SAMSUNG_V310_BL2_LEN |
46 | +SAMSUNG_V310_UIMAGE_LEN = 8192 |
47 | +assert SAMSUNG_V310_UIMAGE_START == 1089, ( |
48 | + "BL2 (u-boot) expects uImage at +1089s") |
49 | +assert SAMSUNG_V310_UIMAGE_LEN * SECTOR_SIZE == 4 * 1024 * 1024, ( |
50 | + "BL2 (u-boot) expects uImage to be 4 MiB") |
51 | +SAMSUNG_V310_UINITRD_START = ( |
52 | + SAMSUNG_V310_UIMAGE_START + SAMSUNG_V310_UIMAGE_LEN) |
53 | +SAMSUNG_V310_UINITRD_RESERVED_LEN = 204800 |
54 | +SAMSUNG_V310_UINITRD_COPY_LEN = 32768 |
55 | +assert SAMSUNG_V310_UINITRD_START == 9281, ( |
56 | + "BL2 (u-boot) expects uInitrd at +9281s") |
57 | +assert SAMSUNG_V310_UINITRD_RESERVED_LEN * SECTOR_SIZE == 100 * 1024 * 1024, ( |
58 | + "BL2 (u-boot) expects uInitrd to be 100 MiB") |
59 | +assert SAMSUNG_V310_UINITRD_COPY_LEN * SECTOR_SIZE == 16 * 1024 * 1024, ( |
60 | + "Only copy 16MiB for a faster boot") |
61 | |
62 | def align_partition(min_start, min_length, start_alignment, end_alignment): |
63 | """Compute partition start and end offsets based on specified constraints. |
64 | @@ -81,6 +125,14 @@ |
65 | return start, end, length |
66 | |
67 | |
68 | +class classproperty(object): |
69 | + """A descriptor that provides @property behavior on class methods.""" |
70 | + def __init__(self, getter): |
71 | + self.getter = getter |
72 | + def __get__(self, instance, cls): |
73 | + return self.getter(cls) |
74 | + |
75 | + |
76 | class BoardConfig(object): |
77 | """The configuration used when building an image for a board.""" |
78 | # These attributes may not need to be redefined on some subclasses. |
79 | @@ -139,9 +191,24 @@ |
80 | return '%s,%s,%s,*\n%s,,,-' % ( |
81 | boot_start, boot_len, partition_type, root_start) |
82 | |
83 | + @classproperty |
84 | + def bootcmd(cls): |
85 | + """Get the bootcmd for this board. |
86 | + |
87 | + In general subclasses should not have to override this. |
88 | + """ |
89 | + replacements = dict( |
90 | + mmc_option=cls.mmc_option, kernel_addr=cls.kernel_addr, |
91 | + initrd_addr=cls.initrd_addr) |
92 | + return ( |
93 | + "fatload mmc %(mmc_option)s %(kernel_addr)s " |
94 | + "uImage; fatload mmc %(mmc_option)s %(initrd_addr)s uInitrd; " |
95 | + "bootm %(kernel_addr)s %(initrd_addr)s" |
96 | + % replacements) |
97 | + |
98 | @classmethod |
99 | - def _get_boot_cmd(cls, is_live, is_lowmem, consoles, rootfs_uuid): |
100 | - """Get the boot command for this board. |
101 | + def _get_bootargs(cls, is_live, is_lowmem, consoles, rootfs_uuid): |
102 | + """Get the bootargs for this board. |
103 | |
104 | In general subclasses should not have to override this. |
105 | """ |
106 | @@ -161,30 +228,37 @@ |
107 | lowmem_opt = 'only-ubiquity' |
108 | |
109 | replacements = dict( |
110 | - mmc_option=cls.mmc_option, kernel_addr=cls.kernel_addr, |
111 | - initrd_addr=cls.initrd_addr, serial_opts=serial_opts, |
112 | + serial_opts=serial_opts, |
113 | lowmem_opt=lowmem_opt, boot_snippet=boot_snippet, |
114 | boot_args_options=boot_args_options) |
115 | return ( |
116 | - "setenv bootcmd 'fatload mmc %(mmc_option)s %(kernel_addr)s " |
117 | - "uImage; fatload mmc %(mmc_option)s %(initrd_addr)s uInitrd; " |
118 | - "bootm %(kernel_addr)s %(initrd_addr)s'\n" |
119 | - "setenv bootargs '%(serial_opts)s %(lowmem_opt)s " |
120 | - "%(boot_snippet)s %(boot_args_options)s'\n" |
121 | - "boot" % replacements) |
122 | + "%(serial_opts)s %(lowmem_opt)s " |
123 | + "%(boot_snippet)s %(boot_args_options)s" |
124 | + % replacements) |
125 | + |
126 | + @classmethod |
127 | + def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_uuid): |
128 | + """Get the boot environment for this board. |
129 | + |
130 | + In general subclasses should not have to override this. |
131 | + """ |
132 | + boot_env = {} |
133 | + boot_env["bootargs"] = cls._get_bootargs( |
134 | + is_live, is_lowmem, consoles, rootfs_uuid) |
135 | + boot_env["bootcmd"] = cls.bootcmd |
136 | + return boot_env |
137 | |
138 | @classmethod |
139 | def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles, |
140 | - root_dir, rootfs_uuid, boot_dir, boot_script, |
141 | + chroot_dir, rootfs_uuid, boot_dir, boot_script, |
142 | boot_device_or_file): |
143 | - boot_cmd = cls._get_boot_cmd( |
144 | - is_live, is_lowmem, consoles, rootfs_uuid) |
145 | + boot_env = cls._get_boot_env(is_live, is_lowmem, consoles, rootfs_uuid) |
146 | cls._make_boot_files( |
147 | - uboot_parts_dir, boot_cmd, root_dir, boot_dir, boot_script, |
148 | + uboot_parts_dir, boot_env, chroot_dir, boot_dir, boot_script, |
149 | boot_device_or_file) |
150 | |
151 | @classmethod |
152 | - def _make_boot_files(cls, uboot_parts_dir, boot_cmd, root_dir, boot_dir, |
153 | + def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir, |
154 | boot_script, boot_device_or_file): |
155 | """Make the necessary boot files for this board. |
156 | |
157 | @@ -194,14 +268,6 @@ |
158 | raise NotImplementedError() |
159 | |
160 | |
161 | -class classproperty(object): |
162 | - """A descriptor that provides @property behavior on class methods.""" |
163 | - def __init__(self, getter): |
164 | - self.getter = getter |
165 | - def __get__(self, instance, cls): |
166 | - return self.getter(cls) |
167 | - |
168 | - |
169 | class OmapConfig(BoardConfig): |
170 | uboot_in_boot_part = True |
171 | |
172 | @@ -247,24 +313,24 @@ |
173 | |
174 | @classmethod |
175 | def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles, |
176 | - root_dir, rootfs_uuid, boot_dir, boot_script, |
177 | + chroot_dir, rootfs_uuid, boot_dir, boot_script, |
178 | boot_device_or_file): |
179 | # XXX: This is also part of our temporary hack to fix bug 697824; we |
180 | # need to call set_appropriate_serial_tty() before doing anything that |
181 | # may use cls.serial_tty. |
182 | - cls.set_appropriate_serial_tty(root_dir) |
183 | + cls.set_appropriate_serial_tty(chroot_dir) |
184 | super(OmapConfig, cls).make_boot_files( |
185 | - uboot_parts_dir, is_live, is_lowmem, consoles, root_dir, |
186 | + uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir, |
187 | rootfs_uuid, boot_dir, boot_script, boot_device_or_file) |
188 | |
189 | @classmethod |
190 | - def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir, |
191 | - boot_dir, boot_script, boot_device_or_file): |
192 | + def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir, |
193 | + boot_script, boot_device_or_file): |
194 | install_omap_boot_loader(chroot_dir, boot_dir) |
195 | make_uImage( |
196 | cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir) |
197 | make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir) |
198 | - make_boot_script(boot_cmd, boot_script) |
199 | + make_boot_script(boot_env, boot_script) |
200 | make_boot_ini(boot_script, boot_dir) |
201 | |
202 | |
203 | @@ -317,12 +383,12 @@ |
204 | uboot_flavor = None |
205 | |
206 | @classmethod |
207 | - def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir, |
208 | - boot_dir, boot_script, boot_device_or_file): |
209 | + def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir, |
210 | + boot_script, boot_device_or_file): |
211 | make_uImage( |
212 | cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir) |
213 | make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir) |
214 | - make_boot_script(boot_cmd, boot_script) |
215 | + make_boot_script(boot_env, boot_script) |
216 | make_boot_ini(boot_script, boot_dir) |
217 | |
218 | |
219 | @@ -343,12 +409,12 @@ |
220 | mmc_option = '1:1' |
221 | |
222 | @classmethod |
223 | - def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir, |
224 | - boot_dir, boot_script, boot_device_or_file): |
225 | + def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir, |
226 | + boot_script, boot_device_or_file): |
227 | make_uImage( |
228 | cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir) |
229 | make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir) |
230 | - make_boot_script(boot_cmd, boot_script) |
231 | + make_boot_script(boot_env, boot_script) |
232 | |
233 | |
234 | class Mx5Config(BoardConfig): |
235 | @@ -392,15 +458,15 @@ |
236 | loader_start, loader_len, boot_start, boot_len, root_start) |
237 | |
238 | @classmethod |
239 | - def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir, |
240 | - boot_dir, boot_script, boot_device_or_file): |
241 | + def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir, |
242 | + boot_script, boot_device_or_file): |
243 | uboot_file = os.path.join( |
244 | chroot_dir, 'usr', 'lib', 'u-boot', cls.uboot_flavor, 'u-boot.imx') |
245 | install_mx5_boot_loader(uboot_file, boot_device_or_file) |
246 | make_uImage( |
247 | cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir) |
248 | make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir) |
249 | - make_boot_script(boot_cmd, boot_script) |
250 | + make_boot_script(boot_env, boot_script) |
251 | |
252 | |
253 | class EfikamxConfig(Mx5Config): |
254 | @@ -427,12 +493,90 @@ |
255 | fat_size = 16 |
256 | |
257 | @classmethod |
258 | - def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir, |
259 | - boot_dir, boot_script, boot_device_or_file): |
260 | + def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir, |
261 | + boot_script, boot_device_or_file): |
262 | make_uImage( |
263 | cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir) |
264 | make_uInitrd(uboot_parts_dir, cls.kernel_suffix, boot_dir) |
265 | |
266 | +class SMDKV310Config(BoardConfig): |
267 | + serial_tty = 'ttySAC1' |
268 | + extra_serial_opts = 'console=%s,115200n8' % serial_tty |
269 | + kernel_addr = '0x40007000' |
270 | + initrd_addr = '0x41000000' |
271 | + load_addr = '0x40008000' |
272 | + kernel_suffix = 's5pv310' |
273 | + boot_script = 'boot.scr' |
274 | + mmc_part_offset = 1 |
275 | + mmc_option = '0:2' |
276 | + |
277 | + @classmethod |
278 | + def get_sfdisk_cmd(cls, should_align_boot_part=False): |
279 | + # bootloader partition needs to hold everything from BL1 to uInitrd |
280 | + # inclusive |
281 | + min_len = ( |
282 | + SAMSUNG_V310_UINITRD_START + SAMSUNG_V310_UINITRD_RESERVED_LEN - |
283 | + SAMSUNG_V310_BL1_START) |
284 | + |
285 | + # bootloader partition |
286 | + loader_start, loader_end, loader_len = align_partition( |
287 | + 1, min_len, 1, PART_ALIGN_S) |
288 | + |
289 | + # FAT boot partition |
290 | + boot_start, boot_end, boot_len = align_partition( |
291 | + loader_end + 1, BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
292 | + |
293 | + # root partition |
294 | + # we ignore _root_end / _root_len and return a sfdisk command to |
295 | + # instruct the use of all remaining space; XXX if we had some root size |
296 | + # config, we could do something more sensible |
297 | + root_start, _root_end, _root_len = align_partition( |
298 | + boot_end + 1, ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
299 | + |
300 | + return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % ( |
301 | + loader_start, loader_len, boot_start, boot_len, root_start) |
302 | + |
303 | + @classmethod |
304 | + def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_uuid): |
305 | + boot_env = super(SMDKV310Config, cls)._get_boot_env( |
306 | + is_live, is_lowmem, consoles, rootfs_uuid) |
307 | + |
308 | + boot_env["ethact"] = "smc911x-0" |
309 | + boot_env["ethaddr"] = "00:40:5c:26:0a:5b" |
310 | + # XXX fixme once FAT support is fixed in u-boot bug 727978 |
311 | + boot_env["bootcmd"] = ( |
312 | + "movi read kernel %(kernel_addr)s; " |
313 | + "movi read rootfs %(initrd_addr)s %(rootfs_size)s; " |
314 | + "bootm %(kernel_addr)s %(initrd_addr)s" % { |
315 | + 'kernel_addr': cls.kernel_addr, |
316 | + 'initrd_addr': cls.initrd_addr, |
317 | + 'rootfs_size': hex(SAMSUNG_V310_UINITRD_COPY_LEN * SECTOR_SIZE)}) |
318 | + |
319 | + return boot_env |
320 | + |
321 | + @classmethod |
322 | + def _make_boot_files(cls, uboot_parts_dir, boot_env, chroot_dir, boot_dir, |
323 | + boot_script, boot_device_or_file): |
324 | + uboot_file = os.path.join( |
325 | + chroot_dir, 'usr', 'lib', 'u-boot', 'smdkv310', 'u-boot.v310') |
326 | + install_smdkv310_boot_loader(uboot_file, boot_device_or_file) |
327 | + |
328 | + env_size = SAMSUNG_V310_ENV_LEN * SECTOR_SIZE |
329 | + env_file = make_flashable_env(boot_env, env_size) |
330 | + install_smdkv310_boot_env(env_file, boot_device_or_file) |
331 | + |
332 | + uImage_file = make_uImage( |
333 | + cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir) |
334 | + install_smdkv310_uImage(uImage_file, boot_device_or_file) |
335 | + |
336 | + uInitrd_file = make_uInitrd( |
337 | + uboot_parts_dir, cls.kernel_suffix, boot_dir) |
338 | + install_smdkv310_initrd(uInitrd_file, boot_device_or_file) |
339 | + |
340 | + # unused at the moment once FAT support enabled for the |
341 | + # Samsung u-boot this can be used bug 727978 |
342 | + #make_boot_script(boot_env, boot_script) |
343 | + |
344 | |
345 | board_configs = { |
346 | 'beagle': BeagleConfig, |
347 | @@ -443,9 +587,26 @@ |
348 | 'efikamx': EfikamxConfig, |
349 | 'mx51evk': Mx51evkConfig, |
350 | 'overo': OveroConfig, |
351 | + 'smdkv310': SMDKV310Config, |
352 | } |
353 | |
354 | |
355 | +def _dd(input_file, output_file, block_size=SECTOR_SIZE, count=None, seek=None, |
356 | + skip=None): |
357 | + """Wrapper around the dd command""" |
358 | + cmd = [ |
359 | + "dd", "if=%s" % input_file, "of=%s" % output_file, |
360 | + "bs=%s" % block_size, "conv=notrunc"] |
361 | + if count is not None: |
362 | + cmd.append("count=%s" % count) |
363 | + if seek is not None: |
364 | + cmd.append("seek=%s" % seek) |
365 | + if skip is not None: |
366 | + cmd.append("skip=%s" % skip) |
367 | + proc = cmd_runner.run(cmd, as_root=True) |
368 | + proc.wait() |
369 | + |
370 | + |
371 | def _run_mkimage(img_type, load_addr, entry_point, name, img_data, img, |
372 | stdout=None, as_root=True): |
373 | cmd = ['mkimage', |
374 | @@ -484,18 +645,26 @@ |
375 | img_data = _get_file_matching( |
376 | '%s/vmlinuz-*-%s' % (uboot_parts_dir, suffix)) |
377 | img = '%s/uImage' % boot_disk |
378 | - return _run_mkimage( |
379 | + _run_mkimage( |
380 | 'kernel', load_addr, load_addr, 'Linux', img_data, img) |
381 | + return img |
382 | |
383 | |
384 | def make_uInitrd(uboot_parts_dir, suffix, boot_disk): |
385 | img_data = _get_file_matching( |
386 | '%s/initrd.img-*-%s' % (uboot_parts_dir, suffix)) |
387 | img = '%s/uInitrd' % boot_disk |
388 | - return _run_mkimage('ramdisk', '0', '0', 'initramfs', img_data, img) |
389 | - |
390 | - |
391 | -def make_boot_script(boot_script_data, boot_script): |
392 | + _run_mkimage('ramdisk', '0', '0', 'initramfs', img_data, img) |
393 | + return img |
394 | + |
395 | + |
396 | +def make_boot_script(boot_env, boot_script): |
397 | + boot_script_data = ( |
398 | + "setenv bootcmd '%(bootcmd)s'\n" |
399 | + "setenv bootargs '%(bootargs)s'\n" |
400 | + "boot" |
401 | + % boot_env) |
402 | + |
403 | # Need to save the boot script data into a file that will be passed to |
404 | # mkimage. |
405 | _, tmpfile = tempfile.mkstemp() |
406 | @@ -509,15 +678,40 @@ |
407 | 'script', '0', '0', 'boot script', plain_boot_script, boot_script) |
408 | |
409 | |
410 | +def make_flashable_env(boot_env, env_size): |
411 | + env_strings = ["%s=%s" % (k, v) for k, v in boot_env.items()] |
412 | + env_strings.sort() |
413 | + env = struct.pack('B', 0).join(env_strings) |
414 | + |
415 | + # we still need to zero-terminate the last string, and 4 bytes for crc |
416 | + assert len(env) + 1 + 4 <= env_size, ( |
417 | + "environment doesn't fit in %s bytes" % env_size) |
418 | + |
419 | + # pad the rest of the env for the CRC calc; the "s" format will write zero |
420 | + # bytes to pad the (empty) string to repeat count |
421 | + env += struct.pack('%ss' % (env_size - len(env) - 4), '') |
422 | + |
423 | + crc = crc32(env) |
424 | + env = struct.pack('<i', crc) + env |
425 | + |
426 | + _, tmpfile = tempfile.mkstemp() |
427 | + |
428 | + with open(tmpfile, 'w') as fd: |
429 | + fd.write(env) |
430 | + |
431 | + return tmpfile |
432 | + |
433 | + |
434 | def install_mx5_boot_loader(imx_file, boot_device_or_file): |
435 | - proc = cmd_runner.run([ |
436 | - "dd", |
437 | - "if=%s" % imx_file, |
438 | - "of=%s" % boot_device_or_file, |
439 | - "bs=1024", |
440 | - "seek=1", |
441 | - "conv=notrunc"], as_root=True) |
442 | - proc.wait() |
443 | + # bootloader partition starts at +1s but we write the file at +2s, so we |
444 | + # need to check that the bootloader partition minus 1s is at least as large |
445 | + # as the u-boot binary; note that the real bootloader partition might be |
446 | + # larger than LOADER_MIN_SIZE_S, but if u-boot is larger it's a sign we |
447 | + # need to bump LOADER_MIN_SIZE_S |
448 | + max_size = (LOADER_MIN_SIZE_S - 1) * SECTOR_SIZE |
449 | + assert os.path.getsize(imx_file) <= max_size, ( |
450 | + "%s is larger than guaranteed bootloader partition size" % imx_file) |
451 | + _dd(imx_file, boot_device_or_file, seek=2) |
452 | |
453 | |
454 | def _get_mlo_file(chroot_dir): |
455 | @@ -554,3 +748,54 @@ |
456 | proc = cmd_runner.run( |
457 | ["cp", "-v", boot_script, "%s/boot.ini" % boot_disk], as_root=True) |
458 | proc.wait() |
459 | + |
460 | + |
461 | +def install_smdkv310_uImage(uImage_file, boot_device_or_file): |
462 | + # the layout keeps SAMSUNG_V310_UIMAGE_LEN sectors for uImage; make sure |
463 | + # uImage isn't actually larger or it would be truncated |
464 | + max_size = SAMSUNG_V310_UIMAGE_LEN * SECTOR_SIZE |
465 | + assert os.path.getsize(uImage_file) <= max_size, ( |
466 | + "%s is larger than the allocated v310 uImage length" % uImage_file) |
467 | + _dd(uImage_file, boot_device_or_file, count=SAMSUNG_V310_UIMAGE_LEN, |
468 | + seek=SAMSUNG_V310_UIMAGE_START) |
469 | + |
470 | + |
471 | +def install_smdkv310_initrd(initrd_file, boot_device_or_file): |
472 | + # the layout keeps SAMSUNG_V310_UINITRD_RESERVED_LEN sectors for uInitrd |
473 | + # but only SAMSUNG_V310_UINITRD_COPY_LEN sectors are loaded into memory; |
474 | + # make sure uInitrd isn't actually larger or it would be truncated in |
475 | + # memory |
476 | + max_size = SAMSUNG_V310_UINITRD_COPY_LEN * SECTOR_SIZE |
477 | + assert os.path.getsize(initrd_file) <= max_size, ( |
478 | + "%s is larger than the v310 uInitrd length as used by u-boot" |
479 | + % initrd_file) |
480 | + _dd(initrd_file, boot_device_or_file, |
481 | + count=SAMSUNG_V310_UINITRD_COPY_LEN, |
482 | + seek=SAMSUNG_V310_UINITRD_START) |
483 | + |
484 | + |
485 | +def install_smdkv310_boot_env(env_file, boot_device_or_file): |
486 | + # the environment file is exactly SAMSUNG_V310_ENV_LEN as created by |
487 | + # make_flashable_env(), so we don't need to check the size of env_file |
488 | + _dd(env_file, boot_device_or_file, count=SAMSUNG_V310_ENV_LEN, |
489 | + seek=SAMSUNG_V310_ENV_START) |
490 | + |
491 | + |
492 | +def install_smdkv310_boot_loader(v310_file, boot_device_or_file): |
493 | + """Samsung specific terminology |
494 | + BL0 is the first stage bootloader, |
495 | + BL1 is the SPL (secondary program loader) |
496 | + v310_file is a binary with the same layout as BL1 + u-boot environment + |
497 | + BL2; write BL1 (SPL) piece first (SAMSUNG_V310_BL1_LEN sectors at +0s in |
498 | + the file and +SAMSUNG_V310_BL1_START on disk), then write BL2 (u-boot) |
499 | + piece (rest of the file starting at +(SAMSUNG_V310_BL1_LEN + |
500 | + SAMSUNG_V310_ENV_LEN)s in the file which is the same as |
501 | + +(SAMSUNG_V310_BL2_START - SAMSUNG_V310_BL1_START)s) |
502 | + """ |
503 | + _dd(v310_file, boot_device_or_file, count=SAMSUNG_V310_BL1_LEN, |
504 | + seek=SAMSUNG_V310_BL1_START) |
505 | + # XXX need to check that the length of v310_file - 64s is smaller than |
506 | + # SAMSUNG_V310_BL2_LEN |
507 | + _dd(v310_file, boot_device_or_file, seek=SAMSUNG_V310_BL2_START, |
508 | + skip=(SAMSUNG_V310_BL2_START - SAMSUNG_V310_BL1_START)) |
509 | + |
510 | |
511 | === modified file 'linaro_media_create/tests/test_media_create.py' |
512 | --- linaro_media_create/tests/test_media_create.py 2011-03-03 13:44:11 +0000 |
513 | +++ linaro_media_create/tests/test_media_create.py 2011-03-05 19:28:12 +0000 |
514 | @@ -43,9 +43,12 @@ |
515 | ) |
516 | import linaro_media_create |
517 | from linaro_media_create.boards import ( |
518 | + LOADER_MIN_SIZE_S, |
519 | + SECTOR_SIZE, |
520 | align_up, |
521 | align_partition, |
522 | board_configs, |
523 | + make_flashable_env, |
524 | install_mx5_boot_loader, |
525 | install_omap_boot_loader, |
526 | make_boot_script, |
527 | @@ -258,6 +261,15 @@ |
528 | 'make_boot_script'] |
529 | self.assertEqual(expected, self.funcs_calls) |
530 | |
531 | + def test_smdkv310_steps(self): |
532 | + self.make_boot_files(boards.SMDKV310Config) |
533 | + expected = [ |
534 | + 'install_smdkv310_boot_loader', 'make_flashable_env', |
535 | + 'install_smdkv310_boot_env', 'make_uImage', |
536 | + 'install_smdkv310_uImage', 'make_uInitrd', |
537 | + 'install_smdkv310_initrd',] |
538 | + self.assertEqual(expected, self.funcs_calls) |
539 | + |
540 | def test_ux500_steps(self): |
541 | self.make_boot_files(boards.Ux500Config) |
542 | expected = ['make_uImage', 'make_uInitrd', 'make_boot_script'] |
543 | @@ -372,44 +384,67 @@ |
544 | '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', |
545 | boards.Mx5Config.get_sfdisk_cmd()) |
546 | |
547 | + def test_smdkv310(self): |
548 | + self.assertEquals( |
549 | + '1,221183,0xDA\n221184,106496,0x0C,*\n327680,,,-', |
550 | + board_configs['smdkv310'].get_sfdisk_cmd()) |
551 | + |
552 | |
553 | class TestGetBootCmd(TestCase): |
554 | |
555 | def test_vexpress(self): |
556 | - boot_cmd = board_configs['vexpress']._get_boot_cmd( |
557 | + boot_commands = board_configs['vexpress']._get_boot_env( |
558 | is_live=False, is_lowmem=False, consoles=['ttyXXX'], |
559 | rootfs_uuid="deadbeef") |
560 | - expected = ( |
561 | - "setenv bootcmd 'fatload mmc 0:1 0x60008000 uImage; fatload mmc " |
562 | - "0:1 0x81000000 uInitrd; bootm 0x60008000 0x81000000'\nsetenv " |
563 | - "bootargs 'console=tty0 console=ttyAMA0,38400n8 console=ttyXXX " |
564 | - "root=UUID=deadbeef rootwait ro'\nboot") |
565 | - self.assertEqual(expected, boot_cmd) |
566 | + expected = { |
567 | + 'bootargs': 'console=tty0 console=ttyAMA0,38400n8 console=ttyXXX ' |
568 | + 'root=UUID=deadbeef rootwait ro', |
569 | + 'bootcmd': 'fatload mmc 0:1 0x60008000 uImage; ' |
570 | + 'fatload mmc 0:1 0x81000000 uInitrd; ' |
571 | + 'bootm 0x60008000 0x81000000'} |
572 | + self.assertEqual(expected, boot_commands) |
573 | |
574 | def test_mx5(self): |
575 | - boot_cmd = boards.Mx5Config._get_boot_cmd( |
576 | - is_live=False, is_lowmem=False, consoles=[], |
577 | - rootfs_uuid="deadbeef") |
578 | - expected = ( |
579 | - "setenv bootcmd 'fatload mmc 0:2 0x90000000 uImage; fatload mmc " |
580 | - "0:2 0x90800000 uInitrd; bootm 0x90000000 0x90800000'\nsetenv " |
581 | - "bootargs 'console=tty0 console=ttymxc0,115200n8 " |
582 | - "root=UUID=deadbeef rootwait ro'\nboot") |
583 | - self.assertEqual(expected, boot_cmd) |
584 | + boot_commands = boards.Mx5Config._get_boot_env( |
585 | + is_live=False, is_lowmem=False, consoles=[], |
586 | + rootfs_uuid="deadbeef") |
587 | + expected = { |
588 | + 'bootargs': 'console=tty0 console=ttymxc0,115200n8 ' |
589 | + 'root=UUID=deadbeef rootwait ro', |
590 | + 'bootcmd': 'fatload mmc 0:2 0x90000000 uImage; ' |
591 | + 'fatload mmc 0:2 0x90800000 uInitrd; ' |
592 | + 'bootm 0x90000000 0x90800000'} |
593 | + self.assertEqual(expected, boot_commands) |
594 | + |
595 | + def test_smdkv310(self): |
596 | + boot_commands = board_configs['smdkv310']._get_boot_env( |
597 | + is_live=False, is_lowmem=False, consoles=[], |
598 | + rootfs_uuid="deadbeef") |
599 | + expected = { |
600 | + 'bootargs': 'console=ttySAC1,115200n8 root=UUID=deadbeef ' |
601 | + 'rootwait ro', |
602 | + 'bootcmd': 'movi read kernel 0x40007000; ' |
603 | + 'movi read rootfs 0x41000000 0x1000000; ' |
604 | + 'bootm 0x40007000 0x41000000', |
605 | + 'ethact': 'smc911x-0', |
606 | + 'ethaddr': '00:40:5c:26:0a:5b'} |
607 | + self.assertEqual(expected, boot_commands) |
608 | |
609 | def test_ux500(self): |
610 | - boot_cmd = board_configs['ux500']._get_boot_cmd( |
611 | + boot_commands = board_configs['ux500']._get_boot_env( |
612 | is_live=False, is_lowmem=False, consoles=[], |
613 | rootfs_uuid="deadbeef") |
614 | - expected = ( |
615 | - "setenv bootcmd 'fatload mmc 1:1 0x00100000 uImage; fatload mmc " |
616 | - "1:1 0x08000000 uInitrd; bootm 0x00100000 0x08000000'\nsetenv " |
617 | - "bootargs 'console=tty0 console=ttyAMA2,115200n8 " |
618 | - "root=UUID=deadbeef rootwait ro earlyprintk rootdelay=1 fixrtc " |
619 | - "nocompcache mem=96M@0 mem_modem=32M@96M mem=44M@128M " |
620 | - "pmem=22M@172M mem=30M@194M mem_mali=32M@224M " |
621 | - "pmem_hwb=54M@256M hwmem=48M@302M mem=152M@360M'\nboot") |
622 | - self.assertEqual(expected, boot_cmd) |
623 | + expected = { |
624 | + 'bootargs': 'console=tty0 console=ttyAMA2,115200n8 ' |
625 | + 'root=UUID=deadbeef rootwait ro earlyprintk ' |
626 | + 'rootdelay=1 fixrtc nocompcache mem=96M@0 ' |
627 | + 'mem_modem=32M@96M mem=44M@128M pmem=22M@172M ' |
628 | + 'mem=30M@194M mem_mali=32M@224M pmem_hwb=54M@256M ' |
629 | + 'hwmem=48M@302M mem=152M@360M', |
630 | + 'bootcmd': 'fatload mmc 1:1 0x00100000 uImage; ' |
631 | + 'fatload mmc 1:1 0x08000000 uInitrd; ' |
632 | + 'bootm 0x00100000 0x08000000'} |
633 | + self.assertEqual(expected, boot_commands) |
634 | |
635 | def test_panda(self): |
636 | # XXX: To fix bug 697824 we have to change class attributes of our |
637 | @@ -417,17 +452,18 @@ |
638 | # don't interfere with us we'll reset that before doing anything. |
639 | config = board_configs['panda'] |
640 | config.serial_tty = config._serial_tty |
641 | - boot_cmd = config._get_boot_cmd( |
642 | + boot_commands = config._get_boot_env( |
643 | is_live=False, is_lowmem=False, consoles=[], |
644 | rootfs_uuid="deadbeef") |
645 | - expected = ( |
646 | - "setenv bootcmd 'fatload mmc 0:1 0x80200000 uImage; fatload mmc " |
647 | - "0:1 0x81600000 uInitrd; bootm 0x80200000 0x81600000'\nsetenv " |
648 | - "bootargs 'console=tty0 console=ttyO2,115200n8 " |
649 | - "root=UUID=deadbeef rootwait ro earlyprintk fixrtc nocompcache " |
650 | - "vram=32M omapfb.vram=0:8M mem=463M " |
651 | - "ip=none'\nboot") |
652 | - self.assertEqual(expected, boot_cmd) |
653 | + expected = { |
654 | + 'bootargs': 'console=tty0 console=ttyO2,115200n8 ' |
655 | + 'root=UUID=deadbeef rootwait ro earlyprintk fixrtc ' |
656 | + 'nocompcache vram=32M omapfb.vram=0:8M mem=463M ' |
657 | + 'ip=none', |
658 | + 'bootcmd': 'fatload mmc 0:1 0x80200000 uImage; ' |
659 | + 'fatload mmc 0:1 0x81600000 uInitrd; ' |
660 | + 'bootm 0x80200000 0x81600000'} |
661 | + self.assertEqual(expected, boot_commands) |
662 | |
663 | def test_beagle(self): |
664 | # XXX: To fix bug 697824 we have to change class attributes of our |
665 | @@ -435,17 +471,17 @@ |
666 | # don't interfere with us we'll reset that before doing anything. |
667 | config = board_configs['beagle'] |
668 | config.serial_tty = config._serial_tty |
669 | - boot_cmd = config._get_boot_cmd( |
670 | + boot_commands = config._get_boot_env( |
671 | is_live=False, is_lowmem=False, consoles=[], |
672 | rootfs_uuid="deadbeef") |
673 | - expected = ( |
674 | - "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; " |
675 | - "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 " |
676 | - "0x81600000'\nsetenv bootargs 'console=tty0 " |
677 | - "console=ttyO2,115200n8 root=UUID=deadbeef rootwait ro " |
678 | - "earlyprintk fixrtc nocompcache vram=12M " |
679 | - "omapfb.mode=dvi:1280x720MR-16@60'\nboot") |
680 | - self.assertEqual(expected, boot_cmd) |
681 | + expected = { |
682 | + 'bootargs': 'console=tty0 console=ttyO2,115200n8 ' |
683 | + 'root=UUID=deadbeef rootwait ro earlyprintk fixrtc ' |
684 | + 'nocompcache vram=12M omapfb.mode=dvi:1280x720MR-16@60', |
685 | + 'bootcmd': 'fatload mmc 0:1 0x80000000 uImage; ' |
686 | + 'fatload mmc 0:1 0x81600000 uInitrd; ' |
687 | + 'bootm 0x80000000 0x81600000'} |
688 | + self.assertEqual(expected, boot_commands) |
689 | |
690 | def test_overo(self): |
691 | # XXX: To fix bug 697824 we have to change class attributes of our |
692 | @@ -453,17 +489,19 @@ |
693 | # don't interfere with us we'll reset that before doing anything. |
694 | config = board_configs['overo'] |
695 | config.serial_tty = config._serial_tty |
696 | - boot_cmd = config._get_boot_cmd( |
697 | + boot_commands = config._get_boot_env( |
698 | is_live=False, is_lowmem=False, consoles=[], |
699 | rootfs_uuid="deadbeef") |
700 | - expected = ( |
701 | - "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; " |
702 | - "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 " |
703 | - "0x81600000'\nsetenv bootargs 'console=tty0 " |
704 | - "console=ttyO2,115200n8 root=UUID=deadbeef rootwait ro " |
705 | - "earlyprintk mpurate=500 vram=12M " |
706 | - "omapfb.mode=dvi:1024x768MR-16@60 omapdss.def_disp=dvi'\nboot") |
707 | - self.assertEqual(expected, boot_cmd) |
708 | + expected = { |
709 | + 'bootargs': 'console=tty0 console=ttyO2,115200n8 ' |
710 | + 'root=UUID=deadbeef rootwait ro earlyprintk ' |
711 | + 'mpurate=500 vram=12M ' |
712 | + 'omapfb.mode=dvi:1024x768MR-16@60 ' |
713 | + 'omapdss.def_disp=dvi', |
714 | + 'bootcmd': 'fatload mmc 0:1 0x80000000 uImage; ' |
715 | + 'fatload mmc 0:1 0x81600000 uInitrd; ' |
716 | + 'bootm 0x80000000 0x81600000'} |
717 | + self.assertEqual(expected, boot_commands) |
718 | |
719 | |
720 | class TestUnpackBinaryTarball(TestCaseWithFixtures): |
721 | @@ -586,14 +624,35 @@ |
722 | '-d', 'parts_dir/initrd.img-*-sub_arch', 'boot_disk/uInitrd'] |
723 | self.assertEqual([expected], fixture.mock.calls) |
724 | |
725 | + def test_make_flashable_env_too_small_env(self): |
726 | + env = {'verylong': 'evenlonger'} |
727 | + self.assertRaises(AssertionError, make_flashable_env, env, 8) |
728 | + |
729 | + def test_make_flashable_env(self): |
730 | + env_file = self.createTempFileAsFixture() |
731 | + self.useFixture(MockSomethingFixture( |
732 | + tempfile, "mkstemp", lambda: (None, env_file))) |
733 | + env = {'a': 'b', 'x': 'y'} |
734 | + make_flashable_env(env, 12) |
735 | + with open(env_file, "r") as fd: |
736 | + self.assertEqual("\x80\x29\x2E\x89a=b\x00x=y\x00", fd.read()) |
737 | + |
738 | def test_install_mx5_boot_loader(self): |
739 | fixture = self._mock_Popen() |
740 | - install_mx5_boot_loader("imx_file", "boot_device_or_file") |
741 | + imx_file = self.createTempFileAsFixture() |
742 | + install_mx5_boot_loader(imx_file, "boot_device_or_file") |
743 | expected = [ |
744 | - 'sudo', 'dd', 'if=imx_file', 'of=boot_device_or_file', 'bs=1024', |
745 | - 'seek=1', 'conv=notrunc'] |
746 | + 'sudo', 'dd', 'if=%s' % imx_file, 'of=boot_device_or_file', |
747 | + 'bs=512', 'conv=notrunc', 'seek=2'] |
748 | self.assertEqual([expected], fixture.mock.calls) |
749 | |
750 | + def test_install_mx5_boot_loader_too_large(self): |
751 | + self.useFixture(MockSomethingFixture( |
752 | + os.path, "getsize", |
753 | + lambda s: (LOADER_MIN_SIZE_S - 1) * SECTOR_SIZE + 1)) |
754 | + self.assertRaises(AssertionError, |
755 | + install_mx5_boot_loader, "imx_file", "boot_device_or_file") |
756 | + |
757 | def test_install_omap_boot_loader(self): |
758 | fixture = self._mock_Popen() |
759 | self.useFixture(MockSomethingFixture( |
760 | @@ -613,7 +672,8 @@ |
761 | fixture = self._mock_Popen() |
762 | boot_script_path = os.path.join(tempdir, 'boot.scr') |
763 | plain_boot_script_path = os.path.join(tempdir, 'boot.txt') |
764 | - make_boot_script('boot script data', boot_script_path) |
765 | + boot_env = {'bootargs': 'mybootargs', 'bootcmd': 'mybootcmd'} |
766 | + make_boot_script(boot_env, boot_script_path) |
767 | expected = [ |
768 | ['sudo', 'cp', '/tmp/random-abxzr', plain_boot_script_path], |
769 | ['sudo', 'mkimage', '-A', 'arm', '-O', 'linux', '-T', 'script', |
770 | @@ -692,6 +752,25 @@ |
771 | [('1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', 255, 63, '', self.media.path)], |
772 | sfdisk_fixture.mock.calls) |
773 | |
774 | + def test_create_partitions_for_smdkv310(self): |
775 | + # For this board we create a one cylinder partition at the beginning. |
776 | + popen_fixture = self.useFixture(MockCmdRunnerPopenFixture()) |
777 | + sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture()) |
778 | + |
779 | + create_partitions( |
780 | + board_configs['smdkv310'], self.media, 255, 63, '') |
781 | + |
782 | + self.assertEqual( |
783 | + [['sudo', 'parted', '-s', self.media.path, 'mklabel', 'msdos'], |
784 | + ['sync']], |
785 | + popen_fixture.mock.calls) |
786 | + # Notice that we create all partitions in a single sfdisk run because |
787 | + # every time we run sfdisk it actually repartitions the device, |
788 | + # erasing any partitions created previously. |
789 | + self.assertEqual( |
790 | + [('1,221183,0xDA\n221184,106496,0x0C,*\n327680,,,-', 255, 63, '', |
791 | + self.media.path)], sfdisk_fixture.mock.calls) |
792 | + |
793 | def test_create_partitions_for_beagle(self): |
794 | popen_fixture = self.useFixture(MockCmdRunnerPopenFixture()) |
795 | sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture()) |
796 | @@ -711,9 +790,9 @@ |
797 | popen_fixture = self.useFixture(MockCmdRunnerPopenFixture()) |
798 | sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture()) |
799 | |
800 | - tempfile = self.createTempFileAsFixture() |
801 | + tmpfile = self.createTempFileAsFixture() |
802 | create_partitions( |
803 | - board_configs['beagle'], Media(tempfile), 255, 63, '') |
804 | + board_configs['beagle'], Media(tmpfile), 255, 63, '') |
805 | |
806 | # Unlike the test for partitioning of a regular block device, in this |
807 | # case parted was not called as there's no existing partition table |
808 | @@ -721,26 +800,26 @@ |
809 | self.assertEqual([['sync']], popen_fixture.mock.calls) |
810 | |
811 | self.assertEqual( |
812 | - [('63,106432,0x0C,*\n106496,,,-', 255, 63, '', tempfile)], |
813 | + [('63,106432,0x0C,*\n106496,,,-', 255, 63, '', tmpfile)], |
814 | sfdisk_fixture.mock.calls) |
815 | |
816 | def test_run_sfdisk_commands(self): |
817 | - tempfile = self.createTempFileAsFixture() |
818 | + tmpfile = self.createTempFileAsFixture() |
819 | proc = cmd_runner.run( |
820 | - ['qemu-img', 'create', '-f', 'raw', tempfile, '10M'], |
821 | + ['qemu-img', 'create', '-f', 'raw', tmpfile, '10M'], |
822 | stdout=subprocess.PIPE) |
823 | proc.communicate() |
824 | stdout, stderr = run_sfdisk_commands( |
825 | - '2,16063,0xDA', 255, 63, '', tempfile, as_root=False, |
826 | + '2,16063,0xDA', 255, 63, '', tmpfile, as_root=False, |
827 | stderr=subprocess.PIPE) |
828 | self.assertIn('Successfully wrote the new partition table', stdout) |
829 | |
830 | def test_run_sfdisk_commands_raises_on_non_zero_returncode(self): |
831 | - tempfile = self.createTempFileAsFixture() |
832 | + tmpfile = self.createTempFileAsFixture() |
833 | self.assertRaises( |
834 | cmd_runner.SubcommandNonZeroReturnValue, |
835 | run_sfdisk_commands, |
836 | - ',1,0xDA', 255, 63, '', tempfile, as_root=False, |
837 | + ',1,0xDA', 255, 63, '', tmpfile, as_root=False, |
838 | stderr=subprocess.PIPE) |
839 | |
840 | |
841 | @@ -756,7 +835,7 @@ |
842 | super(TestPartitionSetup, self).tearDown() |
843 | time.sleep = self.orig_sleep |
844 | |
845 | - def _create_tempfile(self): |
846 | + def _create_tmpfile(self): |
847 | # boot part at +8 MiB, root part at +16 MiB |
848 | return self._create_qemu_img_with_partitions( |
849 | '16384,15746,0x0C,*\n32768,,,-') |
850 | @@ -771,19 +850,19 @@ |
851 | self.assertEqual(12 * 1024**3, convert_size_to_bytes('12G')) |
852 | |
853 | def test_calculate_partition_size_and_offset(self): |
854 | - tempfile = self._create_tempfile() |
855 | + tmpfile = self._create_tmpfile() |
856 | vfat_size, vfat_offset, linux_size, linux_offset = ( |
857 | - calculate_partition_size_and_offset(tempfile)) |
858 | + calculate_partition_size_and_offset(tmpfile)) |
859 | self.assertEqual( |
860 | [8061952L, 8388608L, 14680064L, 16777216L], |
861 | [vfat_size, vfat_offset, linux_size, linux_offset]) |
862 | |
863 | def test_partition_numbering(self): |
864 | # another Linux partition at +24 MiB after the boot/root parts |
865 | - tempfile = self._create_qemu_img_with_partitions( |
866 | + tmpfile = self._create_qemu_img_with_partitions( |
867 | '16384,15746,0x0C,*\n32768,15427,,-\n49152,,,-') |
868 | vfat_size, vfat_offset, linux_size, linux_offset = ( |
869 | - calculate_partition_size_and_offset(tempfile)) |
870 | + calculate_partition_size_and_offset(tmpfile)) |
871 | # check that the linux partition offset starts at +16 MiB so that it's |
872 | # the partition immediately following the vfat one |
873 | self.assertEqual(linux_offset, 32768 * 512) |
874 | @@ -791,39 +870,39 @@ |
875 | def test_get_boot_and_root_partitions_for_media_beagle(self): |
876 | self.useFixture(MockSomethingFixture( |
877 | partitions, '_get_device_file_for_partition_number', |
878 | - lambda dev, partition: '%s%d' % (tempfile, partition))) |
879 | - tempfile = self.createTempFileAsFixture() |
880 | - media = Media(tempfile) |
881 | + lambda dev, partition: '%s%d' % (tmpfile, partition))) |
882 | + tmpfile = self.createTempFileAsFixture() |
883 | + media = Media(tmpfile) |
884 | media.is_block_device = True |
885 | self.assertEqual( |
886 | - ("%s%d" % (tempfile, 1), "%s%d" % (tempfile, 2)), |
887 | + ("%s%d" % (tmpfile, 1), "%s%d" % (tmpfile, 2)), |
888 | get_boot_and_root_partitions_for_media( |
889 | media, board_configs['beagle'])) |
890 | |
891 | def test_get_boot_and_root_partitions_for_media_mx5(self): |
892 | self.useFixture(MockSomethingFixture( |
893 | partitions, '_get_device_file_for_partition_number', |
894 | - lambda dev, partition: '%s%d' % (tempfile, partition))) |
895 | - tempfile = self.createTempFileAsFixture() |
896 | - media = Media(tempfile) |
897 | + lambda dev, partition: '%s%d' % (tmpfile, partition))) |
898 | + tmpfile = self.createTempFileAsFixture() |
899 | + media = Media(tmpfile) |
900 | media.is_block_device = True |
901 | self.assertEqual( |
902 | - ("%s%d" % (tempfile, 2), "%s%d" % (tempfile, 3)), |
903 | + ("%s%d" % (tmpfile, 2), "%s%d" % (tmpfile, 3)), |
904 | get_boot_and_root_partitions_for_media(media, boards.Mx5Config)) |
905 | |
906 | def _create_qemu_img_with_partitions(self, sfdisk_commands): |
907 | - tempfile = self.createTempFileAsFixture() |
908 | + tmpfile = self.createTempFileAsFixture() |
909 | proc = cmd_runner.run( |
910 | - ['qemu-img', 'create', '-f', 'raw', tempfile, '30M'], |
911 | + ['qemu-img', 'create', '-f', 'raw', tmpfile, '30M'], |
912 | stdout=subprocess.PIPE) |
913 | proc.communicate() |
914 | stdout, stderr = run_sfdisk_commands( |
915 | - sfdisk_commands, 255, 63, '', tempfile, as_root=False, |
916 | + sfdisk_commands, 255, 63, '', tmpfile, as_root=False, |
917 | # Throw away stderr as sfdisk complains a lot when operating on a |
918 | # qemu image. |
919 | stderr=subprocess.PIPE) |
920 | self.assertIn('Successfully wrote the new partition table', stdout) |
921 | - return tempfile |
922 | + return tmpfile |
923 | |
924 | def test_ensure_partition_is_not_mounted_for_mounted_partition(self): |
925 | self.useFixture(MockSomethingFixture( |
926 | @@ -841,18 +920,18 @@ |
927 | self.assertEqual(None, popen_fixture.mock.calls) |
928 | |
929 | def test_get_boot_and_root_loopback_devices(self): |
930 | - tempfile = self._create_tempfile() |
931 | + tmpfile = self._create_tmpfile() |
932 | atexit_fixture = self.useFixture(MockSomethingFixture( |
933 | atexit, 'register', AtExitRegister())) |
934 | popen_fixture = self.useFixture(MockCmdRunnerPopenFixture()) |
935 | # We can't test the return value of get_boot_and_root_loopback_devices |
936 | # because it'd require running losetup as root, so we just make sure |
937 | # it calls losetup correctly. |
938 | - get_boot_and_root_loopback_devices(tempfile) |
939 | + get_boot_and_root_loopback_devices(tmpfile) |
940 | self.assertEqual( |
941 | - [['sudo', 'losetup', '-f', '--show', tempfile, '--offset', |
942 | + [['sudo', 'losetup', '-f', '--show', tmpfile, '--offset', |
943 | '8388608', '--sizelimit', '8061952'], |
944 | - ['sudo', 'losetup', '-f', '--show', tempfile, '--offset', |
945 | + ['sudo', 'losetup', '-f', '--show', tmpfile, '--offset', |
946 | '16777216', '--sizelimit', '14680064']], |
947 | popen_fixture.mock.calls) |
948 | |
949 | @@ -873,7 +952,7 @@ |
950 | # but here we mock Popen() and thanks to that the image is not setup |
951 | # (via qemu-img) inside setup_partitions. That's why we pass an |
952 | # already setup image file. |
953 | - tempfile = self._create_tempfile() |
954 | + tmpfile = self._create_tmpfile() |
955 | popen_fixture = self.useFixture(MockCmdRunnerPopenFixture()) |
956 | self.useFixture(MockSomethingFixture( |
957 | sys, 'stdout', open('/dev/null', 'w'))) |
958 | @@ -890,14 +969,14 @@ |
959 | partitions, 'get_boot_and_root_loopback_devices', |
960 | lambda image: ('/dev/loop99', '/dev/loop98'))) |
961 | bootfs_dev, rootfs_dev = setup_partitions( |
962 | - board_configs['beagle'], Media(tempfile), '2G', 'boot', |
963 | + board_configs['beagle'], Media(tmpfile), '2G', 'boot', |
964 | 'root', 'ext3', True, True, True) |
965 | self.assertEqual( |
966 | # This is the call that would create a 2 GiB image file. |
967 | - [['qemu-img', 'create', '-f', 'raw', tempfile, '2147483648'], |
968 | + [['qemu-img', 'create', '-f', 'raw', tmpfile, '2147483648'], |
969 | # This call would partition the image file. |
970 | ['sudo', 'sfdisk', '--force', '-D', '-uS', '-H', '255', '-S', |
971 | - '63', '-C', '261', tempfile], |
972 | + '63', '-C', '261', tmpfile], |
973 | # Make sure changes are written to disk. |
974 | ['sync'], |
975 | ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'], |
976 | @@ -910,21 +989,21 @@ |
977 | # Pretend the partitions are mounted. |
978 | self.useFixture(MockSomethingFixture( |
979 | partitions, 'is_partition_mounted', lambda part: True)) |
980 | - tempfile = self._create_tempfile() |
981 | + tmpfile = self._create_tmpfile() |
982 | self.useFixture(MockSomethingFixture( |
983 | partitions, '_get_device_file_for_partition_number', |
984 | - lambda dev, partition: '%s%d' % (tempfile, partition))) |
985 | - media = Media(tempfile) |
986 | - # Pretend our tempfile is a block device. |
987 | + lambda dev, partition: '%s%d' % (tmpfile, partition))) |
988 | + media = Media(tmpfile) |
989 | + # Pretend our tmpfile is a block device. |
990 | media.is_block_device = True |
991 | popen_fixture = self.useFixture(MockCmdRunnerPopenFixture()) |
992 | bootfs_dev, rootfs_dev = setup_partitions( |
993 | board_configs['beagle'], media, '2G', 'boot', 'root', 'ext3', |
994 | True, True, True) |
995 | self.assertEqual( |
996 | - [['sudo', 'parted', '-s', tempfile, 'mklabel', 'msdos'], |
997 | + [['sudo', 'parted', '-s', tmpfile, 'mklabel', 'msdos'], |
998 | ['sudo', 'sfdisk', '--force', '-D', '-uS', '-H', '255', '-S', |
999 | - '63', tempfile], |
1000 | + '63', tmpfile], |
1001 | ['sync'], |
1002 | # Since the partitions are mounted, setup_partitions will umount |
1003 | # them before running mkfs. |
59 + sfdisk_cmd = super(SamsungCo nfig, cls).get_ sfdisk_ cmd()
60 + return ',14,0xDA\n,,,-'
You don't want to use the sfdisk_cmd that you get from the upcall?
149 +def install_ mx51evk_ boot_loader( imx_file, boot_device_ or_file) :
I don't think you wanted to add this?
166 + "seek=1089",
Could we get some of these magic numbers turned in to local variables, so that
we have a name that means something for them. A comment may be useful too if the
variable name can't express what the number is.
Overall this looks pretty clean, thanks. I'll ask Guilherme for a review
as well, and we'll want the tests before this lands.
Thanks,
James