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.
工程师好、
在 F28004x 上使用闪存 API ROM 库时、我目前面临一些问题。
我写了一个函数在微控制器上执行固件更新/闪存写入:
静态空 btlMsgHandler (uint16 * rx_msg、uint16 * tx_msg)
RX_msg 指向应写入闪存的 UINT16值的数组。 此数组在覆盖函数开始时在本地声明。
当程序运行并且调用 over卧 位函数时、该数组被压入堆栈指针位置处的堆栈、例如0x435。
在 fcn 内部、我调用运行良好的编程函数、但在执行后验证失败。
验证需要指向32位字的指针。 我通过将 Rx_msg 转换为 UINT32 *来生成此指针。
当阵列存储在奇数地址(实际上是0x435)上时、读取之前奇数地址和偶数地址中的值-然后验证将失败。
是否可以确保栈仅填充32位对齐、或者您是否有其他建议来解决此问题?
这是我的数组声明:
Uint16 u16RcvMsg[40];
这是函数原型:
static void msgHandler( Uint16 * rx_msg, Uint16 * tx_msg);
这是(拆分)函数:
static void msgHandler( Uint16 * rx_msg, Uint16 * tx_msg) { uint32 *data_buffer_32 = NULL; data_buffer_32 = (uint32 *)(rx_msg_internal+4); mem_address = 0x80000; for(i = 0; i < 4 ; i++) { // Issue program command return_check = Fapi_issueProgrammingCommand((uint32 *)mem_address, &rx_msg[(4+(8*i))], 8, 0, 0, Fapi_AutoEccGeneration); // Wait until the Flash program operation is over while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady) {} if(return_check != Fapi_Status_Success) { // TODO , error } // Read FMSTAT register contents to know the status of FSM after program command to see if there are any program operation related errors flash_status = Fapi_getFsmStatus(); if(flash_status != 0) { // TODO Error } // Verify the programmed values return_check = Fapi_doVerify((uint32 *)mem_address, 4, data_buffer_32, &flash_status_word); if(return_check != Fapi_Status_Success) { // TODO error } data_buffer_32 += 4; // Shift address Pointer of 32 Bit verify Buffer by 4 32 bit words mem_address += 8; // Shift address Pointer of Data Buffer by 8 16-bit words } // Do some stuff }
这是超文本功能的结构:
static void btlHandler( void ) { Uint16 u16RcvMsg[40]; .... // Write to u16RcvMsg btlMsgHandler( &u16RcvMsg[0], &au16TxBufferSPI_B[0]); .... }
在本例中、数组存储在0x435的堆栈上。
存储器内容:
0x434 - 0000
0x435 - 0001
0x436 - 0203
0x437 - 0405
…
将 DATA_Buffer_32设置为0x435时、比较数据值0x00010000验证失败、这意味着它从0x434和0x435读取。
是否可以确保第一个数据字放置在堆栈上的偶数(32位对齐)地址上?
此致、Chris
Chris、
我将在几天内回顾这一点并返回给您。
谢谢、此致、
Vamsi
您好、Vamsi、
感谢您的快速回复。 请注意、我最近编辑了上述帖子、因为代码中存在错误。
此致、Chris
Christian、
在 C2000Ware 中提供的用于闪存 API 编程示例的链接器命令文件中、您将注意到数据缓冲区使用 align 在32位边界(或64位或128位)上对齐。 这可确保缓冲器在偶数地址上对齐。 请尝试相同的方法、并告诉我它是如何实现的。
谢谢、此致、
Vamsi