Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

Building DSPLink with kbuild

From Texas Instruments Wiki
Jump to: navigation, search

END OF LIFE

DSP Link is still available for download, but no further releases or updates are planned. Please see IPC Software Options for details and alternatives.

Introduction

This page gives information for users attempting to build DSPLink kernel module with Kbuild (Kernel Build)

Overview

DSPLink has its own make system, which builds DSPLink product for all supported platforms. This makesystem is different from the standard makesystem like KBuild or visual studio based projects. It has some core files setting up the toolchains, rules and targets for the gmake. So it cannot built with Linux kernel build infrastructure.

Following text describes how one can build DSPLink with kernel build infrastructure using the existing support from DSPLink.

For compiling DSPLink with 2.6.27 kernel onwards, you are required to patch the DSPLink sources with a patch (provided).

Usage

Copy the below text into a file called Makefile. Make sure that tab characters are not replaced with spaces.

# Composite Makefile
DIRSEP=/

TI_DSPLINK_RELATIVE_PATH :=../

# include the CURRENTCFG.mk
include $(DSPLINK)$(DIRSEP)config$(DIRSEP)BUILD$(DIRSEP)CURRENTCFG.MK

# Generate the list of sources
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)arch$(DIRSEP)SOURCES
ARCH_SOURCES := $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)arch$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)ldrv$(DIRSEP)SOURCES
LDRV_SOURCES := $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)ldrv$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)ldrv$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)SOURCES
LDRV_SOURCES += $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)ldrv$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)gen$(DIRSEP)SOURCES
GEN_SOURCES := $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)gen$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)pmgr$(DIRSEP)SOURCES
PMGR_SOURCES := $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)pmgr$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)pmgr$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)SOURCES
PMGR_SOURCES += $(addpreifx $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)pmgr$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)pmgr$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)$(TI_DSPLINK_GPPOSVERSION)$(DIRSEP)SOURCES
PMGR_SOURCES += $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)pmgr$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)$(TI_DSPLINK_GPPOSVERSION)$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)osal$(DIRSEP)$(DIRSEP)SOURCES
OSAL_SOURCES := $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)osal$(DIRSEP)$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)osal$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)SOURCES
OSAL_SOURCES += $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)osal$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)osal$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)$(TI_DSPLINK_GPPOSVERSION)$(DIRSEP)SOURCES
OSAL_SOURCES += $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)osal$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)$(TI_DSPLINK_GPPOSVERSION)$(DIRSEP),$(SOURCES))

DSPLINK_SOURCES := $(ARCH_SOURCES) $(LDRV_SOURCES) $(GEN_SOURCES) $(OSAL_SOURCES) $(PMGR_SOURCES)
DSPLINK_OBJS    := $(foreach srcFile, $(DSPLINK_SOURCES),$(basename $(srcFile)).o)

# CFLAGS
EXTRA_CFLAGS += $(addprefix -D, $(TI_DSPLINK_GPP_DEFINES))
EXTRA_CFLAGS += $(addprefix -I, $(TI_DSPLINK_GPP_INC_PATH))
EXTRA_CFLAGS += -DEXPORT_SYMTAB -DTRACE_KERNEL

ifneq ($(KERNELRELEASE),)
obj-m	:= dsplinkk.o
libs-m  := $(shell pwd)
lib-m   := $(foreach srcFile, $(API_SOURCES),$(basename $(srcFile)).o)
dsplinkk-objs := $(DSPLINK_OBJS)
else
KDIR    := /toolchains/git/REL_OMAP35x_02.01.00.01/PSP_02.01.00.01/src/linux-02.01.01.01
PWD	:= $(shell pwd) 
DRV:
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
endif

clean:
	find $(DSPLINK) -name "*.o" -exec rm {} \;
	rm -fr dsplinkk.ko  dsplinkk.mod.c Module.symvers



################################################################################################
# USER SIDE
BUILD_CONFIG := ..$(DIRSEP)..$(DIRSEP)..$(DIRSEP)config$(DIRSEP)BUILD
# Generate the list of sources
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)api$(DIRSEP)SOURCES
API_SOURCES := $(addprefix $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)api$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)api$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)SOURCES
API_SOURCES += $(addprefix $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)api$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP),$(SOURCES))

# Update the CFLAG
CC     = arm-none-linux-gnueabi-gcc
AR     = arm-none-linux-gnueabi-ar
LD     = arm-none-linux-gnueabi-ld
ARFLAGS = -rs
LDFLAGS = -r
EXTRA_CFLAGS += $(addprefix -D, $(TI_DSPLINK_GPP_DEFINES)) $(addprefix -I, $(TI_DSPLINK_GPP_INC_PATH))

define CONFIG_template
$(shell cp $(DSPLINK)$(DIRSEP)config$(DIRSEP)all$(DIRSEP)$(1) $(DSPLINK)$(DIRSEP)config$(DIRSEP)BUILD$(DIRSEP))
endef

define PROGRAM_template 
$(basename $(1)).o: $(1)
	$(CC) $(EXTRA_CFLAGS) -c $(1) -o $(basename $(1)).o
endef
$(foreach prog,$(API_SOURCES),$(eval $(call PROGRAM_template,$(prog))))
$(foreach prog,$(CONFIG),$(eval $(call CONFIG_template,$(prog))))

DSPLINK_API_OBJS := $(foreach srcFile, $(API_SOURCES),$(basename $(srcFile)).o)

LIB: $(DSPLINK_API_OBJS)
	$(LD) $(LDFLAGS) -o dsplink.lib $(DSPLINK_API_OBJS)
	$(AR) $(ARFLAGS) dsplink.a $(DSPLINK_API_OBJS)

	
######################################### SAMPLES ###################################
SOURCES :=
define SAMPLES_template
ifneq ($(1),message_multi)
$(1): $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(1).c $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)$(1)_os.c
	$(CC) $(EXTRA_CFLAGS) -I$(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1) -I$(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS) -o $(1)gpp $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(1).c $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)$(1)_os.c $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)main.c dsplink.lib -lpthread
else
$(1): $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)message.c $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)message_os.c
    $(CC) $(EXTRA_CFLAGS) -I$(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1) -I$(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS) -o $(1)gpp $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)message.c $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)message_os.c $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)main.c dsplink.lib -lpthread
endif
endef

include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)DIRS
$(foreach prog,$(DIRS),$(eval $(call SAMPLES_template,$(prog))))

SAMPLES : $(foreach prog,$(DIRS),$(prog))

all: DRV LIB SAMPLES

Details

Details regarding how to write kernel makefile is described in the kernel documentation, hence is not covered here.

This Makefile includes the CURRENTCFG.MK file to get the configuration details, then it reads the SOURCES files from the GPP src directory to make a list of C sources files required for building DSPLink module. It also updates the CFLAGS for DSPLink defines and include paths. Using the obj-m function of kernel build it creates the rules for building DSPLink.

Steps to build DSPLink kernel module

1. Configure DSPLINK using Perl script dsplinkcfg.pl

2. Copy patch file 1.61patchTo2_6_28.patch in to $DSPLINK and Apply the patch using command

      patch -p1 < 1.61patchTo2_6_28.patch

File:DSPLINK 1.61Patchfiles.zip link contains the patch.

3. Building the GPP side kernel module

a) Create a directory under $DSPLINK

b) Copy the Makefile into the above created directory.

c) CD in to the newly created directory(step 3.a). Edit the Makefile to change the variables:

  TI_DSPLINK_RELATIVE_PATH := ../ /* Give the relative path of the DSPLink */  
  KDIR /* Give path of LSP*/ 

d) Add toolchain bin path to PATH environment variable. For example export PATH=$PATH:/toolchains/omap3530/arm-2007q3/bin/

e) Now issue make command to build the kernel module (dsplinkk.ko) make ARCH=xxx CROSS_COMPILE=yyy DRV

where xxx is the architecture. for example arm

where yyy is cross complier for example. arm-none-linux-gnueabi-

f) The generated DSPLink kernel module will be present in this directory.


4. Building DSPLink user space library and samples (Currently it does not generate message_multi sample)

a) Change the compiler, archiver and linker (i.e. CC, AR and LD) in the Make file if necessary.

b) Issue make LIB && make SAMPLES dsplink.lib and gpp side sample executables will be present in the crated directory (directory that is crated in step 2.a)


5. You can issue make all to generate kernel module, DSPLink library and GPP side sample application at a single step.


6. Alternatively to build the DSPLink libraries and gpp samples you can use the DSPLink build system itself

a) Update the distribution file.

b) cd gpp/src/api and issue make

c) cd gpp/src/samples and issue make

d) After successful build. Gpp samples executables will be present under $dsplink/gpp/export/BIN/Linux/OMAPL1XX/{RELEASE|DEBUG}/


7. Building the DSP side samples: As usual mentioned in the installation guide and user guides


8. For Running samples refer to install guides.

Upgrade and compatibility information

  • Supported on DSPLink 1.60 version onwards only.
  • Provided patch is for DSPLINK version 1.61 only.