AnsweredAssumed Answered

ENET from MCF to K66

Question asked by Roman Gassmann on May 25, 2016
Latest reply on May 31, 2016 by jeremyzhou

Hi Everyone,


some years ago I implemented a minimalist Ethernet stack (which just covers my needs) on an MCF52259 (PHY is DB83640). Now I need to port that stack to a new Device which runs a K66 again with a DB83640.

While I could communicate with the DB83640 really fast, I'm stuck at sending something.

Well what exactly happens is:

As soon as I detect a Link, I try to send a Gratuitous ARP every 100ms. This lets the Act_LED on the phy flash, signaling that the phy sends my message. And also the switch which the device is connected to flashes its led.

But I don't see a Gratuitous ARP in Wireshark on the PC (also connected to the switch, btw. yes, I checked every connection twice ;-)).

Now since I got really confused by all the Big/Little-Endian stuff, I have some questions.

First int the ECR register of the ENET controller there is this DBSWP flag which should Swap the buffer descriptors bytes to support little-endian devices.

In order to get send something this bit has to be set and also the description buffers need to be changed from:

typedef struct{
  uint16 status;  /* control and status */
  uint16 length;  /* transfer length */
  uint8  *data;   /* buffer address */
} FECBD __attribute__((packed));


typedef struct{
  uint16 length;  /* transfer length */
  uint16 status;  /* control and status */
  uint8  *data;   /* buffer address */
} FECBD __attribute__((packed));


But to be honest I don't really get that bit. Clearly this bit is for the uC architecture and should be set to little-endian on all Kinetis devices so why bothering making such a bit?

Secoundly how is it possible to send something out in to the net that's seen by the switch but not in the Wireshark? Are my packages corrupt? If so why?

Do I have to change some other structs and stuff from big to little-endian? If so? Which ones and how do they have to look? I have a lot of structs for all the layers like:

typedef struct {
  MAC_addr_t destination_addr;   /**< 48-bit destination address.*/
  MAC_addr_t source_addr;        /**< 48-bit source address.*/
  unsigned short type;          /**< 16-bit type field. 0x0800(IP) / 0x0806(ARP)*/
 } ETH_header_t __attribute__((packed));

or the

typedef struct{
  unsigned short hard_type;           /**< The type of hardware address (=1 for Ethernet).*/
  unsigned short prot_type;           /**< The type of protocol address (=0x0800 for IP).*/
  unsigned char hard_size;            /**< The size in bytes of the hardware address (=6).*/
  unsigned char prot_size;            /**< The size in bytes of the protocol address (=4).*/
  unsigned short op;                  /**< Opcode.*/
  MAC_addr_t sender_hard_addr;   /**< Hardware address of sender of this packet.*/
  IP_addr_t sender_prot_addr;    /**< Protocol address of sender of this packet.*/
  MAC_addr_t target_hard_addr;   /**< Hardware address of target of this packet.*/
  IP_addr_t target_prot_addr;    /**< Protocol address of target of this packet.*/
} ARP_header_t __attribute__((packed));

Thanks for your help!