0

I dumped a NAND flash a while ago and analyzed the dump with binwalk. Binwalk could find a SQUASHFS filesystem but unfortunately it was not possible to retrieve the data because it is monted on top of UBI and neither unsquashfs utility nor sasquatch could do something.

However binwalk could also find a UBI image. So my next approach was to extract the content from this image to get eventually the squashfs filesystem.

To do so I wanted to use the ubireader tool (https://github.com/jrspruitt/ubi_reader).

ubireader_display_info gave me the following output:

UBI File
---------------------
Min I/O: 2048
LEB Size: 126976
PEB Size: 131072
Total Block Count: 847
Data Block Count: 377
Layout Block Count: 2
Internal Volume Block Count: 0
Unknown Block Count: 468
First UBI PEB Number: 10

Image: 1681423409
---------------------
    Image Sequence Num: 1681423409
    Volume Name:spare
    Volume Name:data1
    Volume Name:root1
    Volume Name:root0
    Volume Name:data0
    PEB Range: 0 - 855

    Volume: spare
    ---------------------
        Vol ID: 4
        Name: spare
        Block Count: 142

        Volume Record
        ---------------------
            alignment: 1
            crc: '0x743003a9'
            data_pad: 0
            errors: ''
            flags: 0
            name: u'spare'
            name_len: 5
            padding: u'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
            rec_index: 4
            reserved_pebs: 386
            upd_marker: 0
            vol_type: 'dynamic'


    Volume: data1
    ---------------------
        Vol ID: 3
        Name: data1
        Block Count: 8

        Volume Record
        ---------------------
            alignment: 1
            crc: '0xefc3e0d'
            data_pad: 0
            errors: ''
            flags: 0
            name: u'data1'
            name_len: 5
            padding: u'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
            rec_index: 3
            reserved_pebs: 34
            upd_marker: 0
            vol_type: 'dynamic'


    Volume: root1
    ---------------------
        Vol ID: 1
        Name: root1
        Block Count: 110

        Volume Record
        ---------------------
            alignment: 1
            crc: '0x4a7089bd'
            data_pad: 0
            errors: ''
            flags: 0
            name: u'root1'
            name_len: 5
            padding: u'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
            rec_index: 1
            reserved_pebs: 232
            upd_marker: 0
            vol_type: 'dynamic'


    Volume: root0
    ---------------------
        Vol ID: 0
        Name: root0
        Block Count: 108

        Volume Record
        ---------------------
            alignment: 1
            crc: '0x38a2ed27'
            data_pad: 0
            errors: ''
            flags: 0
            name: u'root0'
            name_len: 5
            padding: u'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
            rec_index: 0
            reserved_pebs: 232
            upd_marker: 0
            vol_type: 'dynamic'


    Volume: data0
    ---------------------
        Vol ID: 2
        Name: data0
        Block Count: 9

        Volume Record
        ---------------------
            alignment: 1
            crc: '0x7c2e5a97'
            data_pad: 0
            errors: ''
            flags: 0
            name: u'data0'
            name_len: 5
            padding: u'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
            rec_index: 2
            reserved_pebs: 34
            upd_marker: 0
            vol_type: 'dynamic'

There are a couple of unknown blocks and I do not know if that is a problem but if I try to extract the files with ubireader_extract_files I get the following error:

Extracting files to: ubifs-root/1681423409/spare
extract_files Error: No inodes found
Extracting files to: ubifs-root/1681423409/data1
read Error: LEB: 10 is corrupted or has no data.
extract_files Error: 1
UBIFS Fatal: Super block error: Wrong node type.

I am not sure but I believe that the UBI image (or even the entire dump) might be corrupted in some way.

I can't explain this to me because the NAND flash that I worked wih has internal ECC enabled and in the datasheet it sais:

During a READ operation, the page data is read from the array to the cache 
register, where the ECC code is calculated and compared with the ECC code 
value read from the array. If error bits are detected, the error is corrected 
in the cache register. Only corrected data is output on the I/O bus.

Is there anything I can do to retrieve the data like this or am I doing something wrong?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.