This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/TPS65910: DMTimer not found when compiling using TI SDK

Part Number: TPS65910

Tool/software: Linux

I am using the TI Linux SDK 4.1.8-ti-r18 on an Beaglebone Black-based custom design. Want to use a DM Timer to restore unit out of low-power Standby mode but having trouble compiling the following test module. 

1300.testDMtimer.c
#include <ctype.h>      // tolower, toupper
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>     // strcasecmp, strcasestr
#include <sysexits.h>
#include <syslog.h>     // for satfi_logger entry levels
#include <time.h>       // time, localtime, clock_gettime
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/time.h>   // gettimeofday
#include <sys/types.h>

#include <plat/dmtimer.h> // DM Timers

#define MODIFY_DATE    "3/20/2017"
#define TIMER_IRQ_NUM  7

char logString[MAX_LOG_LEN];

//  Definition of the data type for this global region
typedef struct
{
    int irq_num;
    struct omap_dm_timer *stndby_tmr;
} dm_timer_t;

typedef struct
{
    dm_timer_t standby_timer;      // DM Timer for wakeup after standby
} SysCfg_t;

SysCfg_t SysCfg;    // System configuration information

irqreturn_t standby_interrupt_handler (int irq, void *dev_id)
{
    int status = 0;

    /* Read the current Status */
    status = omap_dm_timer_read_status(SysCfg.standby_timer.stndby_tmr);

    /* Clear the timer interrupt */
    if (status == OMAP_TIMER_INT_MATCH)
    {
        omap_dm_timer_write_status(SysCfg.standby_timer.stndby_tmr,
                                   OMAP_TIMER_INT_MATCH);
    }

    /* Stop the timer, disable interrupt & timer then free up both */
    omap_dm_timer_stop(SysCfg.standby_timer.stndby_tmr);
    omap_dm_timer_set_int_enable(SysCfg.standby_timer.stndby_tmr, 0);
    omap_dm_timer_free(SysCfg.standby_timer.stndby_tmr);
    free_irq(SysCfg.standby_timer.irq_num, &SysCfg.standby_timer);

    /* Indicate the Interrupt was handled */
    return (IRQ_HANDLED);
}

int init_wakeup_timer(int timerNum)
{
    int retVal;

    SysCfg.standby_timer.stndby_tmr = omap_dm_timer_request_specific(timerNum);

    /* Get irq number and register an interrupt handler for this irq */
    SysCfg.standby_timer.irq_num = omap_dm_timer_get_irq(SysCfg.standby_timer.stndby_tmr);
    retVal = request_irq(SysCfg.standby_timer.irq_num, standby_interrupt_handler,
                         IRQF_DISABLED, "pm_standby", &SysCfg.standby_timer);
    if (retVal < 0)
    {
        printf("init_wakeup_timer: Could not initialize Timer %d (%s)",
                timerNum, strerror(errno));
        return (retVal);
    }

    /* Clear any pending events by writing to the Status Register */
    omap_dm_timer_write_status(SysCfg.standby_timer.stndby_tmr, OMAP_TIMER_INT_OVERFLOW);

    /* Enable overflow interrupt */
    omap_dm_timer_set_int_enable(SysCfg.standby_timer.stndby_tmr, OMAP_TIMER_INT_OVERFLOW);

    /* Load the counter register and start the timer */
    omap_dm_timer_set_load_start(SysCfg.standby_timer.stndby_tmr, 0, 0xF8D8A6FC);

    return (retVal);
}

int main(int argc, char *argv[])
{
    init_wakeup_timer(TIMER_IRQ_NUM);

    /* Main Processing */

    return (EX_OK);
}

Compilation error is giving:

../src/testDMtimer.c:18:39: fatal error: plat/dmtimer.h: No such file or directory

  #include <plat/dmtimer.h> // DM Timers

compilation terminated.

make: *** [src/testDMtimer.o] Error 1

I know the dmtimer.h file is in the KERNEL directory but it was not carried over to the libc directory where the compiler looks for it. What am I missing?

  • Hi Michael,

    I suspect that your kernel directory is not correctly exported. Could you give more details describing step by step how compiling your module. Are you using a make file?

    BR
    Tsvetolin Shulev
  • Tsvetolin,

    Thank you for your reply. I use Eclipse IDE for compiling and am attaching the makefile & subdir.mk files for you to review.

    makefile:
    -include ../makefile.init

    RM := rm -rf

    # All of the sources participating in the build are defined here
    -include sources.mk
    -include src/subdir.mk
    -include subdir.mk
    -include objects.mk

    ifneq ($(MAKECMDGOALS),clean)
    ifneq ($(strip $(C_DEPS)),)
    -include $(C_DEPS)
    endif
    endif

    -include ../makefile.defs

    # Add inputs and outputs from these tool invocations to the build variables

    # All Target
    all: testDMtimer

    # Tool invocations
    testDMtimer: $(OBJS) $(USER_OBJS)
    @echo 'Building target: $@'
    @echo 'Invoking: Cross GCC Linker'
    /mnt/big1/opt/ti-kernel/yakbuild/dl/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -o "testDMtimer" $(OBJS) $(USER_OBJS) $(LIBS)
    @echo 'Finished building target: $@'
    @echo ' '

    # Other Targets
    clean:
    -$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) testDMtimer
    -@echo ' '

    .PHONY: all clean dependents
    .SECONDARY:

    -include ../makefile.targets

    subdir.mk file:
    # Add inputs and outputs from these tool invocations to the build variables
    C_SRCS += \
    ../src/testDMtimer.c \

    OBJS += \
    ./src/testDMtimer.o \

    C_DEPS += \
    ./src/testDMtimer.d \


    # Each subdirectory must supply rules for building sources it contributes
    src/%.o: ../src/%.c
    @echo 'Building file: $<'
    @echo 'Invoking: Cross GCC Compiler'
    /mnt/big1/opt/ti-kernel/yakbuild/dl/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -O0 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
    @echo 'Finished building: $<'
    @echo ' '


    Michael
  • Michael,

    I can not find kernel directory setting in your configuration. I suggest you to take a look at the linked discussion:
    stackoverflow.com/.../proper-makefile-setup-for-external-kernel-modules
    Pay attention on the KERNELRELEASE and KERNELDIR variables.

    BR
    Tsvetolin Shulev
  • Tsvetolin ,

    Does this mean I have to compile the program as a module?
    I was hoping to incorporate it into a user-space program, is that not possible?

    Regards,
    Michael
  • Michael,

    Of course, it is possible to compile your program as user space program.

    BR
    Tsvetolin Shulev