void ExecuteAPP()
{
FLASH_OBProgramInitTypeDef pOBInit;
pOBInit.OptionType = OPTIONBYTE_BOOTADDR_0;
pOBInit.BootAddr0 = ((uint32_t)0x2008); // 0x2008 for 0x802 0000
/* Allow Access to option bytes sector */
HAL_FLASH_OB_Unlock();
/* Program option bytes */
HAL_FLASHEx_OBProgram(&pOBInit);
/* Start the Option Bytes programming process */
if (HAL_FLASH_OB_Launch() != HAL_OK)
{
/* User can add here some code to deal with this error */
while (1)
{
}
}
/* Prevent Access to option bytes sector */
HAL_FLASH_OB_Lock();
/* Generate Reset by software */
NVIC_SystemReset();
//复位后执行APP
}
本帖最后由 wofei1314 于 2017-12-15 10:56 编辑
void ExecuteAPP()
{
FLASH_OBProgramInitTypeDef pOBInit;
pOBInit.OptionType = OPTIONBYTE_BOOTADDR_0;
pOBInit.BootAddr0 = ((uint32_t)0x2008); // 0x2008 for 0x802 0000
/* Allow Access to option bytes sector */
HAL_FLASH_OB_Unlock();
/* Program option bytes */
HAL_FLASHEx_OBProgram(&pOBInit);
/* Start the Option Bytes programming process */
if (HAL_FLASH_OB_Launch() != HAL_OK)
{
/* User can add here some code to deal with this error */
while (1)
{
}
}
/* Prevent Access to option bytes sector */
HAL_FLASH_OB_Lock();
/* Generate Reset by software */
NVIC_SystemReset();
//复位后执行APP
}
wofei1314 发表于 2017-12-15 10:52
我试试看,多谢多谢啊
hpdell 发表于 2017-12-15 19:35
我试试看,多谢多谢啊
注意那个地址你要查手册的,我给的0x2008 不一定适合你的板子,它和ROM的地址有个映射关系
wofei1314 发表于 2017-12-16 09:23
注意那个地址你要查手册的,我给的0x2008 不一定适合你的板子,它和ROM的地址有个映射关系 ...
好的,不过我看这个编程貌似是 opt 类型的吧,
不是从 0x080xxxxxx 开始的吧 ??????
hpdell 发表于 2017-12-16 09:47
好的,不过我看这个编程貌似是 opt 类型的吧,
不是从 0x080xxxxxx 开始的吧 ?????? ...
是FLASH地址,只是有个映射关系,所以才说让你查看一下手册,看看这个关系是怎么映射的
wofei1314 发表于 2017-12-16 16:54
是FLASH地址,只是有个映射关系,所以才说让你查看一下手册,看看这个关系是怎么映射的 ...
目前使用 http 更新程序已经搞定啦 ,多谢多谢啊,
但是使用 tftp 不行,不知道是不是我的 tftp 使用的版本不对呀 ?
我目前使用 tftpd32.452,tftpd64.400 这两个版本的都试过了不行,具体如下:
/**
* @briefProcesses traffic received on UDP port 69
* @paramargs: pointer on tftp_connection arguments
* @paramupcb: pointer on udp_pcb structure
* @parampbuf: pointer on packet buffer
* @paramaddr: pointer on the receive IP address
* @paramport: 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,message, *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);
}
hpdell 发表于 2017-12-17 10:58
目前使用 http 更新程序已经搞定啦 ,多谢多谢啊,
但是使用 tftp 不行,不知道是不是我的 tftp 使用的 ...
搞定就好,传统的跳转的方法应该也没问题,设置启动地址是F7的新特性
fFTP我还没用过....
hpdell 发表于 2017-12-17 10:58
目前使用 http 更新程序已经搞定啦 ,多谢多谢啊,
但是使用 tftp 不行,不知道是不是我的 tftp 使用的 ...
搞定就好,传统的跳转的方法应该也没问题,设置启动地址是F7的新特性
fFTP我还没用过....