Solved MacBook Pro Retina 2015 adding smc settings to asmc, need a bit of help

I have Macbook Pro Retina 13-inch, Early 2015 which i installed Freebsd 14 on,
however there are no asmc settings in asmc.c and asmcvar.h for this particular model

MacBook Pro (Retina, 13-inch, Early 2015)
Model Identifier: MacBookPro12,1
Serial: CO2R459BFVH5

Apple specs

macbook-pro-retina.jpg


Which means the keyboard backlight doesnt work

I know that you need to build a custom kernel and add the smc settings
to the asmc.c and asmcvar.h files

I already created asmc entries for the macbook air 4,1,
which i submitted and are now included in the asmc.c and asmcvar.h files

asmc create new entry for macbook air 4,1

when i reinstalled freebsd on my macbook air a while a go and found my asmc setttings
had been accepted and worked out of the box without needing to build a custom kernel that was very cool

I download a Mac osx Catina iso from arhive.org, dd to a usb stick
installed Catalina on the Macbook Pro Retina and then installed smcFanControl


Then i dumped the smc settings by running the following commands

Code:
cd /Applications/smcFanControl.app/Contents/Resources
./smc -l > ~/Desktop/smc.txt

Of course you get the Apple "Nanny" prompt
saying Terminal.app wants to access files on your desktop

Didnt take long to remind me why i stopped using Macs

The last time i did this was 7 years ago and i cant remember how to convert the smc settings from the mac
into the asmc settings for Freebsd

I have already installed Freebsd 14 on the Macbook Pro Retina
with Wayland and set the scaling to 1.5 with dwl and everything works except the keyboard backlight (and wifi)

But then i had to install Mac osx Catalina to dump the smc settings

If anyone knows how to convert the mac smc settings to asmc entries for Freebsd
and could outline the procedure then i ill try to get asmc working on the Macbook Pro Retina
and then submit the settings

There isnt a lot of documentation out there about dumping mac smc and creating asmc entries
and it would be good to outline the procedure so other users could dump the smc settings for their mac
and then submit the entries

Which would give better hardware support on newer Mac on Freebsd

I searched through all my notes from when i last created asmc entries
but it seems like the one step i didnt document was how to create asmc entries from the smc settings

If anyone could help out that would be great
i know how to build a custom kernel with the new asmc settings

Im just cant remember how to create the asmc settings from the mac smc dump

It would be nice to get Freebsd working on the Retina Macs
im more that happy to do all the donkey work and test everything out

Then hopefully i could outline all the steps for other users

If im going to build a custom kernel for asmc
i might as well try getting the wifi working

I have attached the smc stats for the MacBookPro12,1 as a text file to this post
 

Attachments

  • macbook-pro-retina-smc.txt
    23.6 KB · Views: 12
I found the Apple Technician Guide for the Macbook Pro Retina 13inch 2015

Which mentions all the Thermal and Electrical Sensors names needed for the asmc settings

Ill have to try and creating asmc entries for them and build a custom kernel

There is a post on reddit with links to all the Apple Technician Guide for different models of Mac
a lot of the guides have all the sensor names needed for asmc

reddit - Apple Technician Guides

https://www.reddit.com/r/ifixit/comments/11t0sqb/free_download_all_official_apple_technician/

Macbook Pro Retina 13inch 2015 - Apple Technician Guide


the asmc.c and asmcvar.h on freebsd contain a list of sensor names needed for various models of mac
but the problem is you normally need to dump the smc settings from a mac running mac osx to get the settings

which obviously means you need a that particular model of mac to get the settings
thats why Freebsd mac support for asmc is a bit hit and miss

because it required users with a particular model to dump the settings and submit them
obviously the freebsd foundation couldnt buy every mac that came out to get the settings to add to the asmc files

to increase support for mac hardware you need the asmc settings for different models

the Apple Technician Guide pdfs have all the asmc settings and names

so its just a matter of downloading the pdfs for the different models of mac hardware
getting the asmc settings from the pdf and then creating and submitting a patch for the asmc files

this would really increase Freebsd support on mac hardware
instead of relying on users with a particular model to submit the settings we can get them directly from Apple

If you have Mac hardware it might be worth having a look on the reddit post
and seeing if there is a guide for your machine with the asmc settings

which you could then try out and if they work create a patch and submit it

or we could just extract all the asmc settings from the pdfs and create patches for them
if we dont have the particular model to test it on

Dropbox note

if you click the download button on dropbox where the pdfs are hosted
it opens a pop up window asking you to sign in

you dont need to login into dropbox
underneath the login form is a link that says

"or continue with download only"

just click that to download the pdf
i found that firefox with ublock kept closing the tab for some reason

so i used chromium to download the pdf
just thought id mention it in case you couldnt download the pdfs

I have attached Thermal Sensor page from the Guide
the whole pdf was too large to attach
 

Attachments

  • mbp-13-2015-early-retina-sensors.pdf
    17.2 KB · Views: 8
progress so far, no luck yet

i created a new entry for the MacBookPro12,1 in the asmc.c

and created new entries in asmcvar.h taken from the Apple pdf for
ASMC_MBP114_TEMPS, ASMC_MBP114_TEMPNAMES, ASMC_MBP114_TEMPDESCS

Built the custom kernel
but i get an error message about slot 10

asmc.c - new entry for MacBookPro12,1

Code:
    {
      "MacBookPro12,1", "Apple SMC MacBook Pro (Retina, 13-inch, Early 2015)",
      ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS,
      ASMC_MBP114_TEMPS, ASMC_MBP114_TEMPNAMES, ASMC_MBP114_TEMPDESCS
    },

asmcvar.h

new entry with settings taken from the Apple manual for the MacBook Pro Retina 13inch 2015

Code:
#define ASMC_MBP114_TEMPS    { "TB0T", "TB1T", "TB2T", "TA0P", "TC0C", \
                                  "TC0P", "TC1C", "Th1H", "THSP", "TM0P", \
                                  "TPCD", "Ts0P", "Ts1P", "Tw0P", NULL }

#define ASMC_MBP114_TEMPNAMES    { "TB0T", "TB1T", "TB2T", "TA0P", "TC0C", \
                                  "TC0P", "TC1C", "Th1H", "THSP", "TM0P", \
                                  "TPCD", "Ts0P", "Ts1P", "Tw0P", NULL }

#define ASMC_MBP114_TEMPDESCS    { "battery0", "battery1", "battery2", "logicboard", "logicboard_cpu0" \
                                  "logicboard_nearcpu", "logicboard_cpu1", "logicboard_leftfin", "logicboard_rightfin", "logicboard_nearmemory", \
                                  "logicboard_pch)", "trackpad", "trackpad_actuator", "io", NULL }

asmc.c - last model before the MacBook Pro Retina

Code:
    {
      "MacBookPro11,3", "Apple SMC MacBook Pro Retina Core i7 (2013/2014)",
      ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS,
      ASMC_MBP113_TEMPS, ASMC_MBP113_TEMPNAMES, ASMC_MBP113_TEMPDESCS
    },

asmcvar.h - previous model MacBookPro11,3

Code:
#define ASMC_MBP113_TEMPS    { "TB0T", "TB1T", "TB2T", "TBXT", "TC0E", \
                  "TC0F", "TC0P", "TC1C", "TC2C", "TC3C", \
                  "TC4C", "TCFC", "TCGC", "TCSA", "TCTD", \
                  "TCXC", "TG0D", "TG0P", "TG1D", "TG1F", \
                  "TG1d", "TH0A", "TH0B", "TH0F", "TH0R", \
                  "TH0V", "TH0a", "TH0b", "TH0c", "TM0P", \
                  "TM0S", "TP0P", "TPCD", "TW0P", "Ta0P", \
                  "TaSP", "Th1H", "Th2H", "Ts0P", "Ts0S", \
                  "Ts1S", NULL }

notice it has a lot more entries than listed for the MacBook Pro Retina in the pdf
i tried using those settings for the Retina and it didnt work

back to the drawing board

These are all the Thermal settings dumped from the mac smc

Code:
  TA0P  [sp78]  38.500 (bytes 26 80)
  TB0T  [sp78]  33.297 (bytes 21 4c)
  TB1T  [sp78]  33.297 (bytes 21 4c)
  TB2T  [sp78]  30.398 (bytes 1e 66)
  TBXT  [sp78]  33.297 (bytes 21 4c)
  TC0C  [sp78]  46.000 (bytes 2e 00)
  TC0E  [sp78]  52.727 (bytes 34 ba)
  TC0F  [sp78]  53.980 (bytes 35 fb)
  TC0P  [sp78]  45.500 (bytes 2d 80)
  TC1C  [sp78]  46.000 (bytes 2e 00)
  TCFC  [ui16]  32 (bytes 00 20)
  TCGC  [sp78]  47.000 (bytes 2f 00)
  TCSA  [sp78]  0.000 (bytes 00 00)
  TCXC  [sp78]  47.781 (bytes 2f c8)
  TH0A  [sp78]  39.625 (bytes 27 a0)
  TH0B  [sp78]  38.625 (bytes 26 a0)
  TH0C  [sp78]  38.625 (bytes 26 a0)
  TH0F  [sp78]  -44.328 (bytes d3 ac)
  TH0R  [sp78]  -45.375 (bytes d2 a0)
  TH0V  [sp78]  37.793 (bytes 25 cb)
  TH0a  [sp78]  39.625 (bytes 27 a0)
  TH0b  [sp78]  38.625 (bytes 26 a0)
  TH0c  [sp78]  38.625 (bytes 26 a0)
  TH0x  [sp78]  38.625 (bytes 26 a0)
  THSP  [sp78]  -127.000 (bytes 81 00)
  TM0P  [sp78]  42.750 (bytes 2a c0)
  TMLB  [sp78]  -127.000 (bytes 81 00)
  TPCD  [sp78]  45.000 (bytes 2d 00)
  TW0P  [sp78]  -127.000 (bytes 81 00)
  Th1H  [sp78]  39.875 (bytes 27 e0)
  Ts0P  [sp78]  29.812 (bytes 1d d0)
  Ts0S  [sp78]  37.684 (bytes 25 af)
  Ts1P  [sp78]  29.750 (bytes 1d c0)
  Ts1S  [sp78]  37.543 (bytes 25 8b)
  Ts2S  [sp78]  35.805 (bytes 23 ce)
 
i tried removing the names i set in ASMC_MBP114_TEMPDESCS
and just used the sensor names

but i get an error saying asmc couldnt read key MOCN
the annoying thing is googling for answers just returns the posts on this forum

the asmc.c is unchanged

asmcvar.h

Code:
#define ASMC_MBP114_TEMPS    { "TB0T", "TB1T", "TB2T", "TA0P", "TC0C", \
                                  "TC0P", "TC1C", "Th1H", "THSP", "TM0P", \
                                  "TPCD", "Ts0P", "Ts1P", "Tw0P", NULL }

#define ASMC_MBP114_TEMPNAMES    { "TB0T", "TB1T", "TB2T", "TA0P", "TC0C", \
                                  "TC0P", "TC1C", "Th1H", "THSP", "TM0P", \
                                  "TPCD", "Ts0P", "Ts1P", "Tw0P", NULL }

#define ASMC_MBP114_TEMPDESCS    { "TB0T", "TB1T", "TB2T", "TA0P", "TC0C", \
                                  "TC0P", "TC1C", "Th1H", "THSP", "TM0P", \
                                  "TPCD", "Ts0P", "Ts1P", "Tw0P", NULL }
 
on line 97 of the asmcvar.h i found reference to MOCN

Code:
/*
 * Sudden Motion Sensor (SMS).
 */
#define ASMC_KEY_SMS        "MOCN"    /* RW; 2 bytes */

in the asmc.c

i copied the settings for the previous model

Code:
    {
      "MacBookPro12,1", "Apple SMC MacBook Pro (Retina, 13-inch, Early 2015)",
      ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS,
      ASMC_MBP114_TEMPS, ASMC_MBP114_TEMPNAMES, ASMC_MBP114_TEMPDESCS
    },

note this line

Code:
ASMC_SMS_FUNCS

another model has this line in the asmc.c

Code:
ASMC_SMS_FUNCS_DISABLED

ill try using that and see if it resolves the issue
 
asmcvar.h contains

Code:
#define ASMC_KEY_SMS_FLAG    "MSDW"    /* RW; 1 byte */

which is also present in the smc settings i dumped from the mac

Code:
MSDW  [flag]  (bytes 00)

so ill try that instead of

Code:
#define ASMC_KEY_SMS        "MOCN"    /* RW; 2 bytes */
 
kernel didnt build with that option

now trying with the following in the asmc.c

Code:
    {
      "MacBookPro12,1", "Apple SMC MacBook Pro (Retina, 13-inch, Early 2015)",
      ASMC_SMS_FUNCS_DISABLED, ASMC_FAN_FUNCS2, ASMC_LIGHT_FUNCS,
      ASMC_MBP114_TEMPS, ASMC_MBP114_TEMPNAMES, ASMC_MBP114_TEMPDESCS
    },

using these options from a previous model

Code:
ASMC_SMS_FUNCS_DISABLED, ASMC_FAN_FUNCS2

takes a while to build the kernel and test the options
 
Eureka

asmc working on MacBook Pro (Retina, 13-inch, Early 2015)

ill have to create a patch and submit it

Code:
sysctl dev.asmc

Code:
dev.asmc.0.light.control: 0
dev.asmc.0.light.right: 0
dev.asmc.0.light.left: 4
dev.asmc.0.temp.Tw0P: -1
dev.asmc.0.temp.Ts1P: 30
dev.asmc.0.temp.Ts0P: 30
dev.asmc.0.temp.TPCD: 49
dev.asmc.0.temp.TM0P: 46
dev.asmc.0.temp.THSP: 129
dev.asmc.0.temp.Th1H: 42
dev.asmc.0.temp.TC1C: 54
dev.asmc.0.temp.TC0P: 49
dev.asmc.0.temp.TC0C: 53
dev.asmc.0.temp.TA0P: 41
dev.asmc.0.temp.TB2T: 31
dev.asmc.0.temp.TB1T: 35
dev.asmc.0.temp.TB0T: 35
dev.asmc.0.fan.0.targetspeed: 1299
dev.asmc.0.fan.0.maxspeed: 6199
dev.asmc.0.fan.0.minspeed: 1299
dev.asmc.0.fan.0.speed: 1293
dev.asmc.0.fan.0.id: Right Side   üǶ
dev.asmc.0.%parent: acpi0
dev.asmc.0.%pnpinfo: _HID=APP0001 _UID=0 _CID=SMC-HURONRIVER
dev.asmc.0.%location: handle=\_SB_.PCI0.LPCB.SMC_
dev.asmc.0.%driver: asmc
dev.asmc.0.%desc: Apple SMC MacBook Pro (Retina, 13-inch, Early 2015)
dev.asmc.%parent:

keyboard backlight works

aliases in my ~/.zshrc

Code:
# keyboard backlight on
alias backlight-on='sysctl dev.asmc.0.light.control:255'

# keyboard backlight off
alias backlight-off='sysctl dev.asmc.0.light.control:0'

so i just type backlight-on or backlight-off in the terminal to enable the keyboard backlight

asmc.c

Code:
    {
      "MacBookPro12,1", "Apple SMC MacBook Pro (Retina, 13-inch, Early 2015)",
      ASMC_SMS_FUNCS_DISABLED, ASMC_FAN_FUNCS2, ASMC_LIGHT_FUNCS,
      ASMC_MBP114_TEMPS, ASMC_MBP114_TEMPNAMES, ASMC_MBP114_TEMPDESCS
    },

asmcvar.h

Code:
#define ASMC_MBP114_TEMPS    { "TB0T", "TB1T", "TB2T", "TA0P", "TC0C", \
                                  "TC0P", "TC1C", "Th1H", "THSP", "TM0P", \
                                  "TPCD", "Ts0P", "Ts1P", "Tw0P", NULL }

#define ASMC_MBP114_TEMPNAMES    { "TB0T", "TB1T", "TB2T", "TA0P", "TC0C", \
                                  "TC0P", "TC1C", "Th1H", "THSP", "TM0P", \
                                  "TPCD", "Ts0P", "Ts1P", "Tw0P", NULL }

#define ASMC_MBP114_TEMPDESCS    { "TB0T", "TB1T", "TB2T", "TA0P", "TC0C", \
                                  "TC0P", "TC1C", "Th1H", "THSP", "TM0P", \
                                  "TPCD", "Ts0P", "Ts1P", "Tw0P", NULL }
 
Back
Top