Skip to content

Conversation

@rsa9000
Copy link

@rsa9000 rsa9000 commented Nov 2, 2025

Troubleshooting a firmware issue I've noticed that Sony images cannot be handled by simg2img utility:

$ file oem.sin
oem.sin: POSIX tar archive
$ tar -xvf oem.sin
oem.cms
oem.000
$ file oem.000
oem.000: Android sparse image, version: 1.0, Total of 102400 4096-byte output blocks in 14 input chunks.
$ ./simg2img oem.000 oem.raw
Invalid sparse file format at unknown block CAC5 at 40
...
Failed to read sparse file
$ ls -sh oem.000 oem.raw 
81M oem.000    0 oem.raw

The issue is that Sony augmented sparse format with a new chunk type - 0xCAC5 carrying LZ4 compressed data [1]. Proposed solution implements such chunk support using liblz4. With these changes applied I can convert all the available images from sparse to raw:

$ ./simg2img oem.000 oem.raw
$ ls -sh oem.000 oem.raw 
81M oem.000  92M oem.raw
$ file oem.raw 
oem.raw: Linux rev 1.0 ext4 filesystem data, UUID=..., volume name "oem" (extents) (large files)
  1. https://xdaforums.com/t/tool-unsin-sin-v3-v4-v5-unpacker-v2-0.3128106/post-75983550

Sony device firmware images in SIN format are basically the same sparse
images, augmented with a custom chunk type, 0xCAC5 [1]. Such chunk
contains a raw LZ4-compressed block. See few more notes in the code
comment.

Implement this vendor-specific chunk type support to be capable to
convert SIN-images into RAW-images in a regular way. Use liblz4 [2] to
decompress the chunk data.

Creating SIN-images with LZ4-compression is not yet supported.

1. https://xdaforums.com/t/tool-unsin-sin-v3-v4-v5-unpacker-v2-0.3128106/post-75983550
2. https://github.com/lz4/lz4

Signed-off-by: Sergey Ryazanov <[email protected]>
Mention SIN images support in a new section 'Vendor extensions' and
extend the dependencies list with liblz4 for both Windows and Linux
platforms.

Signed-off-by: Sergey Ryazanov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant