Fixing Ryzen Freezes Due to C6 Power States


Finally, I figured out how to make my system stable. For about a year I had been experiencing random freezes on my new system — but not ever while using it. I would come back in the morning and try to wake up the machine and it would be frozen. Turns out the root cause is the C6 power saving states in the Ryzen core are not fully compatible with the Linux kernel. Grrrr!

I’ll detail my fix here. I got on to this solution from a thread on and implemented it following this reddit thread.

Clone the ZenStates repo:

You can find it here:

git clone

Create a Script:

I called my

if [ "${1}" == "post" ]; then

# Disable c6 coming out of sleep
/home/mike/compile/ZenStates-Linux/ --c6-disable

Make it executable:

chmod a+x

Turn it into a service:

sudo nano /etc/systemd/system/disable-c6.service

and paste:

Description=Disable C6 on boot

ExecStart=/home/dk/Ryzen/ZenStates-Linux/ --c6-disable


Start it to disable C6 if it is currently enabled…

# systemctl start disable-c6.service

And get it to run on boot

# systemctl enable disable-c6.service

Custom Resolutions for Dell XPS 13 Running Ubuntu 16.04


I upgraded from a Chromebook to the Dell XP 13 (9360). The Developer Edition comes with Ubuntu 16.04 Xenial preinstall — which I love because it means this machine is counted as a Linux laptop and not as a Windows machine.

After installing the Cinnamon Desktop and doing a dist-upgrade the screen resolution settings were lacking. I could only choose 1920×1080 and 1360×768 as my 16:9 options. The former was tiny font, the latter was comically huge. And setting the scaling to 2 on the larger resolution looked horrible.

But this is why I really do love Linux. You can, of course, choose your own resolutions. It’s easy, and one set up they are chosen through the GUI tools just like normal.

How to create modelines for custom resolution in Linux:

I started by looking up a list of 16:9 resolutions. I selected two that are perfectly divisible by 8: 1792×1008 and 1664×936.

The process for adding these resolutions comes from thom’s askubuntu answer. Use xrandr to create and add modelines. First, just run xrandr without any parameters to establish the name of your display. Mine is eDP-1


Next, use cvt to generate the modeline for your target resolution

cvt 1792 1008


Use xrandr to add that resolution and assign it to the display. Notice for the second line we get the display name from our previous xrandr use, and the mode name from inside the quotes of the cvt output.

sudo xrandr --newmode "1792x1008_60.00"  149.50  1792 1904 2088 2384  1008 1011 1016 1046 -hsync +vsync
sudo xrandr --addmode eDP-1 1792x1008_60.00

Repeat this for any other resolutions you wish to add. Now when you load up the display settings you’ll have the new resolutions to choose from.


Make It Permanent

We’re not quite done yet. You need to make sure to make the changes persistent across reboots. Create the file ~/.xprofile and save your xrandr directives there. My file looks like this:

xrandr --newmode "1792x1008_60.00" 149.50 1792 1904 2088 2384 1008 1011 1016 1046 -hsync +vsync
xrandr --addmode eDP-1 1792x1008_60.00
xrandr --newmode "1664x936_60.00" 128.50 1664 1768 1936 2208 936 939 944 972 -hsync +vsync
xrandr --addmode eDP-1 1664x936_60.00

Photoresistor and an ATmega168 ADC

I’m starting on a new project and thought I’d share the first step. I eventually want to use two photoresistors to push data into the microcontroller. You’ve got to crawl before you can walk and I’ve set up a simple circuit to make sure everything is working.

Using a voltage divider that includes a CdS photoresistor I can take a measurement using the ADC that correlates to the intensity of light shining on that CdS sensor. In the video after the break I’m using a set of LEDs on the development board as a signal. When light intensity is low the LEDs are on. When I use a flashlight to increase the light intensity the LEDs go off.

This proves that I have everything set up correctly before I make my firmware more complicated. I followed along with the ADC tutorial over at AVR freaks to get this far. Eventually I’ll use two photoresistors, one to sense the clock and the other to sense the data. That will require interrupt based ADC readings. For now I’m using the free ranging mode. Keep reading to see the code.

Continue reading