How to debug non functioning PHY driver and network interface for ethernet MAC on freertos?

Viewed 20

Hi I'm desperately looking for some advice on things to try to figure out what's wrong with my code. I'm using the ATSAM4S Xplained Pro dev board with the Ethernet1 Xplained Pro Ext (the ethernet chip on this is ksz8851snl). I've ported freeRTOS onto the board using atmel studio. I have a blinky light task working. :) My problem is porting the tcp/ip stack native to freeRTOS. I found a pre written PHY and network interface in the freeRTOS zip. I thought that was sweet but it does not appear to work.

Here is a link to the whole driver I'm using. Just for reference, not asking anyone to do my work for me: https://github.com/particle-iot/freertos/tree/master/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ksz8851snl

Basically I'm able to receive what appears to be erroneous ethernet packets. It's horrible!

I've been working all day without breaks on this, so I'm totally out of ideas as to how to approach this problem.

If you had a broken PHY driver, how would you go about getting it working? What clever debugging tricks would you try? I've never ported the tcp ip stack in freeRTOS before and I'm at a complete loss as to why it's still broken after so many things I've tried.

Also, one more important file is my conf_eth.h I'm just gonna paste this one in since its short.

#ifndef CONF_ETH_H_INCLUDED
#define CONF_ETH_H_INCLUDED

#include "ioport.h"
#include "ioport_pio.h"
#include "FreeRTOSConfig.h"

/** Disable lwIP checksum (performed by hardware). */
#define CHECKSUM_GEN_IP                               0
#define CHECKSUM_GEN_UDP                              0
#define CHECKSUM_GEN_TCP                              0
#define CHECKSUM_GEN_ICMP                             0
#define CHECKSUM_CHECK_IP                             0
#define CHECKSUM_CHECK_UDP                            0
#define CHECKSUM_CHECK_TCP                            0

/** Number of buffer for RX */
#define NETIF_RX_BUFFERS                              3

/** Number of buffer for TX */
#define NETIF_TX_BUFFERS                              3

/** MAC address definition.  The MAC address must be unique on the network. */
#define ETHERNET_CONF_ETHADDR0                        configMAC_ADDR0
#define ETHERNET_CONF_ETHADDR1                        configMAC_ADDR1
#define ETHERNET_CONF_ETHADDR2                        configMAC_ADDR2
#define ETHERNET_CONF_ETHADDR3                        configMAC_ADDR3
#define ETHERNET_CONF_ETHADDR4                        configMAC_ADDR4
#define ETHERNET_CONF_ETHADDR5                        configMAC_ADDR5

/** SPI settings. */
#define KSZ8851SNL_SPI                                SPI
#define KSZ8851SNL_CLOCK_SPEED                        30000000
#define KSZ8851SNL_CS_PIN                             0     //This is the cs channel to use on atsam, there are 4 channels so 0-3

/** Pins configuration. GPIO values need to be set properly. */
#define KSZ8851SNL_RSTN_GPIO                          PIO_PA25_IDX
#define KSZ8851SNL_RSTN_FLAGS                         (PIO_PERIPH_A | PIO_PULLUP | PIO_TYPE_PIO_OUTPUT_1)
#define KSZ8851SNL_CSN_GPIO                           SPI_NPCS0_GPIO
#define KSZ8851SNL_CSN_FLAGS                          PIO_PERIPH_A | PIO_PULLUP | PIO_TYPE_PIO_OUTPUT_1//SPI_NPCS0_FLAGS

/** Push button pin definition. */
#define INTN_PIO                                      PIOA
#define INTN_ID                                       ID_PIOA
#define INTN_PIN_MSK                                  PIO_PA1
#define INTN_ATTR                                     (PIO_DEBOUNCE | PIO_IT_FALL_EDGE)

/* Interrupt priorities. (lowest value = highest priority) */
/* ISRs using FreeRTOS *FromISR APIs must have priorities below or equal to */
/* configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY. */
#define INT_PRIORITY_SPI                              12
#define INT_PRIORITY_PIO                              12

#define INTN_IRQn                                     PIOA_IRQn

#endif /* CONF_ETH_H_INCLUDED */
0 Answers
Related