A few days ago I updated my Raspberry Pi (Rev. 3) to the new Raspbian 9 (based on Debian "Stretch"). Everything went fine but when I tested some of my own tools I recognized a strange behaviour concerning the GPIO pin access.

If I only use function "digitalWrite()" (C++ code) everything is fine. But if I use try to generate a PWM output at the same pin and use the function "pwmWrite()" instead then I always get a lot of file system errors "ext4_find_entry:1463" and finally the system crashes.

First I thought of a damaged SD card so I exchanged it but nothing changed. Also changing power supply (some people mentioned as helpful) did not have any effect.

Note: I checked the SD card and also the file system on other computers; it's fine! These errors only occur when PWM signals should be created. What can I do to make my programs run again?


You need to use sudo (root privileges) to use hardware PWM from wiringPi.

If you are using software PWM you do not need to use sudo.

  • Regarding Gordon wiringPi version 2.44 should be able to alter GPIOs also with user priviledges. Nevertheless I tried but it doesn't work. I was wondering why is the filesystem ext4 corrupted when generating a PWM signal? On Debian/Raspbian "jessie" it was working. NOTE: I have found out something interesting. If I start my precompiled code (generated from the former "jessie") it seems to work but if I want to start a fresh compiled binary (of course without any errors and warnings) the ext4 error message appears and system crashes.
    – R.H.
    Aug 23 '17 at 17:46
  • Since the introduction of /dev/gpiomem you can use standard GPIO functions (such as read/write) without requiring root privileges. Hardware PWM requires access to a different area of peripheral memory and needs root privileges. It's a bug in wiringPi that you are not prevented from using hardware PWM if you start the program without sudo. Presumably it is scribbling over memory.
    – joan
    Aug 23 '17 at 17:58
  • Thanks for your explanation. Actually I don't use hardware PWM, I use SoftPWM of the wiringPi library. And that seems to crash somehow the file system or the gcc compiler is generating "wrong" code but it is not complaining about missing libraries or dependencies. But I will try if it makes a difference using hardware pwm or software generated ones.
    – R.H.
    Aug 23 '17 at 18:14

I ran into the same issue. The documentation about using PWM from WiringPi states:

Note: The PWM control functions can not be used when in Sys mode. To understand more about the PWM system, you’ll need to read the Broadcom ARM peripherals manual.

Sys mode is user mode. When I run my program with sudo, it runs fine. When I run it without, it crashes with the EXT4 errors...

See: http://wiringpi.com/reference/raspberry-pi-specifics/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.