Re: [U-Boot] [PATCH 6/6] mx6q: mx6qsabrelite: Provide defaults for placing environment in serial flash
On 20/01/2012 08:48, Jason Hui wrote: I'm wondering how the CONFIG_ENV_SPI_CS could be 0x5300? Vague? Then the left open question is only above one. The SPI driver can take as chip select the controller's chip selects as well as an external GPIO. The LSB byte has the value of the internal chip select, the highest (thought as 16-bit value) contains the GPIO number. Reading this configuration, the GPIO used on this board should be the number 83 (0x53). Stefano -- = DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2 V2] arm926: Flush the data cache before disabling it.
Sughosh, On Friday 20 January 2012 12:58 PM, Christian Riesch wrote: On Thu, Jan 19, 2012 at 12:54 PM, Aneesh Vane...@ti.com wrote: On Thursday 19 January 2012 05:00 PM, Christian Riesch wrote: On Thu, Jan 19, 2012 at 11:17 AM, Aneesh Vane...@ti.comwrote: On Thursday 19 January 2012 12:23 PM, Sughosh Ganu wrote: Tried a few things on my end. * Read the D-cache value in the spl, and confirmed that the data cache is indeed not enabled. What is the value of the B bit in CP15 SCR register? I wonder if RBL is doing all the IMB operations required after copying the SPL image and before executing it. IMB is required for consistency between data and instruction sides. Only if caches are used, right? Or also without caches? Tom wrote that RBL does not turn on cache. Regards, Christian Only D-cache seems to be disabled in this case. I-cache and Write buffer are likely to be enabled. If so, all the IMB operations except the data-cache flushing are still relevant. Tom, when you wrote that RBL does not turn on caches, did you mean it never turns it on or it turns some of them on and turns them off before exit? Christian Can you send the value of SCR you found at SPL entry? This will clarify what's enabled and what's not. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] uboot configuration for uImage
hi, I am manish. I recently started working with beagleboard xm . I have a basic doubt.. The sd card is divided into fat32 and ext3 partition. All the neccesary files such as MLO, uboot.bin,uimage are put in the fat32 folder.I belive this is done so that the uboot will pick up uimage from this partition. But i have seen that uboot is configured to take uimage from rootfs partition from /boot/ folder. I observed this in the file /inlcude/configs/omap3_beagle.h Can someone tell me why is it so.? I made changes to this file and re built uboot to make it pick uimage from fat32 partition. Why is it configure like that??/ regards Manish Kanchan -- View this message in context: http://old.nabble.com/uboot-configuration-for-uImage-tp33168753p33168753.html Sent from the Uboot - Users mailing list archive at Nabble.com. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [RFC] CDC Ethernet support + USB Gadget in U-boot
Hi Remy, I am in the process of adding USB CDC-ECM support for the platform based on OAMP3. Can you give the pointers to start my porting 1. Linux files you modified to port gadget driver to U-boot 2. Under which U-Boot directory you copied these files 2. Linux files you modified to port CDC-ECM Driver. Regards, Subhashini Remy Bohmer-5 wrote: Hello All, We (Thomas Smits and I) have been working on CDC Ethernet support in U-boot. We ported the Linux Gadget and CDC Ethernet driver to U-boot and added support for the Atmel AT91SAM9261-EK kit. Support for other cores can be added easily. Although it is still work in progress, it is already working stable. I also have a patch for adding RNDIS support on top of this series, but that is not finished/stable yet. The series is quite huge, and still in development, so I decided to not post this series inline. I made the tree public via the U-boot-usb tree, 'cdc' branch ( http://git.denx.de/?p=u-boot/u-boot-usb.git;a=shortlog;h=refs/heads/cdc) I would like to stabilise this code in a separate branch until it is mature enough for mainline integration, I will keep this branch always ahead mainline. So, any comments on this code are welcome! But, even more welcome are patches on top of it to make it even better and add more board support for it. Kind Regards, Remy ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot -- View this message in context: http://old.nabble.com/-U-Boot---RFC--CDC-Ethernet-support-%2B-USB-Gadget-in-U-boot-tp21452905p33170232.html Sent from the Uboot - Users mailing list archive at Nabble.com. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 11/28] net: Refactor IP, UPD, and ICMP header writing functions
ICMP (ping) was reimplementing IP header code... it now shares code. Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- include/net.h |4 +++- net/bootp.c |6 +++--- net/net.c | 47 --- net/ping.c| 52 +++- 4 files changed, 57 insertions(+), 52 deletions(-) diff --git a/include/net.h b/include/net.h index add2080..19e9463 100644 --- a/include/net.h +++ b/include/net.h @@ -421,7 +421,9 @@ extern int NetEthHdrSize(void); extern int NetSetEther(uchar *, uchar *, uint); /* Set IP header */ -extern void NetSetIP(uchar *, IPaddr_t, int, int, int); +extern void NetSetIPHeader(uchar *pkt, IPaddr_t dest, IPaddr_t source); +extern void NetSetUDPHeader(uchar *pkt, IPaddr_t dest, int dport, + int sport, int len); /* Checksum */ extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */ diff --git a/net/bootp.c b/net/bootp.c index 2be8083..0c2af48 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -619,7 +619,7 @@ BootpRequest(void) * determined. * C. Hallinan, DS4.COM, Inc. */ - /* NetSetIP(pkt, 0xL, PORT_BOOTPS, PORT_BOOTPC, + /* NetSetUDPHeader(pkt, 0xL, PORT_BOOTPS, PORT_BOOTPC, sizeof (struct Bootp_t)); */ iphdr = pkt;/* We need this later for NetSetUDPHeader() */ pkt += IP_UDP_HDR_SIZE; @@ -663,7 +663,7 @@ BootpRequest(void) pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - sizeof(bp-bp_vend) + ext_len; iplen = BOOTP_HDR_SIZE - sizeof(bp-bp_vend) + ext_len; - NetSetIP(iphdr, 0xL, PORT_BOOTPS, PORT_BOOTPC, iplen); + NetSetUDPHeader(iphdr, 0xL, PORT_BOOTPS, PORT_BOOTPC, iplen); NetSetTimeout(SELECT_TIMEOUT, BootpTimeout); #if defined(CONFIG_CMD_DHCP) @@ -844,7 +844,7 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - sizeof(bp-bp_vend) + extlen; iplen = BOOTP_HDR_SIZE - sizeof(bp-bp_vend) + extlen; - NetSetIP(iphdr, 0xL, PORT_BOOTPS, PORT_BOOTPC, iplen); + NetSetUDPHeader(iphdr, 0xL, PORT_BOOTPS, PORT_BOOTPC, iplen); debug(Transmitting DHCPREQUEST packet: len = %d\n, pktlen); #ifdef CONFIG_BOOTP_DHCP_REQUEST_DELAY diff --git a/net/net.c b/net/net.c index 9bf74d5..a47b215 100644 --- a/net/net.c +++ b/net/net.c @@ -625,7 +625,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, pkt = NetArpWaitTxPacket; pkt += NetSetEther(pkt, NetArpWaitPacketMAC, PROT_IP); - NetSetIP(pkt, dest, dport, sport, payload_len); + NetSetUDPHeader(pkt, dest, dport, sport, payload_len); memcpy(pkt + IP_UDP_HDR_SIZE, (uchar *)NetTxPacket + (pkt - (uchar *)NetArpWaitTxPacket) + IP_UDP_HDR_SIZE, payload_len); @@ -645,7 +645,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, pkt = (uchar *)NetTxPacket; pkt += NetSetEther(pkt, ether, PROT_IP); - NetSetIP(pkt, dest, dport, sport, payload_len); + NetSetUDPHeader(pkt, dest, dport, sport, payload_len); eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_UDP_HDR_SIZE + payload_len); @@ -1250,40 +1250,49 @@ NetSetEther(uchar *xet, uchar * addr, uint prot) } void -NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len) +NetSetIPHeader(uchar *pkt, IPaddr_t dest, IPaddr_t source) { - struct IP_UDP_t *ip = (struct IP_UDP_t *)xip; + struct IP_UDP_t *ip = (struct IP_UDP_t *)pkt; /* -* If the data is an odd number of bytes, zero the -* byte after the last byte so that the checksum -* will work. -*/ - if (len 1) - xip[IP_UDP_HDR_SIZE + len] = 0; - - /* -* Construct an IP and UDP header. -* (need to set no fragment bit - XXX) +* Construct an IP header. */ /* IP_HDR_SIZE / 4 (not including UDP) */ ip-ip_hl_v = 0x45; ip-ip_tos = 0; - ip-ip_len = htons(IP_UDP_HDR_SIZE + len); + ip-ip_len = htons(IP_HDR_SIZE); ip-ip_id= htons(NetIPID++); ip-ip_off = htons(IP_FLAGS_DFRAG); /* Don't fragment */ ip-ip_ttl = 255; - ip-ip_p = 17; /* UDP */ ip-ip_sum = 0; /* already in network byte order */ - NetCopyIP((void *)ip-ip_src, NetOurIP); - /* - - */ + NetCopyIP((void *)ip-ip_src, source); + /* already in network byte order */ NetCopyIP((void *)ip-ip_dst, dest); +} + +void +NetSetUDPHeader(uchar *pkt, IPaddr_t dest, int dport, int sport, int len) +{ + struct
[U-Boot] [PATCH 22/28] net: Fix net buffer initialization
A new non-static function NetInit() will initialize buffers and read from the env Only update from the env on each entry to NetLoop() Check when attempting to send a packet that the buffers were initialized Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- include/net.h |7 --- net/net.c | 48 +--- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/include/net.h b/include/net.h index af6a803..1861406 100644 --- a/include/net.h +++ b/include/net.h @@ -400,7 +400,8 @@ extern IPaddr_t Mcast_addr; #endif /* Initialize the network adapter */ -extern int NetLoop(enum proto_t); +extern voidNetInit(void); +extern int NetLoop(enum proto_t protocol); /* Shutdown adapters and cleanup */ extern voidNetStop(void); @@ -439,10 +440,10 @@ extern void NetSetState(int state); #define NETLOOP_SUCCESS3 #define NETLOOP_FAIL 4 -/* Transmit NetTxPacket */ +/* Transmit a packet */ extern void NetSendPacket(uchar *, int); -/* Transmit UDP packet, performing ARP request if needed +/* Transmit NetTxPacket as UDP packet, performing ARP request if needed (ether will be populated) */ extern int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int payload_len); diff --git a/net/net.c b/net/net.c index 1c0c822..51d899b 100644 --- a/net/net.c +++ b/net/net.c @@ -236,7 +236,7 @@ void net_auto_load(void) TftpStart(TFTPGET); } -static void NetInitLoop(enum proto_t protocol) +static void NetInitLoop(void) { static int env_changed_id; bd_t *bd = gd-bd; @@ -269,6 +269,30 @@ NetCleanupLoop(void) NetSetTimeout(0, NULL); } +void +NetInit(void) +{ + static int first_call = 1; + + if (first_call) { + /* +* Setup packet buffers, aligned correctly. +*/ + int i; + NetTxPacket = PktBuf[0] + (PKTALIGN - 1); + NetTxPacket -= (ulong)NetTxPacket % PKTALIGN; + for (i = 0; i PKTBUFSRX; i++) + NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN; + + ArpInit(); + + /* Only need to setup buffer pointers once. */ + first_call = 0; + } + + NetInitLoop(); +} + /**/ /* * Main network processing loop. @@ -276,26 +300,14 @@ NetCleanupLoop(void) int NetLoop(enum proto_t protocol) { - int i; bd_t *bd = gd-bd; int ret = -1; NetRestarted = 0; NetDevExists = 0; - - NetTxPacket = NULL; NetTryCount = 1; - ArpInit(); - - /* -* Setup packet buffers, aligned correctly. -*/ - NetTxPacket = PktBuf[0] + (PKTALIGN - 1); - NetTxPacket -= (ulong)NetTxPacket % PKTALIGN; - for (i = 0; i PKTBUFSRX; i++) - NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN; - + NetInit(); eth_halt(); eth_set_current(); if (eth_init(bd) 0) { @@ -313,7 +325,7 @@ restart: * here on, this code is a state machine driven by received * packets and timer events. */ - NetInitLoop(protocol); + NetInitLoop(); switch (net_check_prereq(protocol)) { case 1: @@ -627,6 +639,12 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, { uchar *pkt; + /* make sure the NetTxPacket is initialized (NetInit() was called) */ + if (NetTxPacket == NULL) { + puts(*** ERROR: NetTxPacket buffer pointer is NULL!\n); + return -1; + } + /* convert to new style broadcast */ if (dest == 0) dest = 0x; -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 04/28] net: Make the MAC-seeded random number generator available to /net
MAC-seeded rand() will be needed by link-local as well, so give it an interface Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- net/Makefile |1 + net/bootp.c| 69 +++ net/bootp.h|3 -- net/net_rand.c | 68 +++ net/net_rand.h | 18 ++ 5 files changed, 101 insertions(+), 58 deletions(-) create mode 100644 net/net_rand.c create mode 100644 net/net_rand.h diff --git a/net/Makefile b/net/Makefile index 0544f6b..5901046 100644 --- a/net/Makefile +++ b/net/Makefile @@ -31,6 +31,7 @@ COBJS-$(CONFIG_CMD_NET) += bootp.o COBJS-$(CONFIG_CMD_DNS) += dns.o COBJS-$(CONFIG_CMD_NET) += eth.o COBJS-$(CONFIG_CMD_NET) += net.o +COBJS-$(CONFIG_BOOTP_RANDOM_DELAY) += net_rand.o COBJS-$(CONFIG_CMD_NFS) += nfs.o COBJS-$(CONFIG_CMD_RARP) += rarp.o COBJS-$(CONFIG_CMD_SNTP) += sntp.o diff --git a/net/bootp.c b/net/bootp.c index 07870d0..9824cd1 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -12,6 +12,9 @@ #include command.h #include net.h #include bootp.h +#ifdef CONFIG_BOOTP_RANDOM_DELAY +#include net_rand.h +#endif #include tftp.h #include nfs.h #ifdef CONFIG_STATUS_LED @@ -37,9 +40,6 @@ ulong BootpID; intBootpTry; -#ifdef CONFIG_BOOTP_RANDOM_DELAY -ulong seed1, seed2; -#endif #if defined(CONFIG_CMD_DHCP) dhcp_state_t dhcp_state = INIT; @@ -583,66 +583,25 @@ BootpRequest(void) uchar *pkt, *iphdr; struct Bootp_t *bp; int ext_len, pktlen, iplen; +#ifdef CONFIG_BOOTP_RANDOM_DELAY + ulong i, rand_ms; +#endif #if defined(CONFIG_CMD_DHCP) dhcp_state = INIT; #endif #ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */ - unsigned char bi_enetaddr[6]; - int reg; - ulong tst1, tst2, sum, m_mask, m_value = 0; - - if (BootpTry == 0) { - /* get our mac */ - eth_getenv_enetaddr(ethaddr, bi_enetaddr); - - debug(BootpRequest = Our Mac: ); - for (reg = 0; reg 6; reg++) - debug(%x%c, bi_enetaddr[reg], reg == 5 ? '\n' : ':'); - - /* Mac-Manipulation 2 get seed1 */ - tst1 = 0; - tst2 = 0; - for (reg = 2; reg 6; reg++) { - tst1 = tst1 8; - tst1 = tst1 | bi_enetaddr[reg]; - } - for (reg = 0; reg 2; reg++) { - tst2 = tst2 | bi_enetaddr[reg]; - tst2 = tst2 8; - } - - seed1 = tst1^tst2; + if (BootpTry == 0) + srand_mac(); - /* Mirror seed1*/ - m_mask = 0x1; - for (reg = 1; reg = 32; reg++) { - m_value |= (m_mask seed1); - seed1 = seed1 1; - m_value = m_value 1; - } - seed1 = m_value; - seed2 = 0xB78D0945; - } - - /* Random Number Generator */ - for (reg = 0; reg = 0; reg++) { - sum = seed1 + seed2; - if (sum seed1 || sum seed2) - sum++; - seed2 = seed1; - seed1 = sum; - - if (BootpTry = 2) {/* Start with max 1024 * 1ms */ - sum = sum (22-BootpTry); - } else {/*After 3rd BOOTP request max 8192 * 1ms */ - sum = sum 19; - } - } + if (BootpTry = 2) /* Start with max 1024 * 1ms */ + rand_ms = rand() (22-BootpTry); + else/* After 3rd BOOTP request max 8192 * 1ms */ + rand_ms = rand() 19; - printf(Random delay: %ld ms...\n, sum); - for (reg = 0; reg sum; reg++) + printf(Random delay: %ld ms...\n, rand_ms); + for (i = 0; i rand_ms; i++) udelay(1000); /*Wait 1ms*/ #endif /* CONFIG_BOOTP_RANDOM_DELAY */ diff --git a/net/bootp.h b/net/bootp.h index ce73734..bf4e875 100644 --- a/net/bootp.h +++ b/net/bootp.h @@ -63,9 +63,6 @@ struct Bootp_t { extern ulong BootpID;/* ID of cur BOOTP request */ extern charBootFile[128]; /* Boot file name */ extern int BootpTry; -#ifdef CONFIG_BOOTP_RANDOM_DELAY -extern ulong seed1, seed2; /* seed for random BOOTP delay */ -#endif /* Send a BOOTP request */ diff --git a/net/net_rand.c b/net/net_rand.c new file mode 100644 index 000..744e2f9 --- /dev/null +++ b/net/net_rand.c @@ -0,0 +1,68 @@ +/* + * Based on LiMon - BOOTP. + * + * Copyright 1994, 1995, 2000 Neil Russell. + * (See License) + * Copyright 2000 Roland Borde + * Copyright 2000 Paolo Scaffardi + * Copyright 2000-2004 Wolfgang Denk, w...@denx.de + */ +
[U-Boot] [PATCH 25/28] net: Add option CONFIG_BOOTP_CAN_FAIL
This is useful if you want to look for a DHCP server, but try some other settings if not available Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- README |7 +++ net/bootp.c |5 + 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/README b/README index 9d713e8..352db7d 100644 --- a/README +++ b/README @@ -1573,10 +1573,17 @@ The following options need to be configured: CONFIG_BOOTP_NTPSERVER CONFIG_BOOTP_TIMEOFFSET CONFIG_BOOTP_VENDOREX + CONFIG_BOOTP_CAN_FAIL CONFIG_BOOTP_SERVERIP - TFTP server will be the serverip environment variable, not the BOOTP server. + CONFIG_BOOTP_CAN_FAIL - If the DHCP server is not found + after the configured retry count, the call will fail + instead of starting over. This can be used to fail over + to Link-local IP address configuration if the DHCP server + is not available. + CONFIG_BOOTP_DNS2 - If a DHCP client requests the DNS serverip from a DHCP server, it is possible that more than one DNS serverip is offered to the client. diff --git a/net/bootp.c b/net/bootp.c index 187b3a8..07f9d0e 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -327,8 +327,13 @@ static void BootpTimeout(void) { if (BootpTry = TIMEOUT_COUNT) { +#ifdef CONFIG_BOOTP_CAN_FAIL + puts(\nRetry count exceeded\n); + NetSetState(NETLOOP_FAIL); +#else puts(\nRetry count exceeded; starting again\n); NetStartAgain(); +#endif } else { NetSetTimeout(TIMEOUT, BootpTimeout); BootpRequest(); -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 03/28] net: Move mv64x6x_eth_initialize() to board_eth_init()
Clears up checkpatch.pl complaint about extern in c file Completes the effort started by Ben Warren in 2008 to generalize eth init Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- board/Marvell/db64360/db64360.c | 12 ++- board/Marvell/db64360/mv_eth.c | 76 +++ board/Marvell/db64360/mv_eth.h | 63 +--- board/Marvell/db64460/db64460.c | 12 ++- board/Marvell/db64460/mv_eth.c | 76 +++ board/Marvell/db64460/mv_eth.h | 63 +--- board/esd/cpci750/cpci750.c |6 +++ board/esd/cpci750/mv_eth.c | 76 +++ board/esd/cpci750/mv_eth.h | 63 +--- board/prodrive/p3mx/mv_eth.c| 76 +++ board/prodrive/p3mx/mv_eth.h| 63 +--- board/prodrive/p3mx/p3mx.c |6 +++ net/eth.c |9 - 13 files changed, 314 insertions(+), 287 deletions(-) diff --git a/board/Marvell/db64360/db64360.c b/board/Marvell/db64360/db64360.c index 5183466..c66dc14 100644 --- a/board/Marvell/db64360/db64360.c +++ b/board/Marvell/db64360/db64360.c @@ -40,6 +40,7 @@ #include mpsc.h #include i2c.h #include 64360.h +#include mv_eth.h #include mv_regs.h #undef DEBUG @@ -934,5 +935,14 @@ void board_prebootm_init () int board_eth_init(bd_t *bis) { - return pci_eth_init(bis); + int pci_retval; + int mv_retval; + + pci_retval = pci_eth_init(bis); + mv_retval = mv6436x_eth_initialize(bis); + + if (pci_retval 0 mv_retval 0) + return -1; + else + return 0; } diff --git a/board/Marvell/db64360/mv_eth.c b/board/Marvell/db64360/mv_eth.c index 550610e..c6b618f 100644 --- a/board/Marvell/db64360/mv_eth.c +++ b/board/Marvell/db64360/mv_eth.c @@ -78,6 +78,67 @@ #define MV_SET_REG_BITS(regOffset,bits) ((*((volatile unsigned int*)((INTERNAL_REG_BASE_ADDR) + (regOffset |= ((unsigned int)my_cpu_to_le32(bits))) #define MV_RESET_REG_BITS(regOffset,bits) ((*((volatile unsigned int*)((INTERNAL_REG_BASE_ADDR) + (regOffset = ~((unsigned int)my_cpu_to_le32(bits))) +/* ethernet.h API list */ + +/* Port operation control routines */ +static void eth_port_init(ETH_PORT_INFO *p_eth_port_ctrl); +static void eth_port_reset(ETH_PORTeth_port_num); +static bool eth_port_start(ETH_PORT_INFO *p_eth_port_ctrl); + + +/* Port MAC address routines */ +static void eth_port_uc_addr_set(ETH_PORT eth_port_num, + unsigned char *p_addr, + ETH_QUEUE queue); +#if 0 /* FIXME */ +static void eth_port_mc_addr(ETH_PORT eth_port_num, +unsigned char *p_addr, +ETH_QUEUE queue, +int option); +#endif + +/* PHY and MIB routines */ +static bool ethernet_phy_reset(ETH_PORT eth_port_num); + +static bool eth_port_write_smi_reg(ETH_PORT eth_port_num, + unsigned int phy_reg, + unsigned int value); + +static bool eth_port_read_smi_reg(ETH_PORT eth_port_num, + unsigned int phy_reg, + unsigned int *value); + +static void eth_clear_mib_counters(ETH_PORTeth_port_num); + +/* Port data flow control routines */ +static ETH_FUNC_RET_STATUS eth_port_send(ETH_PORT_INFO *p_eth_port_ctrl, +ETH_QUEUE tx_queue, +PKT_INFO *p_pkt_info); +static ETH_FUNC_RET_STATUS eth_tx_return_desc(ETH_PORT_INFO *p_eth_port_ctrl, + ETH_QUEUE tx_queue, + PKT_INFO *p_pkt_info); +static ETH_FUNC_RET_STATUS eth_port_receive(ETH_PORT_INFO *p_eth_port_ctrl, +ETH_QUEUE rx_queue, +PKT_INFO *p_pkt_info); +static ETH_FUNC_RET_STATUS eth_rx_return_buff(ETH_PORT_INFO *p_eth_port_ctrl, + ETH_QUEUE rx_queue, + PKT_INFO *p_pkt_info); + + +static bool ether_init_tx_desc_ring(ETH_PORT_INFO *p_eth_port_ctrl, + ETH_QUEUE tx_queue, + int tx_desc_num, + int tx_buff_size, + unsigned inttx_desc_base_addr, + unsigned inttx_buff_base_addr); + +static bool ether_init_rx_desc_ring(ETH_PORT_INFO *p_eth_port_ctrl, + ETH_QUEUE rx_queue, +
[U-Boot] [PATCH 23/28] net: Refactor NetSendUDPPacket to share more code
Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- net/net.c | 44 +--- 1 files changed, 25 insertions(+), 19 deletions(-) diff --git a/net/net.c b/net/net.c index 51d899b..59ac167 100644 --- a/net/net.c +++ b/net/net.c @@ -638,6 +638,9 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int payload_len) { uchar *pkt; + int need_arp = 0; + int eth_hdr_size; + int pkt_hdr_size; /* make sure the NetTxPacket is initialized (NetInit() was called) */ if (NetTxPacket == NULL) { @@ -658,40 +661,43 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, * an ARP request */ if (memcmp(ether, NetEtherNullAddr, 6) == 0) { + need_arp = 1; + pkt = NetArpWaitTxPacket; + } else + pkt = (uchar *)NetTxPacket; + + eth_hdr_size = NetSetEther(pkt, ether, PROT_IP); + pkt += eth_hdr_size; + NetSetUDPHeader(pkt, dest, dport, sport, payload_len); + pkt_hdr_size = eth_hdr_size + IP_UDP_HDR_SIZE; - debug(sending ARP for %08x\n, dest); + if (need_arp) { + debug(sending ARP for %pI4\n, dest); + /* save the ip and eth addr for the packet to send after arp */ NetArpWaitPacketIP = dest; NetArpWaitPacketMAC = ether; - pkt = NetArpWaitTxPacket; - pkt += NetSetEther(pkt, NetArpWaitPacketMAC, PROT_IP); - - NetSetUDPHeader(pkt, dest, dport, sport, payload_len); + /* +* Copy the packet data from the NetTxPacket into the +* NetArpWaitTxPacket to send after arp +*/ memcpy(pkt + IP_UDP_HDR_SIZE, (uchar *)NetTxPacket + - (pkt - (uchar *)NetArpWaitTxPacket) + - IP_UDP_HDR_SIZE, payload_len); + pkt_hdr_size, payload_len); /* size of the waiting packet */ - NetArpWaitTxPacketSize = (pkt - NetArpWaitTxPacket) + - IP_UDP_HDR_SIZE + payload_len; + NetArpWaitTxPacketSize = pkt_hdr_size + payload_len; /* and do the ARP request */ NetArpWaitTry = 1; NetArpWaitTimerStart = get_timer(0); ArpRequest(); return 1; /* waiting */ + } else { + debug(sending UDP to %pI4/%pM\n, dest, ether); + NetSendPacket(NetTxPacket, pkt_hdr_size + payload_len); + return 0; /* transmitted */ } - - debug(sending UDP to %08x/%pM\n, dest, ether); - - pkt = (uchar *)NetTxPacket; - pkt += NetSetEther(pkt, ether, PROT_IP); - NetSetUDPHeader(pkt, dest, dport, sport, payload_len); - NetSendPacket(NetTxPacket, (pkt - NetTxPacket) + IP_UDP_HDR_SIZE + - payload_len); - - return 0; /* transmitted */ } #ifdef CONFIG_IP_DEFRAG -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 20/28] net: Fix compile warning if CONFIG_BOOTP_SERVERIP is not defined
There is no reason to use compiler magic to fix this Actually move the definition inside the #ifdef Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- net/bootp.c |7 +++ 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/net/bootp.c b/net/bootp.c index 9d709f1..187b3a8 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -20,7 +20,6 @@ #ifdef CONFIG_STATUS_LED #include status_led.h #endif -#include linux/compiler.h #define BOOTP_VENDOR_MAGIC 0x63825363 /* RFC1048 Magic Cookie */ @@ -98,15 +97,15 @@ static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len) */ static void BootpCopyNetParams(struct Bootp_t *bp) { - __maybe_unused IPaddr_t tmp_ip; - - NetCopyIP(NetOurIP, bp-bp_yiaddr); #if !defined(CONFIG_BOOTP_SERVERIP) + IPaddr_t tmp_ip; + NetCopyIP(tmp_ip, bp-bp_siaddr); if (tmp_ip != 0) NetCopyIP(NetServerIP, bp-bp_siaddr); memcpy(NetServerEther, ((struct Ethernet_t *)NetRxPacket)-et_src, 6); #endif + NetCopyIP(NetOurIP, bp-bp_yiaddr); if (strlen(bp-bp_file) 0) copy_filename(BootFile, bp-bp_file, sizeof(BootFile)); -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 15/28] net: Refactor to call NetSendPacket() instead of calling eth_send()
Use this entry-point consistently across the net/ code Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- net/arp.c |6 +++--- net/cdp.c |2 +- net/net.c |2 +- net/ping.c |3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/net/arp.c b/net/arp.c index 60a1ded..d9113dc 100644 --- a/net/arp.c +++ b/net/arp.c @@ -88,7 +88,7 @@ void ArpRequest(void) } NetWriteIP(arp-ar_tpa, NetArpWaitReplyIP); - (void) eth_send(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE); + NetSendPacket(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE); } void ArpTimeoutCheck(void) @@ -165,7 +165,7 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) NetCopyIP(arp-ar_tpa, arp-ar_spa); memcpy(arp-ar_sha, NetOurEther, ARP_HLEN); NetCopyIP(arp-ar_spa, NetOurIP); - (void) eth_send((uchar *)et, eth_hdr_size + ARP_HDR_SIZE); + NetSendPacket((uchar *)et, eth_hdr_size + ARP_HDR_SIZE); return; case ARPOP_REPLY: /* arp reply */ @@ -198,7 +198,7 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) /* modify header, and transmit it */ memcpy(((struct Ethernet_t *)NetArpWaitTxPacket)- et_dest, NetArpWaitPacketMAC, ARP_HLEN); - (void) eth_send(NetArpWaitTxPacket, + NetSendPacket(NetArpWaitTxPacket, NetArpWaitTxPacketSize); /* no arp request pending now */ diff --git a/net/cdp.c b/net/cdp.c index 38b79bd..305ecad 100644 --- a/net/cdp.c +++ b/net/cdp.c @@ -215,7 +215,7 @@ CDPSendTrigger(void) chksum = 0x; *cp = htons(chksum); - (void) eth_send(NetTxPacket, (uchar *)s - NetTxPacket); + NetSendPacket(NetTxPacket, (uchar *)s - NetTxPacket); return 0; } diff --git a/net/net.c b/net/net.c index a47b215..16cbadc 100644 --- a/net/net.c +++ b/net/net.c @@ -646,7 +646,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, pkt = (uchar *)NetTxPacket; pkt += NetSetEther(pkt, ether, PROT_IP); NetSetUDPHeader(pkt, dest, dport, sport, payload_len); - eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_UDP_HDR_SIZE + + NetSendPacket(NetTxPacket, (pkt - NetTxPacket) + IP_UDP_HDR_SIZE + payload_len); return 0; /* transmitted */ diff --git a/net/ping.c b/net/ping.c index e4a7a21..7d03072 100644 --- a/net/ping.c +++ b/net/ping.c @@ -114,8 +114,7 @@ void PingReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) icmph-checksum = 0; icmph-checksum = ~NetCksum((uchar *)icmph, (len - IP_HDR_SIZE) 1); - (void) eth_send((uchar *)et, - ETHER_HDR_SIZE + len); + NetSendPacket((uchar *)et, ETHER_HDR_SIZE + len); return; /* default: return;*/ -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 18/28] net: Add NetUpdateEther() to handle ARP or Ping replies (VLAN or SNAP)
NetUpdateEther() will preserve the original Ethernet packet header and simply replace the src and dest MACs and the protocol Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- include/net.h |1 + net/arp.c |2 +- net/net.c | 22 ++ net/ping.c| 10 +- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/include/net.h b/include/net.h index dca8e1c..af6a803 100644 --- a/include/net.h +++ b/include/net.h @@ -413,6 +413,7 @@ extern int NetEthHdrSize(void); /* Set ethernet header; returns the size of the header */ extern int NetSetEther(uchar *, uchar *, uint); +extern int NetUpdateEther(struct Ethernet_t *et, uchar *addr, uint prot); /* Set IP header */ extern void NetSetIPHeader(uchar *pkt, IPaddr_t dest, IPaddr_t source); diff --git a/net/arp.c b/net/arp.c index 5b6c787..8c3557b 100644 --- a/net/arp.c +++ b/net/arp.c @@ -158,7 +158,7 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) /* reply with our IP address */ debug(Got ARP REQUEST, return our IP\n); pkt = (uchar *)et; - eth_hdr_size = NetSetEther(pkt, et-et_src, PROT_ARP); + eth_hdr_size = NetUpdateEther(et, et-et_src, PROT_ARP); pkt += eth_hdr_size; arp-ar_op = htons(ARPOP_REPLY); memcpy(arp-ar_tha, arp-ar_sha, ARP_HLEN); diff --git a/net/net.c b/net/net.c index 2dc49f5..1c0c822 100644 --- a/net/net.c +++ b/net/net.c @@ -1274,6 +1274,28 @@ NetSetEther(uchar *xet, uchar * addr, uint prot) } } +int +NetUpdateEther(struct Ethernet_t *et, uchar *addr, uint prot) +{ + ushort protlen; + + memcpy(et-et_dest, addr, 6); + memcpy(et-et_src, NetOurEther, 6); + protlen = ntohs(et-et_protlen); + if (protlen == PROT_VLAN) { + struct VLAN_Ethernet_t *vet = (struct VLAN_Ethernet_t *)et; + vet-vet_type = htons(prot); + return VLAN_ETHER_HDR_SIZE; + } else if (protlen 1514) { + et-et_protlen = htons(prot); + return ETHER_HDR_SIZE; + } else { + /* 802.2 + SNAP */ + et-et_prot = htons(prot); + return E802_HDR_SIZE; + } +} + void NetSetIPHeader(uchar *pkt, IPaddr_t dest, IPaddr_t source) { diff --git a/net/ping.c b/net/ping.c index 795d5c9..913506b 100644 --- a/net/ping.c +++ b/net/ping.c @@ -89,6 +89,7 @@ void PingReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) { struct ICMP_t *icmph = (struct ICMP_t *)(ip-udp_src); IPaddr_t src_ip; + int eth_hdr_size; switch (icmph-type) { case ICMP_ECHO_REPLY: @@ -97,11 +98,10 @@ void PingReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) NetSetState(NETLOOP_SUCCESS); return; case ICMP_ECHO_REQUEST: - debug(Got ICMP ECHO REQUEST, return - %d bytes\n, ETHER_HDR_SIZE + len); + eth_hdr_size = NetUpdateEther(et, et-et_src, PROT_IP); - memcpy(et-et_dest[0], et-et_src[0], 6); - memcpy(et-et_src[0], NetOurEther, 6); + debug(Got ICMP ECHO REQUEST, return + %d bytes\n, eth_hdr_size + len); ip-ip_sum = 0; ip-ip_off = 0; @@ -114,7 +114,7 @@ void PingReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) icmph-checksum = 0; icmph-checksum = ~NetCksum((uchar *)icmph, (len - IP_HDR_SIZE) 1); - NetSendPacket((uchar *)et, ETHER_HDR_SIZE + len); + NetSendPacket((uchar *)et, eth_hdr_size + len); return; /* default: return;*/ -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 26/28] net: Add link-local addressing support
Code based on networking/zcip.c in busybox - commit 8531d76a15890c2c535908ce888b2e2aed35b172 Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- README | 15 +++- common/cmd_net.c | 30 + include/net.h|2 +- net/Makefile |4 +- net/arp.c|3 + net/link_local.c | 333 ++ net/link_local.h | 21 net/net.c| 15 +++ 8 files changed, 420 insertions(+), 3 deletions(-) create mode 100644 net/link_local.c create mode 100644 net/link_local.h diff --git a/README b/README index 352db7d..776614e 100644 --- a/README +++ b/README @@ -782,6 +782,7 @@ The following options need to be configured: CONFIG_CMD_JFFS2* JFFS2 Support CONFIG_CMD_KGDB * kgdb CONFIG_CMD_LDRINFOldrinfo (display Blackfin loader) + CONFIG_CMD_LINK_LOCAL * link-local IP address auto-configuration (169.254.*.*) CONFIG_CMD_LOADB loadb CONFIG_CMD_LOADS loads CONFIG_CMD_MD5SUM print md5 message digest @@ -797,7 +798,7 @@ The following options need to be configured: CONFIG_CMD_PCA953X * PCA953x I2C gpio commands CONFIG_CMD_PCA953X_INFO * PCA953x I2C gpio info command CONFIG_CMD_PCI * pciinfo - CONFIG_CMD_PCMCIA * PCMCIA support + CONFIG_CMD_PCMCIA * PCMCIA support CONFIG_CMD_PING * send ICMP ECHO_REQUEST to network host CONFIG_CMD_PORTIO * Port I/O @@ -1614,6 +1615,18 @@ The following options need to be configured: the DHCP timeout and retry process takes a longer than this delay. + - Link-local IP address negotiation: + Negotiate with other link-local clients on the local network + for an address that doesn't require explicit configuration. + This is especially useful if a DHCP server cannot be guaranteed + to exist in all environments that the device must operate. + + The llipaddr variable is set with the most recently + negotiated address and is preferred in future negotiations. + + The ipaddr, netmask, and gatewayip variables are set + after successful negotiation to enable network access. + - CDP Options: CONFIG_CDP_DEVICE_ID diff --git a/common/cmd_net.c b/common/cmd_net.c index 49ef680..ffca8c9 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -418,3 +418,33 @@ U_BOOT_CMD( ); #endif /* CONFIG_CMD_DNS */ + +#if defined(CONFIG_CMD_LINK_LOCAL) +int do_link_local(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + char tmp[22]; + + if (NetLoop(LINKLOCAL) 0) + return 1; + + NetOurGatewayIP = 0; + ip_to_string(NetOurGatewayIP, tmp); + setenv(gatewayip, tmp); + + ip_to_string(NetOurSubnetMask, tmp); + setenv(netmask, tmp); + + ip_to_string(NetOurIP, tmp); + setenv(ipaddr, tmp); + setenv(llipaddr, tmp); /* store this for next time */ + + return 0; +} + +U_BOOT_CMD( + linklocal, 1, 1, do_link_local, + acquire a network IP address using the link-local protocol, + +); + +#endif /* CONFIG_CMD_LINK_LOCAL */ diff --git a/include/net.h b/include/net.h index 1861406..fbb1412 100644 --- a/include/net.h +++ b/include/net.h @@ -368,7 +368,7 @@ extern int NetRestartWrap; /* Tried all network devices */ enum proto_t { BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP, - TFTPSRV, TFTPPUT + TFTPSRV, TFTPPUT, LINKLOCAL }; /* from net/net.c */ diff --git a/net/Makefile b/net/Makefile index f1c4859..5264687 100644 --- a/net/Makefile +++ b/net/Makefile @@ -32,15 +32,17 @@ COBJS-$(CONFIG_CMD_NET) += bootp.o COBJS-$(CONFIG_CMD_CDP) += cdp.o COBJS-$(CONFIG_CMD_DNS) += dns.o COBJS-$(CONFIG_CMD_NET) += eth.o +COBJS-$(CONFIG_CMD_LINK_LOCAL) += link_local.o COBJS-$(CONFIG_CMD_NET) += net.o COBJS-$(CONFIG_BOOTP_RANDOM_DELAY) += net_rand.o +COBJS-$(CONFIG_CMD_LINK_LOCAL) += net_rand.o COBJS-$(CONFIG_CMD_NFS) += nfs.o COBJS-$(CONFIG_CMD_PING) += ping.o COBJS-$(CONFIG_CMD_RARP) += rarp.o COBJS-$(CONFIG_CMD_SNTP) += sntp.o COBJS-$(CONFIG_CMD_NET) += tftp.o -COBJS := $(COBJS-y) +COBJS := $(sort $(COBJS-y)) SRCS := $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS)) diff --git a/net/arp.c b/net/arp.c index 938db59..9eb4ab0 100644 --- a/net/arp.c +++ b/net/arp.c @@ -11,6 +11,9 @@ #include common.h #include arp.h +#if defined(CONFIG_CMD_LINK_LOCAL) +#include link_local.h +#endif #ifndefCONFIG_ARP_TIMEOUT /* Milliseconds before
[U-Boot] [PATCH 12/28] net: Refactor packet length computations
Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- net/arp.c | 13 - net/ping.c |7 --- net/rarp.c |6 -- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/net/arp.c b/net/arp.c index 456decd..60a1ded 100644 --- a/net/arp.c +++ b/net/arp.c @@ -52,12 +52,14 @@ void ArpRequest(void) { uchar *pkt; struct ARP_t *arp; + int eth_hdr_size; debug(ARP broadcast %d\n, NetArpWaitTry); pkt = NetTxPacket; - pkt += NetSetEther(pkt, NetBcastAddr, PROT_ARP); + eth_hdr_size = NetSetEther(pkt, NetBcastAddr, PROT_ARP); + pkt += eth_hdr_size; arp = (struct ARP_t *) pkt; @@ -86,7 +88,7 @@ void ArpRequest(void) } NetWriteIP(arp-ar_tpa, NetArpWaitReplyIP); - (void) eth_send(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE); + (void) eth_send(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE); } void ArpTimeoutCheck(void) @@ -118,6 +120,7 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) struct ARP_t *arp; IPaddr_t reply_ip_addr; uchar *pkt; + int eth_hdr_size; /* * We have to deal with two types of ARP packets: @@ -155,14 +158,14 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) /* reply with our IP address */ debug(Got ARP REQUEST, return our IP\n); pkt = (uchar *)et; - pkt += NetSetEther(pkt, et-et_src, PROT_ARP); + eth_hdr_size = NetSetEther(pkt, et-et_src, PROT_ARP); + pkt += eth_hdr_size; arp-ar_op = htons(ARPOP_REPLY); memcpy(arp-ar_tha, arp-ar_sha, ARP_HLEN); NetCopyIP(arp-ar_tpa, arp-ar_spa); memcpy(arp-ar_sha, NetOurEther, ARP_HLEN); NetCopyIP(arp-ar_spa, NetOurIP); - (void) eth_send((uchar *)et, - (pkt - (uchar *)et) + ARP_HDR_SIZE); + (void) eth_send((uchar *)et, eth_hdr_size + ARP_HDR_SIZE); return; case ARPOP_REPLY: /* arp reply */ diff --git a/net/ping.c b/net/ping.c index 356f107..12f9185 100644 --- a/net/ping.c +++ b/net/ping.c @@ -42,6 +42,7 @@ static int PingSend(void) { static uchar mac[6]; uchar *pkt; + int eth_hdr_size; /* XXX always send arp request */ @@ -53,13 +54,13 @@ static int PingSend(void) NetArpWaitPacketMAC = mac; pkt = NetArpWaitTxPacket; - pkt += NetSetEther(pkt, mac, PROT_IP); + eth_hdr_size = NetSetEther(pkt, mac, PROT_IP); + pkt += eth_hdr_size; SetICMPHeader(pkt, NetPingIP); /* size of the waiting packet */ - NetArpWaitTxPacketSize = - (pkt - NetArpWaitTxPacket) + IP_HDR_SIZE + 8; + NetArpWaitTxPacketSize = eth_hdr_size + IP_ICMP_HDR_SIZE; /* and do the ARP request */ NetArpWaitTry = 1; diff --git a/net/rarp.c b/net/rarp.c index 305b0a4..3097341 100644 --- a/net/rarp.c +++ b/net/rarp.c @@ -91,11 +91,13 @@ RarpRequest(void) { uchar *pkt; struct ARP_t *rarp; + int eth_hdr_size; printf(RARP broadcast %d\n, ++RarpTry); pkt = NetTxPacket; - pkt += NetSetEther(pkt, NetBcastAddr, PROT_RARP); + eth_hdr_size = NetSetEther(pkt, NetBcastAddr, PROT_RARP); + pkt += eth_hdr_size; rarp = (struct ARP_t *)pkt; @@ -111,7 +113,7 @@ RarpRequest(void) /* dest IP addr set to broadcast */ memset(rarp-ar_data[16], 0xff,4); - NetSendPacket(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE); + NetSendPacket(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE); NetSetTimeout(TIMEOUT, RarpTimeout); } -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 19/28] net: Don't write the serverip env var if told not to in the config
Before this patch, bootp would not overwrite the value, but the value was still clobbered in the env Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- common/cmd_net.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/cmd_net.c b/common/cmd_net.c index 89519fa..49ef680 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -148,12 +148,12 @@ static void netboot_update_env (void) ip_to_string (NetOurIP, tmp); setenv (ipaddr, tmp); } - +#if !defined(CONFIG_BOOTP_SERVERIP) if (NetServerIP) { ip_to_string (NetServerIP, tmp); setenv (serverip, tmp); } - +#endif if (NetOurDNSIP) { ip_to_string (NetOurDNSIP, tmp); setenv (dnsip, tmp); -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 21/28] net: Remove unneeded static allocation for MAC address in PingSend()
Don't force ARP clients to return the MAC address if they don't care about it (such as ping) Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- net/arp.c |9 + net/ping.c | 10 +++--- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/net/arp.c b/net/arp.c index 8c3557b..b3be0a6 100644 --- a/net/arp.c +++ b/net/arp.c @@ -170,7 +170,7 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) case ARPOP_REPLY: /* arp reply */ /* are we waiting for a reply */ - if (!NetArpWaitPacketIP || !NetArpWaitPacketMAC) + if (!NetArpWaitPacketIP) break; #ifdef CONFIG_KEEP_SERVERADDR @@ -189,8 +189,9 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) arp-ar_data); /* save address for later use */ - memcpy(NetArpWaitPacketMAC, - arp-ar_sha, ARP_HLEN); + if (NetArpWaitPacketMAC != NULL) + memcpy(NetArpWaitPacketMAC, + arp-ar_sha, ARP_HLEN); if (NetGetARPHandler() != NULL) NetGetARPHandler()((uchar *)arp, 0, @@ -198,7 +199,7 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) /* modify header, and transmit it */ memcpy(((struct Ethernet_t *)NetArpWaitTxPacket)- - et_dest, NetArpWaitPacketMAC, ARP_HLEN); + et_dest, arp-ar_sha, ARP_HLEN); NetSendPacket(NetArpWaitTxPacket, NetArpWaitTxPacketSize); diff --git a/net/ping.c b/net/ping.c index 913506b..687c5aa 100644 --- a/net/ping.c +++ b/net/ping.c @@ -40,22 +40,18 @@ static void SetICMPHeader(uchar *pkt, IPaddr_t dest) static int PingSend(void) { - static uchar mac[6]; uchar *pkt; int eth_hdr_size; /* XXX always send arp request */ - memcpy(mac, NetEtherNullAddr, 6); - debug(sending ARP for %pI4\n, NetPingIP); NetArpWaitPacketIP = NetPingIP; - NetArpWaitPacketMAC = mac; - pkt = NetArpWaitTxPacket; - eth_hdr_size = NetSetEther(pkt, mac, PROT_IP); - pkt += eth_hdr_size; + eth_hdr_size = NetSetEther(NetArpWaitTxPacket, NetEtherNullAddr, + PROT_IP); + pkt = NetArpWaitTxPacket + eth_hdr_size; SetICMPHeader(pkt, NetPingIP); -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 06/28] net: Move ARP out of net.c
Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- include/net.h |3 +- net/Makefile |1 + net/arp.c | 213 + net/arp.h | 30 net/net.c | 209 5 files changed, 259 insertions(+), 197 deletions(-) create mode 100644 net/arp.c create mode 100644 net/arp.h diff --git a/include/net.h b/include/net.h index 0396b69..2d00233 100644 --- a/include/net.h +++ b/include/net.h @@ -418,7 +418,8 @@ extern void NetSetIP(uchar *, IPaddr_t, int, int, int); extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */ extern uintNetCksum(uchar *, int); /* Calculate the checksum */ -/* Set callbacks */ +/* Callbacks */ +extern rxhand_f *NetGetHandler(void); /* Get RX packet handler */ extern voidNetSetHandler(rxhand_f *); /* Set RX packet handler */ extern void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */ extern voidNetSetTimeout(ulong, thand_f *);/* Set timeout handler */ diff --git a/net/Makefile b/net/Makefile index b350bfc..0916a56 100644 --- a/net/Makefile +++ b/net/Makefile @@ -27,6 +27,7 @@ include $(TOPDIR)/config.mk LIB= $(obj)libnet.o +COBJS-$(CONFIG_CMD_NET) += arp.o COBJS-$(CONFIG_CMD_NET) += bootp.o COBJS-$(CONFIG_CMD_CDP) += cdp.o COBJS-$(CONFIG_CMD_DNS) += dns.o diff --git a/net/arp.c b/net/arp.c new file mode 100644 index 000..f75217c --- /dev/null +++ b/net/arp.c @@ -0,0 +1,213 @@ +/* + * Copied from Linux Monitor (LiMon) - Networking. + * + * Copyright 1994 - 2000 Neil Russell. + * (See License) + * Copyright 2000 Roland Borde + * Copyright 2000 Paolo Scaffardi + * Copyright 2000-2002 Wolfgang Denk, w...@denx.de + */ + +#include common.h + +#include arp.h + +#ifndefCONFIG_ARP_TIMEOUT +/* Milliseconds before trying ARP again */ +# define ARP_TIMEOUT 5000UL +#else +# define ARP_TIMEOUT CONFIG_ARP_TIMEOUT +#endif + + +#ifndefCONFIG_NET_RETRY_COUNT +# define ARP_TIMEOUT_COUNT 5 /* # of timeouts before giving up */ +#else +# define ARP_TIMEOUT_COUNT CONFIG_NET_RETRY_COUNT +#endif + +IPaddr_t NetArpWaitPacketIP; +IPaddr_t NetArpWaitReplyIP; +/* MAC address of waiting packet's destination */ +uchar *NetArpWaitPacketMAC; +/* THE transmit packet */ +uchar *NetArpWaitTxPacket; +intNetArpWaitTxPacketSize; +uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN + PKTALIGN]; +ulong NetArpWaitTimerStart; +intNetArpWaitTry; + +void ArpInit(void) +{ + /* XXX problem with bss workaround */ + NetArpWaitPacketMAC = NULL; + NetArpWaitPacketIP = 0; + NetArpWaitReplyIP = 0; + NetArpWaitTxPacket = NetArpWaitPacketBuf[0] + (PKTALIGN - 1); + NetArpWaitTxPacket -= (ulong)NetArpWaitTxPacket % PKTALIGN; + NetArpWaitTxPacketSize = 0; +} + +void ArpRequest(void) +{ + uchar *pkt; + ARP_t *arp; + + debug(ARP broadcast %d\n, NetArpWaitTry); + + pkt = NetTxPacket; + + pkt += NetSetEther(pkt, NetBcastAddr, PROT_ARP); + + arp = (ARP_t *) pkt; + + arp-ar_hrd = htons(ARP_ETHER); + arp-ar_pro = htons(PROT_IP); + arp-ar_hln = 6; + arp-ar_pln = 4; + arp-ar_op = htons(ARPOP_REQUEST); + + /* source ET addr */ + memcpy(arp-ar_data[0], NetOurEther, 6); + /* source IP addr */ + NetWriteIP((uchar *) arp-ar_data[6], NetOurIP); + /* dest ET addr = 0 */ + memset(arp-ar_data[10], '\0', 6); + if ((NetArpWaitPacketIP NetOurSubnetMask) != + (NetOurIP NetOurSubnetMask)) { + if (NetOurGatewayIP == 0) { + puts(## Warning: gatewayip needed but not set\n); + NetArpWaitReplyIP = NetArpWaitPacketIP; + } else { + NetArpWaitReplyIP = NetOurGatewayIP; + } + } else { + NetArpWaitReplyIP = NetArpWaitPacketIP; + } + + NetWriteIP((uchar *) arp-ar_data[16], NetArpWaitReplyIP); + (void) eth_send(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE); +} + +void ArpTimeoutCheck(void) +{ + ulong t; + + if (!NetArpWaitPacketIP) + return; + + t = get_timer(0); + + /* check for arp timeout */ + if ((t - NetArpWaitTimerStart) ARP_TIMEOUT) { + NetArpWaitTry++; + + if (NetArpWaitTry = ARP_TIMEOUT_COUNT) { + puts(\nARP Retry count exceeded; starting again\n); + NetArpWaitTry = 0; + NetStartAgain(); + } else { + NetArpWaitTimerStart = t; + ArpRequest(); + } + } +} + +void ArpReceive(Ethernet_t *et, IP_t *ip, int len) +{ +
[U-Boot] [PATCH 01/28] net: Remove volatile from all of net except the eth driver interface
The mv_eth driver should not redefine the net function definition Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- board/Marvell/db64360/mv_eth.c |2 -- board/Marvell/db64460/mv_eth.c |2 -- board/esd/cpci750/mv_eth.c |2 -- board/prodrive/p3mx/mv_eth.c |2 -- include/net.h | 16 net/bootp.c|4 ++-- net/net.c | 40 net/rarp.c |2 +- net/tftp.c |6 +++--- 9 files changed, 34 insertions(+), 42 deletions(-) diff --git a/board/Marvell/db64360/mv_eth.c b/board/Marvell/db64360/mv_eth.c index 6340585..550610e 100644 --- a/board/Marvell/db64360/mv_eth.c +++ b/board/Marvell/db64360/mv_eth.c @@ -95,8 +95,6 @@ int mv64360_eth_xmit (struct eth_device *, volatile void *packet, int length); #ifndef UPDATE_STATS_BY_SOFTWARE static void mv64360_eth_print_stat (struct eth_device *dev); #endif -/* Processes a received packet */ -extern void NetReceive (volatile uchar *, int); extern unsigned int INTERNAL_REG_BASE_ADDR; diff --git a/board/Marvell/db64460/mv_eth.c b/board/Marvell/db64460/mv_eth.c index 4aefbaf..c447229 100644 --- a/board/Marvell/db64460/mv_eth.c +++ b/board/Marvell/db64460/mv_eth.c @@ -95,8 +95,6 @@ int mv64460_eth_xmit (struct eth_device *, volatile void *packet, int length); #ifndef UPDATE_STATS_BY_SOFTWARE static void mv64460_eth_print_stat (struct eth_device *dev); #endif -/* Processes a received packet */ -extern void NetReceive (volatile uchar *, int); extern unsigned int INTERNAL_REG_BASE_ADDR; diff --git a/board/esd/cpci750/mv_eth.c b/board/esd/cpci750/mv_eth.c index 001c1ad..db2324b 100644 --- a/board/esd/cpci750/mv_eth.c +++ b/board/esd/cpci750/mv_eth.c @@ -95,8 +95,6 @@ int mv64360_eth_xmit (struct eth_device *, volatile void *packet, int length); #ifndef UPDATE_STATS_BY_SOFTWARE static void mv64360_eth_print_stat (struct eth_device *dev); #endif -/* Processes a received packet */ -extern void NetReceive (volatile uchar *, int); extern unsigned int INTERNAL_REG_BASE_ADDR; diff --git a/board/prodrive/p3mx/mv_eth.c b/board/prodrive/p3mx/mv_eth.c index 15b3bfc..f26ded8 100644 --- a/board/prodrive/p3mx/mv_eth.c +++ b/board/prodrive/p3mx/mv_eth.c @@ -109,8 +109,6 @@ int phy_setup_aneg (char *devname, unsigned char addr); #ifndef UPDATE_STATS_BY_SOFTWARE static void mv64460_eth_print_stat (struct eth_device *dev); #endif -/* Processes a received packet */ -extern void NetReceive (volatile uchar *, int); extern unsigned int INTERNAL_REG_BASE_ADDR; diff --git a/include/net.h b/include/net.h index e4d42c2..ccdb01d 100644 --- a/include/net.h +++ b/include/net.h @@ -342,9 +342,9 @@ extern ucharNetOurEther[6]; /* Our ethernet address */ extern uchar NetServerEther[6]; /* Boot server enet address */ extern IPaddr_tNetOurIP; /* OurIP addr (0 = unknown) */ extern IPaddr_tNetServerIP;/* Server IP addr (0 = unknown) */ -extern volatile uchar * NetTxPacket; /* THE transmit packet */ -extern volatile uchar * NetRxPackets[PKTBUFSRX];/* Receive packets */ -extern volatile uchar * NetRxPacket; /* Current receive packet */ +extern uchar *NetTxPacket; /* THE transmit packet */ +extern uchar *NetRxPackets[PKTBUFSRX];/* Receive packets */ +extern uchar *NetRxPacket; /* Current receive packet */ extern int NetRxPacketLen; /* Current rx packet length */ extern unsignedNetIPID;/* IP ID (counting) */ extern uchar NetBcastAddr[6];/* Ethernet boardcast address */ @@ -408,10 +408,10 @@ extern void NetStartAgain(void); extern int NetEthHdrSize(void); /* Set ethernet header; returns the size of the header */ -extern int NetSetEther(volatile uchar *, uchar *, uint); +extern int NetSetEther(uchar *, uchar *, uint); /* Set IP header */ -extern voidNetSetIP(volatile uchar *, IPaddr_t, int, int, int); +extern void NetSetIP(uchar *, IPaddr_t, int, int, int); /* Checksum */ extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */ @@ -423,7 +423,7 @@ extern void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */ extern voidNetSetTimeout(ulong, thand_f *);/* Set timeout handler */ /* Transmit NetTxPacket */ -extern voidNetSendPacket(volatile uchar *, int); +extern void NetSendPacket(uchar *, int); /* Transmit UDP packet, performing ARP request if needed */ extern int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len); @@ -445,7 +445,7 @@ void net_auto_load(void); * footprint in our
[U-Boot] [PATCH 16/28] net: Refactor to protect access to the NetState variable
Changes to NetState now go through an accessor function called NetSetState() Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- drivers/net/netconsole.c |6 +++--- include/net.h| 13 +++-- net/cdp.c|2 +- net/dns.c|8 net/net.c| 21 ++--- net/nfs.c|6 +++--- net/ping.c |4 ++-- net/sntp.c |4 ++-- net/tftp.c |8 9 files changed, 40 insertions(+), 32 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index ba02fd7..89b5956 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -44,19 +44,19 @@ static void nc_wait_arp_handler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len) { - NetState = NETLOOP_SUCCESS; /* got arp reply - quit net loop */ + NetSetState(NETLOOP_SUCCESS); /* got arp reply - quit net loop */ } static void nc_handler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len) { if (input_size) - NetState = NETLOOP_SUCCESS; /* got input - quit net loop */ + NetSetState(NETLOOP_SUCCESS); /* got input - quit net loop */ } static void nc_timeout(void) { - NetState = NETLOOP_SUCCESS; + NetSetState(NETLOOP_SUCCESS); } void NcStart(void) diff --git a/include/net.h b/include/net.h index 19e9463..fe49ff7 100644 --- a/include/net.h +++ b/include/net.h @@ -364,12 +364,6 @@ extern uchar NetEtherNullAddr[6]; extern ushort NetOurVLAN; /* Our VLAN */ extern ushort NetOurNativeVLAN; /* Our Native VLAN */ -extern int NetState; /* Network loop state */ -#define NETLOOP_CONTINUE 1 -#define NETLOOP_RESTART2 -#define NETLOOP_SUCCESS3 -#define NETLOOP_FAIL 4 - extern int NetRestartWrap; /* Tried all network devices */ enum proto_t { @@ -435,6 +429,13 @@ extern voidNetSetHandler(rxhand_f *); /* Set RX packet handler */ extern void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */ extern voidNetSetTimeout(ulong, thand_f *);/* Set timeout handler */ +/* Network loop state */ +extern voidNetSetState(int state); +#define NETLOOP_CONTINUE 1 +#define NETLOOP_RESTART2 +#define NETLOOP_SUCCESS3 +#define NETLOOP_FAIL 4 + /* Transmit NetTxPacket */ extern void NetSendPacket(uchar *, int); diff --git a/net/cdp.c b/net/cdp.c index 305ecad..31f9ce7 100644 --- a/net/cdp.c +++ b/net/cdp.c @@ -234,7 +234,7 @@ CDPTimeout(void) if (!CDPOK) NetStartAgain(); else - NetState = NETLOOP_SUCCESS; + NetSetState(NETLOOP_SUCCESS); } static void diff --git a/net/dns.c b/net/dns.c index cc7ed51..0b655cc 100644 --- a/net/dns.c +++ b/net/dns.c @@ -98,7 +98,7 @@ static void DnsTimeout(void) { puts(Timeout\n); - NetState = NETLOOP_FAIL; + NetSetState(NETLOOP_FAIL); } static void @@ -128,7 +128,7 @@ DnsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len) /* Received 0 answers */ if (header-nanswers == 0) { puts(DNS: host not found\n); - NetState = NETLOOP_SUCCESS; + NetSetState(NETLOOP_SUCCESS); return; } @@ -141,7 +141,7 @@ DnsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len) /* We sent query class 1, query type 1 */ if (p[5] e || get_unaligned_be16(p+1) != DNS_A_RECORD) { puts(DNS: response was not an A record\n); - NetState = NETLOOP_SUCCESS; + NetSetState(NETLOOP_SUCCESS); return; } @@ -191,7 +191,7 @@ DnsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len) puts(server responded with invalid IP number\n); } - NetState = NETLOOP_SUCCESS; + NetSetState(NETLOOP_SUCCESS); } void diff --git a/net/net.c b/net/net.c index 16cbadc..a92df90 100644 --- a/net/net.c +++ b/net/net.c @@ -154,7 +154,7 @@ uchar NetEtherNullAddr[6]; void (*push_packet)(volatile void *, int len) = 0; #endif /* Network loop state */ -intNetState; +static int NetState; /* Tried all network devices */ intNetRestartWrap; /* Network loop restarted */ @@ -217,7 +217,7 @@ void net_auto_load(void) * Just use BOOTP/RARP to configure system; * Do not use TFTP to load the bootfile. */ - NetState =
[U-Boot] [PATCH 07/28] net: Move PING out of net.c
Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- include/configs/am3517_crane.h |2 +- include/configs/am3517_evm.h |2 +- include/configs/origen.h |2 +- net/Makefile |1 + net/net.c | 133 ++--- net/ping.c | 143 net/ping.h | 20 ++ 7 files changed, 172 insertions(+), 131 deletions(-) create mode 100644 net/ping.c create mode 100644 net/ping.h diff --git a/include/configs/am3517_crane.h b/include/configs/am3517_crane.h index 0a0c261..acd4e3f 100644 --- a/include/configs/am3517_crane.h +++ b/include/configs/am3517_crane.h @@ -146,7 +146,7 @@ #define CONFIG_CMD_MMC /* MMC support */ #define CONFIG_CMD_NAND/* NAND support */ #define CONFIG_CMD_DHCP -#define CONFIG_CMD_PING +#undef CONFIG_CMD_PING #undef CONFIG_CMD_FLASH/* flinfo, erase, protect */ #undef CONFIG_CMD_FPGA /* FPGA configuration Support */ diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h index d44eeec..9775107 100644 --- a/include/configs/am3517_evm.h +++ b/include/configs/am3517_evm.h @@ -145,7 +145,7 @@ #define CONFIG_CMD_MMC /* MMC support */ #define CONFIG_CMD_NAND/* NAND support */ #define CONFIG_CMD_DHCP -#define CONFIG_CMD_PING +#undef CONFIG_CMD_PING #undef CONFIG_CMD_FLASH/* flinfo, erase, protect */ #undef CONFIG_CMD_FPGA /* FPGA configuration Support */ diff --git a/include/configs/origen.h b/include/configs/origen.h index cd502d1..c9bac30 100644 --- a/include/configs/origen.h +++ b/include/configs/origen.h @@ -84,7 +84,7 @@ /* Command definition*/ #include config_cmd_default.h -#define CONFIG_CMD_PING +#undef CONFIG_CMD_PING #define CONFIG_CMD_ELF #define CONFIG_CMD_DHCP #define CONFIG_CMD_MMC diff --git a/net/Makefile b/net/Makefile index 0916a56..f1c4859 100644 --- a/net/Makefile +++ b/net/Makefile @@ -35,6 +35,7 @@ COBJS-$(CONFIG_CMD_NET) += eth.o COBJS-$(CONFIG_CMD_NET) += net.o COBJS-$(CONFIG_BOOTP_RANDOM_DELAY) += net_rand.o COBJS-$(CONFIG_CMD_NFS) += nfs.o +COBJS-$(CONFIG_CMD_PING) += ping.o COBJS-$(CONFIG_CMD_RARP) += rarp.o COBJS-$(CONFIG_CMD_SNTP) += sntp.o COBJS-$(CONFIG_CMD_NET) += tftp.o diff --git a/net/net.c b/net/net.c index 2dae5a0..c2fbcb5 100644 --- a/net/net.c +++ b/net/net.c @@ -98,6 +98,9 @@ #if defined(CONFIG_CMD_DNS) #include dns.h #endif +#if defined(CONFIG_CMD_PING) +#include ping.h +#endif DECLARE_GLOBAL_DATA_PTR; @@ -168,13 +171,6 @@ ushort NetOurNativeVLAN = 0x; /* Boot File name */ char BootFile[128]; -#if defined(CONFIG_CMD_PING) -/* the ip address to ping */ -IPaddr_t NetPingIP; - -static void PingStart(void); -#endif - #if defined(CONFIG_CMD_SNTP) /* NTP server IP address */ IPaddr_t NetNtpServerIP; @@ -653,94 +649,6 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len) return 0; /* transmitted */ } -#if defined(CONFIG_CMD_PING) -static ushort PingSeqNo; - -int PingSend(void) -{ - static uchar mac[6]; - IP_t *ip; - ushort *s; - uchar *pkt; - - /* XXX always send arp request */ - - memcpy(mac, NetEtherNullAddr, 6); - - debug(sending ARP for %08x\n, NetPingIP); - - NetArpWaitPacketIP = NetPingIP; - NetArpWaitPacketMAC = mac; - - pkt = NetArpWaitTxPacket; - pkt += NetSetEther(pkt, mac, PROT_IP); - - ip = (IP_t *)pkt; - - /* -* Construct an IP and ICMP header. -* (need to set no fragment bit - XXX) -*/ - /* IP_HDR_SIZE / 4 (not including UDP) */ - ip-ip_hl_v = 0x45; - ip-ip_tos = 0; - ip-ip_len = htons(IP_HDR_SIZE_NO_UDP + 8); - ip-ip_id= htons(NetIPID++); - ip-ip_off = htons(IP_FLAGS_DFRAG); /* Don't fragment */ - ip-ip_ttl = 255; - ip-ip_p = 0x01;/* ICMP */ - ip-ip_sum = 0; - /* already in network byte order */ - NetCopyIP((void *)ip-ip_src, NetOurIP); - /* - - */ - NetCopyIP((void *)ip-ip_dst, NetPingIP); - ip-ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2); - - s = ip-udp_src; /* XXX ICMP starts here */ - s[0] = htons(0x0800); /* echo-request, code */ - s[1] = 0; /* checksum */ - s[2] = 0; /* identifier */ - s[3] = htons(PingSeqNo++); /* sequence number */ - s[1] = ~NetCksum((uchar *)s, 8/2); - - /* size of the waiting packet */ - NetArpWaitTxPacketSize = - (pkt - NetArpWaitTxPacket) + IP_HDR_SIZE_NO_UDP + 8; - - /* and do the ARP request */ -
[U-Boot] [PATCH 13/28] net: Refactor bootp packet length computations
Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- net/bootp.c | 26 ++ 1 files changed, 14 insertions(+), 12 deletions(-) diff --git a/net/bootp.c b/net/bootp.c index 0c2af48..0d5f4cf 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -582,7 +582,8 @@ BootpRequest(void) { uchar *pkt, *iphdr; struct Bootp_t *bp; - int ext_len, pktlen, iplen; + int extlen, pktlen, iplen; + int eth_hdr_size; #ifdef CONFIG_BOOTP_RANDOM_DELAY ulong i, rand_ms; #endif @@ -610,7 +611,8 @@ BootpRequest(void) pkt = NetTxPacket; memset((void *)pkt, 0, PKTSIZE); - pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP); + eth_hdr_size = NetSetEther(pkt, NetBcastAddr, PROT_IP); + pkt += eth_hdr_size; /* * Next line results in incorrect packet size being transmitted, @@ -639,9 +641,9 @@ BootpRequest(void) /* Request additional information from the BOOTP/DHCP server */ #if defined(CONFIG_CMD_DHCP) - ext_len = DhcpExtended((u8 *)bp-bp_vend, DHCP_DISCOVER, 0, 0); + extlen = DhcpExtended((u8 *)bp-bp_vend, DHCP_DISCOVER, 0, 0); #else - ext_len = BootpExtended((u8 *)bp-bp_vend); + extlen = BootpExtended((u8 *)bp-bp_vend); #endif /* @@ -660,9 +662,8 @@ BootpRequest(void) * Calculate proper packet lengths taking into account the * variable size of the options field */ - pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - - sizeof(bp-bp_vend) + ext_len; - iplen = BOOTP_HDR_SIZE - sizeof(bp-bp_vend) + ext_len; + iplen = BOOTP_HDR_SIZE - OPT_FIELD_SIZE + extlen; + pktlen = eth_hdr_size + IP_UDP_HDR_SIZE + iplen; NetSetUDPHeader(iphdr, 0xL, PORT_BOOTPS, PORT_BOOTPC, iplen); NetSetTimeout(SELECT_TIMEOUT, BootpTimeout); @@ -798,13 +799,15 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) uchar *pkt, *iphdr; struct Bootp_t *bp; int pktlen, iplen, extlen; + int eth_hdr_size; IPaddr_t OfferedIP; debug(DhcpSendRequestPkt: Sending DHCPREQUEST\n); pkt = NetTxPacket; memset((void *)pkt, 0, PKTSIZE); - pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP); + eth_hdr_size = NetSetEther(pkt, NetBcastAddr, PROT_IP); + pkt += eth_hdr_size; iphdr = pkt;/* We'll need this later to set proper pkt size */ pkt += IP_UDP_HDR_SIZE; @@ -841,15 +844,14 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) extlen = DhcpExtended((u8 *)bp-bp_vend, DHCP_REQUEST, NetDHCPServerIP, OfferedIP); - pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - - sizeof(bp-bp_vend) + extlen; - iplen = BOOTP_HDR_SIZE - sizeof(bp-bp_vend) + extlen; + iplen = BOOTP_HDR_SIZE - OPT_FIELD_SIZE + extlen; + pktlen = eth_hdr_size + IP_UDP_HDR_SIZE + iplen; NetSetUDPHeader(iphdr, 0xL, PORT_BOOTPS, PORT_BOOTPC, iplen); - debug(Transmitting DHCPREQUEST packet: len = %d\n, pktlen); #ifdef CONFIG_BOOTP_DHCP_REQUEST_DELAY udelay(CONFIG_BOOTP_DHCP_REQUEST_DELAY); #endif /* CONFIG_BOOTP_DHCP_REQUEST_DELAY */ + debug(Transmitting DHCPREQUEST packet: len = %d\n, pktlen); NetSendPacket(NetTxPacket, pktlen); } -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 14/28] net: Refactor ping recieve handler
There is no need to call through the handler when we can handle it inline Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- net/ping.c | 19 ++- 1 files changed, 2 insertions(+), 17 deletions(-) diff --git a/net/ping.c b/net/ping.c index 12f9185..e4a7a21 100644 --- a/net/ping.c +++ b/net/ping.c @@ -76,22 +76,11 @@ PingTimeout(void) NetState = NETLOOP_FAIL;/* we did not get the reply */ } -static void -PingHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, - unsigned len) -{ - if (sip != NetPingIP) - return; - - NetState = NETLOOP_SUCCESS; -} - void PingStart(void) { printf(Using %s device\n, eth_get_name()); NetSetTimeout(1UL, PingTimeout); - NetSetHandler(PingHandler); PingSend(); } @@ -103,13 +92,9 @@ void PingReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) switch (icmph-type) { case ICMP_ECHO_REPLY: - /* -* IP header OK. Pass the packet to the -* current handler. -*/ - /* XXX point to ip packet */ src_ip = NetReadIP((void *)ip-ip_src); - NetGetHandler()((uchar *)ip, 0, src_ip, 0, 0); + if (src_ip == NetPingIP) + NetState = NETLOOP_SUCCESS; return; case ICMP_ECHO_REQUEST: debug(Got ICMP ECHO REQUEST, return -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 27/28] net: Work-around for brain-damaged Cisco routers with arp-proxy
Cisco's arp-proxy feature fails to ignore the link-local address range This means that a link-local device on a network with this Cisco equipment will reply to ARP requests for our device (in addition to our reply) If we happen to reply first, the requester's ARP table will be populated with our MAC address, and one packet will be sent to us... shortly following this, the requester will get an ARP reply from the Cisco equipment telling the requester to send packets their way instead of to our device from now on This work-around detects this link-local condition and will delay replying to the ARP request for 5ms so that the first packet is sent to the Cisco equipment and all following packets are sent to our device Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- net/arp.c | 13 + 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/net/arp.c b/net/arp.c index 9eb4ab0..8a7b4a2 100644 --- a/net/arp.c +++ b/net/arp.c @@ -172,6 +172,19 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) NetCopyIP(arp-ar_tpa, arp-ar_spa); memcpy(arp-ar_sha, NetOurEther, ARP_HLEN); NetCopyIP(arp-ar_spa, NetOurIP); + + /* +* Work-around for brain-damaged Cisco equipment with +* arp-proxy enabled. +* +* If the requesting IP is not on our subnet, wait 5ms to +* reply to ARP request so that our reply will overwrite +* the arp-proxy's instead of the other way around. +*/ + if ((NetReadIP(arp-ar_tpa) NetOurSubnetMask) != + (NetReadIP(arp-ar_spa) NetOurSubnetMask)) + udelay(5000); + NetSendPacket((uchar *)et, eth_hdr_size + ARP_HDR_SIZE); return; -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 17/28] net: Refactor to separate the UDP handler from the ARP handler
Only call the handlers if one was registered... don't require protocols to register a handler (eliminating dummies) NetConsole now uses the ARP handler when waiting on arp (instead of needing a #define hack in arp.c) Clear handlers at the end of net loop Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- drivers/net/netconsole.c |4 +- include/net.h|9 -- net/arp.c|7 ++-- net/bootp.c |4 +- net/cdp.c|8 - net/dns.c|2 +- net/net.c| 70 +- net/nfs.c|2 +- net/sntp.c |2 +- net/tftp.c |4 +- 10 files changed, 63 insertions(+), 49 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 89b5956..1e31159 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -63,12 +63,12 @@ void NcStart(void) { if (!output_packet_len || memcmp(nc_ether, NetEtherNullAddr, 6)) { /* going to check for input packet */ - NetSetHandler(nc_handler); + NetSetUDPHandler(nc_handler); NetSetTimeout(net_timeout, nc_timeout); } else { /* send arp request */ uchar *pkt; - NetSetHandler(nc_wait_arp_handler); + NetSetARPHandler(nc_wait_arp_handler); pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE; memcpy(pkt, output_packet, output_packet_len); NetSendUDPPacket(nc_ether, nc_ip, nc_port, nc_port, diff --git a/include/net.h b/include/net.h index fe49ff7..dca8e1c 100644 --- a/include/net.h +++ b/include/net.h @@ -424,8 +424,10 @@ extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */ extern uintNetCksum(uchar *, int); /* Calculate the checksum */ /* Callbacks */ -extern rxhand_f *NetGetHandler(void); /* Get RX packet handler */ -extern voidNetSetHandler(rxhand_f *); /* Set RX packet handler */ +extern rxhand_f *NetGetUDPHandler(void); /* Get UDP RX packet handler */ +extern voidNetSetUDPHandler(rxhand_f *); /* Set UDP RX packet handler */ +extern rxhand_f *NetGetARPHandler(void); /* Get ARP RX packet handler */ +extern voidNetSetARPHandler(rxhand_f *); /* Set ARP RX packet handler */ extern void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */ extern voidNetSetTimeout(ulong, thand_f *);/* Set timeout handler */ @@ -439,7 +441,8 @@ extern void NetSetState(int state); /* Transmit NetTxPacket */ extern void NetSendPacket(uchar *, int); -/* Transmit UDP packet, performing ARP request if needed */ +/* Transmit UDP packet, performing ARP request if needed + (ether will be populated) */ extern int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int payload_len); diff --git a/net/arp.c b/net/arp.c index d9113dc..5b6c787 100644 --- a/net/arp.c +++ b/net/arp.c @@ -192,9 +192,10 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) memcpy(NetArpWaitPacketMAC, arp-ar_sha, ARP_HLEN); -#ifdef CONFIG_NETCONSOLE - NetGetHandler()(0, 0, 0, 0, 0); -#endif + if (NetGetARPHandler() != NULL) + NetGetARPHandler()((uchar *)arp, 0, + reply_ip_addr, 0, len); + /* modify header, and transmit it */ memcpy(((struct Ethernet_t *)NetArpWaitTxPacket)- et_dest, NetArpWaitPacketMAC, ARP_HLEN); diff --git a/net/bootp.c b/net/bootp.c index 0d5f4cf..9d709f1 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -669,9 +669,9 @@ BootpRequest(void) #if defined(CONFIG_CMD_DHCP) dhcp_state = SELECTING; - NetSetHandler(DhcpHandler); + NetSetUDPHandler(DhcpHandler); #else - NetSetHandler(BootpHandler); + NetSetUDPHandler(BootpHandler); #endif NetSendPacket(NetTxPacket, pktlen); } diff --git a/net/cdp.c b/net/cdp.c index 31f9ce7..120d410 100644 --- a/net/cdp.c +++ b/net/cdp.c @@ -237,13 +237,6 @@ CDPTimeout(void) NetSetState(NETLOOP_SUCCESS); } -static void -CDPDummyHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, - unsigned len) -{ - /* nothing */ -} - void CDPReceive(const uchar *pkt, unsigned len) { @@ -368,7 +361,6 @@ CDPStart(void) CDPApplianceVLAN = htons(-1); NetSetTimeout(CDP_TIMEOUT, CDPTimeout); - NetSetHandler(CDPDummyHandler); CDPSendTrigger(); } diff --git a/net/dns.c b/net/dns.c index 0b655cc..9da3cac 100644 --- a/net/dns.c +++ b/net/dns.c @@ -200,7 +200,7 @@ DnsStart(void)
[U-Boot] [PATCH 24/28] net: Don't copy every packet that waits for an ARP
Use the NetArpTxPacket for the ARP packet, not to hold what used to be in NetTxPacket This saves a copy and makes the code easier to understand Generalize the formation of the ARP packet Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- net/arp.c | 44 net/arp.h |4 ++-- net/net.c | 24 ++-- net/ping.c |5 ++--- 4 files changed, 34 insertions(+), 43 deletions(-) diff --git a/net/arp.c b/net/arp.c index b3be0a6..938db59 100644 --- a/net/arp.c +++ b/net/arp.c @@ -30,25 +30,26 @@ IPaddr_tNetArpWaitPacketIP; IPaddr_t NetArpWaitReplyIP; /* MAC address of waiting packet's destination */ uchar *NetArpWaitPacketMAC; -/* THE transmit packet */ -uchar *NetArpWaitTxPacket; intNetArpWaitTxPacketSize; -uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN + PKTALIGN]; ulong NetArpWaitTimerStart; intNetArpWaitTry; +uchar *NetArpTxPacket; /* THE ARP transmit packet */ +uchar NetArpPacketBuf[PKTSIZE_ALIGN + PKTALIGN]; + void ArpInit(void) { /* XXX problem with bss workaround */ NetArpWaitPacketMAC = NULL; NetArpWaitPacketIP = 0; NetArpWaitReplyIP = 0; - NetArpWaitTxPacket = NetArpWaitPacketBuf[0] + (PKTALIGN - 1); - NetArpWaitTxPacket -= (ulong)NetArpWaitTxPacket % PKTALIGN; NetArpWaitTxPacketSize = 0; + NetArpTxPacket = NetArpPacketBuf[0] + (PKTALIGN - 1); + NetArpTxPacket -= (ulong)NetArpTxPacket % PKTALIGN; } -void ArpRequest(void) +void ArpRawRequest(IPaddr_t sourceIP, const uchar *targetEther, + IPaddr_t targetIP) { uchar *pkt; struct ARP_t *arp; @@ -56,7 +57,7 @@ void ArpRequest(void) debug(ARP broadcast %d\n, NetArpWaitTry); - pkt = NetTxPacket; + pkt = NetArpTxPacket; eth_hdr_size = NetSetEther(pkt, NetBcastAddr, PROT_ARP); pkt += eth_hdr_size; @@ -69,12 +70,16 @@ void ArpRequest(void) arp-ar_pln = ARP_PLEN; arp-ar_op = htons(ARPOP_REQUEST); - /* source ET addr */ - memcpy(arp-ar_sha, NetOurEther, ARP_HLEN); - /* source IP addr */ - NetWriteIP(arp-ar_spa, NetOurIP); - /* dest ET addr = 0 */ - memset(arp-ar_tha, 0, ARP_HLEN); + memcpy(arp-ar_sha, NetOurEther, ARP_HLEN);/* source ET addr */ + NetWriteIP(arp-ar_spa, sourceIP); /* source IP addr */ + memcpy(arp-ar_tha, targetEther, ARP_HLEN);/* target ET addr */ + NetWriteIP(arp-ar_tpa, targetIP); /* target IP addr */ + + NetSendPacket(NetArpTxPacket, eth_hdr_size + ARP_HDR_SIZE); +} + +void ArpRequest(void) +{ if ((NetArpWaitPacketIP NetOurSubnetMask) != (NetOurIP NetOurSubnetMask)) { if (NetOurGatewayIP == 0) { @@ -87,8 +92,7 @@ void ArpRequest(void) NetArpWaitReplyIP = NetArpWaitPacketIP; } - NetWriteIP(arp-ar_tpa, NetArpWaitReplyIP); - NetSendPacket(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE); + ArpRawRequest(NetOurIP, NetEtherNullAddr, NetArpWaitReplyIP); } void ArpTimeoutCheck(void) @@ -197,11 +201,11 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) NetGetARPHandler()((uchar *)arp, 0, reply_ip_addr, 0, len); - /* modify header, and transmit it */ - memcpy(((struct Ethernet_t *)NetArpWaitTxPacket)- - et_dest, arp-ar_sha, ARP_HLEN); - NetSendPacket(NetArpWaitTxPacket, - NetArpWaitTxPacketSize); + /* set the mac address in the waiting packet's header + and transmit it */ + memcpy(((struct Ethernet_t *)NetTxPacket)-et_dest, + arp-ar_sha, ARP_HLEN); + NetSendPacket(NetTxPacket, NetArpWaitTxPacketSize); /* no arp request pending now */ NetArpWaitPacketIP = 0; diff --git a/net/arp.h b/net/arp.h index d9ce03d..9657e67 100644 --- a/net/arp.h +++ b/net/arp.h @@ -16,14 +16,14 @@ extern IPaddr_tNetArpWaitPacketIP; /* MAC address of waiting packet's destination */ extern uchar *NetArpWaitPacketMAC; -/* THE transmit packet */ -extern uchar *NetArpWaitTxPacket; extern int NetArpWaitTxPacketSize; extern ulong NetArpWaitTimerStart; extern int NetArpWaitTry; void ArpInit(void); void ArpRequest(void); +void ArpRawRequest(IPaddr_t sourceIP, const uchar *targetEther, + IPaddr_t targetIP); void ArpTimeoutCheck(void); void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len); diff --git a/net/net.c b/net/net.c index 59ac167..fe4e528 100644 --- a/net/net.c +++ b/net/net.c @@
[U-Boot] [PATCH 09/28] net: cosmetic: Un-typedef variables in net
Un-typedef IP_t, Ethernet_t, VLAN_Ethernet_t, ARP_t, ICMP_t Rename IP header related things to IP_UDP The existing definition of IP_t includes UDP header, so name it to accurately describe the structure Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- arch/powerpc/cpu/mpc8260/ether_fcc.c | 10 ++-- drivers/net/netconsole.c |4 +- include/net.h| 30 ++- net/arp.c| 12 ++-- net/arp.h|2 +- net/bootp.c |8 ++-- net/bootp.h |2 +- net/cdp.c|4 +- net/dns.c|2 +- net/net.c| 87 + net/nfs.c|2 +- net/ping.c | 18 net/ping.h |2 +- net/rarp.c | 10 ++-- net/rarp.h |2 +- net/sntp.c |2 +- net/tftp.c |2 +- 17 files changed, 102 insertions(+), 97 deletions(-) diff --git a/arch/powerpc/cpu/mpc8260/ether_fcc.c b/arch/powerpc/cpu/mpc8260/ether_fcc.c index 879ec0e..f59d9e1 100644 --- a/arch/powerpc/cpu/mpc8260/ether_fcc.c +++ b/arch/powerpc/cpu/mpc8260/ether_fcc.c @@ -1049,11 +1049,11 @@ eth_loopback_test (void) } else { ushort datlen = bdp-cbd_datlen; - Ethernet_t *ehp; + struct Ethernet_t *ehp; ushort prot; int ours, tb, n, nbytes; - ehp = (Ethernet_t *) \ + ehp = (struct Ethernet_t *) \ ecp-rxbufs[i][0]; ours = memcmp (ehp-et_src, \ @@ -1064,9 +1064,9 @@ eth_loopback_test (void) n = prot 0x7fff; nbytes = ELBT_BUFSZ - \ - offsetof (Ethernet_t, \ - et_dsap) - \ - ELBT_CRCSZ; + offsetof( + struct Ethernet_t, \ + et_dsap) - ELBT_CRCSZ; /* check the frame is correct */ if (datlen != ELBT_BUFSZ) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 7acd5b0..ba02fd7 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -69,7 +69,7 @@ void NcStart(void) /* send arp request */ uchar *pkt; NetSetHandler(nc_wait_arp_handler); - pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE; + pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE; memcpy(pkt, output_packet, output_packet_len); NetSendUDPPacket(nc_ether, nc_ip, nc_port, nc_port, output_packet_len); @@ -131,7 +131,7 @@ static void nc_send_packet(const char *buf, int len) return; inited = 1; } - pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE; + pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE; memcpy(pkt, buf, len); ether = nc_ether; ip = nc_ip; diff --git a/include/net.h b/include/net.h index 2d00233..9de1181 100644 --- a/include/net.h +++ b/include/net.h @@ -155,7 +155,7 @@ u32 ether_crc(size_t len, unsigned char const *p); /* * Ethernet header */ -typedef struct { +struct Ethernet_t { uchar et_dest[6]; /* Destination node */ uchar et_src[6]; /* Source node */ ushort et_protlen; /* Protocol or length */ @@ -166,7 +166,7 @@ typedef struct { uchar et_snap2; uchar et_snap3; ushort et_prot;/* 802 protocol */ -} Ethernet_t; +}; #define ETHER_HDR_SIZE 14 /* Ethernet header size */ #define E802_HDR_SIZE 22 /* 802 ethernet header size */ @@ -174,13 +174,13 @@ typedef struct { /* * Ethernet header */ -typedef struct { +struct
[U-Boot] [PATCH 00/28] Add link-local addressing support
Link-local support allows the bootloader to get a usable network address regardless of network environment. Given that bootloaders may not always have access to a DHCP server, this functionality makes accessing it in those environments easier. It is also referred to as zero-configuration IP. The following script allows the network to be configured for DHCP, link-local, and static IP addresses configurably by the environment using dhcpenabled and linklocalenabled. #define CONFIG_EXTRA_ENV_SETTINGS \ ipconfigcmd=if test \\\$dhcpenabled\\\ -ne 0; \ then \ dhcpfail=0;dhcp || dhcpfail=1;\ else \ dhcpfail=-1; \ fi; \ if test \\\$linklocalenabled\\\ -ne 0 -a\ \\\$dhcpfail\\\ -ne 0; \ then \ linklocal;\ llfail=0; \ else \ llfail=-1;\ fi; \ if test \\\$llfail\\\ -ne 0 -a \ \\\$dhcpfail\\\ -ne 0; \ then \ setenv ipaddr $sipaddr; \ setenv netmask $snetmask; \ setenv gatewayip $sgatewayip; \ fi;\0 \ Some refactoring of net/ was done to make adding link-local support cleaner as well as generally improving the readability and organization of the code. Tested on da850_am18xxevm Tested on MPC8313ERDB_33 check-patch No warnings or errors (depends on ignoring CONSIDER_KSTRTO) MAKEALL -a powerpc No additional warnings or errors beyond master MAKEALL -a arm No additional warnings or errors beyond master git-test-sequence Cleanly bisectable Code-size affects on MPC8313ERDB_33 shown below cat sizeofMCP8313 make BUILD_DIR=/tmp/u-boot-build/ ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- USE_PRIVATE_LIBGG=yes distclean /dev/null \ make BUILD_DIR=/tmp/u-boot-build/ ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- MPC8313ERDB_33_config /dev/null \ make BUILD_DIR=/tmp/u-boot-build/ ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- USE_PRIVATE_LIBGG=yes /dev/null \ powerpc-linux-gnu-size /tmp/u-boot-build/u-boot git-test-sequence origin/master.. './sizeofMCP8313' Testing ./sizeofMCP8313 HEAD is now at 4dbe8d8 net: Remove volatile from all of net except the eth driver interface textdata bss dec hex filename 264917 24880 42104 331901 5107d /tmp/u-boot-build/ppc/u-boot Passed: 90ea672853753b5a4244db60d095e5f99cdcfe7d. Testing ./sizeofMCP8313 HEAD is now at 92893c4 net: cosmetic: checkpatch compliance textdata bss dec hex filename 264917 24880 42104 331901 5107d /tmp/u-boot-build/ppc/u-boot Passed: 12b0b6e953406a1ed98d1c4dd9701078d1dfe00d. Testing ./sizeofMCP8313 HEAD is now at d6c19a3 net: Move mv64x6x_eth_initialize() to board_eth_init() textdata bss dec hex filename 264917 24880 42104 331901 5107d /tmp/u-boot-build/ppc/u-boot Passed: cf9f493ab5d08a282ec9905797fa58d82b15714d. Testing ./sizeofMCP8313 HEAD is now at 52403e8 net: Make the MAC-seeded random number generator available to /net textdata bss dec hex filename 264917 24880 42104 331901 5107d /tmp/u-boot-build/ppc/u-boot Passed: a92c9c9e8f68337a78ee2d7c6775299d7c057b52. Testing ./sizeofMCP8313 HEAD is now at ff86c81 net: Move CDP out of net.c textdata bss dec hex filename 264917 24880 42104 331901 5107d /tmp/u-boot-build/ppc/u-boot Passed: 9bf01065cb04c34e43cc5d56162aa2dac9d61f3e. Testing ./sizeofMCP8313 HEAD is now at da1998d net: Move ARP out of net.c textdata bss dec hex filename 265045 24928 42104 332077 5112d /tmp/u-boot-build/ppc/u-boot Passed: 621d67b8c6126ef6510d0a2b2c06ce410cd60327. Testing ./sizeofMCP8313 HEAD is now at 408b8ab net: Move PING out of net.c textdata bss dec hex filename 265237 24976 42096 332309 51215 /tmp/u-boot-build/ppc/u-boot Passed: e8aaa7382de39137c91809ba2e121f87338627d5. Testing ./sizeofMCP8313 HEAD is now at 1b3ed14 net: Move RARP receive logic out of net.c textdata bss dec hex filename 265237 24976
[U-Boot] [PATCH 10/28] net: cosmetic: Improve variable names and code readability
Rename parameter len to payload_len in NetSendUDPPacket: this name more explicitly claims that it does not include the header size Rename CDPHandler to CDPReceive: this is not called as a handler, so don't name it that way Rename OPT_SIZE to OPT_FIELD_SIZE: clearer constant name and also remove related BOOTP_SIZE which was unused and doesn't take into account VLAN packets Rename tmp to reply_ip_addr in arp.c Alphabetize includes in net.c Replace magic numbers in arp.c with constants Add a more explicit comment about 802.2 Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- include/net.h | 11 +++- net/arp.c | 38 net/bootp.c | 10 net/bootp.h |7 ++--- net/cdp.c |2 +- net/cdp.h |2 +- net/net.c | 67 +--- 7 files changed, 73 insertions(+), 64 deletions(-) diff --git a/include/net.h b/include/net.h index 9de1181..add2080 100644 --- a/include/net.h +++ b/include/net.h @@ -169,7 +169,8 @@ struct Ethernet_t { }; #define ETHER_HDR_SIZE 14 /* Ethernet header size */ -#define E802_HDR_SIZE 22 /* 802 ethernet header size */ + /* 802.2 + SNAP + ethernet header size */ +#define E802_HDR_SIZE (ETHER_HDR_SIZE + 8) /* * Ethernet header @@ -231,7 +232,9 @@ struct ARP_t { # define ARP_ETHER 1 /* Ethernet hardware address */ ushort ar_pro; /* Format of protocol address */ uchar ar_hln; /* Length of hardware address */ +# define ARP_HLEN6 uchar ar_pln; /* Length of protocol address */ +# define ARP_PLEN4 ushort ar_op; /* Operation*/ # define ARPOP_REQUEST1 /* Request to resolve address */ # define ARPOP_REPLY 2 /* Response to previous request */ @@ -245,6 +248,10 @@ struct ARP_t { * specific hardware/protocol combinations. */ uchar ar_data[0]; +#define ar_sha ar_data[0] +#define ar_spa ar_data[ARP_HLEN] +#define ar_tha ar_data[ARP_HLEN + ARP_PLEN] +#define ar_tpa ar_data[ARP_HLEN + ARP_PLEN + ARP_HLEN] #if 0 uchar ar_sha[]; /* Sender hardware address */ uchar ar_spa[]; /* Sender protocol address */ @@ -431,7 +438,7 @@ extern void NetSendPacket(uchar *, int); /* Transmit UDP packet, performing ARP request if needed */ extern int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, - int sport, int len); + int sport, int payload_len); /* Processes a received packet */ extern voidNetReceive(volatile uchar *, int); diff --git a/net/arp.c b/net/arp.c index 96ffb85..456decd 100644 --- a/net/arp.c +++ b/net/arp.c @@ -63,16 +63,16 @@ void ArpRequest(void) arp-ar_hrd = htons(ARP_ETHER); arp-ar_pro = htons(PROT_IP); - arp-ar_hln = 6; - arp-ar_pln = 4; + arp-ar_hln = ARP_HLEN; + arp-ar_pln = ARP_PLEN; arp-ar_op = htons(ARPOP_REQUEST); /* source ET addr */ - memcpy(arp-ar_data[0], NetOurEther, 6); + memcpy(arp-ar_sha, NetOurEther, ARP_HLEN); /* source IP addr */ - NetWriteIP((uchar *) arp-ar_data[6], NetOurIP); + NetWriteIP(arp-ar_spa, NetOurIP); /* dest ET addr = 0 */ - memset(arp-ar_data[10], '\0', 6); + memset(arp-ar_tha, 0, ARP_HLEN); if ((NetArpWaitPacketIP NetOurSubnetMask) != (NetOurIP NetOurSubnetMask)) { if (NetOurGatewayIP == 0) { @@ -85,7 +85,7 @@ void ArpRequest(void) NetArpWaitReplyIP = NetArpWaitPacketIP; } - NetWriteIP((uchar *) arp-ar_data[16], NetArpWaitReplyIP); + NetWriteIP(arp-ar_tpa, NetArpWaitReplyIP); (void) eth_send(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE); } @@ -116,7 +116,7 @@ void ArpTimeoutCheck(void) void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) { struct ARP_t *arp; - IPaddr_t tmp; + IPaddr_t reply_ip_addr; uchar *pkt; /* @@ -139,15 +139,15 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) return; if (ntohs(arp-ar_pro) != PROT_IP) return; - if (arp-ar_hln != 6) + if (arp-ar_hln != ARP_HLEN) return; - if (arp-ar_pln != 4) + if (arp-ar_pln != ARP_PLEN) return; if (NetOurIP == 0) return; - if (NetReadIP(arp-ar_data[16]) != NetOurIP) + if (NetReadIP(arp-ar_tpa) != NetOurIP) return; switch (ntohs(arp-ar_op)) { @@ -157,10 +157,10 @@ void ArpReceive(struct Ethernet_t
[U-Boot] [PATCH 28/28] net: Allow filtering on debug traces in the net subsystem
Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- drivers/net/netconsole.c |6 ++ net/arp.c| 12 net/link_local.c | 31 +++ net/net.c| 45 ++--- net/ping.c |6 -- net/rarp.c |7 +-- 6 files changed, 76 insertions(+), 31 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 1e31159..aee671e 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -26,6 +26,8 @@ #include stdio_dev.h #include net.h +#define DEBUG_DEV_PKT 0 + DECLARE_GLOBAL_DATA_PTR; static char input_buffer[512]; @@ -83,6 +85,8 @@ int nc_input_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len) if (dest != nc_port || !len) return 0; /* not for us */ + debug_cond(DEBUG_DEV_PKT, input: \%*.*s\\n, len, len, pkt); + if (input_size == sizeof(input_buffer)) return 1; /* no space */ if (len sizeof(input_buffer) - input_size) @@ -112,6 +116,8 @@ static void nc_send_packet(const char *buf, int len) uchar *ether; IPaddr_t ip; + debug_cond(DEBUG_DEV_PKT, output: \%*.*s\\n, len, len, buf); + eth = eth_get_dev(); if (eth == NULL) return; diff --git a/net/arp.c b/net/arp.c index 8a7b4a2..b8fb21f 100644 --- a/net/arp.c +++ b/net/arp.c @@ -15,6 +15,9 @@ #include link_local.h #endif +#define DEBUG_DEV_PKT 0 +#define DEBUG_NET_PKT 0 + #ifndefCONFIG_ARP_TIMEOUT /* Milliseconds before trying ARP again */ # define ARP_TIMEOUT 5000UL @@ -58,7 +61,7 @@ void ArpRawRequest(IPaddr_t sourceIP, const uchar *targetEther, struct ARP_t *arp; int eth_hdr_size; - debug(ARP broadcast %d\n, NetArpWaitTry); + debug_cond(DEBUG_DEV_PKT, ARP broadcast %d\n, NetArpWaitTry); pkt = NetArpTxPacket; @@ -138,7 +141,7 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) * address; so if we receive such a packet, we set * the server ethernet address */ - debug(Got ARP\n); + debug_cond(DEBUG_NET_PKT, Got ARP\n); arp = (struct ARP_t *)ip; if (len ARP_HDR_SIZE) { @@ -163,7 +166,7 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) switch (ntohs(arp-ar_op)) { case ARPOP_REQUEST: /* reply with our IP address */ - debug(Got ARP REQUEST, return our IP\n); + debug_cond(DEBUG_DEV_PKT, Got ARP REQUEST, return our IP\n); pkt = (uchar *)et; eth_hdr_size = NetUpdateEther(et, et-et_src, PROT_ARP); pkt += eth_hdr_size; @@ -205,7 +208,8 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) /* matched waiting packet's address */ if (reply_ip_addr == NetArpWaitReplyIP) { - debug(Got ARP REPLY, set eth addr (%pM)\n, + debug_cond(DEBUG_DEV_PKT, + Got ARP REPLY, set eth addr (%pM)\n, arp-ar_data); /* save address for later use */ diff --git a/net/link_local.c b/net/link_local.c index 16ec9a7..5395bf6 100644 --- a/net/link_local.c +++ b/net/link_local.c @@ -16,6 +16,11 @@ #include arp.h #include net_rand.h +#define DEBUG_LL_STATE 0 +#define DEBUG_DEV_PKT 0 +#define DEBUG_NET_PKT 0 +#define DEBUG_INT_STATE 0 + /* We don't need more than 32 bits of the counter */ #define MONOTONIC_MS() ((unsigned)get_timer(0) * (1000 / CONFIG_SYS_HZ)) @@ -93,7 +98,7 @@ static void configure_wait(void) /* set deadline_ms to the point in time when we timeout */ deadline_ms = MONOTONIC_MS() + timeout_ms; - debug(...wait %d %s nprobes=%u, nclaims=%u\n, + debug_cond(DEBUG_DEV_PKT, ...wait %d %s nprobes=%u, nclaims=%u\n, timeout_ms, eth_get_name(), nprobes, nclaims); NetSetTimeout(timeout_ms, LinkLocalTimeout); @@ -132,7 +137,7 @@ LinkLocalTimeout(void) have been received, so we can progress through the states */ if (nprobes PROBE_NUM) { nprobes++; - debug(probe/%u %s@%pI4\n, + debug_cond(DEBUG_LL_STATE, probe/%u %s@%pI4\n, nprobes, eth_get_name(), ip); ArpRawRequest(0, NetEtherNullAddr, ip); timeout_ms = PROBE_MIN * 1000; @@ -141,7 +146,7 @@ LinkLocalTimeout(void) /* Switch to announce state */ state = ANNOUNCE; nclaims = 0; - debug(announce/%u %s@%pI4\n, +
[U-Boot] [PATCH 08/28] net: Move RARP receive logic out of net.c
Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- net/net.c | 25 + net/rarp.c | 38 +++--- net/rarp.h |1 + 3 files changed, 29 insertions(+), 35 deletions(-) diff --git a/net/net.c b/net/net.c index c2fbcb5..fdc1ebe 100644 --- a/net/net.c +++ b/net/net.c @@ -857,9 +857,6 @@ NetReceive(volatile uchar *inpkt, int len) { Ethernet_t *et; IP_t*ip; -#ifdef CONFIG_CMD_RARP - ARP_t *arp; -#endif IPaddr_t tmp; IPaddr_t src_ip; int x; @@ -964,27 +961,7 @@ NetReceive(volatile uchar *inpkt, int len) #ifdef CONFIG_CMD_RARP case PROT_RARP: - debug(Got RARP\n); - arp = (ARP_t *)ip; - if (len ARP_HDR_SIZE) { - printf(bad length %d %d\n, len, ARP_HDR_SIZE); - return; - } - - if ((ntohs(arp-ar_op) != RARPOP_REPLY) || - (ntohs(arp-ar_hrd) != ARP_ETHER) || - (ntohs(arp-ar_pro) != PROT_IP) || - (arp-ar_hln != 6) || (arp-ar_pln != 4)) { - - puts(invalid RARP header\n); - } else { - NetCopyIP(NetOurIP, arp-ar_data[16]); - if (NetServerIP == 0) - NetCopyIP(NetServerIP, arp-ar_data[6]); - memcpy(NetServerEther, arp-ar_data[0], 6); - - (*packetHandler)(0, 0, 0, 0, 0); - } + RarpReceive(ip, len); break; #endif case PROT_IP: diff --git a/net/rarp.c b/net/rarp.c index 5a813a2..761560c 100644 --- a/net/rarp.c +++ b/net/rarp.c @@ -36,18 +36,37 @@ # define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT) #endif - intRarpTry; /* * Handle a RARP received packet. */ -static void -RarpHandler(uchar *dummi0, unsigned dummi1, IPaddr_t sip, unsigned dummi2, - unsigned dummi3) +void +RarpReceive(IP_t *ip, unsigned len) { - debug(Got good RARP\n); - net_auto_load(); + ARP_t *arp; + + debug(Got RARP\n); + arp = (ARP_t *)ip; + if (len ARP_HDR_SIZE) { + printf(bad length %d %d\n, len, ARP_HDR_SIZE); + return; + } + + if ((ntohs(arp-ar_op) != RARPOP_REPLY) || + (ntohs(arp-ar_hrd) != ARP_ETHER) || + (ntohs(arp-ar_pro) != PROT_IP) || + (arp-ar_hln != 6) || (arp-ar_pln != 4)) { + + puts(invalid RARP header\n); + } else { + NetCopyIP(NetOurIP, arp-ar_data[16]); + if (NetServerIP == 0) + NetCopyIP(NetServerIP, arp-ar_data[6]); + memcpy(NetServerEther, arp-ar_data[0], 6); + debug(Got good RARP\n); + net_auto_load(); + } } @@ -70,7 +89,6 @@ RarpTimeout(void) void RarpRequest(void) { - int i; uchar *pkt; ARP_t *rarp; @@ -90,12 +108,10 @@ RarpRequest(void) memcpy(rarp-ar_data[6], NetOurIP, 4); /* source IP addr */ /* dest ET addr = source ET addr ??*/ memcpy(rarp-ar_data[10], NetOurEther, 6); - /* dest. IP addr set to broadcast */ - for (i = 0; i = 3; i++) - rarp-ar_data[16 + i] = 0xff; + /* dest IP addr set to broadcast */ + memset(rarp-ar_data[16], 0xff,4); NetSendPacket(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE); NetSetTimeout(TIMEOUT, RarpTimeout); - NetSetHandler(RarpHandler); } diff --git a/net/rarp.h b/net/rarp.h index 4e92d80..0d728dc 100644 --- a/net/rarp.h +++ b/net/rarp.h @@ -37,6 +37,7 @@ extern int RarpTry; +extern void RarpReceive(IP_t *ip, unsigned len); extern void RarpRequest(void); /* Send a RARP request */ /**/ -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 05/28] net: Move CDP out of net.c
Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- arch/powerpc/cpu/mpc8xx/fec.c |2 +- include/net.h |9 +- net/Makefile |1 + net/cdp.c | 380 + net/cdp.h | 18 ++ net/net.c | 368 +--- 6 files changed, 406 insertions(+), 372 deletions(-) create mode 100644 net/cdp.c create mode 100644 net/cdp.h diff --git a/arch/powerpc/cpu/mpc8xx/fec.c b/arch/powerpc/cpu/mpc8xx/fec.c index f2a2c3a..0bc1e5d 100644 --- a/arch/powerpc/cpu/mpc8xx/fec.c +++ b/arch/powerpc/cpu/mpc8xx/fec.c @@ -274,7 +274,7 @@ static int fec_recv (struct eth_device *dev) #if defined(CONFIG_CMD_CDP) if ((rx[0] 1) != 0 memcmp ((uchar *) rx, NetBcastAddr, 6) != 0 -memcmp ((uchar *) rx, NetCDPAddr, 6) != 0) +!is_cdp_packet((uchar *)rx)) rx = NULL; #endif /* diff --git a/include/net.h b/include/net.h index 09d1b51..0396b69 100644 --- a/include/net.h +++ b/include/net.h @@ -355,10 +355,6 @@ extern uchar NetEtherNullAddr[6]; extern ushort NetOurVLAN; /* Our VLAN */ extern ushort NetOurNativeVLAN; /* Our Native VLAN */ -extern uchar NetCDPAddr[6]; /* Ethernet CDP address */ -extern ushort CDPNativeVLAN; /* CDP returned native VLAN */ -extern ushort CDPApplianceVLAN; /* CDP returned appliance VLAN */ - extern int NetState; /* Network loop state */ #define NETLOOP_CONTINUE 1 #define NETLOOP_RESTART2 @@ -386,8 +382,9 @@ extern IPaddr_t NetPingIP; /* the ip address to ping */ #if defined(CONFIG_CMD_CDP) /* when CDP completes these hold the return values */ -extern ushort CDPNativeVLAN; -extern ushort CDPApplianceVLAN; +extern ushort CDPNativeVLAN; /* CDP returned native VLAN */ +extern ushort CDPApplianceVLAN;/* CDP returned appliance VLAN */ +int is_cdp_packet(const uchar *et_addr); #endif #if defined(CONFIG_CMD_SNTP) diff --git a/net/Makefile b/net/Makefile index 5901046..b350bfc 100644 --- a/net/Makefile +++ b/net/Makefile @@ -28,6 +28,7 @@ include $(TOPDIR)/config.mk LIB= $(obj)libnet.o COBJS-$(CONFIG_CMD_NET) += bootp.o +COBJS-$(CONFIG_CMD_CDP) += cdp.o COBJS-$(CONFIG_CMD_DNS) += dns.o COBJS-$(CONFIG_CMD_NET) += eth.o COBJS-$(CONFIG_CMD_NET) += net.o diff --git a/net/cdp.c b/net/cdp.c new file mode 100644 index 000..c5e54b2 --- /dev/null +++ b/net/cdp.c @@ -0,0 +1,380 @@ +/* + * Copied from Linux Monitor (LiMon) - Networking. + * + * Copyright 1994 - 2000 Neil Russell. + * (See License) + * Copyright 2000 Roland Borde + * Copyright 2000 Paolo Scaffardi + * Copyright 2000-2002 Wolfgang Denk, w...@denx.de + */ + +#include common.h +#include net.h +#if defined(CONFIG_CDP_VERSION) +#include timestamp.h +#endif + +#include cdp.h + +/* Ethernet bcast address */ +static const uchar NetCDPAddr[6] = { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc }; + +#define CDP_DEVICE_ID_TLV 0x0001 +#define CDP_ADDRESS_TLV0x0002 +#define CDP_PORT_ID_TLV0x0003 +#define CDP_CAPABILITIES_TLV 0x0004 +#define CDP_VERSION_TLV0x0005 +#define CDP_PLATFORM_TLV 0x0006 +#define CDP_NATIVE_VLAN_TLV0x000a +#define CDP_APPLIANCE_VLAN_TLV 0x000e +#define CDP_TRIGGER_TLV0x000f +#define CDP_POWER_CONSUMPTION_TLV 0x0010 +#define CDP_SYSNAME_TLV0x0014 +#define CDP_SYSOBJECT_TLV 0x0015 +#define CDP_MANAGEMENT_ADDRESS_TLV 0x0016 + +#define CDP_TIMEOUT250UL /* one packet every 250ms */ + +static int CDPSeq; +static int CDPOK; + +ushort CDPNativeVLAN; +ushort CDPApplianceVLAN; + +static const uchar CDP_SNAP_hdr[8] = { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x0C, 0x20, + 0x00 }; + +static ushort +CDP_compute_csum(const uchar *buff, ushort len) +{ + ushort csum; + int odd; + ulong result = 0; + ushort leftover; + ushort *p; + + if (len 0) { + odd = 1 (ulong)buff; + if (odd) { + result = *buff 8; + len--; + buff++; + } + while (len 1) { + p = (ushort *)buff; + result += *p++; + buff = (uchar *)p; + if (result 0x8000) + result = (result 0x) + (result 16); + len -= 2; +
Re: [U-Boot] mx6qsabrelite U-Boot from SPI-NOR
Hi Eric, On 01/20/2012 01:56 AM, Eric Nelson wrote: Hi Wolfgang, On 01/19/2012 03:26 AM, Dirk Behme wrote: Dear Wolfgang, On 19.01.2012 10:58, Wolfgang Grandegger wrote: Where can I find the SPI_to_SD_loader.bin image? Unfortunately, at the moment you have to ask your Freescale contact for this. We ping Freescale since weeks for this. Last time I heard about this Freescale planned to release this binary under a BSD license. They are still working through the licensing details, though :( What means early version of SabreLite boards? Most probably Eric will be able to better answer this. At this point **all** versions of SabreLite are configured to boot to SPI NOR through the fuses. As Dirk mentioned, we've had some conversations about booting to SD card, but once the fuse is blown, it's blown. What I understood: Up to now, the boards boot from SPI NOR by default. There was some _discussion_ to change this to SD boot. Most probably early version was written while this discussion under the impression that later boards might switch to SD boot. To my understanding the result of this discussion was that this change would be difficult, though. We've discussed, but currently have no plans to support a physical switch to control this decision. This would involve using the Internal boot mode position of SW1 and then pulling a **bunch** of pins high or low to control the boot flow. Note that all of the pins are available on connector J12 (BOOT/EIM), so it might be done with a small daughter-board. OK, I see. How can I select boot from SD-Card on newer versions? To my understanding there are no newer versions yet. Right. And will the u-boot.imx image also boot when loaded to the SPI-NOR fash? Hmm, I'm not sure about this as I haven't tested this. Eric? Yes. If you program u-boot.imx to offset 0x400, it will boot. I just did so as shown below. I started by placing SW1 in the 01 position (boot to USB), and used imx_usb to dowload u-boot.imx: MX6QSABRELITE U-Boot dhcp 1080 192.168.0.112:u-boot.imx fec_open:Speed=100 BOOTP broadcast 1 BOOTP broadcast 2 DHCP client bound to address 29.6.1.24 Using FEC device TFTP from server 192.168.0.112; our IP address is 29.6.1.24; sending through gateway 29.6.1.1 Filename 'u-boot.imx'. Load address: 0x1080 Loading: # done Bytes transferred = 207112 (32908 hex) MX6QSABRELITE U-Boot sf write 0x1080 0x400 $filesize But above you used the network to load u-boot.imx. With imx_usb you loaded and booted an image via USB first, I assume. switched SW1 to BOOT mode 0 and hit the reset button here U-Boot 2011.12-00048-g5c30101 (Jan 19 2012 - 17:14:32) CPU: Freescale i.MX61 family rev1.0 at 792 MHz Reset cause: POR Board: MX6Q-Sabre Lite DRAM: 1 GiB WARNING: Caches not enabled MMC: FSL_SDHC: 0, FSL_SDHC: 1 MMC init failed Using default environment In:serial Out: serial Err: serial Net: FEC Hit any key to stop autoboot: 0 MX6QSABRELITE U-Boot MX6QSABRELITE U-Boot The imx_usb utility is available here: http://boundarydevices.com/git?p=imx_usb_loader.git It requires libusb-1.0-0-dev to build, but has few other dependencies. Usage is simple: hand it the file you want to execute. It will look at the header to find out where to place the image. ~/imx_usb_loader$ sudo sudo ./imx_usb u-boot.imx Nice fallback in case the bootloader does not start. I will give it a try a.s.a.p. We actually plan to use a BDI[23]000 for that purpose. Please note that Eric is in the process of mainlining the SPI driver for i.MX6, atm. If you use my latest patch set, you can place the environment in SPI-NOR as well by commenting out CONFIG_ENV_IS_IN_MMC, and un-commenting ..._IN_SPI_FLASH in include/configs/mx6qsabrelite.h. OK, that's already an excellent starting point. Thanks. Wolfgang. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2 V2] arm926: Flush the data cache before disabling it.
Hi Aneesh, On Fri, Jan 20, 2012 at 9:52 AM, Aneesh V ane...@ti.com wrote: Sughosh, [...] Can you send the value of SCR you found at SPL entry? This will clarify what's enabled and what's not. I would like to try that on my board as well for comparison. Could you please tell me how this register can be read? In the ARM manuals SCR seems to have several meanings... Thank you! Regards, Christian ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2 V2] arm926: Flush the data cache before disabling it.
so sorry to you, i think it's difference between DISABLE and Flush. be careful. On Wed, Jan 11, 2012 at 2:12 AM, Sughosh Ganu urwithsugh...@gmail.comwrote: The current implementation invalidates the cache instead of flushing it. This causes problems on platforms where the spl/u-boot is already loaded to the RAM, with caches enabled by a first stage bootloader. The V bit of the cp15's control register c1 is set to the value of VINITHI on reset. Do not clear this bit by default, as there are SOC's with no valid memory region at 0x0. Signed-off-by: Sughosh Ganu urwithsugh...@gmail.com Cc: Albert Aribaud albert.u.b...@aribaud.net --- Changes since V1 * Added arm926 keyword to the subject line * Removed the superfluous setting of r0. * Fixed the comment to reflect the fact that V is not being cleared arch/arm/cpu/arm926ejs/start.S |9 ++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S index 6a09c02..6e261c2 100644 --- a/arch/arm/cpu/arm926ejs/start.S +++ b/arch/arm/cpu/arm926ejs/start.S @@ -355,17 +355,20 @@ _dynsym_start_ofs: */ cpu_init_crit: /* -* flush v4 I/D caches +* flush D cache before disabling it */ mov r0, #0 - mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */ +flush_dcache: + mrc p15, 0, r15, c7, c10, 3 + bne flush_dcache + mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */ /* * disable MMU stuff and caches */ mrc p15, 0, r0, c1, c0, 0 - bic r0, r0, #0x2300 /* clear bits 13, 9:8 (--V- --RS) */ + bic r0, r0, #0x0300 /* clear bits 9:8 ( --RS) */ bic r0, r0, #0x0087 /* clear bits 7, 2:0 (B--- -CAM) */ orr r0, r0, #0x0002 /* set bit 2 (A) Align */ orr r0, r0, #0x1000 /* set bit 12 (I) I-Cache */ -- 1.7.5.4 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] About mtest on boot
Hello, I want to stop autoboot and use mtest to check if my ram is alright, but 0x07FD2C00 forward freezes, and 0x0902 also freezes, mtest, when using it. My ramsize is 0x0800. Does u-boot uses any parts of ram by itself, I mean, is there any known spots where I can't test because it would crash my system? Thanks Érico V. Porto ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] About mtest on boot
Hi, On Fri, 20 Jan 2012 08:07:41 -0200 Érico Porto ericoporto2...@gmail.com wrote: Hello, I want to stop autoboot and use mtest to check if my ram is alright, but 0x07FD2C00 forward freezes, and 0x0902 also freezes, mtest, when using it. My ramsize is 0x0800. Does u-boot uses any parts of ram by itself, I mean, is there any known spots where I can't test because it would crash my system? U-Boot relocates itself into RAM. You can check the address using 'bdinfo' command (look at 'relocaddr' in the output). There are also some data structures in RAM (global data, board info, stack, malloc area) and also exception vectors. Where it is located in RAM depends on your architecture and board configuration options. You can try to define DEBUG in the arch board.c file to get more info. Board config file should define CONFIG_SYS_MEMTEST_START and CONFIG_SYS_MEMTEST_END to prevent crashing when mtest is invoked. HTH, Anatolij ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] About mtest on boot
Now I understood, LTIB is giving me an older u-boot version - 1.1.6 and not 2011.12. Will try to update it... Érico V. Porto On Fri, Jan 20, 2012 at 8:38 AM, Anatolij Gustschin ag...@denx.de wrote: Hi, On Fri, 20 Jan 2012 08:07:41 -0200 Érico Porto ericoporto2...@gmail.com wrote: Hello, I want to stop autoboot and use mtest to check if my ram is alright, but 0x07FD2C00 forward freezes, and 0x0902 also freezes, mtest, when using it. My ramsize is 0x0800. Does u-boot uses any parts of ram by itself, I mean, is there any known spots where I can't test because it would crash my system? U-Boot relocates itself into RAM. You can check the address using 'bdinfo' command (look at 'relocaddr' in the output). There are also some data structures in RAM (global data, board info, stack, malloc area) and also exception vectors. Where it is located in RAM depends on your architecture and board configuration options. You can try to define DEBUG in the arch board.c file to get more info. Board config file should define CONFIG_SYS_MEMTEST_START and CONFIG_SYS_MEMTEST_END to prevent crashing when mtest is invoked. HTH, Anatolij ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 1/3] ARM: I2C: I2C Multi byte address support
On Fri, Jan 20, 2012 at 12:05 AM, Heiko Schocher h...@denx.de wrote: Hello Patil, Patil, Rachna schrieb: Existing OMAP I2C driver does not support address length greater than one. Hence this patch is to add support for 2 byte address read/write. Signed-off-by: Philip, Avinash avinashphi...@ti.com Signed-off-by: Hebbar, Gururaja gururaja.heb...@ti.com Signed-off-by: Patil, Rachna rac...@ti.com --- Changes for v2: Fixed review comments from Heiko Schocher drivers/i2c/omap24xx_i2c.c | 468 drivers/i2c/omap24xx_i2c.h | 2 + 2 files changed, 298 insertions(+), 172 deletions(-) Sorry, your patch did not apply, nor on u-boot.git master nor on u-boot-ti-git master: [hs@pollux u-boot-i2c]$ git am 20120120/0001.patch Applying: ARM: I2C: I2C Multi byte address support error: patch failed: drivers/i2c/omap24xx_i2c.c:29 error: drivers/i2c/omap24xx_i2c.c: patch does not apply error: patch failed: drivers/i2c/omap24xx_i2c.h:60 error: drivers/i2c/omap24xx_i2c.h: patch does not apply Patch failed at 0001 ARM: I2C: I2C Multi byte address support When you have resolved this problem run git am --resolved. If you would prefer to skip this patch, instead run git am --skip. To restore the original branch and stop patching run git am --abort. [hs@pollux u-boot-i2c]$ [hs@pollux u-boot-ti]$ git am ../u-boot-i2c/20120120/0001.patch Applying: ARM: I2C: I2C Multi byte address support error: patch failed: drivers/i2c/omap24xx_i2c.c:29 error: drivers/i2c/omap24xx_i2c.c: patch does not apply Patch failed at 0001 ARM: I2C: I2C Multi byte address support When you have resolved this problem run git am --resolved. If you would prefer to skip this patch, instead run git am --skip. To restore the original branch and stop patching run git am --abort. [hs@pollux u-boot-ti]$ ... please rebase. @tom: If you want to pick up this patchserie, I can Ack it ... I'm fine with you taking up the series, once it applies. Thanks! -- Tom ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2 V2] arm926: Flush the data cache before disabling it.
On Fri, Jan 20, 2012 at 12:28 AM, Christian Riesch christian.rie...@omicron.at wrote: On Thu, Jan 19, 2012 at 12:54 PM, Aneesh V ane...@ti.com wrote: On Thursday 19 January 2012 05:00 PM, Christian Riesch wrote: On Thu, Jan 19, 2012 at 11:17 AM, Aneesh Vane...@ti.com wrote: On Thursday 19 January 2012 12:23 PM, Sughosh Ganu wrote: Tried a few things on my end. * Read the D-cache value in the spl, and confirmed that the data cache is indeed not enabled. What is the value of the B bit in CP15 SCR register? I wonder if RBL is doing all the IMB operations required after copying the SPL image and before executing it. IMB is required for consistency between data and instruction sides. Only if caches are used, right? Or also without caches? Tom wrote that RBL does not turn on cache. Regards, Christian Only D-cache seems to be disabled in this case. I-cache and Write buffer are likely to be enabled. If so, all the IMB operations except the data-cache flushing are still relevant. Tom, when you wrote that RBL does not turn on caches, did you mean it never turns it on or it turns some of them on and turns them off before exit? I'm away from the code atm (and when I get back I can point Aneesh at it as well), but DCACHE is never enabled and I'm thinking ICACHE too. -- Tom ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2 V2] arm926: Flush the data cache before disabling it.
On Friday 20 January 2012 02:51 PM, Christian Riesch wrote: Hi Aneesh, On Fri, Jan 20, 2012 at 9:52 AM, Aneesh Vane...@ti.com wrote: Sughosh, [...] Can you send the value of SCR you found at SPL entry? This will clarify what's enabled and what's not. I would like to try that on my board as well for comparison. Could you please tell me how this register can be read? In the ARM manuals SCR seems to have several meanings... Thank you! Regards, Christian If you have a JTAG based debugger that has the capability of displaying CP15 registers, look for CP15 System Control Register. Otherwise you will have to read it using an assembly instruction like below: mrc p15, 0, r0, c1, c0, 0 After this instruction r0 will contain the SCR value. arm926ejs/start.S has this instruction at line #367. You can put a breakpoint after this and look at r0. br, Aneesh ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2 V2] arm926: Flush the data cache before disabling it.
Hi Aneesh, On Fri, Jan 20, 2012 at 1:13 PM, Aneesh V ane...@ti.com wrote: On Friday 20 January 2012 02:51 PM, Christian Riesch wrote: On Fri, Jan 20, 2012 at 9:52 AM, Aneesh Vane...@ti.com wrote: Sughosh, [...] Can you send the value of SCR you found at SPL entry? This will clarify what's enabled and what's not. I would like to try that on my board as well for comparison. Could you please tell me how this register can be read? In the ARM manuals SCR seems to have several meanings... Thank you! Regards, Christian If you have a JTAG based debugger that has the capability of displaying CP15 registers, look for CP15 System Control Register. Otherwise you will have to read it using an assembly instruction like below: mrc p15, 0, r0, c1, c0, 0 After this instruction r0 will contain the SCR value. arm926ejs/start.S has this instruction at line #367. You can put a breakpoint after this and look at r0. Thank you! I don't have a JTAG debugger so I stored it in a register, pushed it later to the stack and then read it with md.l from the memory. I tried it on my custom board (AM1808 SoC, direct boot from NOR flash) and on both the da850evm (with AM1808 SoC, AIS boot from SPI flash). The result was the same for both cases, 0x00052078. So DCache and ICache are disabled after the RBL. Regards, Christian ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2 V2] arm926: Flush the data cache before disabling it.
Hi Christian, On Friday 20 January 2012 06:18 PM, Christian Riesch wrote: Hi Aneesh, On Fri, Jan 20, 2012 at 1:13 PM, Aneesh Vane...@ti.com wrote: On Friday 20 January 2012 02:51 PM, Christian Riesch wrote: On Fri, Jan 20, 2012 at 9:52 AM, Aneesh Vane...@ti.comwrote: Sughosh, [...] Can you send the value of SCR you found at SPL entry? This will clarify what's enabled and what's not. I would like to try that on my board as well for comparison. Could you please tell me how this register can be read? In the ARM manuals SCR seems to have several meanings... Thank you! Regards, Christian If you have a JTAG based debugger that has the capability of displaying CP15 registers, look for CP15 System Control Register. Otherwise you will have to read it using an assembly instruction like below: mrc p15, 0, r0, c1, c0, 0 After this instruction r0 will contain the SCR value. arm926ejs/start.S has this instruction at line #367. You can put a breakpoint after this and look at r0. Thank you! I don't have a JTAG debugger so I stored it in a register, pushed it later to the stack and then read it with md.l from the memory. I tried it on my custom board (AM1808 SoC, direct boot from NOR flash) and on both the da850evm (with AM1808 SoC, AIS boot from SPI flash). The result was the same for both cases, 0x00052078. So DCache and ICache are disabled after the RBL. Regards, Christian Hmm.. That's different from the OMAP processors I have seen. At least OMAP4, that I verified again now, leaves the I-cache enabled (0x00C51878) So, Sughosh's problem still remains a mystery:) br, Aneesh ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] [v2] mtd/nand: Fix IFC driver to support 2K NAND page
1) OOB area should be updated irrespective of NAND page size. Earlier it was updated only for 512byte NAND page. 2) During OOB update fbcr should be equal to OOB size. Signed-off-by: Poonam Aggrwal poonam.aggr...@freescale.com Signed-off-by: Prabhakar Kushwaha prabha...@freescale.com --- Based upon git://git.denx.de/u-boot.git (branch master) Changes for v2- Incorporated Scott's comments from linuxppc-dev mailing list http://patchwork.ozlabs.org/patch/135010/ - Added missed NAND_CMD_READOOB - Updated function as per Scott's advice drivers/mtd/nand/fsl_ifc_nand.c | 27 +-- 1 files changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c index cd1a434..27d2028 100644 --- a/drivers/mtd/nand/fsl_ifc_nand.c +++ b/drivers/mtd/nand/fsl_ifc_nand.c @@ -452,21 +452,19 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, out_be32(ifc-ifc_nand.nand_fir1, (IFC_FIR_OP_CW1 IFC_NAND_FIR1_OP5_SHIFT)); - if (column = mtd-writesize) { - /* OOB area -- READOOB */ - column -= mtd-writesize; - nand_fcr0 |= NAND_CMD_READOOB - IFC_NAND_FCR0_CMD0_SHIFT; - ctrl-oob = 1; - } else if (column 256) { - /* First 256 bytes -- READ0 */ - nand_fcr0 |= NAND_CMD_READ0 FCR_CMD0_SHIFT; - } else { - /* Second 256 bytes -- READ1 */ - nand_fcr0 |= NAND_CMD_READ1 FCR_CMD0_SHIFT; - } + if (column = mtd-writesize) + nand_fcr0 |= + NAND_CMD_READOOB IFC_NAND_FCR0_CMD0_SHIFT; + else + nand_fcr0 |= + NAND_CMD_READ0 IFC_NAND_FCR0_CMD0_SHIFT; } + if (column = mtd-writesize) { + /* OOB area -- READOOB */ + column -= mtd-writesize; + ctrl-oob = 1; + } out_be32(ifc-ifc_nand.nand_fcr0, nand_fcr0); set_addr(mtd, column, page_addr, ctrl-oob); return; @@ -475,7 +473,8 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, /* PAGEPROG reuses all of the setup from SEQIN and adds the length */ case NAND_CMD_PAGEPROG: if (ctrl-oob) - out_be32(ifc-ifc_nand.nand_fbcr, ctrl-index); + out_be32(ifc-ifc_nand.nand_fbcr, + ctrl-index - ctrl-column); else out_be32(ifc-ifc_nand.nand_fbcr, 0); -- 1.7.5.4 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] mtd/nand:Fix wrong usage of is_blank() in fsl_ifc_run_command
Freescale IFC NAND Machine calculates ECC on 512byte sector and same is used in fsl_ifc_run_command() during ECC status verification. Also this sector is passed to is_blank() for blank checking. It is wrong at first place because is_blank()'s implementation checks for Page size and OOB area size. is_blank() should be called per page for main and OOB area verification. Variables name are redefined to avoid confusion between buffer and ecc sector. Signed-off-by: Poonam Aggrwal poonam.aggr...@freescale.com Signed-off-by: Scott Wood scottw...@freescale.com Signed-off-by: Prabhakar Kushwaha prabha...@freescale.com --- Applied upon git://git.denx.de/u-boot.git (branch master) This patch is based upon ifc driver patch in linuxppc-dev mailing list http://patchwork.ozlabs.org/patch/136547/ It is a replacement of my earlier patch mtd/nand:Fix wrong address read in is_blank() http://patchwork.ozlabs.org/patch/133388/ drivers/mtd/nand/fsl_ifc_nand.c | 52 +-- 1 files changed, 28 insertions(+), 24 deletions(-) diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c index b3f3c3c..cd1a434 100644 --- a/drivers/mtd/nand/fsl_ifc_nand.c +++ b/drivers/mtd/nand/fsl_ifc_nand.c @@ -1,6 +1,6 @@ /* Integrated Flash Controller NAND Machine Driver * - * Copyright (c) 2011 Freescale Semiconductor, Inc + * Copyright (c) 2012 Freescale Semiconductor, Inc * * Authors: Dipen Dudhat dipen.dud...@freescale.com * @@ -221,24 +221,11 @@ static int check_read_ecc(struct mtd_info *mtd, struct fsl_ifc_ctrl *ctrl, u32 *eccstat, unsigned int bufnum) { u32 reg = eccstat[bufnum / 4]; - int errors = (reg ((3 - bufnum % 4) * 8)) 15; - - if (errors == 15) { /* uncorrectable */ - /* Blank pages fail hw ECC checks */ - if (is_blank(mtd, ctrl, bufnum)) - return 1; - - /* -* We disable ECCER reporting in hardware due to -* erratum IFC-A002770 -- so report it now if we -* see an uncorrectable error in ECCSTAT. -*/ - ctrl-status |= IFC_NAND_EVTER_STAT_ECCER; - } else if (errors 0) { - mtd-ecc_stats.corrected += errors; - } + int errors; - return 0; + errors = (reg ((3 - bufnum % 4) * 8)) 15; + + return errors; } /* @@ -279,16 +266,33 @@ static int fsl_ifc_run_command(struct mtd_info *mtd) printf(%s: Write Protect Error\n, __func__); if (ctrl-eccread) { - int bufperpage = mtd-writesize / 512; - int bufnum = (ctrl-page priv-bufnum_mask) * bufperpage; - int bufnum_end = bufnum + bufperpage - 1; + int errors; + int bufnum = ctrl-page priv-bufnum_mask; + int sector = bufnum * chip-ecc.steps; + int sector_end = sector + chip-ecc.steps - 1; - for (i = bufnum / 4; i = bufnum_end / 4; i++) + for (i = sector / 4; i = sector_end / 4; i++) eccstat[i] = in_be32(ifc-ifc_nand.nand_eccstat[i]); - for (i = bufnum; i = bufnum_end; i++) { - if (check_read_ecc(mtd, ctrl, eccstat, i)) + for (i = sector; i = sector_end; i++) { + errors = check_read_ecc(mtd, ctrl, eccstat, i); + + if (errors == 15) { + /* +* Uncorrectable error. +* OK only if the whole page is blank. +* +* We disable ECCER reporting due to... +* erratum IFC-A002770 -- so report it now if we +* see an uncorrectable error in ECCSTAT. +*/ + if (!is_blank(mtd, ctrl, bufnum)) + ctrl-status |= + IFC_NAND_EVTER_STAT_ECCER; break; + } + + mtd-ecc_stats.corrected += errors; } ctrl-eccread = 0; -- 1.7.5.4 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [u-boot]
Hi, I am new to U-Boot, how do I get started? -- *Thanks Regards** * *periyasamy.R* ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] New MIPS64R2 Target in QEMU
I am trying to emulate a new MIPS64R2 based target in QEMU, which actually uses U-Boot as a bootloader. Can I skip U-Boot and and directly load the kernel as it is done in Matla Mips 64 board?? ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 6/6] mx6q: mx6qsabrelite: Provide defaults for placing environment in serial flash
On 01/19/2012 08:27 PM, Jason Hui wrote: On Wed, Jan 18, 2012 at 6:09 AM, Eric Nelson eric.nel...@boundarydevices.com wrote: Signed-off-by: Eric Nelsoneric.nel...@boundarydevices.com --- include/configs/mx6qsabrelite.h | 12 +++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/include/configs/mx6qsabrelite.h b/include/configs/mx6qsabrelite.h index 44b028a..160894c 100644 --- a/include/configs/mx6qsabrelite.h +++ b/include/configs/mx6qsabrelite.h @@ -174,10 +174,20 @@ /* FLASH and environment organization */ #define CONFIG_SYS_NO_FLASH -#define CONFIG_ENV_OFFSET (6 * 64 * 1024) #define CONFIG_ENV_SIZE(8 * 1024) + #define CONFIG_ENV_IS_IN_MMC +/* #define CONFIG_ENV_IS_IN_SPI_FLASH */ From the commit log, it says the default is in serial flash, but apparently in the code the env is default to MMC, which mismatch. please fix it. You're asking that I change the comment not the default, right? + +#if defined(CONFIG_ENV_IS_IN_MMC) +#define CONFIG_ENV_OFFSET (6 * 64 * 1024) #define CONFIG_SYS_MMC_ENV_DEV 0 +#elif defined(CONFIG_ENV_IS_IN_SPI_FLASH) +#define CONFIG_ENV_OFFSET (768 * 1024) +#define CONFIG_ENV_SECT_SIZE (8 * 1024) +#define CONFIG_ENV_SPI_CS 0x5300 I'm wondering how the CONFIG_ENV_SPI_CS could be 0x5300? Vague? Please review the updated patch below and see whether the expanded commit message fixes things. Regards, Eric commit 0443433bf80c5203a8ce67fb4faaf4032e398e1d Author: Eric Nelson eric.nel...@boundarydevices.com Date: Tue Jan 17 14:11:54 2012 -0700 mx6q: mx6qsabrelite: Provide macros for environment in serial flash The default settings store the persistent environment on SD card and not serial flash (SPI NOR). To use SPI NOR to save the environment instead of SD card, edit include/configs/mx6qsabrelite.h and - undefine CONFIG_ENV_IS_IN_MMC - define CONFIG_ENV_IS_IN_SPI_FLASH Note that the mxc_spi driver (drivers/spi/mxc_spi.c) uses the Chip-Select variable (CONFIG_ENV_SPI_CS) to allow the use of a GPIO if the chip-select is greater than 3. The low 8-bits set the chip select number and bits 8-15 set the GPIO number. The GPIO used on Sabre Lite is GP3:19 == 83. Signed-off-by: Eric Nelson eric.nel...@boundarydevices.com diff --git a/include/configs/mx6qsabrelite.h b/include/configs/mx6qsabrelite.h index e34f108..024a94c 100644 --- a/include/configs/mx6qsabrelite.h +++ b/include/configs/mx6qsabrelite.h @@ -174,10 +174,20 @@ /* FLASH and environment organization */ #define CONFIG_SYS_NO_FLASH -#define CONFIG_ENV_OFFSET (6 * 64 * 1024) #define CONFIG_ENV_SIZE(8 * 1024) + #define CONFIG_ENV_IS_IN_MMC +/* #define CONFIG_ENV_IS_IN_SPI_FLASH */ + +#if defined(CONFIG_ENV_IS_IN_MMC) +#define CONFIG_ENV_OFFSET (6 * 64 * 1024) #define CONFIG_SYS_MMC_ENV_DEV 0 +#elif defined(CONFIG_ENV_IS_IN_SPI_FLASH) +#define CONFIG_ENV_OFFSET (768 * 1024) +#define CONFIG_ENV_SECT_SIZE (8 * 1024) +#define CONFIG_ENV_SPI_CS (0|(838)) +#define CONFIG_ENV_SPI_MODESPI_MODE_0 +#endif #define CONFIG_OF_LIBFDT ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 6/6] mx6q: mx6qsabrelite: Provide defaults for placing environment in serial flash
On 01/20/2012 01:47 AM, Stefano Babic wrote: On 20/01/2012 08:48, Jason Hui wrote: I'm wondering how the CONFIG_ENV_SPI_CS could be 0x5300? Vague? Then the left open question is only above one. The SPI driver can take as chip select the controller's chip selects as well as an external GPIO. The LSB byte has the value of the internal chip select, the highest (thought as 16-bit value) contains the GPIO number. Reading this configuration, the GPIO used on this board should be the number 83 (0x53). Stefano Thanks Stefano, I like your description better than the one I just wrote... I should have scanned all of my e-mails before drafting my earlier commit msg ;) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] mx6qsabrelite U-Boot from SPI-NOR
On 01/20/2012 02:15 AM, Wolfgang Grandegger wrote: On 01/20/2012 01:56 AM, Eric Nelson wrote: Yes. If you program u-boot.imx to offset 0x400, it will boot. I just did so as shown below. I started by placing SW1 in the 01 position (boot to USB), and used imx_usb to dowload u-boot.imx: MX6QSABRELITE U-Boot dhcp 1080 192.168.0.112:u-boot.imx fec_open:Speed=100 BOOTP broadcast 1 BOOTP broadcast 2 DHCP client bound to address 29.6.1.24 Using FEC device TFTP from server 192.168.0.112; our IP address is 29.6.1.24; sending through gateway 29.6.1.1 Filename 'u-boot.imx'. Load address: 0x1080 Loading: # done Bytes transferred = 207112 (32908 hex) MX6QSABRELITE U-Boot sf write 0x1080 0x400 $filesize But above you used the network to load u-boot.imx. With imx_usb you loaded and booted an image via USB first, I assume. Yeah. USB to execute U-Boot, then Ethernet to get a pristine image into RAM for programming. I'd love to get USB support for MX6Q into U-Boot, but that's another project... ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 01/28] net: Remove volatile from all of net except the eth driver interface
Hi Joe, On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: The mv_eth driver should not redefine the net function definition Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- board/Marvell/db64360/mv_eth.c | 2 -- board/Marvell/db64460/mv_eth.c | 2 -- board/esd/cpci750/mv_eth.c | 2 -- board/prodrive/p3mx/mv_eth.c | 2 -- include/net.h | 16 net/bootp.c | 4 ++-- net/net.c | 40 net/rarp.c | 2 +- net/tftp.c | 6 +++--- 9 files changed, 34 insertions(+), 42 deletions(-) diff --git a/board/Marvell/db64360/mv_eth.c b/board/Marvell/db64360/mv_eth.c index 6340585..550610e 100644 --- a/board/Marvell/db64360/mv_eth.c +++ b/board/Marvell/db64360/mv_eth.c @@ -95,8 +95,6 @@ int mv64360_eth_xmit (struct eth_device *, volatile void *packet, int length); #ifndef UPDATE_STATS_BY_SOFTWARE static void mv64360_eth_print_stat (struct eth_device *dev); #endif -/* Processes a received packet */ -extern void NetReceive (volatile uchar *, int); extern unsigned int INTERNAL_REG_BASE_ADDR; diff --git a/board/Marvell/db64460/mv_eth.c b/board/Marvell/db64460/mv_eth.c index 4aefbaf..c447229 100644 --- a/board/Marvell/db64460/mv_eth.c +++ b/board/Marvell/db64460/mv_eth.c @@ -95,8 +95,6 @@ int mv64460_eth_xmit (struct eth_device *, volatile void *packet, int length); #ifndef UPDATE_STATS_BY_SOFTWARE static void mv64460_eth_print_stat (struct eth_device *dev); #endif -/* Processes a received packet */ -extern void NetReceive (volatile uchar *, int); extern unsigned int INTERNAL_REG_BASE_ADDR; diff --git a/board/esd/cpci750/mv_eth.c b/board/esd/cpci750/mv_eth.c index 001c1ad..db2324b 100644 --- a/board/esd/cpci750/mv_eth.c +++ b/board/esd/cpci750/mv_eth.c @@ -95,8 +95,6 @@ int mv64360_eth_xmit (struct eth_device *, volatile void *packet, int length); #ifndef UPDATE_STATS_BY_SOFTWARE static void mv64360_eth_print_stat (struct eth_device *dev); #endif -/* Processes a received packet */ -extern void NetReceive (volatile uchar *, int); extern unsigned int INTERNAL_REG_BASE_ADDR; diff --git a/board/prodrive/p3mx/mv_eth.c b/board/prodrive/p3mx/mv_eth.c index 15b3bfc..f26ded8 100644 --- a/board/prodrive/p3mx/mv_eth.c +++ b/board/prodrive/p3mx/mv_eth.c @@ -109,8 +109,6 @@ int phy_setup_aneg (char *devname, unsigned char addr); #ifndef UPDATE_STATS_BY_SOFTWARE static void mv64460_eth_print_stat (struct eth_device *dev); #endif -/* Processes a received packet */ -extern void NetReceive (volatile uchar *, int); extern unsigned int INTERNAL_REG_BASE_ADDR; diff --git a/include/net.h b/include/net.h index e4d42c2..ccdb01d 100644 --- a/include/net.h +++ b/include/net.h @@ -342,9 +342,9 @@ extern uchar NetOurEther[6]; /* Our ethernet address */ extern uchar NetServerEther[6]; /* Boot server enet address */ extern IPaddr_t NetOurIP; /* Our IP addr (0 = unknown) */ extern IPaddr_t NetServerIP; /* Server IP addr (0 = unknown) */ -extern volatile uchar * NetTxPacket; /* THE transmit packet */ -extern volatile uchar * NetRxPackets[PKTBUFSRX];/* Receive packets */ -extern volatile uchar * NetRxPacket; /* Current receive packet */ +extern uchar *NetTxPacket; /* THE transmit packet */ +extern uchar *NetRxPackets[PKTBUFSRX];/* Receive packets */ +extern uchar *NetRxPacket; /* Current receive packet */ extern int NetRxPacketLen; /* Current rx packet length */ extern unsigned NetIPID; /* IP ID (counting) */ extern uchar NetBcastAddr[6]; /* Ethernet boardcast address */ @@ -408,10 +408,10 @@ extern void NetStartAgain(void); extern int NetEthHdrSize(void); /* Set ethernet header; returns the size of the header */ -extern int NetSetEther(volatile uchar *, uchar *, uint); +extern int NetSetEther(uchar *, uchar *, uint); /* Set IP header */ -extern void NetSetIP(volatile uchar *, IPaddr_t, int, int, int); +extern void NetSetIP(uchar *, IPaddr_t, int, int, int); /* Checksum */ extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */ @@ -423,7 +423,7 @@ extern void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */ extern void NetSetTimeout(ulong, thand_f *);/* Set timeout handler */ /* Transmit NetTxPacket */ -extern void NetSendPacket(volatile uchar *, int); +extern void NetSendPacket(uchar *, int); /* Transmit UDP packet, performing
Re: [U-Boot] [PATCH 02/28] net: cosmetic: checkpatch compliance
Hi Joe, On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- common/main.c | 1 - drivers/net/netconsole.c | 122 + include/common.h | 4 + include/net.h | 123 + net/bootp.c | 338 +++--- net/bootp.h | 56 net/eth.c | 66 +- net/net.c | 19 +-- net/nfs.c | 300 - net/nfs.h | 2 +- net/rarp.c | 28 ++-- net/rarp.h | 4 +- net/sntp.c | 31 +++-- net/sntp.h | 2 +- net/tftp.c | 30 ++--- net/tftp.h | 2 +- 16 files changed, 572 insertions(+), 556 deletions(-) Others may fine with it, but it might be worth splitting this very long patch, perhaps split out some of the larger files or the show_activity() change. Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 5/6] tegra: nand: Add Tegra NAND driver
On 01/13/2012 04:10 PM, Simon Glass wrote: From: Jim Lin ji...@nvidia.com A device tree is used to configure the NAND, including memory timings and block/pages sizes. If this node is not present or is disabled, then NAND will not be initialized. Signed-off-by: Simon Glass s...@chromium.org diff --git a/drivers/mtd/nand/tegra2_nand.c b/drivers/mtd/nand/tegra2_nand.c +/** + * Wait for command completion + * + * @param reg nand_ctlr structure + * @return + * 1 - Command completed + * 0 - Timeout + */ +static int nand_waitfor_cmd_completion(struct nand_ctlr *reg) +{ + int i; + u32 reg_val; + + for (i = 0; i NAND_CMD_TIMEOUT_MS * 1000; i++) { + if ((readl(reg-command) CMD_GO) || + !(readl(reg-status) + STATUS_RBSY0) || + !(readl(reg-isr) + ISR_IS_CMD_DONE)) { + udelay(1); + continue; + } + reg_val = readl(reg-dma_mst_ctrl); + /* +* If DMA_MST_CTRL_EN_A_ENABLE or +* DMA_MST_CTRL_EN_B_ENABLE is set, +* that means DMA engine is running, then we +* have to wait until +* DMA_MST_CTRL_IS_DMA_DONE +* is cleared for DMA transfer completion. +*/ + if (reg_val (DMA_MST_CTRL_EN_A_ENABLE | + DMA_MST_CTRL_EN_B_ENABLE)) { + if (reg_val DMA_MST_CTRL_IS_DMA_DONE) + return 1; + } else + return 1; + udelay(1); To be more consistent with the first if/continue block, wouldn't it be better to recast that last if test and udelay as: if (reg_val (DMA_MST_CTRL_EN_A_ENABLE | DMA_MST_CTRL_EN_B_ENABLE)) { if (!(reg_val DMA_MST_CTRL_IS_DMA_DONE)) { udelay(1); continue; } } break; +/** + * [DEFAULT] Send command to NAND device + * + * @param mtd MTD device structure + * @param command the command to be sent + * @param column the column address for this command, -1 if none + * @param page_addrthe page address for this command, -1 if none + */ +static void nand_command(struct mtd_info *mtd, unsigned int command, + int column, int page_addr) +{ + register struct nand_chip *chip = mtd-priv; + struct nand_info *info; + + info = (struct nand_info *) chip-priv; + + /* +* Write out the command to the device. +*/ + if (mtd-writesize 2048) { + /* +* Only command NAND_CMD_RESET or NAND_CMD_READID will come +* here before mtd-writesize is initialized, we don't have +* any action here because page size of NAND HY27UF084G2B +* is 2048 bytes and mtd-writesize will be 2048 after +* initialized. +*/ What if the NAND flash doesn't have a page size of 2048 bytes? The driver shouldn't make such assumptions about the flash chip that happens to be connected. Should the if above be: if (mtd-writesize == 0) to be generic? Should this if branch validate that the command being executed is a legitimate command for the not-yet-fully-initialized case? +/** + * Set up NAND bus width and page size + * + * @param info nand_info structure + * @param *reg_val address of reg_val + * @return none - value is set in reg_val + */ +static void set_bus_width_page_size(struct fdt_nand *config, + u32 *reg_val) +{ + if (config-width == 8) + *reg_val = CFG_BUS_WIDTH_8BIT; + else Shouldn't that be else if (config-width == 16) + *reg_val = CFG_BUS_WIDTH_16BIT; ... and there be an else clause that returns an error? + + if (config-page_data_bytes == 256) + *reg_val |= CFG_PAGE_SIZE_256; + else if (config-page_data_bytes == 512) + *reg_val |= CFG_PAGE_SIZE_512; + else if (config-page_data_bytes == 1024) + *reg_val |= CFG_PAGE_SIZE_1024; + else if (config-page_data_bytes == 2048) + *reg_val |= CFG_PAGE_SIZE_2048; And similarly, and else clause that returns an error here? -- nvpublic ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] About mtest on boot
Okay, got 2011.12 working here. Same problem, my system stalls when I try using mtest on low position of the memory, but now I have the relocaddr var to tell me what is the superior memory limit. ( I can't paste any output here because the list gives me a BASE ENCODE64 not allowed error... ) And if the system freezes during mtest, I can't ctrl+c out of it. Is there any know workaround? My system is much a like MPC8323ERDB. Other than that, seems I can run linux fine on it after bootload, I just can't use mtest... Érico V. Porto On Fri, Jan 20, 2012 at 8:56 AM, Érico Porto ericoporto2...@gmail.comwrote: Now I understood, LTIB is giving me an older u-boot version - 1.1.6 and not 2011.12. Will try to update it... Érico V. Porto On Fri, Jan 20, 2012 at 8:38 AM, Anatolij Gustschin ag...@denx.de wrote: Hi, On Fri, 20 Jan 2012 08:07:41 -0200 Érico Porto ericoporto2...@gmail.com wrote: Hello, I want to stop autoboot and use mtest to check if my ram is alright, but 0x07FD2C00 forward freezes, and 0x0902 also freezes, mtest, when using it. My ramsize is 0x0800. Does u-boot uses any parts of ram by itself, I mean, is there any known spots where I can't test because it would crash my system? U-Boot relocates itself into RAM. You can check the address using 'bdinfo' command (look at 'relocaddr' in the output). There are also some data structures in RAM (global data, board info, stack, malloc area) and also exception vectors. Where it is located in RAM depends on your architecture and board configuration options. You can try to define DEBUG in the arch board.c file to get more info. Board config file should define CONFIG_SYS_MEMTEST_START and CONFIG_SYS_MEMTEST_END to prevent crashing when mtest is invoked. HTH, Anatolij ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 1/8] sandbox: fdt: Add support for CONFIG_OF_CONTROL
On Tuesday 10 January 2012 19:45:45 Simon Glass wrote: This adds support for a controlling fdt, mirroring the ARM implementation. OK, but what's the point if we aren't doing FDT's ? +#ifdef CONFIG_OF_EMBED + /* Get a pointer to the FDT */ + gd-fdt_blob = _binary_dt_dtb_start; +#elif defined CONFIG_OF_SEPARATE + /* FDT is at end of image */ + gd-fdt_blob = (void *)(_end_ofs + _TEXT_BASE); +#endif i'd be inclined to do: +#if defined(CONFIG_OF_EMBED) ... +#elif defined(CONFIG_OF_SEPARATE) ... +#endif -mike signature.asc Description: This is a digitally signed message part. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 2/8] sandbox: config: Enable fdt and snprintf() options
On Tuesday 10 January 2012 19:45:46 Simon Glass wrote: +#define CONFIG_LMB do we need this ? -mike signature.asc Description: This is a digitally signed message part. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 3/8] sandbox: gpio: Add basic driver for simulating GPIOs
On Tuesday 10 January 2012 19:45:47 Simon Glass wrote: This provides a way of simulating GPIOs by setting values which are seen by the normal gpio_get/set_value() calls. seems to be a desync in types ... all gpio fields should be unsigned and not int --- /dev/null +++ b/arch/sandbox/include/asm/gpio.h +int sandbox_gpio_get_value(int gp); why bother with parallel sandbox gpio API ? why can't we just implement the gpio API directly and throw away sandbox_gpio_xxx ? then we can also stub out sandbox/include/asm/gpio.h ... also, missing gpio_status() define to gpio_info() --- /dev/null +++ b/drivers/gpio/sandbox.c +enum { + CMD_INFO, + CMD_PORT, + CMD_OUTPUT, + CMD_INPUT, +}; CMD_XXX enums are unused - punt +enum { + GPIOF_OUTPUT= 1 1, + GPIOF_HIGH = 1 2, +}; turn enum bit flags into defines also, add a reserved bit flag and check it in gpio_request() +/* read GPIO IN value of port 'gp' */ +int gpio_get_value(int gp) ... + if (get_gpio_flag(gp, GPIOF_OUTPUT)) ... +int gpio_set_value(int gp, int value) ... + if (get_gpio_flag(gp, GPIOF_OUTPUT)) { drop valid gpio checking in these funcs ... only the request func should do this +int gpio_request(unsigned gpio, const char *label) +{ + /* for now, do nothing */ + return 0; +} add (gpio = CONFIG_SANDBOX_GPIO_COUNT) check to verify the gpio is valid +int gpio_info(int gp) +{ + printf(Sandbox GPIOs\n); + return 0; +} implement it ? -mike signature.asc Description: This is a digitally signed message part. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 4/8] sandbox: Enable GPIO driver
On Tuesday 10 January 2012 19:45:48 Simon Glass wrote: --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h +#define CONFIG_SANDBOX_GPIO_COUNT224 do we really need 224 examples GPIOs ? can't we do with like 20 ? -mike signature.asc Description: This is a digitally signed message part. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 6/8] sandbox: Allow processing instead of or before main loop
On Tuesday 10 January 2012 19:45:50 Simon Glass wrote: In order to pass command line arguments to sandbox we need to be able to act on them. So take control back at the end of board_init_r() from where we can call the main loop or do something else. does this need to be done this early ? parsing args can easily be done inside main() (as i showed in my patch that added command line support). in terms of processing the state, i think we can just make this into an init func that runs before we let board_init_r tail into main_loop -mike signature.asc Description: This is a digitally signed message part. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 8/8] sandbox: Add basic command line parsing
On Tuesday 10 January 2012 19:45:52 Simon Glass wrote: --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c +static struct option long_options[] = { constify +void os_usage(int err) +{ + if (err 0) + fprintf(stderr, Try `--help' for more information.\n); + fprintf(stderr, u-boot, + a command line test interface to U-Boot\n\n + usage:\tu-boot [-ch]\n + Options:\n + \t-h\tDisplay help\n + \t-c command\tExecute U-Boot command\n); + exit(1); +} os_usage() should only write to stderr/exit(1) if it's an error, otherwise it should use stdout/exit(0) +int os_parse_args(struct sandbox_state *state, int argc, char *argv[]) +{ ... + while ((c = getopt_long(argc, argv, c:h, + long_options, NULL)) != EOF) { pull the optstring (c:h) out of the getopt_long call and put it into a const next to the long_options[] variable and next to opts array + /* Execute command if required */ + if (state-cmd) { + /* TODO: redo this when cmd tidy-up series lands */ +#ifdef CONFIG_SYS_HUSH_PARSER + run_command(state-cmd, 0); +#else + parse_string_outer(state-cmd, FLAG_PARSE_SEMICOLON | + FLAG_EXIT_FROM_LOOP); +#endif i'm not sure how useful -c is since we can already do: ./u-boot some command each to their own i guess ... -mike signature.asc Description: This is a digitally signed message part. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] sandbox: add ifdef protection to os.h
Signed-off-by: Mike Frysinger vap...@gentoo.org --- include/os.h |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/include/os.h b/include/os.h index f3af4f0..c17a8a5 100644 --- a/include/os.h +++ b/include/os.h @@ -25,6 +25,9 @@ * This provides access to useful OS routines from the sandbox architecture */ +#ifndef __OS_H__ +#define __OS_H__ + /** * Access to the OS read() system call * @@ -98,3 +101,5 @@ void os_usleep(unsigned long usec); * \return A monotonic increasing time scaled in nano seconds */ u64 os_get_nsec(void); + +#endif -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 1/3] cmd_mem: replace custom PRINTF() with debug()
Signed-off-by: Mike Frysinger vap...@gentoo.org --- common/cmd_mem.c | 12 +++- 1 files changed, 3 insertions(+), 9 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 9ad932c..5121b22 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -35,12 +35,6 @@ #include watchdog.h #include asm/io.h -#ifdef CMD_MEM_DEBUG -#definePRINTF(fmt,args...) printf (fmt ,##args) -#else -#define PRINTF(fmt,args...) -#endif - static int mod_mem(cmd_tbl_t *, int, int, int, char * const []); /* Display values from last command. @@ -681,7 +675,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_SYS_ALT_MEMTEST) printf (Testing %08x ... %08x:\n, (uint)start, (uint)end); - PRINTF(%s:%d: start 0x%p end 0x%p\n, + debug(%s:%d: start 0x%p end 0x%p\n, __FUNCTION__, __LINE__, start, end); for (;;) { @@ -698,7 +692,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } printf(Iteration: %6d\r, iterations); - PRINTF(\n); + debug(\n); iterations++; /* @@ -789,7 +783,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) pattern = (vu_long) 0x; anti_pattern = (vu_long) 0x; - PRINTF(%s:%d: length = 0x%.8lx\n, + debug(%s:%d: length = 0x%.8lx\n, __FUNCTION__, __LINE__, len); /* -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 2/3] cmd_mem: cmp: unify size code paths
Not only does the source code get simpler, but it also shrinks the compiled object code too. While we're here, tweak the summary message to avoid the plural issue. It isn't that big of a deal, and it's currently wrong anyways in the single (1 byte) case: Total of 1 byte were the same Grammar wise, that should be was rather than were. The new output people should be able to easily figure out: Total of 1 byte(s) were the same Total of 10 byte(s) were the same Signed-off-by: Mike Frysinger vap...@gentoo.org --- common/cmd_mem.c | 52 +++- 1 files changed, 19 insertions(+), 33 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 5121b22..03e7f87 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -263,6 +263,7 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ulong addr1, addr2, count, ngood; int size; int rcode = 0; + const char *type; if (argc != 4) return cmd_usage(cmdtp); @@ -271,6 +272,7 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) */ if ((size = cmd_get_data_size(argv[0], 4)) 0) return 1; + type = size == 4 ? word : size == 2 ? halfword : byte; addr1 = simple_strtoul(argv[1], NULL, 16); addr1 += base_address; @@ -297,39 +299,25 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ngood = 0; while (count-- 0) { + ulong word1, word2; if (size == 4) { - ulong word1 = *(ulong *)addr1; - ulong word2 = *(ulong *)addr2; - if (word1 != word2) { - printf(word at 0x%08lx (0x%08lx) - != word at 0x%08lx (0x%08lx)\n, - addr1, word1, addr2, word2); - rcode = 1; - break; - } - } - else if (size == 2) { - ushort hword1 = *(ushort *)addr1; - ushort hword2 = *(ushort *)addr2; - if (hword1 != hword2) { - printf(halfword at 0x%08lx (0x%04x) - != halfword at 0x%08lx (0x%04x)\n, - addr1, hword1, addr2, hword2); - rcode = 1; - break; - } + word1 = *(ulong *)addr1; + word2 = *(ulong *)addr2; + } else if (size == 2) { + word1 = *(ushort *)addr1; + word2 = *(ushort *)addr2; + } else { + word1 = *(u_char *)addr1; + word2 = *(u_char *)addr2; } - else { - u_char byte1 = *(u_char *)addr1; - u_char byte2 = *(u_char *)addr2; - if (byte1 != byte2) { - printf(byte at 0x%08lx (0x%02x) - != byte at 0x%08lx (0x%02x)\n, - addr1, byte1, addr2, byte2); - rcode = 1; - break; - } + if (word1 != word2) { + printf(%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n, + type, addr1, size, word1, + type, addr2, size, word2); + rcode = 1; + break; } + ngood++; addr1 += size; addr2 += size; @@ -339,9 +327,7 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) WATCHDOG_RESET(); } - printf(Total of %ld %s%s were the same\n, - ngood, size == 4 ? word : size == 2 ? halfword : byte, - ngood == 1 ? : s); + printf(Total of %ld %s(s) were the same\n, ngood, type); return rcode; } -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 3/3] cmd_mem: cmp: convert while() to for() loop
Simplify the code slightly by using a for() loop since this is basically what we're already doing -- incrementing ngood to the value in count. Signed-off-by: Mike Frysinger vap...@gentoo.org --- common/cmd_mem.c |7 ++- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 03e7f87..7a5addc 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -296,9 +296,7 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } #endif - ngood = 0; - - while (count-- 0) { + for (ngood = 0; ngood count; ++ngood) { ulong word1, word2; if (size == 4) { word1 = *(ulong *)addr1; @@ -318,12 +316,11 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) break; } - ngood++; addr1 += size; addr2 += size; /* reset watchdog from time to time */ - if ((count % (64 10)) == 0) + if ((ngood % (64 10)) == 0) WATCHDOG_RESET(); } -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 01/28] net: Remove volatile from all of net except the eth driver interface
Hi Simon, On Fri, Jan 20, 2012 at 10:22 AM, Simon Glass s...@chromium.org wrote: Hi Joe, On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: The mv_eth driver should not redefine the net function definition Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- snip @@ -1454,9 +1454,9 @@ NetReceive(volatile uchar *inpkt, int len) debug(packet received\n); - NetRxPacket = inpkt; + NetRxPacket = (uchar *)inpkt; NetRxPacketLen = len; - et = (Ethernet_t *)inpkt; + et = (Ethernet_t *)NetRxPacket; Why change this? /* too small packet? */ if (len ETHER_HDR_SIZE) @@ -1491,11 +1491,11 @@ NetReceive(volatile uchar *inpkt, int len) */ x = ntohs(et-et_prot); - ip = (IP_t *)(inpkt + E802_HDR_SIZE); + ip = (IP_t *)(NetRxPacket + E802_HDR_SIZE); and these? You are using a global instead of the passed-in local. len -= E802_HDR_SIZE; } else if (x != PROT_VLAN) { /* normal packet */ - ip = (IP_t *)(inpkt + ETHER_HDR_SIZE); + ip = (IP_t *)(NetRxPacket + ETHER_HDR_SIZE); len -= ETHER_HDR_SIZE; } else { /* VLAN packet */ @@ -1519,7 +1519,7 @@ NetReceive(volatile uchar *inpkt, int len) vlanid = cti VLAN_IDMASK; x = ntohs(vet-vet_type); - ip = (IP_t *)(inpkt + VLAN_ETHER_HDR_SIZE); + ip = (IP_t *)(NetRxPacket + VLAN_ETHER_HDR_SIZE); len -= VLAN_ETHER_HDR_SIZE; } This patch removes volatile from the NetRxPacket and all but 1 of the other places that inpkt was assigned. You will notice that the first assignment of inpkt to NetRxPacket casts away the volatile: @@ -1454,9 +1454,9 @@ NetReceive(volatile uchar *inpkt, int len) snip - NetRxPacket = inpkt; + NetRxPacket = (uchar *)inpkt; All the assignments that need a non-volatile pointer now use NetRxPacket instead of inpkt, since it is already assigned and and the same type minus volatile. Best regards, -Joe ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 02/28] net: cosmetic: checkpatch compliance
Hi Simon, On Fri, Jan 20, 2012 at 10:30 AM, Simon Glass s...@chromium.org wrote: Hi Joe, On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- common/main.c | 1 - drivers/net/netconsole.c | 122 + include/common.h | 4 + include/net.h | 123 + net/bootp.c | 338 +++--- net/bootp.h | 56 net/eth.c | 66 +- net/net.c | 19 +-- net/nfs.c | 300 - net/nfs.h | 2 +- net/rarp.c | 28 ++-- net/rarp.h | 4 +- net/sntp.c | 31 +++-- net/sntp.h | 2 +- net/tftp.c | 30 ++--- net/tftp.h | 2 +- 16 files changed, 572 insertions(+), 556 deletions(-) Others may fine with it, but it might be worth splitting this very long patch, perhaps split out some of the larger files or the show_activity() change. I had this separated by file, but figured since the series was pretty long, it is all cosmetic (making separate patches not especially helpful), and it was under the 100kB mail limit that it would be better as a single patch. If it will be a barrier to review, I can split it up again. Best regards, -Joe ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] About mtest on boot
I've partially solved the ctrl+c situatin inserting more check for it into the code. But this isn't really what I was hoping... Any known alternatives? Thanks. Érico V. Porto On Fri, Jan 20, 2012 at 4:22 PM, Érico Porto ericoporto2...@gmail.comwrote: Okay, got 2011.12 working here. Same problem, my system stalls when I try using mtest on low position of the memory, but now I have the relocaddr var to tell me what is the superior memory limit. ( I can't paste any output here because the list gives me a BASE ENCODE64 not allowed error... ) And if the system freezes during mtest, I can't ctrl+c out of it. Is there any know workaround? My system is much a like MPC8323ERDB. Other than that, seems I can run linux fine on it after bootload, I just can't use mtest... Érico V. Porto On Fri, Jan 20, 2012 at 8:56 AM, Érico Porto ericoporto2...@gmail.comwrote: Now I understood, LTIB is giving me an older u-boot version - 1.1.6 and not 2011.12. Will try to update it... Érico V. Porto On Fri, Jan 20, 2012 at 8:38 AM, Anatolij Gustschin ag...@denx.dewrote: Hi, On Fri, 20 Jan 2012 08:07:41 -0200 Érico Porto ericoporto2...@gmail.com wrote: Hello, I want to stop autoboot and use mtest to check if my ram is alright, but 0x07FD2C00 forward freezes, and 0x0902 also freezes, mtest, when using it. My ramsize is 0x0800. Does u-boot uses any parts of ram by itself, I mean, is there any known spots where I can't test because it would crash my system? U-Boot relocates itself into RAM. You can check the address using 'bdinfo' command (look at 'relocaddr' in the output). There are also some data structures in RAM (global data, board info, stack, malloc area) and also exception vectors. Where it is located in RAM depends on your architecture and board configuration options. You can try to define DEBUG in the arch board.c file to get more info. Board config file should define CONFIG_SYS_MEMTEST_START and CONFIG_SYS_MEMTEST_END to prevent crashing when mtest is invoked. HTH, Anatolij ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] nand_util: correct YAFFS image write function
On 01/20/2012 12:17 AM, Kassey Lee wrote: hi, Lei, Scott: I think this is correct, do you have some comments ? Looks right. -Scott ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] USBTTY for CONFIG_USB_GADGET
Hi, Can new UDCs be written for CONFIG_USB_DEVICE or is that deprecated in favour of CONFIG_USB_GADGET? If that is the case and CONFIG_USB_DEVICE is deprecated, if I want to get USBTTY enabled for a currently unsupported UDC I would need to port USBTTY to CONFIG_USB_GADGET; is there interest in that effort or is there some alternative? Thanks, Michael Schwartz ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2] main: unify command parsing functions
Introduce source_commands() which incorporates run_command2() and parts of source(). All command script are now treated the same, that is newlines are accepted within a command script and variable. Signed-off-by: Michael Walle mich...@walle.cc Cc: Wolfgang Denk w...@denx.de Cc: Mike Frysinger vap...@gentoo.org --- changes v2: - unconditionally include malloc.h, fixes compiler warning common/cmd_pxe.c|2 +- common/cmd_source.c | 32 +- common/main.c | 54 +- include/common.h|4 +-- 4 files changed, 38 insertions(+), 54 deletions(-) diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c index 7c0cb66..347fde1 100644 --- a/common/cmd_pxe.c +++ b/common/cmd_pxe.c @@ -537,7 +537,7 @@ static int label_localboot(struct pxe_label *label) printf(running: %s\n, dupcmd); - ret = run_command2(dupcmd, 0); + ret = source_commands(dupcmd, 0); free(dupcmd); diff --git a/common/cmd_source.c b/common/cmd_source.c index 16a627a..33242df 100644 --- a/common/cmd_source.c +++ b/common/cmd_source.c @@ -160,38 +160,8 @@ source (ulong addr, const char *fit_uname) memmove (cmd, (char *)data, len); *(cmd + len) = 0; -#ifdef CONFIG_SYS_HUSH_PARSER /*?? */ - rcode = parse_string_outer (cmd, FLAG_PARSE_SEMICOLON); -#else - { - char *line = cmd; - char *next = cmd; + rcode = source_commands(cmd, 0); - /* -* break into individual lines, -* and execute each line; -* terminate on error. -*/ - while (*next) { - if (*next == '\n') { - *next = '\0'; - /* run only non-empty commands */ - if (*line) { - debug (** exec: \%s\\n, - line); - if (run_command (line, 0) 0) { - rcode = 1; - break; - } - } - line = next + 1; - } - ++next; - } - if (rcode == 0 *line) - rcode = (run_command(line, 0) = 0); - } -#endif free (cmd); return rcode; } diff --git a/common/main.c b/common/main.c index e96c95a..7327821 100644 --- a/common/main.c +++ b/common/main.c @@ -31,9 +31,7 @@ #include watchdog.h #include command.h #include version.h -#ifdef CONFIG_MODEM_SUPPORT #include malloc.h/* for free() prototype */ -#endif #ifdef CONFIG_SYS_HUSH_PARSER #include hush.h @@ -266,26 +264,44 @@ int abortboot(int bootdelay) # endif/* CONFIG_AUTOBOOT_KEYED */ #endif /* CONFIG_BOOTDELAY = 0 */ +static inline int _run_command(const char *cmd, int flag) +{ +#ifndef CONFIG_SYS_HUSH_PARSER + return (run_command(cmd, flag) == -1); +#else + flag = FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP; + return parse_string_outer(cmd, flag); +#endif +} + /* + * Run a series of commands separated by '\n'. + * * Return 0 on success, or != 0 on error. */ -#ifndef CONFIG_CMD_PXE -static inline -#endif -int run_command2(const char *cmd, int flag) +int source_commands(const char *commands, int flag) { -#ifndef CONFIG_SYS_HUSH_PARSER + int rcode = 0; + char *_commands = strdup(commands); + char *stringp = _commands; + char *line; + /* -* run_command can return 0 or 1 for success, so clean up its result. +* break into individual lines and execute each line; +* terminate on error. */ - if (run_command(cmd, flag) == -1) - return 1; + while ((line = strsep(stringp, \n))) { + /* skip empty lines */ + if (*line == '\0') + continue; + if (_run_command(line, flag)) { + rcode = 1; + break; + } + } - return 0; -#else - return parse_string_outer(cmd, - FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP); -#endif + free(_commands); + return rcode; } // @@ -354,7 +370,7 @@ void main_loop (void) int prev = disable_ctrlc(1);/* disable Control C checking */ # endif - run_command2(p, 0); + source_commands(p, 0); # ifdef CONFIG_AUTOBOOT_KEYED disable_ctrlc(prev);/* restore Control C checking */ @@ -399,7 +415,7 @@ void main_loop (void) int prev = disable_ctrlc(1);/* disable Control C checking */ # endif -
Re: [U-Boot] [PATCH 5/6] tegra: nand: Add Tegra NAND driver
On 01/13/2012 05:10 PM, Simon Glass wrote: +/* Information about an attached NAND chip */ +struct fdt_nand { + struct nand_ctlr *reg; + int enabled;/* 1 to enable, 0 to disable */ + struct fdt_gpio_state wp_gpio; /* write-protect GPIO */ + int width; /* bit width, normally 8 */ + int tag_ecc_bytes; /* ECC bytes to be generated for tag bytes */ + int tag_bytes; /* Tag bytes in spare area */ + int data_ecc_bytes; /* ECC bytes for data area */ + int skipped_spare_bytes; + /* + * How many bytes in spare area: + * spare area = skipped bytes + ECC bytes of data area + * + tag bytes + ECC bytes of tag bytes + */ + int page_spare_bytes; + int page_data_bytes;/* Bytes in data area */ + unsigned timing[FDT_NAND_TIMING_COUNT]; s/unsigned/u32/g Likewise, any of these other fields that correspond to device tree fields should be u32 or s32. ...and even when you do mean unsigned int, please spell it out. +struct nand_info { Please do not define struct nand_info when there is already a different nand_info_t. +struct nand_info nand_ctrl; static (or better, dynamic). +/** + * Wait for command completion + * + * @param regnand_ctlr structure + * @return + * 1 - Command completed + * 0 - Timeout + */ +static int nand_waitfor_cmd_completion(struct nand_ctlr *reg) +{ + int i; + u32 reg_val; + + for (i = 0; i NAND_CMD_TIMEOUT_MS * 1000; i++) { + if ((readl(reg-command) CMD_GO) || + !(readl(reg-status) + STATUS_RBSY0) || + !(readl(reg-isr) + ISR_IS_CMD_DONE)) { + udelay(1); + continue; + } + reg_val = readl(reg-dma_mst_ctrl); + /* + * If DMA_MST_CTRL_EN_A_ENABLE or + * DMA_MST_CTRL_EN_B_ENABLE is set, + * that means DMA engine is running, then we + * have to wait until + * DMA_MST_CTRL_IS_DMA_DONE + * is cleared for DMA transfer completion. + */ + if (reg_val (DMA_MST_CTRL_EN_A_ENABLE | + DMA_MST_CTRL_EN_B_ENABLE)) { + if (reg_val DMA_MST_CTRL_IS_DMA_DONE) + return 1; Please don't line up continuation lines with the if-body. E.g. either line up DMA_MST_CTRL_EN_B_ENABLE with DMA_MST_CTRL_EN_A_ENABLE (my preference), or just add another tab (if you want to be a tabs-only purist). + } else + return 1; If braces are used on one side of the if/else, use on both sides. + udelay(1); + } + return 0; +} + +/** + * [DEFAULT] Read one byte from the chip + * + * @param mtdMTD device structure + * @return data byte + * + * Default read function for 8bit bus-width + */ +static uint8_t read_byte(struct mtd_info *mtd) +{ + struct nand_chip *chip = mtd-priv; + int dword_read; s/int/u32/ + struct nand_info *info; + + info = (struct nand_info *) chip-priv; + + dword_read = readl(info-reg-resp); + dword_read = dword_read (8 * info-pio_byte_index); + info-pio_byte_index++; + return (uint8_t) dword_read; No space after casts. What happens when pio_byte_index 3? Please don't assume that upper bits will be ignored, even if that happens to be true on this chip. How does info-reg-resp work? You don't seem to be choosing the dword to read based on pio_byte_index, which suggests that the act of reading resp changes what will be read the next time. But, you read it on each byte, which would advance resp four times too fast if it's simply returning a new dword each time. If the hardware is really auto-advancing resp only on every fourth access, that needs a comment. +/* Hardware specific access to control-lines */ +static void nand_hwcontrol(struct mtd_info *mtd, int cmd, + unsigned int ctrl) +{ +} Don't implement this at all if it doesn't make sense for this hardware. + +/** + * Clear all interrupt status bits + * + * @param regnand_ctlr structure + */ +static void nand_clear_interrupt_status(struct nand_ctlr *reg) +{ + u32 reg_val; + + /* Clear interrupt status */ + reg_val = readl(reg-isr); + writel(reg_val, reg-isr); +} + +/** + * [DEFAULT] Send command to NAND device + * + * @param mtdMTD device structure + * @param commandthe command to be sent + * @param column the column address for this command, -1 if none + * @param page_addr the page address for this command, -1 if none + */ +static void nand_command(struct mtd_info *mtd, unsigned int command, + int column, int page_addr) +{ + register struct nand_chip *chip = mtd-priv; Are you really seeing any difference by using
Re: [U-Boot] [PATCH v3 4/9] tegra: Add keyboard support to funcmux
On 01/16/2012 11:11 PM, Simon Glass wrote: Add funcmux support for the default keyboard mapping. Signed-off-by: Simon Glass s...@chromium.org diff --git a/arch/arm/cpu/armv7/tegra2/funcmux.c b/arch/arm/cpu/armv7/tegra2/funcmux.c + case PERIPH_ID_KBC: + if (config == FUNCMUX_DEFAULT) { + enum pmux_pingrp grp[] = {PINGRP_KBCA, PINGRP_KBCB, + PINGRP_KBCC, PINGRP_KBCD, PINGRP_KBCE, + PINGRP_KBCF}; + int i; + + for (i = 0; i ARRAY_SIZE(grp); i++) { + pinmux_tristate_disable(grp[i]); + pinmux_set_func(grp[i], PMUX_FUNC_KBC); + pinmux_set_pullupdown(grp[i], PMUX_PULL_UP); Don't you only want to pull up the rows (or the columns) not both? I guess it won't hurt to do both, but it's probably wasting power. -- nvpublic ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 5/9] tegra: fdt: Add keyboard controller definition
On 01/16/2012 11:11 PM, Simon Glass wrote: From: Anton Staff robot...@chromium.org The Tegra keyboard controller provides a simple interface to a matrix keyboard. diff --git a/arch/arm/dts/tegra20.dtsi b/arch/arm/dts/tegra20.dtsi + kbc@7000e200 { + compatible = nvidia,tegra20-kbc; + reg = 0x7000e200 0x0078; + }; The KBC has interrupts to, which should be added to the .dtsi even if you don't use them. I think you want: interrupts = 0 85 0x04; -- nvpublic ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2] main: unify command parsing functions
Am Freitag 20 Januar 2012, 23:46:51 schrieb Michael Walle: Introduce source_commands() which incorporates run_command2() and parts of source(). All command script are now treated the same, that is newlines are accepted within a command script and variable. Signed-off-by: Michael Walle mich...@walle.cc Cc: Wolfgang Denk w...@denx.de Cc: Mike Frysinger vap...@gentoo.org --- changes v2: - unconditionally include malloc.h, fixes compiler warning Actually, this patch is v3. Sorry. -- Michael ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 7/9] tegra: Add tegra keyboard driver
On 01/16/2012 11:11 PM, Simon Glass wrote: From: Rakesh Iyer ri...@nvidia.com Add support for internal matrix keyboard controller for Nvidia Tegra platforms. This driver uses the fdt decode function to obtain its key codes. ... +static uchar *create_keymap(u32 *data, int len, int map_keycode, int *pos) ... + entry = row * KBC_MAX_COL + col; + map[entry] = key_code; This needs to be range-checked. + if (pos map_keycode == key_code) + *pos = entry; + } + + return map; +} +static int fdt_decode_kbc(const void *blob, int node, struct keyb *config) ... + /* Name needs to match 1,typekeymap */ + debug(%s: property '%s'\n, __func__, name); + if (strncmp(name, 1,, 2) || len 8 || + strcmp(name + len - 6, keymap)) + continue; linux, not l,. Why not just strcmp against the two values simply and directly; the above matches against totally bogus stuff like l,bogus-cruft-keymap. + + len -= 8; No need for that right? +static int init_tegra_keyboard(void) ... + if (config.fn_keycode) { + if (input_add_table(config.input, KEY_FN, -1, + config.fn_keycode, KBC_KEY_COUNT)) + return -1; + } I don't see anywhere that calls input_add_table() for config.plain_keycode. +int drv_keyboard_init(void) +{ + struct stdio_dev dev; + + if (input_init(config.input, 0)) { + debug(%s: Cannot set up input\n, __func__); + return -1; + } + config.input.read_keys = tegra_kbc_check; Don't you want to set up config.input.* before passing it to input_init() which might in theory use it? diff --git a/include/tegra-kbc.h b/include/tegra-kbc.h +#define KEY_IS_MODIFIER(key) ((key) = KEY_FIRST_MODIFIER) Shouldn't that be in the input layer or the file that defines the key codes? -- nvpublic ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] sandbox: add ifdef protection to os.h
On Fri, Jan 20, 2012 at 11:07 AM, Mike Frysinger vap...@gentoo.org wrote: Signed-off-by: Mike Frysinger vap...@gentoo.org Acked-by: Simon Glass s...@chromium.org --- include/os.h | 5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/include/os.h b/include/os.h index f3af4f0..c17a8a5 100644 --- a/include/os.h +++ b/include/os.h @@ -25,6 +25,9 @@ * This provides access to useful OS routines from the sandbox architecture */ +#ifndef __OS_H__ +#define __OS_H__ + /** * Access to the OS read() system call * @@ -98,3 +101,5 @@ void os_usleep(unsigned long usec); * \return A monotonic increasing time scaled in nano seconds */ u64 os_get_nsec(void); + +#endif -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2] main: unify command parsing functions
Hi Michael, On Fri, Jan 20, 2012 at 3:37 PM, Michael Walle mich...@walle.cc wrote: Am Freitag 20 Januar 2012, 23:46:51 schrieb Michael Walle: Introduce source_commands() which incorporates run_command2() and parts of source(). All command script are now treated the same, that is newlines are accepted within a command script and variable. Signed-off-by: Michael Walle mich...@walle.cc Cc: Wolfgang Denk w...@denx.de Cc: Mike Frysinger vap...@gentoo.org --- changes v2: - unconditionally include malloc.h, fixes compiler warning Actually, this patch is v3. Sorry. This series seems to touch similar things my command execution refactor starting here: http://patchwork.ozlabs.org/patch/136069/ If nothing else, that series looks like it would simplify your patch a lot. You may have comments also since you have been in the same code. Regards, Simon -- Michael ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] ARM: tegra: Define Tegra20 CAR binding
Hi, On Thu, Jan 19, 2012 at 9:17 AM, Stephen Warren swar...@nvidia.com wrote: Olof Johansson wrote at Wednesday, January 18, 2012 10:32 PM: On Wed, Jan 18, 2012 at 05:16:52PM -0700, Stephen Warren wrote: diff --git a/Documentation/devicetree/bindings/clock/nvidia,tegra20-car.txt +* NVIDIA Tegra20 Clock And Reset Controller + +This binding uses the common clock binding: +Documentation/devicetree/bindings/clock/clock-bindings.txt + +The CAR (Clock And Reset) Controller on Tegra is the HW module responsible +for muxing and gating Tegra's clocks, and setting their rates. + +Required properties : +- compatible : Should be nvidia,chip-car +- reg : Should contain CAR registers location and length +- clocks : Should contain phandle and clock specifiers for two clocks: + the 32 KHz 32k_in, and the board-specific oscillator osc. +- clock-names : Should contain a list of strings, with values 32k_in, + and osc. Hmm. I'd prefer to just ditch the notion of clock-names in the cases where it isn't strictly necessary. Just because some vendors don't want to define an order between their clocks doesn't mean it's a good idea for everybody to use that model. In this case, just declaring that the two clocks refs have to be to those two clocks in that order should be sufficient. OK, that seems reasonable. I'm happy using of_clk_get() rather than of_clk_get_by_name(). I guess that means we should just avoid any discussion of clock-output-names too. Sounds good to me. Let's make sure Grant is OK with it too though. +- #clock-cells : Should be 1. + In clock consumers, this cell represents the clock ID exposed by the CAR. + For a list of valid values, see the clock-output-names property. + +Optional properties : +- clock-output-names : Should contain a list of strings defining the clocks + that the CAR provides. The list of names and clock IDs is below. The IDs + may be used in clock specifiers. The names should be listed in this clock- + output-names property, sorted in ID order, if this property is present. + + The first 96 clocks are numbered to match the bits in the CAR's CLK_OUT_ENB + registers. Later, subsequent IDs will be assigned to all other clocks the + CAR controls. Aren't these names hardcoded per SoC? If so, they can be derived from the compatible field + output number without having a table in the device tree. If anything, you might want to enumerate the allowed/expected values, but actually putting them in a property seems overkill. Yes, the set of clocks is hard-coded per SoC, and the clock is uniquely identified by compatible+id. clock-output-names doesn't actually serve any functional purpose in Grant's common clock bindings patches; it's more of a documentation thing. As such, yes, I can remove the suggestion to actually put the table into the device tree, and rework the binding to simply define what the mapping is independently. Again, sounds good to me. +Example: + +clocks { + clk_32k: oscillator@0 { If it has a unit addres (@x) it needs a reg property with the same base address. I thought everything needed a unit address period? Is the rule more like the unit address is optional, but if present must match reg, so I can simply remove @0 and @1 here? I guess that makes a lot more sense. Nope, you only need a unit address to make a node unique, i.e. if you have more than one with the same name. It's not something that's been followed very well on ARM dts files, I have even seen review comments asking for explicit unit IDs when none are needed. So you can't remove @0 and @1 here, since there are two oscillator subnodes. I'm not 100% sure if you have to have the unit address represented as reg or not, but it should probably be represented by _something_ in the properties of the node. Mitch? Segher? :) + compatible = fixed-clock; + #clock-cells = 0; + clock-frequency = 32768; + }; + + osc: oscillator@1 { + compatible = fixed-clock; + #clock-cells = 0; + clock-frequency = 1200; + }; +}; -Olof ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot