雖然這不是第一次接觸follow Open-WRT架構下開發的工具環境,
但是之前的案子前輩們已經把Code base放到SVN Server上,
很方便直接把svn diff後的result貼成.patch file大致上就沒有問題.
因為進度的關係還來不及放上SVN,所以只能再local環境下出patch file解燃眉之急.
想到用diff這個指令,結果卻與我想像的不同:
scottj@ubuntu-11:src$ diff sfp_net.c.old sfp_net.c 19a20 > #include "sfp_omci.h" 39a41,54 > static void netif_status_callback(struct netif *netif, void *priv) > { > bool ifup; > const char *if_name; > > ifup = netif_is_up(netif) ? true : false; > if_name = ((struct eth_drv_sc *)netif->state)->dev_name; > #ifdef INCLUDE_SFP_OMCI > sfp_omci_netif_callback(priv, if_name, ifup); > #else > diag_printf("sfp_net: %s %s\n", if_name, ifup ? "UP" : "DOWN"); > #endif > } > 76c91 < ethaddr[4] += 1; --- > ethaddr[5] += 1; 92c107 < ethaddr[4] += 1; --- > ethaddr[5] += 1; 134a150,155 > #if LWIP_DHCP > dhcp_stop(net); > #endif > netif_set_status_callback(net, netif_status_callback, > (void *)omci_context); > 187c208 < ethaddr[4] += 1; --- > ethaddr[5] += 1; 201c222 < ethaddr[4] += 1; --- > ethaddr[5] += 1; 254a276,281 > #if LWIP_DHCP > dhcp_stop(net); > #endif > netif_set_status_callback(net, netif_status_callback, > (void *)omci_context); > |
這樣的格式明顯與SDK本來就附上的.patch內容不同,原始的比較像用svn diff後的格式.
後來請教了同事原來還是與帶的參數有關,“diff -Naur file1 file2 > t.patch”
執行的結果:
scottj@ubuntu-11:src$ diff -Naur sfp_net.c.old sfp_net.c --- sfp_net.c.old 2014-03-05 23:49:24.000000000 +0800 +++ sfp_net.c 2014-08-19 09:30:07.000000000 +0800 @@ -17,6 +17,7 @@ #include "sfp_net.h" #include "sfp_onu.h" +#include "sfp_omci.h" #include "sfp_io.h" #include "sfp_console.h" #include "sfp_board.h" @@ -37,6 +38,20 @@ return 0; } +static void netif_status_callback(struct netif *netif, void *priv) +{ + bool ifup; + const char *if_name; + + ifup = netif_is_up(netif) ? true : false; + if_name = ((struct eth_drv_sc *)netif->state)->dev_name; +#ifdef INCLUDE_SFP_OMCI + sfp_omci_netif_callback(priv, if_name, ifup); +#else + diag_printf("sfp_net: %s %s\n", if_name, ifup ? "UP" : "DOWN"); +#endif +} + static void sfp_net_init_1port(uint8_t *ethaddr) { static const uint32_t lan_default_gw[4] = { CYGDAT_LWIP_SERV_ADDR }; @@ -73,7 +88,7 @@ Initialize WAN interface */ - ethaddr[4] += 1; + ethaddr[5] += 1; printf("WAN MAC address : %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n", ethaddr[0], ethaddr[1], ethaddr[2], ethaddr[3], ethaddr[4], ethaddr[5]); @@ -89,7 +104,7 @@ it's just convinient to use the same image on both hardware platforms */ - ethaddr[4] += 1; + ethaddr[5] += 1; printf("LAN1 MAC address : %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n", ethaddr[0], ethaddr[1], ethaddr[2], @@ -132,6 +147,12 @@ IP4_ADDR(&lwip_nm, nm[0], nm[1], nm[2], nm[3]); netif_set_down(net); +#if LWIP_DHCP + dhcp_stop(net); +#endif + netif_set_status_callback(net, netif_status_callback, + (void *)omci_context); + netif_set_addr(net, &lwip_ip, &lwip_nm, &lwip_gw); if (default_interface) netif_set_default(net); @@ -184,7 +205,7 @@ onu_ecos_netdev_init(ONU_NET_NETDEV_LAN1_PORT, FALCON_ETH_INSTANCE_NAME_LAN1, ethaddr); - ethaddr[4] += 1; + ethaddr[5] += 1; #endif printf("LAN0 MAC address : %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n", @@ -198,7 +219,7 @@ Initialize WAN interface */ - ethaddr[4] += 1; + ethaddr[5] += 1; printf("WAN MAC address : %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n", ethaddr[0], ethaddr[1], ethaddr[2], ethaddr[3], ethaddr[4], ethaddr[5]); @@ -252,6 +273,12 @@ IP4_ADDR(&lwip_nm, nm[0], nm[1], nm[2], nm[3]); netif_set_down(net); +#if LWIP_DHCP + dhcp_stop(net); +#endif + netif_set_status_callback(net, netif_status_callback, + (void *)omci_context); + netif_set_addr(net, &lwip_ip, &lwip_nm, &lwip_gw); if (default_interface) netif_set_default(net); |
這樣就可以把patch直接放到SDK裡面去,
當然file head需要修改一下才能讓script吃.
簡單紀錄一下,免得時間久了又給遺忘.
Facebook Comments