Samstag, 12. Oktober 2019

ESP32 to start/stop VMs and control the Fans of my water cooling (Part 1 Theory)

So meanwhile I have decided to stay with the ESP32 micro controller as my preferred solution to turn the signal of the additional buttons into commands for the hypervisor to start and stop VMs.
I also sorted out the issue with the connections to my computer. It seems that I had an old/wrong driver for the CP210x USB to UART Bridge installed, that I had to remove first.
Then I installed the latest drivers from Silicon Labs and it works like a charm.

The next issue was the SSH client that I wanted to use to login to the hypervisor from the ESP32. I spent a whole Sunday to troubleshoot the package I found on GitHub. Long story short, I could not get it work, somewhere in the hex.c I lost it and had no desire to continue.

But, then I tried the precompiled micro python package from Boris Lovosevic:
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki

It is basically a python interpreter that you install as new firmware on the ESP32. First I was sceptic because I did lose the ability to use the Arduino style C to program the ESP32, with all the existing libraries. But then I realized that this package had everything I needed and more.
Also I did some python scripting in the past, so this was not completely new to me.

But most important, it contain a working SSH client that already had a function to remotely execute commands. It worked on the first try.

Shortly after that I had another idea. The fan control outputs on my Gigabyte Designare are not enough to control all the fans I have. Alphacool recommended to get 6 fans for my monster radiator, 3 pull and 3 push fans.
Hey, I have an ESP32 with a lot of unused pins. To my luck the ESP32 can do PWM and the micro python package from Boris has a lib for that. The next problem would be the tacho signal for the fans.
I already did some research how exactly the tacho signal and the PWM control for PC fans work, when I built my first water cooled Prusa MK3 3D printer clone with water cooling.

Noctua provides a white paper on more details about the PWM and the tacho signal:

https://noctua.at/media/wysiwyg/Noctua_PWM_specifications_white_paper.pdf

And there is also the definition from Intel from 2004.

Basically PWM means that the fan is turned on/off with a square wave signal. The rate between the high(on) and low(off) signal is promotional to the speed of the fan. This works much better as lowering the voltage of fan to regulate the speed. A frequency of 25KHz is used for the square wave signal to avoid any noise.
The PWM input on 3/4 pin PWM PC fans have an internal pull up resistor to 5V or 3.3V, even if the fan has a supply voltage of 12V.

The most GPIO pins on the ESP32 can be used for a PWM signal. Only problem is that the ESP32 needs 3.3V for the signals and will be damaged if you connect it to 5V.
Even thought Intel recommended already in 2004 to use an internal pull up resistor to 3.3V instead of 5V, in the Noctua White paper they have written 5V all over the document, except for on sentence.

But there is an easy way to determine if the pull up is to 3.3V or 5V. When the fan is powered up with the 12V supply voltage and nothing connected to the PWM input, you can use a simple multimeter to measure the voltage between ground and the PWM input.

If it is 3.3V you can directly connect it to the ESP32, maybe add a resistor to limit the current.
In the case of a 5V internal pull up, you need a little voltage divider circuit to limit the voltage to the 3.3V.

The tacho signal is an open drain output. You can use a 10KΩ pull up resistor to 3.3Vcc for the connection to the ESP32. But I was curious if the ESP32 could measure the frequency to get the rpm of the fan.

And the frequency is proportional to the rpm. You get 2 pulses from the hall sensor per rotation of the fan. The max RPM of the NF-F12 I use is 1500RPM which translates into 50Hz.
fan speed [rpm] = frequency [Hz] × 60 ÷ 2
1500 rpm = 50 Hz *60 ÷ 2

I will try to use an IRQ to time the signal and get a value for the rpm. It will not be perfect, but for a fan control absolutely sufficient.

I have enough GPIOs left on the ESP32 to control all 6 fans.

The last element will be a temperature sensor for the water. I will use a analog input with a simple circuit to get a value for the temperature.

When I was shopping at Aliexpress I was tempted to order a small LCD or OLED display for the ESP32. I could display the water temperature, fan speeds or display what VM is started/stopped.
But then I realized that those display take up a lot of the GPIO ports.

On ebay I found 2 very good deals this week.
1) I was looking for the Dark Power Pro 11 power supply from beQuiet! with 1200W. I found that beQuiet! has a official store with refurbished ps. Then I found another dealer who offered the ps from a show case with 0 operating hours and full warranty. I made an offer and got it for only 180€, that is 100€ less than the official list price. It came with all the cables and was in perfect condition.
2) Noctua has also an official store at ebay and sell refurbished fans with full 6 year warranty. I bought my 6 fans there in bulk and saved quite a bit of money as well. Unfortunately they did not come with ANY accessories expect for 30cm cables. So the anti vibration pads were missing as well. As I only wanted to have the white ones I got them after friendly asking and reminding that the product photo show the fans with all accessories

I was also hoping to see a price drop for the Intel Core i9 9900 now that Intel announced the new line of CPU. But Intel did not lower any prices, instead you can get the new more powerful CPU for the same price as the old ones. My hope is that the sellers will start to sell off the old CPU for a lower price. The CPU is the last missing piece for my built.

Mittwoch, 2. Oktober 2019

Calculating the Specs for the PS and finishing the power buttons details.

After some tests with acpid daemon on linux and scripts to monitor the power button, I am not happy how this turned out. It is difficult to detect a single press vs a double press as you have to store the 1 press for a short time and then please it again.

So I am back to my idea to use some extra buttons in my chassis. I even managed to get some nice aluminum buttons with LED light. Then I had the idea that I still have some ESP8266 development board lying around. They have WLAN onboard and should be up for the task.
But I was not able to find a SSH client on this platform, but for successor the ESP32. So I ordered one in form of a development board.
There is a SSH client that can be used in Arduino https://github.com/J-Rios/Arduino-esp32sshclient .
Even though the author does not recommend it for usage in production, I guess for my purpose it should be ok.
The other option is to use MicroPython on the ESP32. I would have to flash a new firmware, but would get more programming options as python is a more powerful language than the Arduino IDE. There is a SSH client as well, but as it uses libssh2 also, it might have the same issues as the other client. https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/ssh

I would have started testing both, if I could connect to the board on any of my Macs. For some reason I see the CP2102 USB to UART Bridge Controller in the system report under USB connections. But I cannot get the /dev/tty.SLAB_USBtoUART even I have installed the driver from Silicon Labs https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers .

So once I have figured that out, I can see which is the easiest way to implement this.

The other obstacle is that those nice 12mm button I have found have an integrated LED that runs on 12V, because the are supposed to be used in cars. There is 12V from the pc power supply, but I need to design a small transistor output to drive this with the ESP32 IO ports. So I will add a little perf board to solder the required components together.



On the pc hardware side I made some progress as well. I had a email exchange with Alphacool and got some recommendations. They also replied to my request on the bad reviews of the VPP755 pump and stated that the Version 3 has several changes to address the issues, like ceramic bearings for example. The other recommendation they gave me is to use 6 instead of 3 fans on NexXxoS Monsta 360mm Radiator. Because it is so thick, one set of fans might not ba able to push/suck enough air thru. So I will need 6 of the Noctua fans, 3 will push and 3 will pull air form the other side.
With this setup they were also confident that this one radiator will be enough to cool the CPU and 2 GPU under full load.
I also used the power calculator from beQuiet!. I already estimated around 800W (200W for the CPU and 300W for each GPU) and was prepared to go for the 1000W Dark Power Pro 11 PS. But using the power calculator took also the water cooling, fans and SSD/HDD in consideration and calculated a power consumption between 990W and 1090W depending on the number of drives, fans and loads you add to the USB ports.
Usually I like to go much higher with the PS than I need, just because I hope the fans on the PS will not start as often as if I would be close to the max.  But here I don't have a lot options, so the 1200W Dark Power Pro 11 will be the one for my build.



Samstag, 21. September 2019

An all new start with Hackontosh in 2019

I have some Apple computers, a Mac Mini, some Macbook Pro´s and when I wanted to buy a iMac 27" in 2012 I was annoyed that it took Apple so long to come up with a refreshed model. I did not want to wait any longer, but I also did not want to waste my money on an outdated model.
So I stumbled across a few hackintosh websites. This is how all my hackintosh experience started in 2012.

At the time I bought the components

GigaByte GA-Z68XP-UD3
Corsair CMZ16GX3M4A1600C9B Vengeance 16GB
Intel Core I7-2600K
SAPPHIRE Radeon HD6870
OCZ Nocti SSD 60GB mSata
LG BH10LS38 internal blu-ray burner
Samsung SyncMaster S27A550H

Later in 2012 I upgraded the mSata to a 120G version and added some more HDDs.

The monitor did exactly last for the warranty period and then I had to replace the capacitors in the power supply. Which was a recurring problem until I replaced the whole monitor.

But other than that this setup lastet quite long for me. But in 2018 I had to replace my GPU to a Gigabyte GeForce GTX 1050 Ti GAMING 4GB to be able to play the latest game in the Total War series from Sega.

Then I had a system outage caused by a lightning-induced overvoltage. That is really rare in Germany. But that fried my power supply and might have damaged the mainboard. I replaced the power supply and was able to recover the mainboard with the dual bios feature. I turned out that the 1 BIOS was corrupted an I could fix it by flashing the BIOS again.
The system seemed to work, but sometimes I took extremely long to boot during the BIOS start. But once everything was up, I could work with it.

Then I tripped over a USB cable which resulted in a broken USB port in the chassis and a shortage that fried some of the USB ports on the board. But the rest still seemed to be ok.

With the missing support from Apple, Nvidia was not able to sign the webdrivers for the latest Mac OS version. Also the new Total War Warhammer II, which I bought at a steam sale and couldn't play as it had a minimum requirement for macOS 10.14 Mojave. Which was checked upon game start.
So I had to replace the Nvidia card with a Sapphire Radeon RX580 and upgraded to macOS 10.14 Mojave.

But recently I noticed that the system was getting slower by the day. I use Fusion 360 to create models for my 3D printer or my CNC machine. Here I experienced really long load times and sometimes why computer freezes for a minute or two. But also other areas where the system was no longer responsive enough to have a good user experience.
But hey the system is now over 7 years old, it lasted very long.

So now it is 2019 and after struggling with myself for some months I finally decided that it is time for a ll new hackintosh built.

I have to admit that I looked into the new iMac and even iMac Pro models. But they are ridiculously overpriced in my eyes. In the past I always way a defender of Apple, because you really got a lot for your money. It was just not possible to buy the same high quality parts to built your own Mac with the same features for much less than Apple charged.
But today Apple seems to have lost their mind. I configured an iMac 27" that would suite my needs and was already way above 4000€. For a decent iMac Pro you quickly in the 10000€ price range. Sorry, but I would rather buy a new motorbike, then spending that much money on a computer which has lost most of its value in 4-6 years.
And for a system that you cannot upgrade anymore. Yes, it seems like in the notebooks, Apple is going to solder not only the memory, but also the SDD chips directly on the board. And even worse they started to bond boards in the system together that you are not able to repair it by swiping the defekt board, even if you have exactly the same board salvaged from another system.
I also made some bad experience with the Apple HW support and follow Louis Rossmann on his youtube channel. And honestly, if Apple continues to treat its customers like they do now, then more Apple users should stop buying their products.

But back to my hackintosh.

What annoys me most on computers and game consoles as well are the loud fans that seem to run all on full speed as soon as you start a game.
This lead me to the decision to go with a water cooling for my new system. I also wanted to have a kind of high end system, in hope it will last for a while, just like the old one did.
Even though there are many tutorials out there now, how to built a mackintosh with an AMD Ryzen CPU and I admit that you get more cores and threads for less money than you get from Intel these days, I still picked the Intel Core i9 in hope to have less problems in the future.
I also wanted to have a really powerful GPU and compared the different options from AMD. The Radeon VII is the most powerful GPU they have, that still outperforms the never version and is so far the only GPU in 7nm. But AMD discontinued the Radeon VII in favor of the newer GPUs. But I managed to get a "new" Sappire Radeon VII as a warehouse deal for "only" 700€. Since that it seems like the price is skyrocketing to 1000€ and more. I was not able to test the card yet, as I don't want to plug in my somehow broken old mainboard.

So this is my new hardware for the Hackintosh 2019.

Gigabyte Z390 DESIGNARE S1151v2
Intel Core i9 9900K
32 GB Crucial Ballistix Sport LT BLS2K16G4D32AESE 3200 MHz, DDR4 16GBx2, CL16
Sapphire Radeon VII 16 GB HBM2
Silicon Power PCIe M.2 NVMe SSD 2TB Gen3x4 R/W up to 3, 400/3, 000MB/s internal SSD
ABWB 802,11 AC WI-FI + Bluetooth 4.0 PCI-Express (PCI-E) BCM943602CS Combo card

For the Chassis I went with the Lian Li pc-o11dw in white. I liked the aluminium front and the glas side panel. Also it is a case "optimized" for water cooling.

For the water cooling itself I decided to go with parts from Alphacool and stay in their ecosystem. One of the reasons is that if you mix metals like aluminium and copper in the water cooling you will get galvanic corrosion of the parts. The other reason is that they just had a massive price drop for some parts on sale.

So this is the list of my water cooling parts

Alphacool Eisblock GPX-A Plexi Light AMD Radeon VII - mit Backplate
Alphacool NexXxoS Monsta 360mm Radiator - White Special Edition
Alphacool Eisblock XPX CPU - Intel/AMD - Deep Black
Alphacool Eisbecher D5 250mm Acetal
Alphacool Eispumpe VPP755 V.3
Noctua NF-F12 PWM chromax

I will not go for fancy hard tubes, glas tubes or even metal tubes. To me the only reason is that I want to have a silent system, reliable and not leaking any water on my precious computer parts.

So after all this talk about hardware, let me explain my plan for the OS installation. I am gonna give it a try to install MacOS in parallel to Windows 10. Why, well I love Mac OS, but some Games just are not available on Mac and running them in a VM or with Wine sucks from my point of view.
I could go with a dual boot as I have today. But I find it quite annoying when you just need to check your emails and have to boot into another OS first.
So here I will go with a hypervisor and having then MacOS and Win10 as guest VMs running on the same gear. With the new feature from KVM I can now passthrough the GPU card to a VM guest. My MacOS will then get the Radeon VII and the Win10 will get the old RX580 for now. Maybe I will upgrade later to replace the RX580 with a better Nvidia GPU for windows.
With this setup both OS will have their own dedicated GPU and monitor output.
The internal graphics form the mainboard will be used for the hypervisor host system, in case I have to troubleshoot anything.
I know that I might have a performance drop of 10% from the hypervisor, but the Intel Core i9 should be powerful enough that this should not matter too much for me. I don't play FPS hungry ego shooters anyway.
But I have the very big advantage that I can run both windows and Mac at the same time if I want to, but not have to deal with the limitations of parallels or fusion based windowed solution.

Another issue will be the mouse and keyboard. I could have the USB ports also passed thru to the guest VMs, but I don't really want to have 2 keyboards and 2 mouse on my desk. So I looked into a hardware KVM switch, but then stumbled across the software sharemouse. It is available for Windows and Mac OS and offers a seamless experience to control both systems with only 1 mouse and 1 keyboard. As a bonus this software also allows you copy&paste between the systems as well as to move files around between the systems with the mouse.

For the network I have 2 ports on the mainboard which will be assigned to the guest VMs, so every system will have its own network adapter. I have not decided yet if I may ad an additional external one for the host system.

With regards to sound I am going to use the KVM virtual sound card that should mix the sound of both VMs into one signal that makes use the sound on the mainboard. As I don't plan to play a lot of music on the systems, I am ok if this solution is not 100% perfect.

For the bluetooth and Wifi I plan to use the external card for Mac VM only and the onboard option for the Windows VM. This has the advantage that the external card will not require any patching as it uses 100% Apple compatible hw. But I am not yet sure if I need BT and Wifi on my Windows "gaming only" VM et all.

Currently I am looking into the options to manage the headless hypervisor. How to I start the VMs for example. I could just start both VMs every time I fire up the system. Or just one of them and use the running VM then to connect to the hypervisor to start the other VM. Shutdown both VM from the OS, and turn off the hypervisor with the power button.
Then I thought about a raspberry Pi zero to have buttons connected to the IO ports that then start a script which logs into the hypervisor(then I need network access) to start scripts to start/shutdown the VMs.
But I already use raspberry Pi zero´s in my 3D printers, and they take awful long to boot from an SD card. So I fear I would have to wait for the Pi to finish boot very time I start the system from power off.
This lead me to think about the acpid daemon on linux. You can use acpid to start your own scripts on the press of the power button. I just need to figure out a clever way to detect a single or double press of the button. Then I can start the Mac VM with a single and the Windows VM with a double press of the power button.