Skip to content

Instantly share code, notes, and snippets.

@Gadgetoid
Created February 9, 2015 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gadgetoid/57084ec5817142a118ac to your computer and use it in GitHub Desktop.
Save Gadgetoid/57084ec5817142a118ac to your computer and use it in GitHub Desktop.
/dts-v1/;
/ {
compatible = "brcm,bcm2709";
fragment@0 {
target-path = "/timer";
__overlay__ {
always-on;
};
};
};
@Gadgetoid
Copy link
Author

NOTE

This is an old fix to a temporary problem with the first official release of Raspbian, it's no longer required nor recommended.

It is presented here only for posterity:

This is a minimalist fix for the temporary Raspbian timer issue on Raspberry Pi 2.

The Problem

This bug involves timing of things like usleep, and only occurs with device-tree enabled in Raspbian on the Raspberry Pi 2. To check if you're having this issue create time.c:

#include  <unistd.h>

int main()
{
 int x = 0;
 for(x = 0; x < 1000; x++){
   usleep(1000);
 }
}

Then time it:

gcc time.c -o timetest
time ./timetest

You will generally see this take about 1.08sec without the bug, and around 20sec with.

The ( Temporary ) Fix

Compile with Device Tree Compiler:

sudo apt-get install device-tree-compiler
dtc -I dts -O dtb -o timer-always-on.dtb timer-always-on.dts

Install it into your overlays folder:

sudo cp timer-always-on.dtb /boot/overlays/

Enable by adding this line in /boot/config.txt

device_tree_overlay=overlays/timer-always-on.dtb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment