chipsec icon indicating copy to clipboard operation
chipsec copied to clipboard

chipsec_util.main(['spi', 'dump', 'rom.bin']) dumps 16MB bios rom file, but my bios is 32MB.

Open rhapsodyjay opened this issue 7 years ago • 11 comments

image The dumped rom.bin is only 16MB. image But my BIOS image is actually 32MB(16MB bios + 16MB ME).

rhapsodyjay avatar Apr 26 '18 07:04 rhapsodyjay

After looking at spi_cmd.py it looks like the dump command it looks like it may have a few bugs that need to be fixed. Looks like it may have some assumptions that are no longer valid. Please try using the spi read command and provide the start offset and length and file for output.

chipsec_util spi read 0x0 0x2000000 bios.bin

ErikBjorge avatar Apr 26 '18 21:04 ErikBjorge

Thanks! I've tried chipsec_util spi read 0x0 0x2000000 bios.bin. It works fine.

rhapsodyjay avatar Apr 27 '18 01:04 rhapsodyjay

Glad we could give you a workaround for the issue. I will work on fixing the current issue with the dump command.

ErikBjorge avatar Apr 27 '18 04:04 ErikBjorge

should we use FLCOMP—Flash Components Record (Flash Descriptor Records) with:

Component 1 Density. This field identifies the size of the 1st or only Flash component connected
directly to the PCH.
000 = 512 KB
001 = 1 MB
010 = 2 MB
011 = 4 MB
100 = 8 MB
101 = 16 MB
111 = Reserved
Note: If using a flash part smaller than 512 KB, use the 512 KB setting.

to detect size of SPI chip?

ghost avatar May 14 '18 18:05 ghost

Thanks for the pointer. This is an option but comes from the flash descriptor. I will see if I can extract this information from the SPI controller instead of reading the flash descriptor directly (don't want two flash reads). I think I can get the data via the BIOS_FDOC and BIOS_FDOD registers.

I think the real issue for me is the intent of the dump command. Was the intent to dump only the BIOS region or the entire flash device? The code specifically attempts to determine the size of the BIOS region and dump it. This conflicts with the message at the start that says that it dumps the entire flash device.

This leaves us with two options. We could just fix get_SPI_region to correctly determine the BIOS region or we could update dump to determine the size of the flash part. I am not sure of the best option.

ErikBjorge avatar May 14 '18 20:05 ErikBjorge

IMO the default "dump" command should try to dump the whole chip. I imagine you could eventually add FPT-like options to dump specific regions.

skochinsky avatar May 15 '18 07:05 skochinsky

agree with @skochinsky

ghost avatar May 15 '18 17:05 ghost

I am fine with dumping the entire flash image with the dump command. This does seem the most reasonable. I think we should also add a dump-bios command that will just dump the BIOS region. This way we will also have the legacy functionality available.

ErikBjorge avatar May 15 '18 17:05 ErikBjorge

BIOS_FDOC and BIOS_FDOD registers not returning you size of SPI chipsec, is it? Not sure how it will help to identify size of SPI chip...

abazhaniuk avatar May 18 '18 00:05 abazhaniuk

I believe the intent has always been to dump the whole flash. The BIOS region address was used under the (fair) assumption that its end will correspond to the end of the flash. I can't think of any exception to this?

To the original question, I've come across this issue multiple time with the incorrect definition of the PCH. Could you run chipsec_util platform? If you see the "Default PCH" being used, it is likely that your chipset is unknown. You could: find the correct PCI DID, the matching datasheet and add an entry for the PCH version. You can also test using the "--pch" flag of chipsec_util.

tweksteen avatar Jun 11 '18 14:06 tweksteen

Can read the JEDEC ID by image But this way needs to setup a table to refer to.

rhapsodyjay avatar Aug 02 '18 07:08 rhapsodyjay