小弟最近拿到一块
EK-TM41294的demo板,调试远程升级功能。
背景:
目前用
tivaware_C_Series-2.1.3.156 固件例子中的boot_serial程序可以实现串口升级。
该目录下没有网口升级例子,于是在SW-
DK-TM4C129X-2.1.3.156.exe 例程中找到boot_demo_emac_flash例子
把例子移植到Tivaware_C_Series-2.1.3.156,使用该库的驱动及对应库,可以编译生成bin程序,烧录进去后
可以看到板卡MAC和设置的IP,然后程序就一直在这个位置,使用LM flash program 配置成网络模式升级也失败,连接不上,不知道有没有人做过该例子?
贴上源码
//*****************************************************************************
//
// Demonstrate the use of the boot loader.
//
//*****************************************************************************
int
main(void)
[
// tContext sContext;
uint32_t ui32IPAddr;
SysCtlMOSCConfigSet(SYSCTL_MOSC_HIGHFREQ);
//
// Run from the PLL at 120 MHz.
//
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
//
// Configure the device pins.
//
PinoutSet(true,false);
//
// Initialize the display driver.
//
/// Kentec320x240x16_SSD2119Init(g_ui32SysClock);
//
// Initialize the graphics context.
//
// GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119);
//
// Draw the application frame.
//
// FrameDraw(&sContext, "boot-demo-emac-flash");
//
// Initialize the peripherals that each of the boot loader flavors
// supports. Although this example is only intended for use with the
// Ethernet boot loader, we initialize the other two peripherals too just
// in case it is used with the USB or serial boot loaders.
//
SetupForUART();
SetupForEthernet();
// SetupForUSB();
//
// Add the compile-time defined widgets to the widget tree.
//
// WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sBackground);
//
// Paint the widget tree to make sure they all appear on the display.
//
// WidgetPaint(WIDGET_ROOT);
//
// We don't have an IP address yet so clear the variable to tell us to
// check until we are assigned one.
//
ui32IPAddr = 0;
UARTprintf("g_bFirmwareUpdate=%dnr",g_bFirmwareUpdate);
//
// Loop forever, processing widget messages.
//
while(!g_bFirmwareUpdate)
[
// UARTprintf("ui32IPAddr=%xnr",ui32IPAddr);
//
// Do we have an IP address yet? If not, check to see if we've been
// assigned one since the last time we checked.
//
#if 1
if(ui32IPAddr == 0 || ui32IPAddr == 0xFFFFFFFF)
[
//
// What is our current IP address?
//
ui32IPAddr = lwIPLocalIPAddrGet();
//
// If it's non zero, update the display.
//
if(ui32IPAddr!= 0 && ui32IPAddr != 0xFFFFFFFF)
[
UARTprintf("IP: %d.%d.%d.%dnr",ui32IPAddr & 0xff, (ui32IPAddr >> 8) & 0xff,
(ui32IPAddr >> 16) & 0xff, ui32IPAddr >> 24);
// WidgetPaint((tWidget *)&g_sIPAddr);
]
]
#endif
//
// Process any messages from or for the widgets.
//
// WidgetMessageQueueProcess();
]
//
// If we drop out, the user has sent "Magic Package" via LMFlash
// so we tidy up and transfer control to the boot loader.
//
//
// Tell the user that we got their instruction.
//
// CanvasTextSet(&g_sStatus, "Updating...");
// WidgetPaint((tWidget *)&g_sStatus);
UARTprintf("Updating...nr");
//
// Process all remaining messages on the queue (including the paint message
// we just posted).
//
// WidgetMessageQueueProcess();
//
// Transfer control to the bootloader.
//
SoftwareUpdateBegin(g_ui32SysClock);
//
// The previous function never returns but we need to stick in a return
// code here to keep the compiler from generating a warning.
//
return(0);
]
网络配置如下:
//*****************************************************************************
//
// Perform the initialization steps required to start up the Ethernet controller
// and lwIP stack.
//
//*****************************************************************************
void
SetupForEthernet(void)
[
uint32_t ui32User0, ui32User1;
uint8_t pui8MACAddr[8];
//
// Configure SysTick for a 100Hz interrupt.
//
ROM_SysTickPeriodSet(g_ui32SysClock / TICKS_PER_SECOND);
ROM_SysTickEnable();
ROM_SysTickIntEnable();
//
// Get the MAC address from the UART0 and UART1 registers in NV ram.
//
ROM_FlashUserGet(&ui32User0, &ui32User1);
if((ui32User0 == 0xffffffff) || (ui32User1 == 0xffffffff))
[
//
// We should never get here. This is an error if the MAC address has
// not been programmed into the device. Exit the program.
//
UARTprintf("MAC Address Not Programmed!nr");
while(1)
[
]
]
//
// Convert the 24/24 split MAC address from NV ram into a MAC address
// array.
//
pui8MACAddr[0] = ui32User0 & 0xff;
pui8MACAddr[1] = (ui32User0 >> 8) & 0xff;
pui8MACAddr[2] = (ui32User0 >> 16) & 0xff;
pui8MACAddr[3] = ui32User1 & 0xff;
pui8MACAddr[4] = (ui32User1 >> 8) & 0xff;
pui8MACAddr[5] = (ui32User1 >> 16) & 0xff;
//
// Format this address into the string used by the relevant widget.
//
UARTprintf("MAC: %02X-%02X-%02X-%02X-%02X-%02Xnr",
pui8MACAddr[0], pui8MACAddr[1], pui8MACAddr[2], pui8MACAddr[3],
pui8MACAddr[4], pui8MACAddr[5]);
//
// Remember that we don't have an IP address yet.
//
// usnprintf(g_pcIPAddr, SIZE_IP_ADDR_BUFFER, "IP: Not assigned");
UARTprintf("IP: Not assignednr");
//
// Initialize the lwIP TCP/IP stack.
//
// lwIPInit(g_ui32SysClock, pui8MACAddr, 0, 0, 0, IPADDR_USE_AUTOIP);
lwIPInit(g_ui32SysClock, pui8MACAddr,0xC0A8010C ,0xFFFFFF0, 0xC0A80101 , IPADDR_USE_STATIC);
//
// Setup the device locator service.
//
// LocatorInit();
// LocatorMACAddrSet(pui8MACAddr);
//
// Start the remote software update module.
//
UARTprintf("SoftwareUpdateInitnr");
SoftwareUpdateInit(SoftwareUpdateRequestCallback); //这句一直没有运行,不知道为什么
]