Qball's Weblog

Beati pauperes spiritu

Workaround for Garmin Broken Connect Server

| Comments

For a few days now I was unable to access the Garmin dashboard. The website would load a blank frame without content. Like below:

Garmin Dashboard

Looking at the Garmin forum, there are multiple reports of this:

First Second

Multiple people from the Netherlands reporting this, moderator keeps replying with:

All is fine. Check the status page at
and working perfectly for me right now.


Well it's working perfectly here so it's not a Connect issue. I suggest you call Customer Support by phone so they can
troubleshoot your system in detail.
Well it's working fine for me, both in Classic and Modern view, and has for a while now, so it's not a universal
problem. You'll need to contact Product Support.

Ok, so it works for you, so it cannot be a Garmin issue? WTF? The discussion continues like this, lets investigate.

Opening the developer page:

Garmin Dashboard

So the server is missing a bunch of javascript. Lets resolve connect.garmin.com and find another IP and a simple edit of /etc/hosts file:

1       connect.garmin.com

makes everything work again. I post this, people confirm this, and the moderator replies with:

Anyone with this issue call Garmin Support. They can check individual problems with individual systems, as it's
likely to be a router or your ISP issue. It's not a system wide Garmin problem.

This topic is now closed.

Eeuh wth, it isn’t. It is shown that it isn’t ( To be clear, the moderator is not a Garmin employee, but Garmin should avoid these things happening, this is not how paying customers should be treated.)

Anyway updating your hosts files fixes things and hopefully connect.garmin.com will be fixed soon. Garmin often is troubled with these kind of issues, for example I also have big issues with syncing recently (caused by same problem?).

Rofi 0.15.12 - Greg Is Luci

| Comments

Release 0.15.12

The 0.15.12 release of rofi focusses on improving overall user experience. These improvements mostly focussed on three things, first we (tried to) fix the problems with complex keyboard layouts, second we tried to make theming of rofi easier. Also we added several speedups. Below I will highlight these bigger changes in more details

Now that rofi reached an acceptable maturity level, we will start using more common version numbering. Right now rofi uses 0.year.month for version numbers. Starting with next version the widely used major.minor.bugfix scheme will be used. This means, that next rofi version will either be

  • 0.15.13 (bugfix release)
  • 0.16.0 (minor release) or (if no major bugs are discovered)
  • 1.0.0 (major release)

Keyboard Layouts

Rofi used to have problems with keyboard layouts that used modifier keys to switch between different layers. These problems should now be a thing of the past.

Note the syntax for binding keys has slightly changed. The Mod1, Mod2, etc. keywords are no longer available. There was no good way to detect how these keys where mapped and if they could be used as modifiers. E.g. if the right alt (say Mod3) is configured to switch between layouts, it cannot work as modifier key to make a Mod3-p keybinding. Rofi will now check if the current layout has the SuperR,SuperL,AltGr,HyperL,HyperR keys available. If they are available they can be used for keybindings, if not, the user gets a warning. development Rofi Keyboard Warning


DMenu reading from stdin

Rofi used to have a custom fgets implementation that supported custom separators. The has been repaced by the getdelim feature of POSIX ‘08, this gave a speedup of 6x (from 648 ms for 202000 lines down to 108ms).

Multi-Core power

Still disabled by default, rofi can now spawn multiple threads for filtering rows. Depending on the underlying hardware we saw a 1.5x speedup running on a dual core ARM and up to a 3.5x speedup on a quadcore (8 threads) i7 CPU. It uses Glib’s GThreadPool and will therefore spawn threads as needed and clean them up again afterwards.

To enable this option pass the -threads 0 option, this will autodetect the number number of hw-threads. Pass -threads 4 to force it to use 4 threads. Setting the number to 1, disables it.


Rofi color themes can be specified in a lot of detail, including the use of transparency to get desired results. However color syntax proved to be difficult and testing it can be a hassle. To solve this we added a web frontend for writing themes (with live preview) and a themes repository.

To make things even easier, you can now take screenshots of rofi from within rofi with a simple keybinding.

Rofi Internal Screenshot

Theme repository

This has been requested several times and rofi’s website actually has a theming page. This however got outdated quickly and neither the themes or the screenshots are correct anymore. The newly added rofi-themes git repository allows you to add themes easily: Fork the repository and export your current color theme with rofi -dump-xresources-theme. Place it in the theme directory of the repository and run the update script. This will automatically generate screenshots and update the page. Update your fork and send a pull request. This way your theme will appear on official themes page, once it’s merged.

The repository can be found here

Rofi Theme Site


The second tool is a website allowing you to easily create themes and preview all changes life, the themenator Big thanks to SardemFF7 who got tired of me complaining, took the very rough prototype and turned it into something beautiful.

Hopefully people will make beautiful themes and submit them to the theme repository.

Rofi Themenator

Full ChangeLog

New features:

  • Initial -dump command for dmenu mode. (#216)
  • Threading support.
    • Parallel checking for ASCII.
    • Parallel string matching.
    • Autodetect number of HW-threads.
    • Disabled by default.
  • Highlight multiple selected rows (#287,#293)
  • Dmenu can read from file instead of stdin.
  • Regex matching (#113)
  • Take Screenshot of rofi using keybinding.
  • Hotkey for sorting: (#298)
  • Option to set scrollbar width.


  • Fix return code of multi-select.
  • Update manpage (#289, #291)
  • Improve speed of reading stdin in dmenu mode.
  • Correctly handle modifier keys now. Should now support most weird keyboard layouts and switching between them. (#268, #265, #286)
  • Correctly set locale, fixing issues with entering special characters. (#282)
  • DRun mode support NoDisplay setting (#283)
  • Pango markup is matched when filtering. (#273)

Bug fixes:

  • Improve error message (#290)
  • Correctly switch to next entry on multi-select when list is filtered (#292)
  • Switch FUNCTION for func. (#288)
  • Fix segfault on empty list and moving through it. (#256,#275)
  • Fix one off of colors (#269)
  • Drun fix uninitialized memory (#285)

Android Viagra for 8 Tablet

| Comments

Just a reminder to myself, this simple one liner makes the NVidia Shield K1 tablet usable:

adb shell wm density 240

Now I actually get the tablet interface for apps, instead of stupid phone interface. I am not sure why android thinks that on 8” you want +– 1.5 cm big bars. Now I get the Nederlandse Spoorwegen and Spotify app in tablet mode and others.

The new 200 Euro price point for this tablet seems to be a good deal, especially when things like this are possible.

Rofi 0.15.10

| Comments

Rofi release 0.15.10

Because of large changes within rofi we skipped the 0.15.9 release. But I think it was worth the wait. The extra time allowed us to get some large changes through. I will highlight some of these changes in more details below, at the bottom you can find the full list of changes.

Fast ASCII filtering

Tom Hinton did some amazing work speeding up filtering in rofi for large lists. Rofi now automatically uses ASCII matching when possible, avoiding the very expensive UTF-8 calls. This makes Rofi usable on very last lists, especially tools like clerk benefit from this.


Cairo Drawing

This one should hopefully be invisible for most users, but rofi now uses cairo for all the drawing. This solves some of the weird issues with transparency. Transparent themes now look the way you expect them to look. In addition to the change to cairo, at a small memory cost, we reduced the amount of times fonts are (re)rendered, this gives a nice little performance boost on low end hardware. As a bonus using cairo made it easy to add fake transparency support.

Fake transparancy

Standalone and fullscreen rofi

Rofi now handles resizing and moving of the window better (not perfect yet), allowing it to be used as a standalone application in dmenu mode. Allowing you to switch to other applications, move the window and more. Because of these changes, Rofi can now handle being used in fullscreen mode; allowing for a distraction free work flow.


Combi mode supports ‘bangs’

Combi mode gives you very quick access to window switcher, run dialog and more in one list. You can now filter for a certain mode be prepending your query with a bang:

!r firefox

Will call firefox using the run mode. While it is not a large change it helps being fast and productive with rofi.


Improved help output

Rofi used to open the man page when called with -help, while useful this might not be ideal. It will now list all the available commandline options as you expect, even the dynamically added ones. The (static) options will show a small hint and every option also show the current setting, allowing you to review if your rofi setup is correct.


Rofi can be tweaked into the smallest details to your preferences. You can:

  • Hide the scrollbar
  • Hide the separator, or make it a dashed line.
  • Pango markup in dmenu mode.
  • Use glob style matching.
  • Disable tokenizing of query.

Full ChangeLog

New feature:

  • Support for Startup Notification
  • Standalone mode in dmenu
  • ssh: known_hosts parsing
  • Full screen support
  • Glob style matching
  • Fast ascii filtering (thx to Tom Hinton)
  • Combi bang support
  • normal window mode for dmenu
  • Startup notification support
  • Current desktop window mode


  • Keep same line selected
  • Cleanup menu code by re-using Switcher
  • Fix drawing on resize
  • Fix rofi -h output
  • allow disabling of tokenizing
  • Dragging scrollbar
  • Allow none type on separator
  • Dmenu support markup in fields

Bug fixes:

  • dmenu use switcher system
  • release keyboard on focus out event, regrab it on focus in event
  • Support \0 separator


I would like to thank everybody who made this release possible:

  • Benjamin Cremer
  • Bruno Braga
  • Buglloc
  • Daniel Hahler
  • Dave Davenport
  • Deiwin Sarjas
  • Edwin Pujols
  • Eric Engeström
  • Georgios Bitzes
  • Greg Fitzgerald
  • Hexchain Tong
  • Jason Pleau
  • Michael Vetter
  • Peter Cannici
  • Rasmus Steinke
  • Roomcays
  • Simon Hanna
  • Thomas Adam
  • Thorsten Wißmann
  • Tilman Blumenbach
  • Tom Hinton
  • daemoni
  • koppa
  • qedi
  • seanpringle
  • vimeitor

Rofi - 1 Year Old

| Comments

Around one year ago I decided to expand the functionality of simpleswitcher, because my wild ideas did not match with Sean Pringle his vision, I decided to fork it. Since then a lot of changes happened and simpleswitcher (now called Rofi) is no longer simple. On its one year anniversary I decided I wanted to add something to Rofi. It did not have to be something useful, but ‘special’.

Improved transparency

Given a few days before I realized the one year anniversary, I complained about the transparancy being not so nice (the ‘-opacity’ option) especially because it also makes the text transparent. I complained about fixing it being hard, so this is what I set out to do.

So if you X11 setup support TrueColor colormap (any modern one will) and you have a compositor running, you can now specify an alpha channel in each color. This will look like:

Rofi transparancy

As you can see, the background is transparent but the border, text and selected item not. I find this a lot nicer effect then the old transparency.

You can specify the color as follow: argb:AARRGGBB So for a half transparent black background you set: argb:7F000000. So for the above screenshot, the following settings apply:

rofi.fg:                   argb:FFffffff
rofi.bg:                   argb:cc000000
rofi.bgalt:                argb:dd2c3311
rofi.hlfg:                 #fdf6e3
rofi.hlbg:                 #859900
rofi.bc:                   #859900


I am still looking for a logo for Rofi.


I just release 0.15.1.

BinClock - Binary Clock Qball Style

| Comments

For the 2nd x-mas day I decided to make a clock. I recently (well already 1.5 years ago I build a nixie clock. We are moving building at work and one thing I miss in my current room is a clock. Bringing a nixie clock was my first idea, but it has some problems. Firstly it is expensive to build (especially the tubes that have a real 5 not an upside down 2), it has 170V running through it and relatively easy to access and it probably wears down pretty quickly when used 24/5.

So lets build something new, preferable with LEDs. But any clock won’t do, I had some ideas:

  1. . Binary Clock.
  2. . Non normal clock-face design.

Secondly I had some extra requirements:

  1. . The minimal number of components needed and wires. This so if I like it I can easily make a cheap PCB.
  2. . Possible show temperature.
  3. . PC interface, so maybe to use for notifications.

Clock Face

I had this idea for a binary clock face a while back, its simple and it is round (like a clock). The top part (yellow leds) shows minutes, the middle part (red leds) hours (1-12 h) and bottom part (blue leds) seconds.

Clock Face

I am pretty confident it will work out.


As I said I wanted to use the least amount of components, basically:

  • 16 LEDs and 2 resistors for the display.
  • MCU (for now I took an Arduino I had lying around) plan to take an Cortex m0 later.
  • DS1820 temperature sensor and pull-up resistor.


So I wanted the least amount of wires. So I re-used a trick I used several years back, to hook up LEDs. In this design I control 16 LEDs with 6 wires in total. Not sure hot to do it with less (without using extra hardware or LEDs with controllers build in).


It is a 2x4 grid (4 columns 2 banks), Then we can double the amount of entries by reversing polarity. If it works in star-trek why wouldn’t it work for me. The software is a bit more tricky, you can only enable certain LEDs at the same time (I choose to have only one on at the same time) and you need 3 states: High, Low, Floating. Luckely this is something easy to do on an AVR. The required resistors are in the bank lines.

Wiring - ugly soldering


This is where things get tricky, LEDs have the tendency to be bright, very bright. To top that, the only LEDs I had in stock where ultra-brights. So I tried several solutions:

  1. . Shine through wood. An idea that I had for a while now, but never knew if it would work. I drilled a hole that almost completely through the wood except for the last 0.5 mm (and dried various other depths). This did not give the desired result. The best result gave a weird stripe with the ‘flow of the wood’. I knew it was a long shot. Maybe I find the right wood for this later.
  2. . Veneer. I did not have anything sufficiently thin to work.
  3. . Milk-glass. This worked very well, except that the off-state are hard to see. Making it hard to read the time. So some ‘labeling’ on the glass was needed.
  4. . Paper. This worked surprisingly well and gave a nice ‘look’. Especially with the next point added.
  5. . Deep hole. I sunk the leds in a 3 mm deep hole, This looks very nice when looking at it from a (slight) angle. The problem of brightness still remains when looking directly in it.
  6. . I have some more ideas in combination with 5. If I find something perfect, I will blog about it.

For now I went with method 5, in a small wooden box. This box once held a ‘Amphenol precision connector/APC’ and dates back from 1973 or so. I got a few of these from the trash at work. If I am going to make a PCB I will make a nice small case around it. (Could be a watch?)

I also included the temperature sensor half embedded in the back of the case.

Leds front


The software can be found on GitHub. It is a simple arduino sketch, that uses lower level register access here and there to speed things up (and I am more used doing it this way). As said before, only one led can be turned on at the time, but quickly turning the required LEDs on and off I can create the illusion that any number of led is on. By playing with on/off time I can also dim them when needed.


There currently is a simple API for controlling things:

  • sHHMMSS Set time.
  • t Show temperature.
  • a Turn on all LEDs.
  • x Test sequence.
  • lX Set led on time between 0 and 255 (raw).
  • dX Set led off time between 0 and 255 (raw).

More to come.


There is more to do, like with any project.

  1. Make a final version.
  2. Port to Cortex M0.
  3. Make small PCB.
  4. Get time via Wireless or DCF.
  5. Button to show temperature.

Review Plantronics BackBeat FIT

| Comments

To do something random, I will review my new wireless headset, the plantronics BackBeat FIT. I have been using the headphones for 6 months now (already wrote the first version of this review 3 months back, but I updated it now to include latest experiences).

Reason for purchase

My previous bluetooth headset (plantronics BB903+) broke after many years of reliable service. It was squashed a few years back by somebody bumping full weight in my backpack. This broke off one ear-piece and after being held together by tape and instant glue for a couple of years it died.

BB 903 + (picture from plantronics.com)

Given I am using it traveling from and to work and during cycling, I set the following requirements for the replacement:

  • Bluetooth: Especially when cycling I do not want wires pulling on my ears. Beside it being painfull I broke many headsets this way.
  • Stereo sounds: It needs to support high quality (A2DP?) Audio.
  • Handsfree phone: This is extremely useful when traveling.
  • Multi-device support: My previous headset could connect to both my phone and tablet/laptop at the same time, using one for phone calls, other for music.
  • 6+ Hours battery: It should be similar or better then I had.
  • Easy, reliable fit: The last headset wasn’t the most compact/easy fit (esp. after being broken).
  • Hufter proof: It should be robust.

Reading many online reviews it quickly became apparent that the Plantronics was the best choice for me. It looked liked it satisfied all my requirements, looked very robust and it was the only one that had only positive reviews (some complained about weak base, I do not care about). Adding the fact that they build this for sporting, so it is sweat and rain proof, very robust (everything is flexible), does not block to much traffic noise and the positive previous experience it was an easy decision. I could put a list here of the other headphones I considered, but it seems the list is mostly outdated again.

BackBeat FIT


BackBeat FIT Case

The plantronics comes in a nice box, containing:

  • The head-set
  • USB charge wire. (Just a micro-usb cable)
  • Getting started guide
  • Impressively thick safety guide
  • A carrying case that doubles as an arm-band case for your mobile phone.

A fun note here is the text in the safety guide:

Please note the use of this accessory with iPod, IPhone, or Ipad may affect wireless

Does this affect the wireless performance of the i* or of the headset?

Initial use

Like any bluetooth headset, this was very easy, by holding the power button the device went into paring mode (A friendly female voice tells you ‘Pairing’) and phone/tablet/laptop could pair with it instantly. I tested this on Android 4.3 and up, windows 7, 8, 8.1 and Linux (Debian Jessie). So far so good. The website states, it can keep paired to 8 devices, this should allow me to use it with my phone, tablet and pc without having to re-pair each time. This works fine, although windows seems to be very reluctant to release the device, so it can be connected to something else.

Phone software

There is one thing to say about this one: CRAP. It is a huge program, that serves two purposes:

  1. . Manual. It shows you what buttons are there, and what they do.
  2. . Battery status. Showing you the remaining status.

For this it takes 10 mbyte of data. This would be fine, if it actually works. But no, for 70% of the time it shows a completely incorrect battery life time in the notification area. If you then open the app it will give a communication error and thats it. It is not capable of doing it main job: Show remaining battery. My advice, do not install it, it will just put you off. It is an issue with many hardware companies, they design nice hardware but have no clue about software.

The disappointment

When setting things up I hit one big disappointment, while the device support multiple devices it cannot connect to them simultaneous like the BB903+. I cannot have my tablet playback the music and have my phone connected for calls. After using this for a few months now, this turned out to be a non-dealbreak-issue. I put Spotify on my phone, and have no real use for my tablet. But something that was very useful from time to time and is missed.

Another small thing to note was the voice control, the old headset was a lot more verbose in giving information. It would tell me ‘4 hours remaining’ instead of full, medium and low that the current one does.

Wearing Comfort

One of the requirements was that it should be easy to put in and reliable to wear. The second thing is where it shines, I never had it fall out of my ear, get snagged or hurting my ears. I can easily wear the headphone for many hours. The headset leans on the top of your ears, it is balanced so the band at the back does not pull it out of your ears (you do not really notice it while wearing). The only minor gripe I found was that the headphone sometimes tick against the feet of my glasses (only on one ear though), this can be resolved by taking of the glasses and putting them on again, so the feet are on the outside.


BackBeat buttons (picture taken from the manual)

The small buttons are a bit awkward to use, but you get used to this very quickly. Pressing the left one raises the volume (by one step), holding it longer lowers it (by two steps weirdly). The right one turns it on/off (long press) or reports battery lifetime (short press). The two big buttons allow you to pick/hang up the phone (right), play/pause or skip song (left). The hit rate is still not perfect after using it for half a year. Especially skipping to next song often results in me pausing and unpausing again.

Build quality

The build quality is very good, there are no rough edges, discoloration, etc. After half a year of almost daily usage it is still in good condition, only close inspection shows some wear. This is very impressive. The whole headphone is very flexible. As advertised, you can throw it in your back and forget about it. The headphone also comes with carrying case that also serves as a arm-band for a smart phone. While it looks and feels nice, I haven’t used this one.


The 1st week I had BackBeat I got trapped in a huge shower, one of the showers that flooded several villages and collapse many buildings. Luckily the headphones lived through it perfectly, they kept working and did not fill up with water. It did however direct some of the incoming water into my ear, this was slightly unpleasant. Less heavy rain did not have this problem, I guess I can claim an ‘act of god’ here.

Rain (picture from spreadshirt.com)

Sound quality

One thing to keep in mind about this headset is that its designed to be worn while exercising outside. It does not try to block outside sounds, if you are wearing it on the bike, you are still fully aware of what happens around you. Traffic sound might drown out music (less for phone calls, see below), I find this a good thing, but YMMV.


Keeping in mind it is a wireless headset, the sound quality is more then sufficient. While it is worse then my wired headphones (2 Beyerdynamics), the overall performance is good. Basses are a bit weak, however I noticed this is very dependent on the fit. The better the seal, the nicer the bass. For the middle and high are clear and good for enjoying music while exercising. It is better then many other bluetooth headsets I tried. I won’t go into more details about this, as this is something very subjective. But one last remark, something I find very important, is that there is very little (unwanted) background noise. If the music is quiet (or volume on phone is set to low), so is the headset, no slight hissing (Like a rappoo I had before), no digital noise (like the audio output on my Dell laptop ) or other artifacts.

Phone calls

Where the music sound good, the phone quality is worse. It is a Weird thing; it is very easy to understand, but it is not a pleasant sound. It feels like they are boosting the loudness to improve understandability giving a very harsh sound. I guess in the end it does help you hear the other side, even over heavy traffic noises. People calling me indicated that they could hear me loud and clear, I have not tested this myself. It did not lead to any problems yet.

Battery life time

I cannot judge the talk time, as I never call more then a couple of minutes a day, plantronics claims a 6 hour talk time. The listening time to music is around 7-8 hours, it varies a bit and I haven’t figured out what is causing that. However it is close to the 8 hours advertised. Having it connected but unused, or unconnected seems to be a minimal drain on the battery. This is a significant improvement over other bluetooth devices. As a test I did not turn it off for a week, left it connected to my tablet, and it was still full.

Charging happens via a build in micro-usb port, it is a bit fiddly to open it up and use it, but it does the job. When charging the ring around the big button lights up red, and turns blue once full. Making it easy to see if it is full.

The life time is long enough that I often forget to charge it in time, it seems to be handling 10-20 minutes partial charges just fine. Giving me enough roughly 2 hours of listening time.


I strongly recommend this headset to anybody. The biggest down-side is the price. It is expensive and the price hasn’t dropped, nor is it for sale very often. It is worth it though, it lasts a lot longer then cheap head-sets and it adds a lot of comfort. If it will last more then 2 years (and I expect it to easily do that) it is cheaper over all.

Rofi Getting Popular? We Need a Logo!

| Comments

For reasons yet unknown to me, Rofi seems to be getting more attention lately. Having almost 100 stars at GitHub (pathetic I know, but it is a niche product.).

So any decent programs needs an icon, Right? Given I am the world shittiest artist, see my creation:

ARGH my eyes

So If anybody feels like making one; I am looking for a nice Rofi icon!


PWM on Udoo Using the i.MX6 - Update

| Comments

A small update on the previous blog post.

In the previous post I actually forgot to mention how to enable the high resolution clock for PWM. There are two ways to do this.

Fiddling with registers

The clock can be enabled in the CCM_CCGR4 register. Bit 22 and 23, these can be configured to be:

  • 00 Clock is off during all modes. Stop enter hardware handshake is disabled.
  • 01 Clock is on in run mode, but off in WAIT and STOP modes
  • 10 Not applicable (Reserved).
  • 11 Clock is on during all modes, except STOP mode.

So we want to set these to 11.

$devregs CCM_CCGR4
CCM_CCGR4:0x020c4078    =0x0000c300

Now we want to enable bit 22-23 so we or it with 0x00c00000

So to enable it we set:

$devregs CCM_CCGR4 0x00c0c300

And the clocks are running! However this might be risky, if you screw up you might enable or disable a clock. There is a nice ‘hack’ to accomplish the same!

The hack

Let the ½ working PWM driver do it for us!

echo 0 > /sys/class/pwm/pwmchip3/export
echo 1 > /sys/class/pwm/pwmchip3/pwm0/enable
echo 0 > /sys/class/pwm/pwmchip3/unexport

After this, everything works as expected.

PWM on Udoo Using the i.MX6

| Comments

I have been very bad, not writing blog post. I guess that will be habit I am never going to break.

This blog post is a quick write down what I did to get pwm output working on the Udoo.

Out of the box

Out of the box PWM the only usable PWM is the one on the Atmel, but I did not want to use that, it feels wrong (also it is arduino based, so getting a decent PWM requires hacking, etc.). The Freescale has it, so why not use that See pinout. So looking around on the install I did see a nice /sys/class/pwm/ directory with the 4 pwm generators, however this was completely non working for two reasons:

  1. The pinmux is wrong
  2. The entries do not seem to setup the right registers.

So looking around, I found this post basically the only one I could find that talked about setting up PWM on the Udoo. But it gave a nice starting point. Lets first try to compile that imx-utils repository. This failed, it is setup for cross-compilation, and tries to link against framebuffer device. ( I only want the devregs tool.) A quick hack to the make file fixed this, the whole makefile now looks like:

all: devregs

devregs: devregs.cpp

The second problem when trying to get the tool to work is the processor detection, under ArchLinux (running 3.17 kernel) the right Revision is not exposed. A quick hack of the code to always load the imx6 version made things work. I might post this version later, mail me if interested.

So lets start setting up the PWM, first thing we need to do is setup the right pinmux. BEWARE THAT THIS PIN SHOULD NOT BE AN OUTPUT ON THE ATMEL, IF YOU DO THIS WILL DESTROY THE BOARD


This sets GPIO42 to PWM4 output. Check the pinout. Then I followed the steps from the forum post, setting up the PWM:

devregs PWM4_PWMCR 0x0003fff0   # clocksource = 32kHz, div by 4096 = 8 Hz
devregs PWM4_PWMPR 6            # set period (6 + 2 = 8 cycles)
devregs PWM4_PWMSAR 1           # set duty cycle to 1/8
devregs PWM4_PWMCR 0x0003fff1   # enable PWM output

While I got some output from the PWM, it looked like utter sh??. It has a lot of high frequency components, and the output looks fully random. What could this be? (Sorry I forgot to take a photo of the output). Looking at the freescale manual IMX6DQRM.pdf it mentions several settings related to power? management: STOPEN stop mode enabled, DOZEN doze mode, WAITEN wait mode. By default if we hit any of these modes the PWM is stopped. I am not sure what Linux is doing, but lets be on the safe side and disable these.

devregs PWM4_PWMCR 0x0383fff0

And this instantly cleared up the PWM signal:


It is not perfect, there is still a lot of high frequency scruff on the signal, but it is clean enough. Now lets see if we can get a bit higher frequency going. Looking again at the datasheet, it looks like we can switch to highfreq clock,

devregs PWM4_PWMCR 0x0382fff0

And indeed the frequency goes up, now lets play with the prescaler a bit:

devregs PWM4_PWMCR 0x03824000

This gave me a nice stable 64kHz clock. (half from what I would expect based on the documentation, but that is an investigation for another time).

So to tie things together (I also inversed the PWM because my LED driver also inverts):

## Set pinmux
## Set high freq clock, inverse polairty, disable power  down modes etc.
devregs PWM4_PWMCR         0x03864000
## Set period to 255
devregs PWM4_PWMPR         0xfe
## Lights off
devregs PWM4_PWMSAR        0x00
## Enable clock
devregs PWM4_PWMCR         0x03864001

Now if I want to change the Light strength I call:


Changing the duty cycle.

There is one small thing we still need to tweak, the PWM has a 4 element queue before the ‘SAR’ (duty cycle) register, we need to make sure this fifo is not full before we insert an element. We can do this by checking the Status Register: (PWM4_PWMSR4). The lower 3 bits indicate the remaining space. Luckely, I never manage to hit this, so will fix this at a later stage when making a dedicated PWM application instead of using devregs. Maybe even a kernel driver?

This now gives me a very nice controllable PWM. I need to play a bit with improving ‘fading’ effects. Currently it takes 9 seconds to go from low to high.

Some scripts:

#!/usr/bin/env bash

declare -i LIGHT=$@

if [ -z "$LIGHT" ]

if [ $LIGHT -gt 255 ]

HEX_LIGHT=$(printf "%X" $LIGHT)

#!/usr/bin/env bash

STRENGTH=$(devregs PWM4_PWMSAR | awk -F= '{print strtonum($2)}')

and fading:

#!/usr/bin/env bash

declare -i LIGHT=$@

if [ -z "$LIGHT" ]

if [ $LIGHT -gt 255 ]


echo Going from $START to $LIGHT
if [ $START -gt $LIGHT ]

for a in `seq $START -1 $LIGHT`
        HEX_LIGHT=$(printf "%X" $a)
        devregs PWM4_PWMSAR $HEX_LIGHT > /dev/null


for a in `seq $START 1 $LIGHT`
        HEX_LIGHT=$(printf "%X" $a)
        devregs PWM4_PWMSAR $HEX_LIGHT > /dev/null