Linux/DRV2605: How to control an ERM using the Linux input subsystem

Prodigy 40 points

Replies: 5

Views: 78

Part Number: DRV2605

Tool/software: Linux

I am trying to test the DRV2605 using an ERM with the Linux driver ( installed. On startup the motor works during calibration, however I am unable to get it to work by writing to the device file as described in Test code below

#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>

#include <linux/input.h>
#include <sys/ioctl.h>

#define BITS_TO_LONGS(x) \
        (((x) + 8 * sizeof (unsigned long) - 1) / (8 * sizeof (unsigned long)))
unsigned long features[BITS_TO_LONGS(FF_CNT)];

int main(const int argc, const char **argv)
    int fd;

    if (argc != 2) {
        printf("usage: %s <device-file>\n", argv[0]);
        return 1;

    fd = open(argv[1], O_RDWR);
    if (fd < 0) {
        printf("Error opening file '%s': %s\n", argv[1], strerror(errno));
        return 1;

    int num_effects;
    if (ioctl(fd, EVIOCGEFFECTS, &num_effects) < 0) {
        printf("Error getting number of effects playable at the same time: %s\n", strerror(errno));
        return 1;
    printf("%d effects playable at the same time\n", num_effects);

    struct ff_effect effect = {
        .type = FF_RUMBLE,
        .id = -1,
        .direction = 0,
        .trigger = {0, 0},
        .replay = {
            .length = 1000,
            .delay = 0
    effect.u.rumble.strong_magnitude = 0x7F;

    if (ioctl(fd, EVIOCSFF, &effect) < 0) {
        printf("Error creating new effect: %s\n", strerror(errno));
        return 1;
    printf("New effect ID: %d\n",;

    struct input_event play = {
        .type = EV_FF,
        .code =,
        .value = 3

    if (write(fd, (const void*) &play, sizeof(play)) < 0) {
        printf("Error writing effect to file: %s\n", strerror(errno));
        return 1;
    printf("Wrote effect\n");

    return 0;

 The program runs fine with no errors but nothing happens to the ERM. 

5 Replies

  • Hi,

    Welcome to E2E and thank you for your interest in our products!

    Have you verified if the device files are created according to the 5.2 section? It seems that the utility fftest is also required to test the driver:

    Best regards,
    Luis Fernando Rodríguez S.

  • In reply to Luis Fernando Rodríguez S.:

    Hi Luis, thanks for your reply. The input device is loaded - the relevant segment from /proc/bus/input/devices is pasted below

    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name="drv260x:haptics"
    P: Phys=
    S: Sysfs=/devices/soc0/soc/30800000.aips-bus/30a30000.i2c/i2c-1/1-005a/input/input1
    U: Uniq=
    H: Handlers=event1 evbug 
    B: PROP=0
    B: EV=200001
    B: FF=1 7030000 0 0

    Unfortunately I don't have fftest on my device although I will look into it

  • In reply to h:

    I managed to get fftest on the device and ran it:

    Force feedback test program.
    Device /dev/input/event1 opened
      * Absolute axes: 
        [00 00 00 00 00 00 00 00 ]
      * Relative axes: 
        [00 00 ]
      * Force feedback effects types: Periodic, Rumble, Gain, 
        Force feedback periodic effects: Square, Triangle, Sine, 
        [00 00 00 00 00 00 00 00 00 00 03 07 01 00 00 00 ]
      * Number of simultaneous effects: 16
    Setting master gain to 75% ... OK
    Uploading effect #0 (Periodic sinusoidal) ... OK (id 0)
    Uploading effect #1 (Constant) ... Error: Invalid argument
    Uploading effect #2 (Spring) ... Error: Invalid argument
    Uploading effect #3 (Damper) ... Error: Invalid argument
    Uploading effect #4 (Strong rumble, with heavy motor) ... OK (id 1)
    Uploading effect #5 (Weak rumble, with light motor) ... OK (id 2)
    Enter effect number, -1 to exit
    Now Playing: Sine vibration
    Enter effect number, -1 to exit
    Now Playing: Strong Rumble
    Enter effect number, -1 to exit
    Now Playing: Weak Rumble
    Enter effect number, -1 to exit
    Stopping effects

    I tried playing the effects that were uploaded OK and still no luck

  • In reply to h:


    Sorry for late response. I'm following up on this thread.
    Are you still facing difficulties to test our device? What is the current status?
    Have you tried something else additional to the information provided above?

    Thanks and Best regards,
    -Ivan Salazar
    Applications Engineer - Low Power Audio & Actuators
  • In reply to Ivan Salazar:

    I have managed to make some progress. On debugging the driver I found the work queue wasn't running the queued function that was supposed to play the driver. I have rewrote much of the driver to configure it as a simple character device instead of an input device so I can write waveform sequences to it. This was a functionality missing from the supplied driver and I couldn't find an obvious way to use the input subsystem to play any specific waveform number so if you know any way to do this that would be preferred to my customised driver solution. Unfortunately I made quite a number of different changes to the driver so couldn't say exactly what caused it to work (I am relatively new to Linux kernel development).