你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

请教下,使用tftP 升级固件,数据发送返回错误 ?

[复制链接]
hpdell 提问时间:2017-12-16 14:36 /
悬赏5ST金币未解决
本帖最后由 hpdell 于 2017-12-16 14:42 编辑

请教下,使用tftP 升级固件,数据发送返回错误 ?

tftp 使用的 是 tftpd32.452 这个版本的


tftp.png

有谁知道是怎么回事莫 ??  

使用 http 更新固件,完全正常

static void IAP_tftp_recv_callback(void *arg, struct udp_pcb *upcb, struct pbuf *pkt_buf,
                        const ip_addr_t *addr, u16_t port)
{
  tftp_opcode op;
  struct udp_pcb *upcb_tftp_data;
  err_t err;

  uint32_t i;
  char filename[40],message[40], *ptr;

  /* create new UDP PCB structure */
  upcb_tftp_data = udp_new();
  if (!upcb_tftp_data)
  {
    /* Error creating PCB. Out of Memory  */

    printf("Can not create pcb 1\r\n");
    __LTDC_drv->LTDC_DispStringAt(12, 180,
                                  LCD_COLOR_RED,
                                  LCD_COLOR_WHITE,
                                  &FontAscii8x16,
                             (const uint8_t *)"Can not create pcb 1");
    return;
  }

  /* bind to port 0 to receive next available free port */
  /* NOTE:  This is how TFTP works.  There is a UDP PCB for the standard port
  * 69 which al transactions begin communication on, however, _all_ subsequent
  * transactions for a given "stream" occur on another port  */
  err = udp_bind(upcb_tftp_data, IP_ADDR_ANY, 0);
  if (err != ERR_OK)
  {
    /* Unable to bind to port */

    printf("Can not create pcb 2\r\n");
    __LTDC_drv->LTDC_DispStringAt(12, 200,
                                  LCD_COLOR_RED,
                                  LCD_COLOR_WHITE,
                                  &FontAscii8x16,
                             (const uint8_t *)"Can not create pcb 2");
    return;
  }

  op = IAP_tftp_decode_op(pkt_buf->payload);
  if (op != TFTP_WRQ)     // op 实际返回的值为 1,而这个 TFTP_WRQ 定义的为2 ,
  {
    /* remove PCB */

    printf("Bad TFTP opcode \r\n");                      // 问题就出在这里了 ?????????????????????
    __LTDC_drv->LTDC_DispStringAt(12, 200,
                                  LCD_COLOR_RED,
                                  LCD_COLOR_WHITE,
                                  &FontAscii8x16,
                             (const uint8_t *)"Bad TFTP opcode");
    udp_remove(upcb_tftp_data);
  }
  else
  {


    ptr = pkt_buf->payload;
    ptr = ptr +2;
    // extract file name info
    i= 0;
    while (*(ptr+i)!=0x0)
    {
      i++;
    }
    strncpy(filename, ptr, i+1);

    printf("IAP using TFTP \r\n");

    __LTDC_drv->LTDC_DispStringAt(12, 220,
                                  LCD_COLOR_RED,
                                  LCD_COLOR_WHITE,
                                  &FontAscii8x16,
                             (const uint8_t *)"IAP using TFTP");

    sprintf(message, "File: %s",filename);

    printf("State: Erasing...\r\n");
    __LTDC_drv->LTDC_DispStringAt(12, 240,
                                  LCD_COLOR_RED,
                                  LCD_COLOR_WHITE,
                                  &FontAscii8x16,
                             (const uint8_t *)message);   

    __LTDC_drv->LTDC_DispStringAt(12, 260,
                                  LCD_COLOR_RED,
                                  LCD_COLOR_WHITE,
                                  &FontAscii8x16,
                             (const uint8_t *)"State: Erasing...");     


    // Start the TFTP write mode
    IAP_tftp_process_write(upcb_tftp_data, addr, port);
  }
  pbuf_free(pkt_buf);
}


/**
  * @brief Returns the TFTP opcode
  * @param buf: pointer on the TFTP packet
  * @retval None
  */
static tftp_opcode IAP_tftp_decode_op(char *buf)
{
  return (tftp_opcode)(buf[1]);
}

收藏 1 评论1 发布时间:2017-12-16 14:36

举报

1个回答
feixiang20 回答时间:2018-5-19 02:10:10
查看软件是否被正确解压,升级包中的TFTP升级软件是否已经开启运行,升级页面的文件名是否和解压后文件夹中的文件名相同

评分

参与人数 1蝴蝶豆 +3 收起 理由
zero99 + 3

查看全部评分

所属标签

相似问题

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
微信公众号二维码 微信公众号
手机版二维码 手机版