This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TM4C1294NCPDT:我想将新的 UDP 发送和接收操作添加到闪存以太网引导加载程序中。

Guru**** 2535750 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1293122/tm4c1294ncpdt-i-want-to-add-new-udp-sending-and-receiving-operations-to-the-flash-ethernet-bootloader

器件型号:TM4C1294NCPDT
闪存以太网引导加载程序定期发送 BOOTP 并始终等待接收 BOOTP,但如何编写代码以并行发送和接收任意 UDP?

我想使用单独的程序提前在器件的用户寄存器中设置某个值、将闪存以太网引导加载程序写入 TM4C129、并使用 UDP 通信来获取用户寄存器值。
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Muneto-San:

     BOOTP 基于 UDP 协议。 如果查看 TivaWare 以太网引导加载程序、您会发现 BOOTP 请求是使用 UIP 堆栈发送的。 请参阅 C:\ti\TivaWare_C_Series-2.2.0.295\boot_loader\bl_emac.c 中的 bl_emac.c 文件、其中 uip_udp_send (sizeof (tBOOTPPacket))是发送 BOOTP 请求的函数。 UIP  协议栈是 TCP/IP 网络协议栈的开源实现  、旨在 降低其内存占用量。 UIP 协议栈位于 C:\ti\TivaWare_C_Series-2.2.0.295\third_party\uIP-1.0\uip 中。 您可以参考如何在自定义引导加载程序中使用 uIP_udp_send ()来实现应用程序特定的要求。  

    static void
    SendBOOTPRequest(void)
    {
        uint8_t *pui8Packet = (uint8_t *)uip_appdata;
        tBOOTPPacket *psBOOTP = (tBOOTPPacket *)uip_appdata;
        uint32_t ui32Idx;
    
        //
        // Zero fill the BOOTP request packet.
        //
        for(ui32Idx = 0; ui32Idx < sizeof(tBOOTPPacket); ui32Idx++)
        {
            pui8Packet[ui32Idx] = 0;
        }
    
        //
        // Construct a BOOTP request.
        //
        psBOOTP->ui8Op = BOOTP_REQUEST;
    
        //
        // Set the hardware type to Ethernet.
        //
        psBOOTP->ui8HType = 0x01;
    
        //
        // Set the hardware address length to 6.
        //
        psBOOTP->ui8HLen = 0x06;
    
        //
        // Choose a random number for the transaction ID.
        //
        psBOOTP->ui32XID = g_ui32XID = RandomNumber();
    
        //
        // Set the number of seconds since we started.
        //
        psBOOTP->ui16Secs = HTONS(g_ui32Ticks / SYSTICKHZ);
    
        //
        // Fill in the Ethernet MAC address.
        //
        for(ui32Idx = 0; ui32Idx < 6; ui32Idx++)
        {
            psBOOTP->pui8CHAddr[ui32Idx] = g_sMACAddr.addr[ui32Idx];
        }
    
        //
        // Set the server name if defined.
        //
    #ifdef ENET_BOOTP_SERVER
        for(ui32Idx = 0;
            (psBOOTP->pcSName[ui32Idx] = ENET_BOOTP_SERVER[ui32Idx]) != 0;
            ui32Idx++)
        {
        }
    #endif
    
        //
        // Send the BOOTP request packet.
        //
        uip_udp_send(sizeof(tBOOTPPacket));
    }