Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError: Logical partition metadata has invalid geometry magic signature. #83

Open
PerroDev opened this issue Apr 25, 2024 · 5 comments

Comments

@PerroDev
Copy link

PerroDev commented Apr 25, 2024

Im having this error

[INFO] Copying super.img
[INFO] Pattern payload.bin not found
[INFO] Found multipartition image: super.img
[INFO] Failed to unsparse super.img
[INFO] Found multipartition image: super.img.lz4
[INFO] Failed to unsparse super.img.lz4
Traceback (most recent call last):
  File "/usr/local/bin/dumpyara", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/dumpyara/main.py", line 43, in main
    output_path = dumpyara(args.file, output, args.debug)
  File "/usr/local/lib/python3.9/dist-packages/dumpyara/dumpyara.py", line 47, in dumpyara
    prepare_images(extracted_archive_path, raw_images_path)
  File "/usr/local/lib/python3.9/dist-packages/dumpyara/steps/prepare_images.py", line 50, in prepare_images
    func(multipart_image, raw_images_path)
  File "/usr/local/lib/python3.9/dist-packages/dumpyara/utils/multipartitions.py", line 33, in extract_super
    lpunpack(image, output_dir)
  File "/usr/local/lib/python3.9/dist-packages/liblp/partition_tools/lpunpack.py", line 87, in lpunpack
    metadata = ReadMetadata(image, slot)
  File "/usr/local/lib/python3.9/dist-packages/liblp/reader.py", line 275, in ReadMetadata
    geometry = ReadLogicalPartitionGeometry(fd)
  File "/usr/local/lib/python3.9/dist-packages/liblp/reader.py", line 97, in ReadLogicalPartitionGeometry
    geometry = ReadPrimaryGeometry(fd)
  File "/usr/local/lib/python3.9/dist-packages/liblp/reader.py", line 84, in ReadPrimaryGeometry
    return ParseGeometry(buffer)
  File "/usr/local/lib/python3.9/dist-packages/liblp/reader.py", line 54, in ParseGeometry
    assert geometry.magic == LP_METADATA_GEOMETRY_MAGIC, \
AssertionError: Logical partition metadata has invalid geometry magic signature.```

Firmware is Galaxy A54's .zip from samfw.com. I can't send download link but you can check it

@SebaUbuntu
Copy link
Member

Looks like an older version? Try to update

@PerroDev
Copy link
Author

Looks like an older version? Try to update

Older version of what? Python or dumpyara? I installed it with pip3 install dumpyara

@SebaUbuntu
Copy link
Member

pip -U install dumpyara

@ramenrolls
Copy link

ramenrolls commented May 12, 2024

Similar issue. failed to unsparse the super.img.lz4 file extracted from a samloader-bifrost firmware dump of the A146P device.

The error occurs during step 2 ("Preparing partition images"):

`[INFO] Pattern payload.bin not found
[INFO] Found multipartition image: super.img.lz4
[INFO] Failed to unsparse super.img.lz4
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/martin/Downloads/dumpyara/lib/python3.12/site-packages/dumpyara/__main__.py", line 11, in <module>
    main()
  File "/home/martin/Downloads/dumpyara/lib/python3.12/site-packages/dumpyara/main.py", line 43, in main
    output_path = dumpyara(args.file, output, args.debug)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/Downloads/dumpyara/lib/python3.12/site-packages/dumpyara/dumpyara.py", line 47, in dumpyara
    prepare_images(extracted_archive_path, raw_images_path)
  File "/home/martin/Downloads/dumpyara/lib/python3.12/site-packages/dumpyara/steps/prepare_images.py", line 50, in prepare_images
    func(multipart_image, raw_images_path)
  File "/home/martin/Downloads/dumpyara/lib/python3.12/site-packages/dumpyara/utils/multipartitions.py", line 33, in extract_super
    lpunpack(image, output_dir)
  File "/home/martin/Downloads/dumpyara/lib/python3.12/site-packages/liblp/partition_tools/lpunpack.py", line 87, in lpunpack
    metadata = ReadMetadata(image, slot)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/Downloads/dumpyara/lib/python3.12/site-packages/liblp/reader.py", line 275, in ReadMetadata
    geometry = ReadLogicalPartitionGeometry(fd)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/Downloads/dumpyara/lib/python3.12/site-packages/liblp/reader.py", line 97, in ReadLogicalPartitionGeometry
    geometry = ReadPrimaryGeometry(fd)
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/Downloads/dumpyara/lib/python3.12/site-packages/liblp/reader.py", line 84, in ReadPrimaryGeometry
    return ParseGeometry(buffer)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/martin/Downloads/dumpyara/lib/python3.12/site-packages/liblp/reader.py", line 54, in ParseGeometry
    assert geometry.magic == LP_METADATA_GEOMETRY_MAGIC, \
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Logical partition metadata has invalid geometry magic signature.
`

Steps to Reproduce:

Acquire firmware for A146P using samloader-bifrost.
Extract the super.img.lz4 file from the firmware dump.
Install dumpyara v1.0.6 (latest as of reporting).
Run dumpyara against the extracted super.img.lz4.
Expected Behavior:

Dumpyara should successfully unsparse the super.img.lz4 file without errors, allowing for further analysis of the firmware partitions.

Actual Behavior:

The AssertionError is raised, indicating that dumpyara cannot correctly interpret the partition layout within the super.img.lz4 file.

Environment:

Operating System: Ubuntu 24.04LTS (Noble Numbat)
Python Version: 3.12
Dumpyara Version: 1.0.6

The AssertionError suggests an issue with the way dumpyara handles multipartition super.img files.

@ramenrolls
Copy link

ramenrolls commented May 12, 2024

Minor workaround for handling the multipartition super img, the issue above. However, ran into more problems down the line.
Unzip firmware archive: Unzipped the initial firmware, untar the AP partition
Decompress: locate super multipartition img - lz4 -d super.img.lz4 super.img
Unsparse: simg2img super.img super_unsparse.img
Extract Partitions: I had success using the lpunpack.py script from the unix3dgforce fork: python3 lpunpack.py super_unsparse.img extracted_images
Resulting in extracted img partitions: system, system-ext, vendor, product, odm.
Recompress Firmware: Placed extracted partitions in the AP directory, and recompress the firmware back to .zip archive

Two errors threw during the extraction of boot.img and recovery.img due to a ModuleNotFoundError: No module named distutils.

Regading the above "ModuleNotFoundError" error: No module named 'distutils'. The fix is straightforward since Python 3.12 doesn't package distutils by default

Solution:

Just install setuptools within the virt. environment :

pip install setuptools

This will automatically make distutils available, resolving the error during the extraction process.

Might be beneficial to add setuptools as a dependency to the project - @SebaUbuntu

For reference, log file of the dump.
logdump.txt

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

No branches or pull requests

3 participants