Solved MacBook7,1 ASMC support

Hello everyone.

Recently I've got MacBook Mid-2010 model (MacBook7,1) and I want to install FreeBSD on it. I noticed one problem - asmc doesn't support this model. I need to manually control fan speed because automatic speed is not very good and seems to prefer less noise than less temperature. On macOS I'm using Mac Fan Control, on FreeBSD I think asmc is needed (I can't find other solution). I don't know how to make patch for this model. The most close patch I've found is patch for MacBookPro7,1 which is similar machine but not identical and I don't want to risk damaging my machine. How can I find or make patch for this machine to make asmc work?

Thank you in advance.
 
I made several asmc(4) patches for the various Mac minis I own which have been incorporated in the FreeBSD source tree. Unfortunately I don't have access to a MacBook.

The process is to first find the relevant system management controller keys. For this process it is very helpful to have a copy of the relevant Apple Technician Guide (eBay is a source for these) which mentions the keys and what they are used for (at least the Mac mini Guides do). The other useful tool is smcdump which dumps every key. I've attached a zip archive with the Makfile and source and a compiled version (for macOS 10.6+). It takes a fair while to run to completion.

The FreeBSD source files which need patching are:

* /usr/src/sys/dev/asmc/asmc.c
* /usr/src/sys/dev/asmc/asmcvar.h

To start off, I would use an existing entry as a template and remove/add keys. I would also make the key names meaningful and not just leave them as the raw key name, for example, "TB0T" rather than "enclosure_bottom0". These names show up when you list them with sysctl and so useful names are very helpful.

After patching, compile the module by switching to /usr/src/sys/modules/asmc and typing make. Install the new module with make install.

To load the module kldload asmc and to unload the module kldunload asmc.

Once loaded, sysctl dev.asmc should list the keys and allow you to set the minimum fan speed. On my Mac minis, which only have one fan, this is done on the command line with sysctl dev.asmc.0.fan.0.minspeed=3300 or by putting dev.asmc.0.fan.0.minspeed=3300 in /etc/sysctl.conf so it happens at boot automatically (you can still change it manually afterwards if needed).

Finally, once ytou have it all working, submit your patches via https://bugs.freebsd.org/bugzilla/ for inclusion in the FreeBSD source tree so that others can benefit in future.
 
Interesting. trev: I have a MacBook Pro (MacBookPro8,1) that I could run smcdump on, if that is of value? If so, please point me at smcdump, no attachment showed up with your post
 
trev I started analyzing asmc source and patch for MacbookPro I've found and it doesn't look very complicated. With your instructions I should be able to produce working patch (of course I will post it when I'll succeed). I see that I need to get temp sensors names from my machine add add it to asmcvar.h with new definition for my model in asmc.c. I'm going to try make this work.

Edit: First question. I've dumped all SMC values from macOS and it's indeed looks pretty similar to Macbook Pro patch I've found but there is one thing which is unknown to me - doubled values. I have some values which names differs by one letter size. For example I have Th1H value and Th1h. Both gives me same value but I can't understand why one value is listed double with slightly different name. Is it safe to to just omit doubled values? There are 3 of them.
 
For example I have Th1H value and Th1h. Both gives me same value but I can't understand why one value is listed double with slightly different name. Is it safe to to just omit doubled values? There are 3 of them.

It usually means that they are two distinct keys which mean similar but different things. That's why the Apple Technician Guide is valuable - so you know what they mean. A quick look at the values in asmcvar.h for the MBP112_TEMPS turns up "TH0A", "TH0B" and "TH0a", "TH0b" but unfortunately the person who submitted that patch did not bother naming the keys at all.

I forgot to mention before that when you load the patched module, you can check /var/log/messages for complaints about non-existent keys (if any). It should also record the loading/unloading of the module if you're doing it manually. For example:

Code:
Aug 10 23:55:27 shadow kernel: asmc0: detached [unloaded]
Aug 10 23:55:31 shadow kernel: asmc0: <Apple SMC Mac Mini 5,2> port 0x300-0x31f irq 6 on acpi0 [loaded]
 
trev Thank you for answer. I was able to implement initial support (without doubled values) and it seems to work fine. I can read temperatures and control fan without any problems or errors in dmesg. I wasn't able to find description for some keys so before I'll post it, I want to check more sources (probably Apple Technician Guide you've mentioned) to find what these doubled and unknown values means. Also I want to test it more. When I'll finish this - I will post patch on bugzilla.

Edit: About Apple Technician Guide - looks like it won't be easy to find. I can find this for MacBook Pro 2010 without problems but not for regular MacBook. It doesn't look like very popular machine with easy to find sources. When I'm checking other sources about SMC keys I can't even find doubled values. I'm not sure what to do with it.
 
From an extensive web search all the MacBook TH0a/TH0A TH0b/TH0B entry pairs I could find had the same values. So maybe it's safe to ignore one of each pair.

From a quick look at a couple of Apple Technician Guides for the MBP, I did not find any explanations of the SMC keys (unlike the Mac mini Technician Guides).

If you list the paired SMC keys you have (and any others for which you have no descriptive name), I have one last straw to grab - the author of a macOS utility to read/set fan speeds and read temperatures etc whom I helped out last year. He might be willing to share if I ask nicely :)
 
I've found one source for paired keys which listed keys TC0P and TC0p. First was described as "CPU 0 Proximity" (which is obvious because a lot of sources describe this similar) and second was described as "CPU 0 Proximity Raw". No idea about others, there are 3 of them in this model: TC0p, Th1h and Ts0p. SystemInfoKit documentation simply describes keys with lowercase same as keys with upper keys. I don't know if they should be ignored or listed with same description like in some sources. It looks like it doesn't matter for asmc if they are listed or not. Haven't noticed any bugs with or without them.

It would be nice if you can get those informations. Patch is ready, I haven't noticed any bugs or errors. Aside from temperatures and fan speed, SMS (Sudden Motion Sensor) also works fine - I get warnings in dmesg about possible shock when I move laptop suddenly. The only thing that is missing now is description for some keys. Aside from three doubled keys I've mentioned before, these keys are missing description for now: TN0S, TN1E, TN1F, TN1G, TN1S. Sadly Apple Technician Guide for MacBook Pro 2010 or iMac 2010 I've found don't cover these keys.
 
I received a reply this morning - good and bad news I'm afraid:

For the first question, the doubled keys seem to be exactly the same, so you should be able to just use the all caps version without any issues.

For the second question, I also don't know exactly what those keys are for. I've been doing my research and so far I haven't come up with a specific use for the those suffixes.

Sorry I wish I could be of more help!
 
I received a reply this morning - good and bad news I'm afraid:

Thank you for bringing this information. Your answers were really helpful. Yeah, too bad we couldn't figure out all these keys but most important are working fine. So, I'm ignoring lower case keys and leave unknown keys without description. I'll make some final preparations on patch and publish it on bugzilla. I hope it can land soon. Thank you again for your help.
 
Patches sent I think this topic is solved now.

dragon321, you should have also set a link to the patch. It might take some time until the patch lands in head and MFH to STABLE and subsequent to RELEASE. Meanwhile there might be others finding this thread and wish to apply and test the patch now on their system. I might be a future candidate, running currently High Sierra on MacBookPro8,2, no further macOS updates possible, after end of support the plan is to install FreeBSD.

Thank you both dragon321, trev.

 
Back
Top