andreiw / RaspberryPiPkg

DEPRECATED - DO NOT USE | Go here instead ->
https://github.com/tianocore/edk2-platforms/tree/master/Platform/RaspberryPi/RPi3
746 stars 143 forks source link

RPi3: fix corrupted I2C1 MsftFunctionConfig #108

Closed driver1998 closed 5 years ago

driver1998 commented 5 years ago

This fixes #96.

Signed-off-by: driver1998 driver1998@foxmail.com

driver1998 commented 5 years ago

Further exploration reveals there is an command before the actual asl compilation (stripped the path for clearity):

# Trim is from edk2 BaseTools
Trim --asl-file -o DSDT.i DSDT.asl
aarch64-linux-gnu-gcc -x c -E DSDT.i > DSDT.iii

I checked DSDT.i, and the code is not much changed, especially the VendorLong is unchanged.

Then the next line stripped out all the comments from the file using GCC, not sure why that is necessary.

But it turns out since GCC is reading the file in C syntax, the '\' and the '\n' next to it in the end of the 0x0020 line is treated as an escape sequence. So it just treated the whole next line as comment and stripped that out.

It is just wonderful.

VendorLong  ()      // Length = 0x31
{
    /* 0000 */  0x00, 0x60, 0x44, 0xD5, 0xF3, 0x1F, 0x11, 0x60,  // .`D....`
    /* 0008 */  0x4A, 0xB8, 0xB0, 0x9C, 0x2D, 0x23, 0x30, 0xDD,  // J...-#0.
    /* 0010 */  0x2F, 0x8D, 0x1D, 0x00, 0x01, 0x10, 0x00, 0x01,  // /.......
    /* 0018 */  0x04, 0x00, 0x12, 0x00, 0x00, 0x16, 0x00, 0x20,  // ....... 
    /* 0020 */  0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x5C,  // .......\
    /* 0028 */  0x5F, 0x53, 0x42, 0x2E, 0x47, 0x50, 0x49, 0x30,  // _SB.GPI0
    /* 0030 */  0x00                                             // .
}
andreiw commented 5 years ago

Thanks for contributing this fix.