MACRAW Application Note?

#1

Hello Wiznet people,

I’m intending to implement IP/IPv6 on top of MACRAW for educational purposes.
Although there are good Application Notes for TCP/UDP there aren’t any for MACRAW.

Any chance you will publish such on the wiki or data sheet?
It so much better to have an official documentation then figuring it out by trial&error :slight_smile:

Best,
Zick

#2

Hi Zick :slight_smile:

We publish the PPPoE application on the wiki site in April 2014.
In this application note, we described the structure of PPPoE protocol implemented by MACRAW mode firmware.

You can download the application note & source code from http://wizwiki.net/wiki/doku.php?id=products:w5500:application:pppoe

thanks
EK :slight_smile:

#3

Dear Zick,

As you know, MACRAW can handle the Ethernet frame.

  • The received MACRAW data format
    |-- data length (2byte) --|-- DATA packet (with data length) --|

*Pseudo code for MACRAW mode
(ref. code: wizwiki.net/wiki/lib/exe/fetch.p … legacy.zip / socket.c)

  1. macraw_open
void macraw_open(void)
{
  uint8 sock_num;
  uint16 dummyPort = 0;
  uint8 mFlag = 0;
  sock_num = 0; [u]// socket number '0' can only support[/u]

  close(sock_num); // Close the 0-th socket
  socket(sock_num, Sn_MR_MACRAW, dummyPort,mFlag);  // OPen the 0-th socket with MACRAW mode
}
  1. macraw_send
uint16 macraw_send( const uint8 * buf, uint16 len )
{
   uint16 ret=0;
   uint8 sock_num;
   sock_num =0;

   if (len > getIINCHIP_TxMAX(sock_num)) ret = getIINCHIP_TxMAX(sock_num); // check size not to exceed MAX size.
   else ret = len;

   send_data_processing(sock_num, (uint8 *)buf, len);

   //W5500 SEND COMMAND
   IINCHIP_WRITE(Sn_CR(sock_num),Sn_CR_SEND);
   while( IINCHIP_READ(Sn_CR(sock_num)) );
   while ( (IINCHIP_READ(Sn_IR(sock_num)) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK );
   IINCHIP_WRITE(Sn_IR(sock_num), Sn_IR_SEND_OK);

   return ret;
}
  1. macraw_recv
uint16 macraw_recv( uint8 * buf, uint16 len )
{
   uint8 sock_num;
   uint16 data_len=0;
   uint16 dummyPort = 0;
   uint16 ptr = 0;
   uint8 mFlag = 0;
   sock_num = 0;

   if ( len > 0 )
   {

      data_len = 0;

      ptr = IINCHIP_READ(Sn_RX_RD0(sock_num));
      ptr = (uint16)((ptr & 0x00ff) << 8) + IINCHIP_READ( Sn_RX_RD1(sock_num) );
      //-- read_data(s, (uint8 *)ptr, data, len); // read data
      data_len = IINCHIP_READ_RXBUF(0, ptr);
      ptr++;
      data_len = ((data_len<<8) + IINCHIP_READ_RXBUF(0, ptr)) - 2;
      ptr++;

      if(data_len > 1514)
      {
         printf("data_len over 1514\r\n");
         printf("\r\nptr: %X, data_len: %X", ptr, data_len);
         //while(1);
         /** recommand : close and open **/
         close(sock_num); // Close the 0-th socket
         socket(sock_num, Sn_MR_MACRAW, dummyPort,mFlag);  // OPen the 0-th socket with MACRAW mode
         return 0;
      }

      IINCHIP_READ_RXBUF_BURST(sock_num, ptr, data_len, (uint8*)(buf));
      ptr += data_len;

      IINCHIP_WRITE(Sn_RX_RD0(sock_num),(uint8)((ptr & 0xff00) >> 8));
      IINCHIP_WRITE(Sn_RX_RD1(sock_num),(uint8)(ptr & 0x00ff));
      IINCHIP_WRITE(Sn_CR(sock_num), Sn_CR_RECV);
      while( IINCHIP_READ(Sn_CR(sock_num)) ) ;
   }

   return data_len;
}

Thanks,

#4

Dear ekkim and suhwan,

thanks a lot!
It’s nice to get good answers so early in the morning :slight_smile:
(UTC+2 here…)

#5

Hello,
I’m dealing with MACRAW mode and have some difficulties with filtration of incomig packets. I set up MFEN in Sn_MR according to datasheet

[quote]If user wants to implement Hybrid TCP/IP stack, it is
recommended that this bit is set as „1‟ for reducing host overhead to
process the all received packets.[/quote]
but where to I must write info about MAC addresses to be passed? haven’t found in dosc… neither datashit, not app note :frowning:

#6

@vitech,
check out the SHAR register in datasheet page 33.

#7

Hello Zick,
All I see about SHAR register is it configures the source hardware address. Could you explain a little bit more, what I should write there when I want to enter multicast group and when I want to receive all multicast packets. By now I don’t get any meaning of this reg in MACRAW mode :cry:

#8

@vitech,

I didn’t try that myself so everything below is how I interpret the datasheet.

  1. Write the MAC address into the SHAR. On the WIZ550io board there’s a sticker with a MAC address. If you don’t have the W550io board come with a valid address you like (e.g. 00:11:22:33:44:55).
  2. Set MFEN

Then you’ll only get packets sent to 00:11:22:33:44:55 and FF:FF:FF:FF:FF:FF (broadcast).

#9

Some strange stuff continues to happen.
Initializing socket in MACRAW mode like that:

setSHAR(enaddr); setSn_MR(MACRAW_SOCK, Sn_MR_MULTI | Sn_MR_MACRAW); setSn_CR(MACRAW_SOCK,Sn_CR_OPEN); while(getSn_CR(MACRAW_SOCK)); while(getSn_SR(MACRAW_SOCK) == SOCK_CLOSED);
MAC-address in SHAR non-zero. But, suddenly I receive all packets in networks, even with destination addresses that non-multicast and not mine (checked with wireshark).
How can I receive only broadcast packets (FF:FF:FF:FF:FF:FF) and packets with my MAC in SHAR?

upd: Fighting this problem for a week, still receiving all packets in network by the MACRAW socket without any filtration. Tried all flags in Sn_MR. so is that normal that there is no filtering of incoming packets??

upd2: was wrong, all works fine, was confused by ipv6 multicast addresses.