OpenCorsairLink in a jail to control fans?

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
I read about the Corsair Commander Pro[module] in another [thread] , and since no one has yet started a new thread on this matter as suggested by Kevin Horton...

This is a very interesting project! Congrats for getting it working. It really merits its own thread, as I expect there will be a fair bit of interest, and it can get confusing when threads contain discussions on more than one disparate subject.

I have borked the IPMI on my backup server, so depending on what it takes to resurrect it, I may be tempted to follow you down the CorsairLink road.

I think the Corsair Commander Pro is a super interesting product. Has anybody else also made succesfull use of the Corsair Commander Pro on a FreeNAS system? There is an active version of the Corsair Link software in Linux available [OpenCorsairLink]….maybe it is possible to make a FreeBSD variant sometime so one could run it in a jail (if possible…) to have better controle over the different fans and fanspeed in a system (and maybe leds.. ;))
 
Last edited:

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
@sretalla already did a lot of the work on this. I hope that sharing of the details will come with time. Often it is a matter of having the dime to do it because other priorities get in the way.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
I will eventually get there... I just had a look at the project ( OpenCorsairLink ) which has had updates since I did my work (and didn't contribute back), so it's entirely possible that since the project is at release candidate stage, it may already be OK... just needs to be compiled and tested on FreeNAS... I have the notes I used to remember how to do that somewhere at home and will post those here.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
I added and modified a bunch of code in the project (my local copy) over the course of several weeks in July, but it seems there were some changes to the master branch as late as September, so I would be most keen to see that compiled before I add the mess of my code into the mix.

In order to get it to compile, I needed to modify the makefile and a bunch of jigging on the FreeNAS box I had to test on.

So it seems after review of the makefile, I really only added 2 things to it (it seems they have radically changed the last section, so I have ignored that for now):
CFLAGS += -D_XOPEN_SOURCE=500
CFLAGS += -B/usr/lib32

Actually the first one is already there, just commented.

Then, the process to compile according to my notes (this was to do it on a disposable FreeNAS system... no comments please about how a couple of the changes are really bad for the system, no production data here..., so feel free to just not do this, instead get a FreeBSD system and just take the steps to install packages, cd into the root of the git project and run gmake):

Create a new jail
pkg upgrade
pkg install gcc
pkg install gmake
mount the storage location of opencorsairlink into the jail so it can be reached from both main and jail with rw.

on main system
ee /usr/local/etc/pkg/repos/FreeBSD.conf
set yes
ee /usr/local/etc/pkg/repos/local.conf
set no

pkg install gmake
pkg install gcc

in jail
cp /usr/lib/libc_nonshared.a ./
cp /usr/lib/libssp_nonshared.a ./

in main
cp libssp_nonshared.a /usr/lib/libssp_nonshared.a
cp libc_nonshared.a /usr/lib/libc_nonshared.a

gmake in jail (this does a partial make and fails, but leaves behind the prepared files for the main system to work with... seems it can't do this step on the main system)
gmake in main (now with access to the hardware and the critical libusb libraris that the jail can't install, we can finish the compile and have our executable)

There were a bunch of errors in the compiling process, but I looked into them all at the time and nothing important was wrong, plus the executable runs fine, so we're all good as long as the file is created at the end.

I actually bought 3 of the Commander Pros and haven't used the third one yet, so I may be able to mount it up in a test system, but it will be at least 2 months before I will be able to get to that.

I don't think it's necessarily the case that a device even needs to be present in the system where the code is compiled, so someone with the time and a FreeNAS/FreeBSD box could do it, then give the resulting executable to somebody with a device already installed to test (I could try it if requested).


Then I made a number of changes to the PID script from Kevin's github to make it work with the executable... I think it's safe to share that if anyone gets to that stage and wants it.

I have had it running in my main system since then and have the 3-pin version running in my old main system, ESXi FreeNAS box (passing through the USB). I had a little issue or 2 with the 3-pin version which was losing connection in the early days, I think due to ESXi being an older, non-patched version and was dropping the USB, but has been rock-stable for at least 2 months now.
 

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
Glad I could give this project a boost again!
Last week I had a Noctua fan which had quit spinning without me knowing it since there where 3 fans with 2 noctua splitters on the FANA-header (zone=0) of my supermicro X11SSH mobo. It indicated a normal RPM of one of the two other fans still spinning, but HDD temperatures were actually rising to alert levels. I only found out after some time what was going on by taking a look in the case itself…
It proofed to me that the chosen setup with spitters is weak… but since the Supermicro X11-boards have only 2 FAN-zones en 4 FAN-headers there is simply no other option at this moment :oops:.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
OK, so this has been bugging me and I spent a few hours trying to get the latest version from the project to compile, but I'm tearing my hair out with compile errors at the second stage where it's reporting stdint.h is missing from a path where it is clearly present and with OK permissions.

I give up.

What I will do is post (here) the source code I used to compile my 2 versions of the executable (with the executables) and the PID scripts with my mods.

This way, anyone with enough interest can at least get themselves to the same point as me (where I'm happy to remain for the foreseeable future).

Post to come after I check my PID scripts for passwords or something I don't want to see online.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
OK, so here it all is:

I have provided the source, which includes the GPL2 license information, so I'm doing what's right by the license (I think).

In addition to the 2 .elf files, clearly named by function, I have provided the hybrid fan controller scripts as adapted in each case.

With all of that, there should be sufficient information to get a device (Corsair Commander Pro... I did not do any of the other branches as I had nothing to test with... those bits of code were compiled as-is and may be working, broken or harmful to use, I have no idea, so stick to the Commander Pro functions please... or just don't bug me about the consequences if you try other things) working if it's correctly connected to an internal USB port and to the fans you want to use.

You can also optionally connect the temperature sensors, which I corrected the measurements from (a little vs big endian issue I needed to learn about in order to understand and fix) compared to the original code.

Here's a sample of the command from my main system (FAN 6 not connected):
Code:
root@FreeNAS:/mnt/vol4/scripts # ./OpenCorsairLink.elf --device 0 --fan channel=0,mode=0
Dev=0, CorsairLink Device Found: Commander PRO!

Vendor: Corsair
Product: Commander PRO
Firmware: V0.5.180
Temperature 0: 33.00 C
Temperature 1: 35.00 C
Temperature 2: 36.00 C
Temperature 3: 34.00 C
Output 12v: 12.13 V
Output 5v:  5.01 V
Output 3.3v:  3.38 V
FAN PWM 1: 55 %
FAN 1: 1243
FAN PWM 2: 55 %
FAN 2: 1203
FAN PWM 3: 45 %
FAN 3: 1422
FAN PWM 4: 45 %
FAN 4: 1426
FAN PWM 5: 45 %
FAN 5: 1424
FAN PWM 6: 100 %
FAN 6: 0


I note that the code also reads and displays the firmware version of the device, but I am certain that it does not manage it, so you would be best served to connect the device to a supported OS (i.e. windows) and update the firmware before installing it in your FreeNAS box.

EDIT: I forgot to mention, the executables simply run on the FreeNAS main system, no need (actually doesn't work without some serious tweaking) for a Jail.

EDIT2: I should probably mention that the 3-pin version is the last one I compiled, so the source is set up for that... it's just a case of changing a single argument from 0x1 to 0x2 or something, so should be easily found if somebody wants to compile it again and has (a lot) more patience than me.

Let me know how it goes and I'm happy to help (within limits) to get somebody running with it. Good luck (no, really, no sarcasm intended).
 

Attachments

  • fan controller scripts.zip
    23.4 KB · Views: 575
  • Executables.zip
    127.5 KB · Views: 548
  • OpenCorsairLink.zip
    636.4 KB · Views: 566
Last edited:

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
And once again, a massive thanks to @Kevin Horton and @Stux for their inspiration and work, which I have proudly stolen/built on top of to my best ability (which isn't actually great, but gets the job done).
 

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
I was wonderdering; would it also be possible to run Corsairlink on a Windows-10-VM in FN, or to run OpenCorairLink on a Linux-VM in FN and have the same functionality or better?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
It may be possible, but passing devices in bhyve is difficult, so would be better if you used vmware with two guests.

Windows is expensive in terms of RAM and CPU to do that job though. The stuff I posted works fine, so I am going to stick with it.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Also, there would be the problem of having the disk temperature measures, so you would also need some kind of service bridge to know when to control the fans and by how much.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Maybe it wasn't clear from my post, but you already have everything needed (including the already compiled executables and fan controller scripts) you can just copy them to your pool, make any script adjustment needed for your specific setup and run directly on FreeNAS.

OK, so you can't make the LEDs flash...

I get your point if you wanted one of the other devices.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Although, thinking about it, it might be nice to have LEDs change colour based on the HDD temps. That will have to be a project for another life.
 

Constantin

Vampire Pig
Joined
May 19, 2017
Messages
1,829
Thank you Srettalla, I will attempt to follow in your footsteps. The Corsair has the potential to be a really great problemsolver for my case.

At the moment, I'm using the resources on the ASROCK C2750 board and the lowest "smart fan" temperature threshold is 45*C... argh!
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
I'd be happy to hear feedback from anyone who has managed to get it working... seems nobody has had trouble/needed to ask for help.
 

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
I'd be happy to hear feedback from anyone who has managed to get it working... seems nobody has had trouble/needed to ask for help.
I would like to but I'd rather wait for some more experienced users to go ahead. Willl you be able to use the Corsair Link GUI or is it all CLI?
Is there a chance that this code will be implented in some future version of Freenas? That way its function is more secured after a systemupdate…
 
Last edited:

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Willl you be able to use the Corsair Link GUI or is it all CLI?
No, that's not an option as part of this as it's based on OpenCorsairLink (not the corsair official software... which is only really for Windows).

Is there a chance that this code will be implented in some future version of Freenas?
Considering what it is, I doubt that very much. It runs without needing installation and leverages the already installed USBHID drivers, so I don't see how including it in FreeNAS would be helpful for the very small (but perhaps slightly increasing) percentage of us using a Commander Pro.
 

Mannekino

Patron
Joined
Nov 14, 2012
Messages
332
Hi,

I really want to give this a try but I'm not sure where to start. I have a Commander Pro available and hooked up to the system with one of my fans connected and it's spinning and I'm running the latest version of FreeNAS 11.3. I have 4-pin Noctua fans and I want to have them spin a bit faster than my motherboard is currently setting them to. My hard drives are a bit too warm for my liking right now.

Where do I go from here?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Where do I go from here?
Download the executables and the script from the thread above.

Try running the executable as indicated in the example... you should see which fan is there and what speed it's currently running at

if all you want is to make the fan go faster, you can just run the command like this:

./OpenCorsairLink.elf --device 0 --fan channel=0,mode=0,pwm=100

Where 100 would be 100% fan speed... vary to your needs.

If you want to get the scripts running, you need to look for a couple of lines in the 4-pin one to update to where you are running the command from and where you want logging to go... then set thresholds and setup an init script to ensure it runs at startup.

Happy to provide guidance with more feedback.
 
Last edited:

Mannekino

Patron
Joined
Nov 14, 2012
Messages
332
Thanks, I've managed to get it working. That was much easier than I thought. I've set the PWM to 70% now for the two fans I hooked up to the Commander Pro. Disk temps have dropped. I will take a look at the scripts also.
 
Last edited:
Top