|
|
@ -463,6 +463,74 @@ static void _debug_pkt_update_iap(void)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 设备 FPGA 升级回复 */
|
|
|
|
|
|
|
|
static void _debug_pkt_update_fpga(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
|
|
|
|
mul_head_t *m_head = (mul_head_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
uint8_t *data = (uint8_t*)(debug_buf.buf + sizeof(proto_head_t) + sizeof(mul_head_t));
|
|
|
|
|
|
|
|
uint32_t addr = TFTP_APP_ADDRESS;
|
|
|
|
|
|
|
|
uint32_t app_len = 0;
|
|
|
|
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
HAL_GPIO_WritePin(LED_RUN_GPIO_Port, LED_RUN_Pin, GPIO_PIN_SET);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* index 为 0 表示是首保, 需要擦除 FLASH. */
|
|
|
|
|
|
|
|
if (0 == m_head->index)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
while(addr != TFTP_APP_ADDRESS_END)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (spi_flash_erase(addr, SPI_CMD_BLOCK64_ERASE) != HAL_OK)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addr += SPI_FLASH_BLOCK64_SIZE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算写 FLASH 地址, 并写入 FLASH. */
|
|
|
|
|
|
|
|
addr = TFTP_APP_ADDRESS + m_head->index * DEBUG_FLASH_BUF_SIZE;
|
|
|
|
|
|
|
|
if (addr >= TFTP_APP_ADDRESS_END)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_head->len > DEBUG_DATA_SIZE
|
|
|
|
|
|
|
|
|| m_head->index >= 2944)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(m_head->len > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (spi_flash_write(addr, data, m_head->len) != HAL_OK)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 长度小于 DEBUG_FLASH_BUF_SIZE 则认为是最后一包. */
|
|
|
|
|
|
|
|
if(m_head->len < DEBUG_FLASH_BUF_SIZE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* 校验数据. */
|
|
|
|
|
|
|
|
app_len = addr - TFTP_APP_ADDRESS + m_head->len;
|
|
|
|
|
|
|
|
dau_ctrl.update_flag = TRUE;
|
|
|
|
|
|
|
|
dau_ctrl.update_len = app_len;
|
|
|
|
|
|
|
|
dau_ctrl.update_rt = DAU_UPD_NONE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(mul_head_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
|
|
|
|
*crc = crc32(debug_buf.buf, head->len);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 发送报文 */
|
|
|
|
|
|
|
|
_debug_pkt_send(head->len + 4, 28);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 修改配置报文处理. */
|
|
|
|
/* 修改配置报文处理. */
|
|
|
|
static void _debug_pkt_config_get(void)
|
|
|
|
static void _debug_pkt_config_get(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1578,6 +1646,30 @@ static void _debug_pkt_csg_config_set(void)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 主动上传fpga升级结果. */
|
|
|
|
|
|
|
|
static void _debug_pkt_update_fpga_result()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
|
|
|
|
int32_t *res = (int32_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(int32_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
|
|
|
|
head->cmd_type = DEBUG_CT_PRV_REPLY;
|
|
|
|
|
|
|
|
head->cmd = DEBUG_PRV_UPDATE_RT;
|
|
|
|
|
|
|
|
*res = (dau_ctrl.update_rt != DAU_UPD_OK);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
|
|
|
|
*crc = crc32(debug_buf.buf, head->len);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 发送报文 */
|
|
|
|
|
|
|
|
_debug_pkt_send(head->len + 4, 20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 收包报文处理. */
|
|
|
|
/* 收包报文处理. */
|
|
|
|
static void _debug_pkt_process(void)
|
|
|
|
static void _debug_pkt_process(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1670,6 +1762,9 @@ static void _debug_pkt_process(void)
|
|
|
|
case DEBUG_PRV_CSG_CONFIG_SET:
|
|
|
|
case DEBUG_PRV_CSG_CONFIG_SET:
|
|
|
|
_debug_pkt_csg_config_set();
|
|
|
|
_debug_pkt_csg_config_set();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEBUG_PRV_UPDATE_FPGA:
|
|
|
|
|
|
|
|
_debug_pkt_update_fpga();
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1689,6 +1784,12 @@ void debug_start(void)
|
|
|
|
while(1)
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
common_watchdog_set(COM_WDG_CLI);
|
|
|
|
common_watchdog_set(COM_WDG_CLI);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dau_ctrl.update_rt == DAU_UPD_OK)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_debug_pkt_update_fpga_result();
|
|
|
|
|
|
|
|
dau_ctrl.update_rt = DAU_UPD_NONE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 开启串口空闲中断 DMA 收包. 注意这里会收到空闲中断, DMA 收一半中断, 全收中断, 注意中断处理. */
|
|
|
|
/* 开启串口空闲中断 DMA 收包. 注意这里会收到空闲中断, DMA 收一半中断, 全收中断, 注意中断处理. */
|
|
|
|
if (HAL_OK == HAL_UARTEx_ReceiveToIdle_DMA(debug_uart, debug_buf.buf + debug_buf.end, USART_BUF_SIZE - debug_buf.end))
|
|
|
|
if (HAL_OK == HAL_UARTEx_ReceiveToIdle_DMA(debug_uart, debug_buf.buf + debug_buf.end, USART_BUF_SIZE - debug_buf.end))
|
|
|
|