if self.ftype == TYPE_STAGE:
pass
elif self.ftype == TYPE_RAW:
- hdr_len += ATTR_COMPRESSION_LEN
+ if self.compress:
+ hdr_len += ATTR_COMPRESSION_LEN
elif self.ftype == TYPE_EMPTY:
pass
else:
data = self.comp_bintool.compress(orig_data)
self.memlen = len(orig_data)
self.data_len = len(data)
- attr = struct.pack(ATTR_COMPRESSION_FORMAT,
- FILE_ATTR_TAG_COMPRESSION, ATTR_COMPRESSION_LEN,
- self.compress, self.memlen)
+ if self.compress:
+ attr = struct.pack(ATTR_COMPRESSION_FORMAT,
+ FILE_ATTR_TAG_COMPRESSION,
+ ATTR_COMPRESSION_LEN, self.compress,
+ self.memlen)
elif self.ftype == TYPE_EMPTY:
data = tools.get_bytes(self.erase_byte, self.size)
else:
if expected_len != actual_len: # pragma: no cover
# Test coverage of this is not available since this should never
# happen. It probably indicates that get_header_len() is broken.
- raise ValueError("Internal error: CBFS file '%s': Expected headers of %#x bytes, got %#d" %
+ raise ValueError("Internal error: CBFS file '%s': Expected headers of %#x bytes, got %#x" %
(self.name, expected_len, actual_len))
return hdr + name + attr + pad + content + data, hdr_len
self.assertEqual(arch, cbfs.arch)
return cbfs
- def _check_uboot(self, cbfs, ftype=cbfs_util.TYPE_RAW, offset=0x38,
+ def _check_uboot(self, cbfs, ftype=cbfs_util.TYPE_RAW, offset=0x28,
data=U_BOOT_DATA, cbfs_offset=None):
"""Check that the U-Boot file is as expected
self.assertEqual(len(data), cfile.memlen)
return cfile
- def _check_dtb(self, cbfs, offset=0x38, data=U_BOOT_DTB_DATA,
+ def _check_dtb(self, cbfs, offset=0x28, data=U_BOOT_DTB_DATA,
cbfs_offset=None):
"""Check that the U-Boot dtb file is as expected
data = cbw.get_data()
cbfs = cbfs_util.CbfsReader(data)
- self.assertEqual(0x38, cbfs.files['u-boot'].cbfs_offset)
- self.assertEqual(0x78, cbfs.files['u-boot-dtb'].cbfs_offset)
+ self.assertEqual(0x28, cbfs.files['u-boot'].cbfs_offset)
+ self.assertEqual(0x68, cbfs.files['u-boot-dtb'].cbfs_offset)
if __name__ == '__main__':
'cbfs/u-boot:offset': 0x38,
'cbfs/u-boot:uncomp-size': len(U_BOOT_DATA),
'cbfs/u-boot:image-pos': 0x38,
- 'cbfs/u-boot-dtb:offset': 0xb8,
+ 'cbfs/u-boot-dtb:offset': 0xa8,
'cbfs/u-boot-dtb:size': len(U_BOOT_DATA),
- 'cbfs/u-boot-dtb:image-pos': 0xb8,
+ 'cbfs/u-boot-dtb:image-pos': 0xa8,
}, props)
def testCbfsBadType(self):
' u-boot 0 4 u-boot 0',
' section 100 %x section 100' % section_size,
' cbfs 100 400 cbfs 0',
-' u-boot 138 4 u-boot 38',
+' u-boot 128 4 u-boot 28',
' u-boot-dtb 180 105 u-boot-dtb 80 3c9',
' u-boot-dtb 500 %x u-boot-dtb 400 3c9' % fdt_size,
' fdtmap %x 3bd fdtmap %x' %