<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>15075</bug_id>
          
          <creation_ts>2023-03-21 01:04:12 +0000</creation_ts>
          <short_desc>filemap.py does not handle 64KB block size</short_desc>
          <delta_ts>2023-06-21 00:17:40 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>Scripts and Tools</component>
          <version>5.99</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>4.3 M1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Andrew">geissonator</reporter>
          <assigned_to name="Andrew">geissonator</assigned_to>
          <cc>randy.macleod</cc>
    
    <cc>ross.burton</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>95171</commentid>
    <comment_count>0</comment_count>
    <who name="Andrew">geissonator</who>
    <bug_when>2023-03-21 01:04:12 +0000</bug_when>
    <thetext>I&apos;m attempting to get yocto building on a ppc64le POWER9 based server. I&apos;m building master from the OpenBMC project (which builds find on x86 machines).

I hit the following errror:

```
| Traceback (most recent call last):
|   File &quot;/home/fspcibld/284637575/openbmc/scripts/wic&quot;, line 547, in &lt;module&gt;
|     sys.exit(main(sys.argv[1:]))
|              ^^^^^^^^^^^^^^^^^^
|   File &quot;/home/fspcibld/284637575/openbmc/scripts/wic&quot;, line 542, in main
|     return hlp.invoke_subcommand(args, parser, hlp.wic_help_usage, subcommands)
|            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|   File &quot;/home/fspcibld/284637575/openbmc/poky/scripts/lib/wic/help.py&quot;, line 83, in invoke_subcommand
|     subcmd[0](args, usage)
|   File &quot;/home/fspcibld/284637575/openbmc/scripts/wic&quot;, line 222, in wic_create_subcommand
|     engine.wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir,
|   File &quot;/home/fspcibld/284637575/openbmc/poky/scripts/lib/wic/engine.py&quot;, line 190, in wic_create
|     plugin.do_create()
|   File &quot;/home/fspcibld/284637575/openbmc/poky/scripts/lib/wic/plugins/imager/direct.py&quot;, line 99, in do_create
|     self.assemble()
|   File &quot;/home/fspcibld/284637575/openbmc/poky/scripts/lib/wic/plugins/imager/direct.py&quot;, line 194, in assemble
|     self._image.assemble()
|   File &quot;/home/fspcibld/284637575/openbmc/poky/scripts/lib/wic/plugins/imager/direct.py&quot;, line 624, in assemble
|     sparse_copy(source, self.path, seek=part.start * self.sector_size)
|   File &quot;/home/fspcibld/284637575/openbmc/poky/scripts/lib/wic/filemap.py&quot;, line 540, in sparse_copy
|     for first, last in fmap.get_mapped_ranges(0, fmap.blocks_cnt):
|   File &quot;/home/fspcibld/284637575/openbmc/poky/scripts/lib/wic/filemap.py&quot;, line 458, in get_mapped_ranges
|     first_prev, last_prev = next(iterator)
|                             ^^^^^^^^^^^^^^
|   File &quot;/home/fspcibld/284637575/openbmc/poky/scripts/lib/wic/filemap.py&quot;, line 440, in _do_get_mapped_ranges
|     assert extent_len % self.block_size == 0
|            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| AssertionError
| WARNING: exit code 1 from a shell command.
ERROR: Task (/home/fspcibld/284637575/openbmc/meta-phosphor/recipes-phosphor/images/obmc-phosphor-image.bb:do_image_wic) failed with exit code &apos;1&apos;
NOTE: Tasks Summary: Attempted 5214 tasks of which 5213 didn&apos;t need to be rerun and 1 failed.

Summary: 1 task failed:
  /home/fspcibld/284637575/openbmc/meta-phosphor/recipes-phosphor/images/obmc-phosphor-image.bb:do_image_wic
```

I added some debug and found the following on my system:

```
| DEBUG: Python function extend_recipe_sysroot finished
| DEBUG: Executing python function set_image_size
| DEBUG: 197444.000000 = 151880 * 1.300000
| DEBUG: 197444.000000 = max(197444.000000, 65536)[197444.000000] + 0
| DEBUG: 197444.000000 = int(197444.000000)
| DEBUG: 197444 = aligned(197444)
| DEBUG: returning 197444
| DEBUG: Python function set_image_size finished
| Var &lt;EXTRA_USERS_PARAMS:pn-obmc-phosphor-image&gt;:1: DeprecationWarning: invalid escape sequence &apos;\$&apos;
| Var &lt;EXTRA_USERS_PARAMS&gt;:1: DeprecationWarning: invalid escape sequence &apos;\$&apos;
| DEBUG: Executing shell function do_image_wic
| INFO: Creating image(s)...
| 
| extend_start and block_size(0, 65536)
| extend_len and block_size(65536, 65536)

| extend_start and block_size(0, 65536)
| extend_len and block_size(65536, 65536)

| extend_start and block_size(0, 65536)
| extend_len and block_size(274432, 65536)
&lt;ASSERT&gt;
```

The issue appears to be that this is a 65536 block_size system and the script does not handle that well(?). The 64KB does not evenly divide into the 274432. A quick hack was to just have get_block_size() return 4KB and all worked fine. I could send a patch up that adds a little logic to return a max of 4KB?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95187</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2023-03-23 14:38:45 +0000</bug_when>
    <thetext>Where is the 64 KB block size coming in?
Propsing a patch on the email list would be great and a good start to gettting to the root cause of the issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95198</commentid>
    <comment_count>2</comment_count>
    <who name="Andrew">geissonator</who>
    <bug_when>2023-03-24 20:16:52 +0000</bug_when>
    <thetext>&gt; Proposing a patch on the email list would be great and a good start to getting to the root cause of the issue.

ok, I sent https://lists.openembedded.org/g/openembedded-core/message/179079 upstream.

&gt; Where is the 64 KB block size coming in?

The 64KB is coming from the logic in get_block_size() from within the script. It appears to do an ioctl into the kernel.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95753</commentid>
    <comment_count>3</comment_count>
    <who name="Andrew">geissonator</who>
    <bug_when>2023-06-20 12:26:35 +0000</bug_when>
    <thetext>Patch to mailing list was accepted and merged.

https://lists.openembedded.org/g/openembedded-core/message/179079</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95762</commentid>
    <comment_count>4</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2023-06-21 00:17:40 +0000</bug_when>
    <thetext>Thanks Andrew.
If you could it&apos;s appreciated if you can include a link to the commit.
Here, that&apos;s: https://git.openembedded.org/openembedded-core/commit/?id=1e23b803af6991fc20e4a4e88a0ef0541399e722</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>