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

请教下,使用 iap 程序跳转 运行失败 ?

[复制链接]
hpdell 提问时间:2017-12-11 12:14 /
阅读主题, 点击返回1楼
收藏 评论38 发布时间:2017-12-11 12:14
38个回答
wofei1314 回答时间:2017-12-15 09:35:44
  1. void ExecuteAPP()
  2. {
  3.     FLASH_OBProgramInitTypeDef pOBInit;
  4.     pOBInit.OptionType = OPTIONBYTE_BOOTADDR_0;
  5.     pOBInit.BootAddr0 = ((uint32_t)0x2008); // 0x2008 for 0x802 0000
  6.     /* Allow Access to option bytes sector */
  7.     HAL_FLASH_OB_Unlock();
  8.     /* Program option bytes */
  9.     HAL_FLASHEx_OBProgram(&pOBInit);

  10.     /* Start the Option Bytes programming process */
  11.     if (HAL_FLASH_OB_Launch() != HAL_OK)
  12.     {
  13.         /* User can add here some code to deal with this error */
  14.         while (1)
  15.         {
  16.         }
  17.     }

  18.     /* Prevent Access to option bytes sector */
  19.     HAL_FLASH_OB_Lock();
  20.     /* Generate Reset by software */
  21.     NVIC_SystemReset();
  22.     //复位后执行APP
  23. }
复制代码
wofei1314 回答时间:2017-12-15 10:52:19
本帖最后由 wofei1314 于 2017-12-15 10:56 编辑
  1. void ExecuteAPP()
  2. {
  3.     FLASH_OBProgramInitTypeDef pOBInit;
  4.     pOBInit.OptionType = OPTIONBYTE_BOOTADDR_0;
  5.     pOBInit.BootAddr0 = ((uint32_t)0x2008); // 0x2008 for 0x802 0000
  6.     /* Allow Access to option bytes sector */
  7.     HAL_FLASH_OB_Unlock();
  8.     /* Program option bytes */
  9.     HAL_FLASHEx_OBProgram(&pOBInit);

  10.     /* Start the Option Bytes programming process */
  11.     if (HAL_FLASH_OB_Launch() != HAL_OK)
  12.     {
  13.         /* User can add here some code to deal with this error */
  14.         while (1)
  15.         {
  16.         }
  17.     }

  18.     /* Prevent Access to option bytes sector */
  19.     HAL_FLASH_OB_Lock();
  20.     /* Generate Reset by software */
  21.     NVIC_SystemReset();
  22.     //复位后执行APP
  23. }
复制代码
hpdell 回答时间:2017-12-15 19:35:17

我试试看,多谢多谢啊
wofei1314 回答时间:2017-12-16 09:23:54
hpdell 发表于 2017-12-15 19:35
我试试看,多谢多谢啊

注意那个地址你要查手册的,我给的  0x2008 不一定适合你的板子,它和ROM的地址有个映射关系
hpdell 回答时间:2017-12-16 09:47:48
wofei1314 发表于 2017-12-16 09:23
注意那个地址你要查手册的,我给的  0x2008 不一定适合你的板子,它和ROM的地址有个映射关系 ...

好的,不过我看这个编程貌似是 opt 类型的吧,

不是从 0x080xxxxxx 开始的吧 ??????
wofei1314 回答时间:2017-12-16 16:54:15
hpdell 发表于 2017-12-16 09:47
好的,不过我看这个编程貌似是 opt 类型的吧,

不是从 0x080xxxxxx 开始的吧 ?????? ...

是FLASH地址,只是有个映射关系,所以才说让你查看一下手册,看看这个关系是怎么映射的
hpdell 回答时间:2017-12-17 10:58:58
wofei1314 发表于 2017-12-16 16:54
是FLASH地址,只是有个映射关系,所以才说让你查看一下手册,看看这个关系是怎么映射的 ...

目前使用 http 更新程序已经搞定啦 ,多谢多谢啊,

但是使用 tftp 不行,不知道是不是我的 tftp 使用的版本不对呀 ?

我目前使用 tftpd32.452,tftpd64.400 这两个版本的都试过了不行,具体如下:
/**
  * @brief  Processes traffic received on UDP port 69
  * @param  args: pointer on tftp_connection arguments
  * @param  upcb: pointer on udp_pcb structure
  * @param  pbuf: pointer on packet buffer
  * @param  addr: pointer on the receive IP address
  * @param  port: receive port number
  * @retval None
  */
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_TRANSPARENT,
                                  &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_TRANSPARENT,
                                  &FontAscii8x16,
                             (const uint8_t *)"Can not create pcb 2");
    return;
  }

  op = IAP_tftp_decode_op(pkt_buf->payload);
  if (op != TFTP_WRQ)
  {
    /* remove PCB */

    printf("Bad TFTP opcode \r\n");                  // 错误就在这里, ?????????????????
    __LTDC_drv->LTDC_DispStringAt(12, 200,
                                  LCD_COLOR_RED,
                                  LCD_COLOR_TRANSPARENT,
                                  &FontAscii8x16,
                             (const uint8_t *)"Bad TFTP opcode");
    udp_remove(upcb_tftp_data);
  }
  else
  {
   
//#ifdef USE_LCD
    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_TRANSPARENT,
                                  &FontAscii8x16,
                             (const uint8_t *)"IAP using TFTP");
   
    sprintf(message, "File: %s",filename);
//    LCD_UsrLog("%s\n", message);
    printf("State: Erasing...\r\n");
    __LTDC_drv->LTDC_DispStringAt(12, 240,
                                  LCD_COLOR_RED,
                                  LCD_COLOR_TRANSPARENT,
                                  &FontAscii8x16,
                             (const uint8_t *)message);   
   
    __LTDC_drv->LTDC_DispStringAt(12, 260,
                                  LCD_COLOR_RED,
                                  LCD_COLOR_TRANSPARENT,
                                  &FontAscii8x16,
                             (const uint8_t *)"State: Erasing...");     
//#endif
     
    // Start the TFTP write mode
    IAP_tftp_process_write(upcb_tftp_data, addr, port);
  }
  pbuf_free(pkt_buf);
}

评分

参与人数 1ST金币 +2 收起 理由
zero99 + 2 发帖奖励

查看全部评分

wofei1314 回答时间:2017-12-17 16:40:35
hpdell 发表于 2017-12-17 10:58
目前使用 http 更新程序已经搞定啦 ,多谢多谢啊,

但是使用 tftp 不行,不知道是不是我的 tftp 使用的 ...

搞定就好,传统的跳转的方法应该也没问题,设置启动地址是F7的新特性

fFTP我还没用过....
wofei1314 回答时间:2017-12-17 16:40:38
hpdell 发表于 2017-12-17 10:58
目前使用 http 更新程序已经搞定啦 ,多谢多谢啊,

但是使用 tftp 不行,不知道是不是我的 tftp 使用的 ...

搞定就好,传统的跳转的方法应该也没问题,设置启动地址是F7的新特性

fFTP我还没用过....
1234

所属标签

相似问题

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版