我目前使用 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 */
我试试看,多谢多谢啊
注意那个地址你要查手册的,我给的 0x2008 不一定适合你的板子,它和ROM的地址有个映射关系
好的,不过我看这个编程貌似是 opt 类型的吧,
不是从 0x080xxxxxx 开始的吧 ??????
是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);
}
评分
查看全部评分
搞定就好,传统的跳转的方法应该也没问题,设置启动地址是F7的新特性
fFTP我还没用过....
搞定就好,传统的跳转的方法应该也没问题,设置启动地址是F7的新特性
fFTP我还没用过....