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
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:
The pinmux is wrong
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:
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
devregs IOMUXC_SW_MUX_CTL_PAD_SD4_DAT2 2
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 Hzdevregs PWM4_PWMPR 6 # set period (6 + 2 = 8 cycles)devregs PWM4_PWMSAR 1 # set duty cycle to 1/8devregs 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 pinmuxdevregs IOMUXC_SW_MUX_CTL_PAD_SD4_DAT2 2
## Set high freq clock, inverse polairty, disable power down modes etc.devregs PWM4_PWMCR 0x03864000
## Set period to 255devregs PWM4_PWMPR 0xfe
## Lights offdevregs PWM4_PWMSAR 0x00
## Enable clockdevregs PWM4_PWMCR 0x03864001
Now if I want to change the Light strength I call:
devregs PWM4_PWMSAR $HEX_LIGHT
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.
Yesterday somebody made a nice post mentioning that we might be able to get native (so no wine
running silverlight) Netflix working under
linux. This uses html-5 DRM
enabled video playback. It requires the latest chrome beta, specific libraries and user-agent
tweaking. For some reason I had a very hard time to get the latest part working, this is also why
I am making this blog, to keep this one around:
Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2114.2 Safari/537.36
The big change is the chrome version (from previous link):
Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36
Do not ask me why, I had to do this a couple of times before Netflix took it… It works now, not
touching it anymore.
The playback is pretty stable and my aging pc seems to have little problems with it.
Also yesterday I released Rofi 0.14.8. I won’t repeat the previous blog posts, but in short the
Pango support: Switching to pango gives us correct fallback fonts, fixing issue #69.
RTL support: Pango also fixed this bug: issue #70
RTL entering: Rafi confirmed this is now working correctly.
Correct UTF-8 collating of strings. Rofi now converts the strings to a case insensitive form, then
creates collating keys. (using glib).
Improved dmenu support and minor extensions. This improves clerk.
Custom modi support using simple bash scripts.
A first throw at cleaning up the keybindings, thanks to lolilolicon. Issue: #73.
Trying out hoedown for Notes.CC. Hoedown only produces a body,
not the rest of the HTML page and CSS. So I am going to need a nice template to fill in. So far it
seems to be working fine, it seems to be actively developed. If anybody is willing to make a nice
So what is Notes.CC? It is a rewrite of Notes.txt in
C++. It tries to be faster and more integrated then the previous bash hack. It uses libgit2 to
handle the git repository and hoedown/discount for parsing the markdown file. I will release the
thing when it is mostly feature full and reliable.
For the past few years, my Samsung 740BF
been acting up a bit. When turning it on, or waking up from standby it would go give a garbled
image. However turning it off and on fixed it. However the last few weeks it been failing all
around, until today it decided to fail completely.
Experience learns that in most cases monitors and other devices die because of bad capacitors. This
must be true, because there is a wikipedia
So opening it up, I must say, Samsung nicely constructed this. It nicely clicks together and only a
few screws are needed to hold everything firmly in place. So I opened it up and took out the power
If you take a good look you see that one capacitors is swollen. The 3rd capacitor in the lower
left corner. So with a bit of careful soldering I took the capacitor out, a 16V 1000µF one. Replaced
it by a new one with exactly identical specifications I had in my collection. Though I am not sure
that it is of better quality, but never hurts to replace it. So after a few minutes of soldering:
A fresh new capacitor in place. A quick assembly later, it worked like new. It now turns on without
an issue and wakes up from standby. So using a € 0.03 capacitor I gave my (ancient) monitor a new
life, a very dutch thing for me to do.
Rofi recently got some nice updates. They are mostly tweaks to make things work just a bit better
but in total they are a good improvement.
In Rofi you can switch between the following modi’s: window switcher, run dialog, ssh dialog. The
latest changes allow you to specify the set of active modi, so if you do not use the ssh dialog you
can disable it. Simple change, but very useful. In addition I made an option to add switchers using
simple bash scripts. It is like the dmenu mode, but then more integrated.
Say I want to add a modi that allows me to quickly switch between the available
i3 desktops (instead of windows). You first specify (either via Xresources or
command line) the new switcher:
Rofi will first call the script with no arguments, this will make it generate the list of available
workspaces. Once the user selected an entry, Rofi calls the script again and passes the selected
item as argument. (the above script can be found in Rofi’s git Examples/ directory).
More advanced scripts can be made that have sub-menu’s, an example of this is the
domo_rofi_script.sh in the repository.
If you the user selects a command, the script returns a new set of options, Rofi will list this
until the script returns nothing, indicating it is done.
To quicker switch between the different modi, the user can press alt-4 to switch to the 4th modi
This is a change that won’t affect much for most users, but fixes a lot of issues people had that
uses ‘complex’ character sets. Because of the switch to pango the following things now work as they
Fallback fonts: If some characters are not supported by the font, it will now fallback (using
fontconfig) to a font that has it. This way everything is shown as expected.
RTL fonts: Right to left fonts are now correctly displayed and correctly aligned.
Entering RTL: Rafi confirmed he is capable of entering RTL text, moving through the text and
matching text this way.
Ellipsize: The strings are nicely ellipsized this looks better then being cut off.
There are of course some downsides:
It is slower then using Xft directly. But nothing problematic. Benefits far outweighs the
The font-string has slightly changed, the dash between font name and size should now be a
A video demonstrating (made by Rafi) can be found here
Other fixes and additions
Disable levenshtein sorting when in dmenu mode.
I also broke dmenu compatibly by added a shift-enter mode. This outputs the selected line, but
redraws the menu with the next entry selected. This way a script can make the user select multiple
items more efficiently. Clerk uses this.
Several small (1 pixel) offsets and other issues where fixed. So the overall look should be a bit
I like documentation, even though I am not very good creating it myself (and hate myself for it).
But I try to do better with Rofi and generally it feels good once it is done. But in some cases, why
did the developer even bother creating something?
This one especially annoyed me today, and would have been better with no documentation at all:
FcNameParse - Parse a pattern string
FcPattern * FcNameParse (const FcChar8 *name);
Converts name from the standard text format described above into a pattern.
Fontconfig version 2.11.0
11 10 2013 FcNameParse(3)
What explanation above? Is this a joke? So I entered the thing into a search engine and the first
hit was this.
Helpful the same bloody thing. Lets hit the up button, because that is above isn’t it? No
At that point, I was so annoyed, I gave up. Another day another shot at it.
Although Rofi is in a good place and is mostly feature complete, I did manage to fix several small
annoyances and added several new features. I will list the most important ones below. I hope to make
a new release in the coming weeks. It would be nice if I could promote Rofi a bit more. If you have
ideas for this, please let me know.
You can now paste the current clipboard (both primary as secondary) to the search entry box.
Insert or Ctrl-v: Pastes the primary clipboard.
Shift-Insert or Ctrl-Shift-v: Pastes the secondary clipboard.
On request it is now possible to disable the history function. People who use Rofi to enter a lot of
manual commands might find this useful.
Levenshtein Distance Sorting
When you start typing to filter the list, initially the results where sorted alphabetically. I have
added an option that allows you to sort it by Levenshtein
distance. This should allow you to find your desired option more quickly.
Many small fixes
Several small sizing and drawing bugs have been fixed, making things look just that little bit
Every blog post needs atleast one image, so here we go.
I know I haven't blogged in a long time, yet I probably have enough things to talk about that
others might find interesting. Like Rofi search updates, notes.sh rewrite in C++, etc.
I will try to catch-up in the coming months. But for now my latest GmG.
After many years of typing on crappy keyboards and wearing them out in no-time at all, I decided to
get a real keyboard again. I used to be a big fan of the old IBM Model-M keyboards and still mourn
the day my stash got lost (they where nice ones with detachable cables and all). So I got a
mechanical keyboard, the Ducky DK2108 with Blue Switches and the only thing I can say is: I should
have done this years ago! The feel is lovely, the sound is heavenly and the overall typing
experience is paradise.
However paradise never lasts, I noticed that when typing command lines I often noticed I wound up
with this: some command |\ grep <keyword>.
This happens when I press shift \ and release the shift earlier then the \ key (for my feeling I
release them at exactly the same time).
After some fiddling around, I noticed that it only happens with N-Key Rollover enabled. After firing
up xev and taking a closer look this is what I saw:
KeyPress: | (keycode 51)
KeyRelease | (keycode 51)
KeyPress: \ (keycode 51)
KeyRelease \ (keycode 51)
While I get without NKRO or old keyboard and would expect the following:
KeyPress: | (keycode 51)
KeyRelease \ (keycode 51)
First thinking my keyboard might be buggy, or there being a problem with NKRO anyway, I decided to
try it on a windows box. Here it works as expected………
The whole problem is mostly academic, I really do not need N-Key Rollover, I do not play games, so
it is very doubtful I will press more then 6 keys at the time. If (and that is a big if) I would
play a game where I have to press more then 6 keys, I can enable NKRO without issues given it only
goes wrong with the \. I would be very pleased if I could fix the issue, so if anybody has a clue
on how to do this? Please let me know.
While typing this I got an E-mail from MKH with a firmware
update (but no guarantees that it fixes it). So far the service of the shop has been very good, they
where quick with sending the keyboard, it was well packaged (the original box in a 2nd box with
wrapping) and there support response time is impressing (even in the weekend).
Rofi now has an official website, this is a first step
towards making a release.
Currently the following is left to do:
Extend command-line options to cover all options.
Provide some configuration examples on the website.
The second point will take the most time, help is always welcome.
Some recent tweaks to Rofi include:
Abstract out history code that was duplicate between ssh/run dialog.
This fixes a bug with loosing history.
Allow more fine-grain tweaking of window position, allowing it to behave like a dropdown.
Fix small font rendering issue.
When no result is matched, double-tab will switch to next dialog. Allowing for a more fluent work-flow.
The rofi website is made using Jekyll, and I do like it. It did not take a lot of effort to tweak
the theme so it did what I wanted. It seems octopress is kinda dead (no release for years now), so
maybe someday I will try to strip off the octopress part and just use jekyll directly.