patjak / facetimehd-firmware

FacetimeHD firmware download and extraction tool
GNU General Public License v2.0
93 stars 29 forks source link

extracting the sensor calibration files for macbook 12 inch models #3

Open leifliddy opened 4 years ago

leifliddy commented 4 years ago

this wiki page gives excellent instructions on how to extract the sensor calibration from from the AppleCamera.sys file: https://github.com/patjak/bcwc_pcie/wiki/Extracting-the-sensor-calibration-files

...using strings I can see the names of the four sensor calibration dat files contained within

[root@black bootcamp.2015]$ strings AppleCamera.sys | grep firmware
/usr/local/share/firmware/isp/9112_01XX.dat
/usr/local/share/firmware/isp/1771_01XX.dat
/usr/local/share/firmware/isp/1871_01XX.dat
/usr/local/share/firmware/isp/1874_01XX.dat

My question is: how did you find the offsets? I'm a bit new at dealing with firmware, but I'd like to learn this.

So, I have a macbook9,1 (12 inch 2016). **your facetimehd driver doesn't seem to work correctly (no video) on the 12 inch macbook models {8,1 + 9,1 + 10,1}, but I'll deal with that issue in your other repo.

What I'd like to sort out for this issue is how to extract the 1675_01XX.dat firmware.

[ 2976.929253] facetimehd 0000:03:00.0: Direct firmware load for facetimehd/1675_01XX.dat failed with error -2

In the Apple.sys file I pulled off my bootcamp file, I can see there are nine dat files

[root@black apple.camera.macbook91]$ strings AppleCamera.sys  | grep firmware
/usr/local/share/firmware/isp/9112_01XX.dat
/usr/local/share/firmware/isp/1771_01XX.dat
/usr/local/share/firmware/isp/1871_01XX.dat
/usr/local/share/firmware/isp/1874_01XX.dat
/usr/local/share/firmware/isp/1222_01XX.dat
/usr/local/share/firmware/isp/8221_01XX.dat
/usr/local/share/firmware/isp/1674_01XX.dat
/usr/local/share/firmware/isp/1675_01XX.dat
/usr/local/share/firmware/isp/1671_01XX.dat

I'd like to find the offsets for these files, could you help me with that?

leifliddy commented 4 years ago

I think I figured it out (not sure if it's the correct way, I'm still new at this)

I just did a hexdump -d AppleCamera.sys on your file and used the offsets you provided to in the wiki the locate the dat files. just the first and last lines are shown for each file

1871_01XX.dat
    28952   01793   02560   00021   00000   00000   00000   00000
    02599   00000   00000   00000   03500   00000   04500   00000

1874_01XX.dat
    29720   01793   02560   00021   00000   00000   00000   00000
    02599   00000   00000   00000   03500   00000   04500   00000

1771_01XX.dat   
    28951   02049   02560   00021   00000   00000   00000   00000
    00000   00000   00000   00000   00000   00000   00000   00000

I was able to easily identify these three dat files in my AppleCamera.sys file I also located an additional three files immediately following 1771_01XX.dat

unknown.dat
    29718   01281   02560   00021   00000   00000   00000   00000
    00000   00000   03500   00000   04500   00000   00000   00000

unknown.dat
    29974   01793   02560   00021   00000   00000   00000   00000
    00000   00000   03500   00000   04500   00000   00000   00000

unknown.dat
    28950   01793   02560   00021   00000   00000   00000   00000
    00000   00000   03500   00000   04500   00000   00000   00000

Each of these files is the exact same length of 18048 bytes I believe they correspond to these three dat files:

/usr/local/share/firmware/isp/1671_01XX.dat
/usr/local/share/firmware/isp/1674_01XX.dat
/usr/local/share/firmware/isp/1675_01XX.dat

I'm not sure how to sort out which file is which. If were to install windows + bootcamp drivers on my macbook, would these dat files manifest themselves on the filesystem somewhere?

patjak commented 4 years ago

Hi, I found the offsets by looking at the disassembly of the driver. The code that loads them into the ISP tells the offset and size of the sensor files. Unfortunately the 167x versions are not available in the bootcamp driver from 2015 that we can download directly from Apple.