【TI毫米波雷达笔记】IWR6843AOP的CCS工程模板创建(MSS)(cannot find file "libsleep_xwr68xx.aer4f"解决方案)
主要参考:
blog.csdn.net/qq_16660871/article/details/126246572
本文大体上与之类似 但用的SDK是3.5版本
若遇到报错:
cannot find file "libsleep_xwr68xx.aer4f"
则按我的配置流程和我先前的文章来
MSS工程模板:
download.csdn.net/download/weixin_53403301/88215083
在CCS里面新建工程 选择芯片 调试用设备和typical工程类型
Next之后要求选择Target和Platform,在页面下方处如下填写:
Target: ti.targets.arm.elf.R4Ft
Platform: ti.platforms.cortexR:IWR68XX:false:200
Build-profile任意选择
建立好工程以后 在工程属性的general中也可以进行更改 只不过改到release版本以后需要重新配置各个设置
另外 在products中 点击add 添加mmwave sdk和sysconfig 如图
这样工程就创建好了。在左侧的Project Explorer中,可以看到。接下来,我们需要对工程的属性进行调整,并覆盖一些工程自带的文件来满足开发需求。
其中 main.h main_callback.h和main_callback.h是我自己添加的
代码如下:
main.c:
#include "main.h"
//MCPI_LOGBUF_INIT(9216);
MMWave_Global MMWave_Global_Params={0};
void Init_UART(void)
{
UART_Params uart0_params;
/* 串口引脚初始化 */
/* 共有两个串口,分别为UART-1和UART-3,序号为0和2 */
/* Setup the PINMUX to bring out the MSS UART-1 */
Pinmux_Set_FuncSel(SOC_XWR68XX_PINN5_PADBE, SOC_XWR68XX_PINN5_PADBE_MSS_UARTA_TX);
Pinmux_Set_OverrideCtrl(SOC_XWR68XX_PINN5_PADBE, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
Pinmux_Set_FuncSel(SOC_XWR68XX_PINN4_PADBD, SOC_XWR68XX_PINN4_PADBD_MSS_UARTA_RX);
Pinmux_Set_OverrideCtrl(SOC_XWR68XX_PINN4_PADBD, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
// 这一块用不上
/* Setup the PINMUX to bring out the MSS UART-3 */
// Pinmux_Set_OverrideCtrl(SOC_XWR68XX_PINF14_PADAJ, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
// Pinmux_Set_FuncSel(SOC_XWR68XX_PINF14_PADAJ, SOC_XWR68XX_PINF14_PADAJ_MSS_UARTB_TX);
UART_Params_init(&uart0_params);
uart0_params.baudRate = 115200*8; //波特率115200*8
uart0_params.clockFrequency = MSS_SYS_VCLK; //系统时钟频率200MHz
uart0_params.dataLength = UART_LEN_8; //8bit字长
uart0_params.isPinMuxDone = 1; //已经完成引脚复用初始化
uart0_params.parityType = UART_PAR_NONE; //无校验位
uart0_params.readDataMode = UART_DATA_BINARY; //按位方式读取数据
uart0_params.readEcho = UART_ECHO_OFF; //关闭回显
uart0_params.readReturnMode = UART_RETURN_FULL; //完整读取
uart0_params.stopBits = UART_STOP_ONE; //1停止位
uart0_params.writeDataMode = UART_DATA_BINARY; //按位方式写入(发送)数据
MMWave_Global_Params.handle.uart0_handle = UART_open(0, &uart0_params); //打开串口
if(MMWave_Global_Params.handle.uart0_handle == NULL)
{
System_printf("[INFO] UART0 open fail\n!");
return;
}
else
{
System_printf("[INFO] UART0 open success\n!");
/*
while(1)
{
//不断读取收到的数据,并通过串口发送出去
//该函数会使进程进入挂起等待状态,不会使其他任务无法执行
//可以发现打印任务也可以执行
UART_read(MMWave_Global_Params.handle.uart0_handle, &MMWave_Global_Params.uart0_rx, 1);
UART_write(MMWave_Global_Params.handle.uart0_handle, &MMWave_Global_Params.uart0_rx, 1);
}
*/
}
}
/**
* @b Description
* @n
* The task is used to provide an execution context for the MMWave
* control task
*
* @retval
* Not Applicable.
*/
void Ctrl_MMWave(UArg arg0, UArg arg1)
{
int32_t errCode;
while (1)
{
/* Execute the MMWave control module: */
if (MMWave_execute (MMWave_Global_Params.handle.MMWave_handle, &errCode) < 0)
{
//System_printf ("Error: MMWave control execution failed [Error code %d]\n", errCode);
}
}
}
void Init_MMWave(void)
{
int32_t errCode;
MMWave_InitCfg initCfg;
MMWave_OpenCfg openCfg;
MMWave_CtrlCfg ctrlCfg;
MMWave_CalibrationCfg calibrationCfg;
Task_Params taskParams; //任务参数
memset ((void*)&initCfg, 0 , sizeof(MMWave_InitCfg));
memset ((void*)&initCfg, 0 , sizeof(MMWave_OpenCfg));
memset ((void *)&calibrationCfg, 0, sizeof(MMWave_CalibrationCfg));
memset ((void*)&ctrlCfg, 0 , sizeof(MMWave_CtrlCfg));
initCfg.domain = MMWave_Domain_MSS;
initCfg.socHandle = MMWave_Global_Params.handle.socHandle;
initCfg.eventFxn = MMWave_eventFxnCallback; //事件回调
initCfg.linkCRCCfg.useCRCDriver = 0U; //1开启CRC 0关闭CRC
initCfg.linkCRCCfg.crcChannel = CRC_Channel_CH1; //CRC通道1
initCfg.cfgMode = MMWave_ConfigurationMode_MINIMAL; //最小模式 也可以设置成全部模式
initCfg.executionMode = MMWave_ExecutionMode_ISOLATION; //MSS和DSS不通讯 如果需要 则换个模式
//以下全是回调
initCfg.cooperativeModeCfg.cfgFxn = MMWave_cfgFxnCallback;
initCfg.cooperativeModeCfg.closeFxn = MMWave_closeFxnCallback;
initCfg.cooperativeModeCfg.openFxn = MMWave_openFxnCallback;
initCfg.cooperativeModeCfg.startFxn = MMWave_startFxnCallback;
initCfg.cooperativeModeCfg.stopFxn = MMWave_stopFxnCallback;
/* Initialize and setup the MMWave Control module */
MMWave_Global_Params.handle.MMWave_handle = MMWave_init (&initCfg, &errCode);
if (MMWave_Global_Params.handle.MMWave_handle == NULL)
{
/* Error: Unable to initialize the MMWave control module */
System_printf ("[INFO] Error: MMWave Control Initialization failed [Error code %d]\n", errCode);
return;
}
System_printf ("[INFO] Debug: MMWave Control Initialization was successful\n");
/* Synchronization: This will synchronize the execution of the control module
* between the domains. This is a prerequiste and always needs to be invoked. */
//同步
if (MMWave_sync (MMWave_Global_Params.handle.MMWave_handle, &errCode) < 0)
{
/* Error: Unable to synchronize the MMWave control module */
System_printf ("[INFO] Error: MMWave Control Synchronization failed [Error code %d]\n", errCode);
return;
}
System_printf ("[INFO] Debug: MMWave Control Synchronization was successful\n");
/*****************************************************************************
* Launch the MMWave control execution task
* - This should have a higher priroity than any other task which uses the
* MMWave control API
*****************************************************************************/
//这里是开了一个线程循环调用
Task_Params_init(&taskParams);
taskParams.priority = 5;
taskParams.stackSize = 3*1024;
MMWave_Global_Params.task.MMWaveCtrl = Task_create(Ctrl_MMWave, &taskParams, NULL);
openCfg.freqLimitLow = 600U; //低频限制
openCfg.freqLimitHigh = 640U; //高频限制
openCfg.chCfg.rxChannelEn = 0x000F; //开启四个RX
openCfg.chCfg.txChannelEn = 0x0007; //开启四个TX
openCfg.chCfg.cascading = 0x0000; //不开启级联
openCfg.chCfg.cascadingPinoutCfg = 0; //直接给0
openCfg.lowPowerMode.lpAdcMode = 0x0000; //Regular ADC mode
openCfg.adcOutCfg.fmt.b2AdcBits = 2; //16bit
openCfg.adcOutCfg.fmt.b8FullScaleReducFctr = 0; //16bit只能为0
openCfg.adcOutCfg.fmt.b2AdcOutFmt = 2; //Complex with Image band
openCfg.defaultAsyncEventHandler = MMWave_DefaultAsyncEventHandler_MSS;
openCfg.disableFrameStartAsyncEvent = false;
openCfg.disableFrameStopAsyncEvent = false;
openCfg.useCustomCalibration = false; // 无自定义校准 false表示默认启用所有校准
openCfg.customCalibrationEnableMask = 0x0;
openCfg.calibMonTimeUnit = 1; //一帧一次校准
/*
MMWave_CalibrationData calibrationData;
memset ((void*)&calibrationCfg, 0 , sizeof(MMWave_CalibrationCfg));
calibrationData.ptrCalibData->calibChunk
calibrationData.ptrPhaseShiftCalibData->PhShiftcalibChunk
*/
/* Open the mmWave module: */
if (MMWave_open (MMWave_Global_Params.handle.MMWave_handle, &openCfg, NULL, &errCode) < 0)
{
/* Error: decode and Report the error */
//MMWave_decodeError (errCode, &errorLevel, &mmWaveErrorCode, &subsysErrorCode);
//System_printf ("Error: mmWave Open failed [Error code: %d Subsystem: %d]\n",mmWaveErrorCode, subsysErrorCode);
}
ctrlCfg.dfeDataOutputMode = MMWave_DFEDataOutputMode_FRAME;
ctrlCfg.u.frameCfg.profileHandle[0]=NULL;
ctrlCfg.u.frameCfg.profileHandle[1]=NULL;
ctrlCfg.u.frameCfg.profileHandle[2]=NULL;
ctrlCfg.u.frameCfg.profileHandle[3]=NULL;
ctrlCfg.u.frameCfg.frameCfg.chirpStartIdx = 0;
ctrlCfg.u.frameCfg.frameCfg.chirpEndIdx = 2;
ctrlCfg.u.frameCfg.frameCfg.numLoops = 96;
ctrlCfg.u.frameCfg.frameCfg.numFrames = 0;
ctrlCfg.u.frameCfg.frameCfg.numAdcSamples = 96;
ctrlCfg.u.frameCfg.frameCfg.framePeriodicity = 11000; //55ms
ctrlCfg.u.frameCfg.frameCfg.triggerSelect = 0x0001; //软件API触发
ctrlCfg.u.frameCfg.frameCfg.numDummyChirpsAtEnd = 0;
ctrlCfg.u.frameCfg.frameCfg.frameTriggerDelay = 0;
/*
//frame模式不用配
ctrlCfg.u.continuousModeCfg.cfg.startFreqConst
ctrlCfg.u.continuousModeCfg.cfg.txOutPowerBackoffCode
ctrlCfg.u.continuousModeCfg.cfg.txPhaseShifter
ctrlCfg.u.continuousModeCfg.cfg.digOutSampleRate
ctrlCfg.u.continuousModeCfg.cfg.hpfCornerFreq1
ctrlCfg.u.continuousModeCfg.cfg.hpfCornerFreq2
ctrlCfg.u.continuousModeCfg.cfg.rxGain
ctrlCfg.u.continuousModeCfg.cfg.vcoSelect
ctrlCfg.u.continuousModeCfg.dataTransSize
*/
//ctrlCfg.u.advancedFrameCfg.profileHandle = //NULL; //frame模式不用配
/* Configure the mmWave module: */
if (MMWave_config (MMWave_Global_Params.handle.MMWave_handle, &ctrlCfg, &errCode) < 0)
{
/* Error: Report the error */
//MMWave_decodeError (errCode, &errorLevel, &mmWaveErrorCode, &subsysErrorCode);
//System_printf ("Error: mmWave Config failed [Error code: %d Subsystem: %d]\n",mmWaveErrorCode, subsysErrorCode);
}
calibrationCfg.dfeDataOutputMode = ctrlCfg.dfeDataOutputMode;
calibrationCfg.u.chirpCalibrationCfg.enableCalibration = true;
calibrationCfg.u.chirpCalibrationCfg.enablePeriodicity = true;
calibrationCfg.u.chirpCalibrationCfg.periodicTimeInFrames = 10; //每10帧一次校准
//calibrationCfg.u.contCalibrationCfg.enableOneShotCalibration //frame模式不用配
/* Start the mmWave module: The configuration has been applied successfully. */
if (MMWave_start(MMWave_Global_Params.handle.MMWave_handle, &calibrationCfg, &errCode) < 0)
{
/* Error/Warning: Unable to start the mmWave module */
//MMWave_decodeError (errCode, &errorLevel, &mmWaveErrorCode, &subsysErrorCode);
//System_printf ("Error: mmWave Start failed [mmWave Error: %d Subsys: %d]\n", mmWaveErrorCode, subsysErrorCode);
/* datapath has already been moved to start state; so either we initiate a cleanup of start sequence or
assert here and re-start from the beginning. For now, choosing the latter path */
}
}
void MMWave_InitTask (UArg arg0, UArg arg1)
{
//MCPI_Initialize();
GPIO_init(); //GPIO初始化
UART_init(); //串口初始化
Init_UART();
Init_MMWave();
}
int main (void)
{
int32_t errCode; //存放SOC初始化错误代码
SOC_Cfg socCfg; //SOC配置结构体
Task_Params taskParams; //任务参数
ESM_init(0U); //与安全等有关,可略过
/* Initialize the SOC configuration: */
/* 初始化SOC配置结构体 */
memset ((void *)&socCfg, 0, sizeof(SOC_Cfg));
/* 配置SOC配置结构体 */
/* Populate the SOC configuration: */
socCfg.clockCfg = SOC_SysClock_INIT;
socCfg.mpuCfg = SOC_MPUCfg_CONFIG;
/* require to UNHALT the DSS if this core is available in selected device */
socCfg.dssCfg = SOC_DSSCfg_UNHALT;
/* Initialize the SOC Module: This is done as soon as the application is started
* to ensure that the MPU is correctly configured. */
/* SOC初始化,必须在系统运行后尽快调用该初始化函数 */
MMWave_Global_Params.handle.socHandle = SOC_init (&socCfg, &errCode);
if (MMWave_Global_Params.handle.socHandle == NULL)
{
System_printf ("[INFO] Error: SOC Module Initialization failed [Error code %d]\n", errCode);
return -1;
}
/* Initialize the Task Parameters. */
/* 创建一个任务用于测试 */
Task_Params_init(&taskParams);
taskParams.priority = 3; //优先级3
MMWave_Global_Params.task.init = Task_create(MMWave_InitTask, &taskParams, NULL);
/* Start BIOS */
BIOS_start();
return 0;
}
main.h:
/*
* main.h
*
* Created on: 2023年7月31日
* Author: ZHOU
*/
#ifndef MAIN_H_
#define MAIN_H_
#include
#include
#include
#include
#include
#include
#include
/* BIOS/XDC Include Files. */
/* SYS/BIOS所使用的头文件 */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
/* MMWave SDK Include Files: */
/* SDK头文件 */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "main_callback.h"
typedef struct
{
SOC_Handle socHandle;
UART_Handle uart0_handle;
MMWave_Handle MMWave_handle;
ADCBuf_Handle adcbuf_handle;
}
MMWave_Global_Handle;
typedef struct
{
Task_Handle init;
Task_Handle MMWaveCtrl;
}
MMWave_Global_Task;
typedef struct
{
MMWave_Global_Handle handle;
MMWave_Global_Task task;
uint8_t uart0_rx;
uint8_t uart0_rxbuf[1024];
uint8_t uart0_tx;
uint8_t uart0_txbuf[1024];
}MMWave_Global;
extern MMWave_Global MMWave_Global_Params;
#endif /* MAIN_H_ */
main_callback.c:
/*
* main_callback.c
*
* Created on: 2023年8月3日
* Author: ZHOU
*/
#include "main_callback.h"
int32_t MMWave_eventFxnCallback(uint16_t msgId, uint16_t sbId, uint16_t sbLen, uint8_t *payload)
{
return 0;
}
void MMWave_cfgFxnCallback(MMWave_CtrlCfg* ptrCtrlCfg)
{
}
void MMWave_openFxnCallback(MMWave_OpenCfg* ptrOpenCfg)
{
}
void MMWave_closeFxnCallback(void)
{
}
void MMWave_startFxnCallback(MMWave_CalibrationCfg* ptrCalibrationCfg)
{
}
void MMWave_stopFxnCallback(void)
{
}
main_callback.h:
/*
* main_callback.h
*
* Created on: 2023年8月3日
* Author: ZHOU
*/
#ifndef MAIN_CALLBACK_H_
#define MAIN_CALLBACK_H_
#include "main.h"
int32_t MMWave_eventFxnCallback(uint16_t msgId, uint16_t sbId, uint16_t sbLen, uint8_t *payload);
void MMWave_cfgFxnCallback(MMWave_CtrlCfg* ptrCtrlCfg);
void MMWave_openFxnCallback(MMWave_OpenCfg* ptrOpenCfg);
void MMWave_closeFxnCallback(void);
void MMWave_startFxnCallback(MMWave_CalibrationCfg* ptrCalibrationCfg);
void MMWave_stopFxnCallback(void);
#endif /* MAIN_CALLBACK_H_ */
关于如何新建文件 可以查看CCS相关操作
这段代码是我基于官方demo例程进行的编写和修改。
其中 MCPI 是用于系统调试log输出的 但是也可以不加 不然可能会因为没有指定MCPI模块运行的地方而报错 所以我直接注释了
从
打开**
Build->XDCtools->Advanced Options中,页面下方的Additional complier options,填入"–enum_type=int",如下
一定要注意–是两个英文的横杠(减号)
3. Build->Arm Complier->Processor Options,右侧的Designate code state,从32修改为16,否则会产生一些奇奇怪怪的问题。
4. Build->Arm Complier->Include Options,右侧上方的搜索路径列表,点击带有绿色加号的图标添加,添加目录 ${MMWAVE_SDK_DIR}/packages
Build->Arm Complier->Prodefined Symbols,右侧上方添加以下符号(直接复制下面的内容,然后点击框内原先已有的宏,按Ctrl+V即可一次性直接粘贴进去)
SOC_XWR68XX
SUBSYS_MSS
DOWNLOAD_FROM_CCS
MMWAVE_L3RAM_NUM_BANK=6
MMWAVE_SHMEM_TCMA_NUM_BANK=0
MMWAVE_SHMEM_TCMB_NUM_BANK=0
MMWAVE_SHMEM_BANK_SIZE=0x20000
DebugP_ASSERT_ENABLED
_LITTLE_ENDIAN
OBJDET_NO_RANGE
AOP
其中 如果需要指定L3代码和MSS用的大小 则配置:
MMWAVE_L3_CODEMEM_SIZE=0x100
MMWAVE_MSSUSED_L3RAM_SIZE=0x90000
6. 此处需要更改Runtime Model Options内的选项,同样也是将enum类型设置为int,与在XDCtools中的设置保持一致。
Build->Arm Complier->Advanced Options,右侧Designate enum type更改为int类型
7. 大部分驱动的函数都封装成库提供给用户了,所以需要将库文件添加到连接器的搜索路径中,否则会出现未解析符号的问题。
Build->Arm Linker->File Search Path,上方添加如下内容(一样可以直接复制过去)
libosal_xwr68xx.aer4f
libesm_xwr68xx.aer4f
libtestlogger_xwr68xx.aer4f
libgpio_xwr68xx.aer4f
libsoc_xwr68xx.aer4f
libpinmux_xwr68xx.aer4f
libcrc_xwr68xx.aer4f
libuart_xwr68xx.aer4f
libmailbox_xwr68xx.aer4f
libmmwavelink_xwr68xx.aer4f
libmmwave_xwr68xx.aer4f
libadcbuf_xwr68xx.aer4f
libdma_xwr68xx.aer4f
libedma_xwr68xx.aer4f
libcli_xwr68xx.aer4f
libhwa_xwr68xx.aer4f
libdpm_xwr68xx.aer4f
libmathutils.aer4f
libcbuff_xwr68xx.aer4f
libhsiheader_xwr68xx.aer4f
librangeproc_hwa_xwr68xx.aer4f
libdpedma_hwa_xwr68xx.aer4f
libqspi_xwr68xx.aer4f
libqspiflash_xwr68xx.aer4f
rtsv7R4_T_le_v3D16_eabi.lib
其中 libsleep_xwr68xx.aer4f是3.6才有的 3.5没有
下方添加如下内容,其中MMWAVE_SDK_DIR和前面设定Linked Resources时添加的变量名保持一致即可。
${MMWAVE_SDK_DIR}/packages/ti/control/mmwave/lib
${MMWAVE_SDK_DIR}/packages/ti/control/mmwavelink/lib
${MMWAVE_SDK_DIR}/packages/ti/control/dpm/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/adcbuf/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/crc/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/dma/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/edma/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/esm/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/gpio/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/hwa/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/mailbox/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/osal/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/pinmux/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/soc/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/uart/lib
${MMWAVE_SDK_DIR}/packages/ti/utils/cli/lib
${MMWAVE_SDK_DIR}/packages/ti/utils/mathutils/lib
${MMWAVE_SDK_DIR}/packages/ti/datapath/dpu/rangeproc/lib
${MMWAVE_SDK_DIR}/packages/ti/datapath/dpedma/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/cbuff/lib
${MMWAVE_SDK_DIR}/packages/ti/utils/hsiheader/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/qspi/lib
${MMWAVE_SDK_DIR}/packages/ti/drivers/qspiflash/lib
${MMWAVE_SDK_DIR}/packages/ti/utils/libsleep/lib
${MMWAVE_SDK_DIR}/packages/ti/utils/testlogger/lib
8. 同样地,在此处也需要填入一些预定义的符号,比如r4f_linker.cmd文件中用到的几个宏的大小。
Build->Arm Linker->Advanced Options->Command File PreProcess,上方添加
MMWAVE_L3RAM_NUM_BANK=6
MMWAVE_SHMEM_TCMA_NUM_BANK=0
MMWAVE_SHMEM_TCMB_NUM_BANK=0
MMWAVE_SHMEM_BANK_SIZE=0x20000
其中 如果需要指定L3代码和MSS用的大小 则配置:
MMWAVE_L3_CODEMEM_SIZE=0x100
MMWAVE_MSSUSED_L3RAM_SIZE=0x90000
9. 修改大端格式
因为芯片烧录是大端 所以要在general里面修改为大端格式:
小端格式也可以 官方工程大多就是小端格式 但是不要用be32或者be8格式 否则会警告只能用大端格式
systemHeap : {} > DATA_RAM