mirror of
https://github.com/openmv/openmv.git
synced 2025-09-26 23:09:13 +08:00
scripts/libraries: Add romfs util.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit is contained in:
parent
fe590b627b
commit
cf571aec92
26
scripts/libraries/romfs.py
Normal file
26
scripts/libraries/romfs.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import os
|
||||||
|
import uctypes
|
||||||
|
|
||||||
|
|
||||||
|
def ls_romfs():
|
||||||
|
# Define possible alignment sizes in descending order
|
||||||
|
alignments = [128, 64, 32, 16, 8, 4]
|
||||||
|
|
||||||
|
for fname in os.listdir("/rom"):
|
||||||
|
with open("/rom/" + fname, "rb") as file:
|
||||||
|
address = uctypes.addressof(file) & 0xFFFFFFF
|
||||||
|
size = len(memoryview(file))
|
||||||
|
aligned = False
|
||||||
|
# Check alignment for each size, starting from the highest alignment
|
||||||
|
for alignment in alignments:
|
||||||
|
if address % alignment == 0:
|
||||||
|
print(
|
||||||
|
f"addr: 0x{address:08X} size: {size:<8} alignment: {alignment:<4} name: {fname}"
|
||||||
|
)
|
||||||
|
aligned = True
|
||||||
|
break
|
||||||
|
# If not aligned to any of the specified sizes
|
||||||
|
if not aligned:
|
||||||
|
print(
|
||||||
|
f"addr: 0x{address:08X} size: {size:<8} alignment: NOT aligned name: {fname}"
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user