Other Parts Discussed in Thread: AM4379, SYSBIOS
I have put together a very simple experimental application for AM4379 processor using idkAM437x development platform. The application is using Ti-RTOS and it comprises of a config file and a main(). The goal of the application is to start an I2C driver and turn LEDs on and off. The importance of this development for me is to become more comfortable with using drivers in Ti-RTOS. Unfortunately, there are not many examples to show this for idkAM437x development platform.
I have a compilation problem and I think I know what the problem is, but I don't know how to solve it. Ti documentation for RTOS (SPRUHD4M—June 2016) says that before instantiating a the I2C driver handle, "The board.c file also declare the I2C_config structure. This structure must be provided to the I2C driver. It must be initialized before the I2C_init() function is called and cannot be changed afterwards." This does not seem to be correct and the document does not seem to be applicable to AM437x evms.
As you can see from the compilation output, I am having problems with the referencing of I2C_config in my code. Here is the output:
**** Build of configuration Release for project Her_Project ****
"C:\\ti\\ccs1011\\ccs\\utils\\bin\\gmake" -k -j 8 all -O
making ../src/sysbios/sysbios.aa9fg ...
gmake[1]: Nothing to be done for 'all'.
Building file: "../main.c"
Invoking: GNU Compiler
"C:/ti/gcc-arm-none-eabi-7-2018-q2-update/bin/arm-none-eabi-gcc-7.3.1.exe" -c -mcpu=cortex-a9 -march=armv7-a -mtune=cortex-a9 -marm -mfloat-abi=hard -Dam4379 -I"C:/ti/pdk_am437x_1_0_17/packages/ti/starterware/include/am43xx" -I"C:/ti/pdk_am437x_1_0_17/packages/ti/starterware/include" -I"C:/Users/FaroukEshragi/workspace_v10/Her_Project" -I"C:/ti/bios_6_76_03_01/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/include/newlib-nano" -I"C:/ti/bios_6_76_03_01/packages/ti/posix/gcc" -I"C:/ti/gcc-arm-none-eabi-7-2018-q2-update/arm-none-eabi/include" -Os -Wall -MMD -MP -MF"main.d" -MT"main.o" -std=c99 @"configPkg/compiler.opt" -o"main.o" "../main.c"
../main.c: In function 'taskFxn':
../main.c:43:21: warning: unused variable 'i2cTransaction' [-Wunused-variable]
I2C_Transaction i2cTransaction;
^~~~~~~~~~~~~~
../main.c:42:21: warning: unused variable 'params' [-Wunused-variable]
I2C_Params params;
^~~~~~
../main.c:41:21: warning: unused variable 'handle' [-Wunused-variable]
I2C_Handle handle;
^~~~~~
../main.c:38:16: warning: unused variable 'i2c_Config' [-Wunused-variable]
I2C_Config i2c_Config[2];
^~~~~~~~~~
Finished building: "../main.c"
making ../src/sysbios/sysbios.aa9fg ...
gmake[2]: Nothing to be done for 'all'.
Building target: "Her_Project.out"
Invoking: GNU Linker
"C:/ti/gcc-arm-none-eabi-7-2018-q2-update/bin/arm-none-eabi-gcc-7.3.1.exe" -mtune=cortex-a9 -marm -Dam4379 -Os -Wall -mfloat-abi=hard -Wl,-Map,"Her_Project.map" -nostartfiles -static -Wl,--gc-sections -L"C:/ti/bios_6_76_03_01/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/lib/hard" -Wl,--defsym,STACKSIZE=0x18000 -Wl,--defsym,HEAPSIZE=0x400 --specs=nano.specs -o"Her_Project.out" "./main.o" -Wl,-T"configPkg/linker.cmd" -Wl,--start-group -lgcc -lm -lnosys -lc -Wl,--end-group
makefile:145: recipe for target 'Her_Project.out' failed
C:\ti\pdk_am437x_1_0_17\packages\ti\drv\i2c\lib\a9\release\ti.drv.i2c.aa9fg(I2C_drv.oa9fg): In function `I2C_init':
C:\ti\pdk_am437x_1_0_17\packages\ti\drv\i2c/src/I2C_drv.c:117: undefined reference to `I2C_config'
C:\ti\pdk_am437x_1_0_17\packages\ti\drv\i2c/src/I2C_drv.c:117: undefined reference to `I2C_config'
collect2.exe: error: ld returned 1 exit status
gmake[1]: *** [Her_Project.out] Error 1
gmake: *** [all] Error 2
makefile:141: recipe for target 'all' failed
**** Build Finished ****
And here is my main file:
/*
* ======== main.c ========
*/
#include <xdc/std.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/drv/i2c/I2C.h>
#include <ti/drv/i2c/soc/I2C_soc.h>
#include <ti/drv/i2c/soc/I2C_v1.h>
#include "chipdb_defs.h"
#include <ti/board/board.h>
extern int32_t PINMUXModuleConfig(chipdbModuleID_t moduleId, uint32_t instNum,
void *pParam1);
/*
void I2CCallbackFunction();
void I2CCallbackFunction(){
System_printf("making progress");
}
*/
/*
* ======== taskFxn ========
*/
Void taskFxn(UArg a0, UArg a1)
{
System_printf("enter taskFxn()\n");
PINMUXModuleConfig(CHIPDB_MOD_ID_I2C, 2U, NULL);
I2C_Config_list I2C_config[2];
I2C_init();
I2C_Handle handle;
I2C_Params params;
I2C_Transaction i2cTransaction;
/* I2C_init();
I2C_Params_init(¶ms);
params.transferMode = I2C_MODE_CALLBACK;
params.transferCallbackFxn = I2CCallbackFunction;
handle = I2C_open(((int32_t) 2), ¶ms);
if (!handle) {
System_printf("I2C did not open");
*/
Task_sleep(10);
System_printf("exit taskFxn()\n");
System_flush(); /* force SysMin output to console */
}
/*
* ======== main ========
*/
Int main()
{
Task_Handle task;
Error_Block eb;
System_printf("enter main()\n");
Error_init(&eb);
task = Task_create(taskFxn, NULL, &eb);
if (task == NULL) {
System_printf("Task_create() failed!\n");
BIOS_exit(0);
You may see odd things in my main() file. That is because I have been experimenting with possibilities to understand what it is that I must do.
And here is the config file:
var Defaults = xdc.useModule('xdc.runtime.Defaults');
var Diags = xdc.useModule('xdc.runtime.Diags');
var Error = xdc.useModule('xdc.runtime.Error');
var Log = xdc.useModule('xdc.runtime.Log');
var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
var Main = xdc.useModule('xdc.runtime.Main');
var Memory = xdc.useModule('xdc.runtime.Memory')
var SysMin = xdc.useModule('xdc.runtime.SysMin');
var System = xdc.useModule('xdc.runtime.System');
var Text = xdc.useModule('xdc.runtime.Text');
var BIOS = xdc.useModule('ti.sysbios.BIOS');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Swi = xdc.useModule('ti.sysbios.knl.Swi');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
var I2c = xdc.loadPackage('ti.drv.i2c');
var deviceType = "am437x";
var Csl = xdc.loadPackage('ti.csl');
Csl.Settings.deviceType = deviceType;
var Board = xdc.loadPackage('ti.board');
Board.Settings.boardName = "idkAM437x";
/*
* Uncomment this line to globally disable Asserts.
* All modules inherit the default from the 'Defaults' module. You
* can override these defaults on a per-module basis using Module.common$.
* Disabling Asserts will save code space and improve runtime performance.
Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
*/
/*
* Uncomment this line to keep module names from being loaded on the target.
* The module name strings are placed in the .const section. Setting this
* parameter to false will save space in the .const section. Error and
* Assert messages will contain an "unknown module" prefix instead
* of the actual module name.
Defaults.common$.namedModule = false;
*/
/*
* Minimize exit handler array in System. The System module includes
* an array of functions that are registered with System_atexit() to be
* called by System_exit().
*/
System.maxAtexitHandlers = 4;
/*
* Uncomment this line to disable the Error print function.
* We lose error information when this is disabled since the errors are
* not printed. Disabling the raiseHook will save some code space if
* your app is not using System_printf() since the Error_print() function
* calls System_printf().
Error.raiseHook = null;
*/
/*
* Uncomment this line to keep Error, Assert, and Log strings from being
* loaded on the target. These strings are placed in the .const section.
* Setting this parameter to false will save space in the .const section.
* Error, Assert and Log message will print raw ids and args instead of
* a formatted message.
Text.isLoaded = false;
*/
/*
* Uncomment this line to disable the output of characters by SysMin
* when the program exits. SysMin writes characters to a circular buffer.
* This buffer can be viewed using the SysMin Output view in ROV.
SysMin.flushAtExit = false;
*/
/*
* The BIOS module will create the default heap for the system.
* Specify the size of this default heap.
*/
BIOS.heapSize = 0x1000;
/*
* Build a custom SYS/BIOS library from sources.
*/
BIOS.libType = BIOS.LibType_Custom;
/* System stack size (used by ISRs and Swis) */
Program.stack = 0x2000;
/* Circular buffer size for System_printf() */
SysMin.bufSize = 0x200;
/*
* Create and install logger for the whole system
*/
var loggerBufParams = new LoggerBuf.Params();
loggerBufParams.numEntries = 16;
var logger0 = LoggerBuf.create(loggerBufParams);
Defaults.common$.logger = logger0;
Main.common$.diags_INFO = Diags.ALWAYS_ON;
System.SupportProxy = SysMin;
I would appreciate it you would have a look and let me know what piece of code must be added so that the compiler/linker will resolved the issue of undefined reference to `I2C_config' .
Thank you.