From 06473e89de4c5f57876af12e95c4fb16725ddee8 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 16 Aug 2017 09:37:51 -0600 Subject: [PATCH] Update MRF24J40 starhub configuration for the SAME70 Xplained. --- arch/arm/src/samv7/sam_spi.c | 6 +- configs/same70-xplained/README.txt | 89 ++++++++++++ .../mrf24j40-starhub/defconfig | 132 ++++++++++++++++++ configs/same70-xplained/src/sam_ethernet.c | 2 +- configs/same70-xplained/src/sam_mrf24j40.c | 16 +-- configs/same70-xplained/src/same70-xplained.h | 3 + 6 files changed, 235 insertions(+), 13 deletions(-) create mode 100644 configs/same70-xplained/mrf24j40-starhub/defconfig diff --git a/arch/arm/src/samv7/sam_spi.c b/arch/arm/src/samv7/sam_spi.c index b2f5f8daea..583cb7aca5 100644 --- a/arch/arm/src/samv7/sam_spi.c +++ b/arch/arm/src/samv7/sam_spi.c @@ -2086,8 +2086,6 @@ FAR struct spi_dev_s *sam_spibus_initialize(int port) if (!spi->initialized) { - /* Enable clocking to the SPI block */ - flags = enter_critical_section(); #if defined(CONFIG_SAMV7_SPI0_MASTER) && defined(CONFIG_SAMV7_SPI1_MASTER) if (spino == 0) @@ -2190,8 +2188,8 @@ FAR struct spi_dev_s *sam_spibus_initialize(int port) * be reconfigured if there is a change. */ - offset = (unsigned int)g_csroffset[csno]; - regval = spi_getreg(spi, offset); + offset = (unsigned int)g_csroffset[csno]; + regval = spi_getreg(spi, offset); regval &= ~(SPI_CSR_CPOL | SPI_CSR_NCPHA | SPI_CSR_BITS_MASK); regval |= (SPI_CSR_NCPHA | SPI_CSR_BITS(8)); spi_putreg(spi, regval, offset); diff --git a/configs/same70-xplained/README.txt b/configs/same70-xplained/README.txt index b3088bb92f..21de807dfb 100644 --- a/configs/same70-xplained/README.txt +++ b/configs/same70-xplained/README.txt @@ -1238,6 +1238,95 @@ NOTES: Configuration sub-directories ----------------------------- + mrf24j40-starhub + + This configuration implement a hub node in a 6LoWPAN start network. + It is intended for the us the mrf24j40-starpoint configuration with + the clicker2-stm32 configurations. Essentially, the SAME70 Xplained + plays the roll of the hub in the configuration and the clicker2-stm32 + boards are the endpoints in the start. + + NOTES: + + 1. The serial console is configured by default for use with and Arduino + serial shield (UART3). You will need to reconfigure if you will + to use a different U[S]ART. + + 2. This configuration derives from the netnsh configuration, but adds + support for IPv6, 6LoWPAN, and the MRF24J40 IEEE 802.15.4 radio. + + 3. This configuration uses the Mikroe BEE MRF24j40 click boards and + connects to the SAMV71-XULT using a click shield as described above. + + 4. You must must have also have at least two clicker2-stm32 boards each + with an MRF24J40 BEE click board in order to run these tests. + + 5. The network initialization thread is NOT enabled. As a result, the + startup will hang if the Ethernet cable is not plugged in. For more + information, see the paragraphs above entitled "Network Initialization + Thread" and "Network Monitor". + + 6. This configuration supports logging of debug output to a circular + buffer in RAM. This feature is discussed fully in this Wiki page: + http://nuttx.org/doku.php?id=wiki:howtos:syslog . Relevant + configuration settings are summarized below: + + Device Drivers: + CONFIG_RAMLOG=y : Enable the RAM-based logging feature. + CONFIG_RAMLOG_CONSOLE=n : (We don't use the RAMLOG console) + CONFIG_RAMLOG_SYSLOG=y : This enables the RAM-based logger as the + system logger. + CONFIG_RAMLOG_NONBLOCKING=y : Needs to be non-blocking for dmesg + CONFIG_RAMLOG_BUFSIZE=8192 : Buffer size is 8KiB + + NOTE: This RAMLOG feature is really only of value if debug output + is enabled. But, by default, no debug output is disabled in this + configuration. Therefore, there is no logic that will add anything + to the RAM buffer. This feature is configured and in place only + to support any future debugging needs that you may have. + + If you don't plan on using the debug features, then by all means + disable this feature and save 8KiB of RAM! + + NOTE: There is an issue with capturing data in the RAMLOG: If + the system crashes, all of the crash dump information will go into + the RAMLOG and you will be unable to access it! You can tell that + the system has crashed because (a) it will be unresponsive and (b) + the LD2 will be blinking at about 2Hz. + + You can also reconfigure to use stdout for debug output be disabling + all of the CONFIG_RAMLOG* settings listed above and enabling the + following in the .config file: + + CONFIG_SYSLOG_CONSOLE=y + CONFIG_SYSLOG_SERIAL_CONSOLE=y + + 7. Telnet: The clicker2-stm32 star point configuration supports the + Telnet daemon, but not the Telnet client; the star hub configuration + supports the Telnet client, but not the Telnet daemon. Therefore, + the star hub can Telnet to any point in the star, the star endpoints + cannot initiate telnet sessions. + + 8. TCP and UDP Tests: The same TCP and UDP tests as described for + the clicker2-stm32 mrf24j40-starpoint configuration are supported on + the star endpoints, but NOT on the star hub. Therefore, all network + testing is between endpoints with the hub acting, well, only like a + hub. + + The nsh> dmesg command can be use at any time on any node to see + any debug output that you have selected. + + Telenet sessions may be initiated only from the hub to a star + endpoint: + + C: nsh> telnet <-- Runs the Telnet client + + Where is the IP address of either the E1 or I2 endpoints. + + STATUS: + 2017-08-16: Configurations added. Currently hangs in mrf24j40_reset() + before the NSH appears on the serial console. + netnsh: Configures the NuttShell (nsh) located at examples/nsh. There are two diff --git a/configs/same70-xplained/mrf24j40-starhub/defconfig b/configs/same70-xplained/mrf24j40-starhub/defconfig new file mode 100644 index 0000000000..27ef74b91d --- /dev/null +++ b/configs/same70-xplained/mrf24j40-starhub/defconfig @@ -0,0 +1,132 @@ +# CONFIG_ARCH_RAMFUNCS is not set +# CONFIG_NET_IPv4 is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_SAMV7_UART0 is not set +# CONFIG_SAMV7_UART2 is not set +# CONFIG_SAMV7_UART4 is not set +CONFIG_ARCH_BOARD_SAME70_XPLAINED=y +CONFIG_ARCH_BOARD="same70-xplained" +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_CHIP_SAME70=y +CONFIG_ARCH_CHIP_SAME70Q=y +CONFIG_ARCH_CHIP_SAME70Q21=y +CONFIG_ARCH_CHIP_SAMV7=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_IRQBUTTONS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH="arm" +CONFIG_ARMV7M_DCACHE=y +CONFIG_ARMV7M_ICACHE=y +CONFIG_ARMV7M_LAZYFPU=y +CONFIG_AT24XX_ADDR=0x57 +CONFIG_AT24XX_EXTENDED=y +CONFIG_AT24XX_EXTSIZE=160 +CONFIG_AT24XX_SIZE=2 +CONFIG_BOARD_LOOPSPERMSEC=51262 +CONFIG_BUILTIN=y +CONFIG_DISABLE_POLL=y +CONFIG_DRIVERS_IEEE802154=y +CONFIG_DRIVERS_WIRELESS=y +CONFIG_ETH0_PHY_KSZ8061=y +CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y +CONFIG_EXAMPLES_NSH=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_HOST_WINDOWS=y +CONFIG_IEEE802154_I8SAK=y +CONFIG_IEEE802154_IND_PREALLOC=32 +CONFIG_IEEE802154_MACDEV=y +CONFIG_IEEE802154_MRF24J40=y +CONFIG_IEEE802154_NETDEV=y +CONFIG_INTELHEX_BINARY=y +CONFIG_IOB_BUFSIZE=128 +CONFIG_IOB_NBUFFERS=32 +CONFIG_IOB_NCHAINS=16 +CONFIG_MAC802154_NNOTIF=48 +CONFIG_MAC802154_NTXDESC=32 +CONFIG_MAX_TASKS=16 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_MTD_AT24XX=y +CONFIG_MTD_AT25=y +CONFIG_MTD_CONFIG=y +CONFIG_MTD=y +CONFIG_NET_6LOWPAN=y +CONFIG_NET_BROADCAST=y +CONFIG_NET_ETH_MTU=590 +CONFIG_NET_ETH_TCP_RECVWNDO=536 +CONFIG_NET_HOSTNAME="MRF24J40-Hub" +CONFIG_NET_ICMPv6_NEIGHBOR=y +CONFIG_NET_ICMPv6_PING=y +CONFIG_NET_ICMPv6=y +CONFIG_NET_IPv6=y +CONFIG_NET_SOCKOPTS=y +CONFIG_NET_STAR=y +CONFIG_NET_STARHUB=y +CONFIG_NET_STATISTICS=y +CONFIG_NET_TCP_WRITE_BUFFERS=y +CONFIG_NET_TCP=y +CONFIG_NET_TCPBACKLOG=y +CONFIG_NET_UDP=y +CONFIG_NET=y +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDB_DNSSERVER_NOADDR=y +CONFIG_NETDEV_PHY_IOCTL=y +CONFIG_NETDEV_STATISTICS=y +CONFIG_NETDEV_WIRELESS_IOCTL=y +CONFIG_NETUTILS_TELNETC=y +CONFIG_NETUTILS_TELNETD=y +CONFIG_NETUTILS_WEBCLIENT=y +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_GET=y +CONFIG_NSH_DISABLE_PUT=y +CONFIG_NSH_DISABLE_WGET=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_MACADDR=0x00fade00deadbeef +CONFIG_NSH_NOMAC=y +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=393216 +CONFIG_RAM_START=0x20400000 +CONFIG_RAMLOG_BUFSIZE=8192 +CONFIG_RAMLOG_SYSLOG=y +CONFIG_RAMLOG=y +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SAME70XPLAINED_CLICKSHIELD=y +CONFIG_SAMV7_EMAC_HPWORK=y +CONFIG_SAMV7_EMAC0_PHYSR_100FD=0x6 +CONFIG_SAMV7_EMAC0_PHYSR_100HD=0x2 +CONFIG_SAMV7_EMAC0_PHYSR_10FD=0x5 +CONFIG_SAMV7_EMAC0_PHYSR_10HD=0x1 +CONFIG_SAMV7_EMAC0_PHYSR_ALTCONFIG=y +CONFIG_SAMV7_EMAC0_PHYSR_ALTMODE=0x7 +CONFIG_SAMV7_EMAC0_PHYSR=30 +CONFIG_SAMV7_EMAC0_RMII=y +CONFIG_SAMV7_EMAC0=y +CONFIG_SAMV7_GPIO_IRQ=y +CONFIG_SAMV7_GPIOA_IRQ=y +CONFIG_SAMV7_GPIOC_IRQ=y +CONFIG_SAMV7_SPI0=y +CONFIG_SAMV7_UART3=y +CONFIG_SAMV7_XDMAC=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPERIOD=50000 +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_LPWORKPRIORITY=160 +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_START_DAY=16 +CONFIG_START_MONTH=8 +CONFIG_UART3_SERIAL_CONSOLE=y +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_WIRELESS_IEEE802154=y +CONFIG_WIRELESS=y diff --git a/configs/same70-xplained/src/sam_ethernet.c b/configs/same70-xplained/src/sam_ethernet.c index 413eec4762..be536acb99 100644 --- a/configs/same70-xplained/src/sam_ethernet.c +++ b/configs/same70-xplained/src/sam_ethernet.c @@ -314,7 +314,7 @@ int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg, else { nerr("ERROR: Unsupported interface: %s\n", intf); - return NULL; + return -ENODEV; } /* Disable interrupts until we are done. This guarantees that the diff --git a/configs/same70-xplained/src/sam_mrf24j40.c b/configs/same70-xplained/src/sam_mrf24j40.c index c7f718855c..dae40e76c0 100644 --- a/configs/same70-xplained/src/sam_mrf24j40.c +++ b/configs/same70-xplained/src/sam_mrf24j40.c @@ -75,7 +75,7 @@ struct sam_priv_s uint32_t rstcfg; #endif uint8_t irq; - uint8_t spidev; + uint8_t csno; }; /**************************************************************************** @@ -121,7 +121,7 @@ static struct sam_priv_s g_mrf24j40_mb1_priv = .rstcfg = CLICK_MB1_RESET, #endif .irq = IRQ_MB1, - .spidev = 0, + .csno = MB1_CSNO, }; #endif @@ -135,7 +135,7 @@ static struct sam_priv_s g_mrf24j40_mb2_priv = .rstcfg = CLICK_MB2_RESET, #endif .irq = IRQ_MB2, - .spidev = 0, + .csno = MB2_CSNO, }; #endif @@ -244,10 +244,10 @@ static int sam_mrf24j40_devsetup(FAR struct sam_priv_s *priv) /* Initialize the SPI bus and get an instance of the SPI interface */ - spi = sam_spibus_initialize(priv->spidev); + spi = sam_spibus_initialize(priv->csno); if (spi == NULL) { - wlerr("ERROR: Failed to initialize SPI bus %d\n", priv->spidev); + wlerr("ERROR: Failed to initialize SPI bus %d\n", priv->csno); return -ENODEV; } @@ -256,7 +256,7 @@ static int sam_mrf24j40_devsetup(FAR struct sam_priv_s *priv) radio = mrf24j40_init(spi, &priv->dev); if (radio == NULL) { - wlerr("ERROR: Failed to initialize SPI bus %d\n", priv->spidev); + wlerr("ERROR: Failed to initialize MRF24J40 radio\n"); return -ENODEV; } @@ -271,7 +271,7 @@ static int sam_mrf24j40_devsetup(FAR struct sam_priv_s *priv) #ifdef CONFIG_IEEE802154_NETDEV /* Use the IEEE802.15.4 MAC interface instance to create a 6LoWPAN - * network interface by wrapping the MAC intrface instance in a + * network interface by wrapping the MAC interface instance in a * network device driver via mac802154dev_register(). */ @@ -286,7 +286,7 @@ static int sam_mrf24j40_devsetup(FAR struct sam_priv_s *priv) #ifdef CONFIG_IEEE802154_MACDEV /* If want to call these APIs from userspace, you have to wrap the MAC - * interface in a character device viamac802154dev_register(). + * interface in a character device via mac802154dev_register(). */ ret = mac802154dev_register(mac, 0); diff --git a/configs/same70-xplained/src/same70-xplained.h b/configs/same70-xplained/src/same70-xplained.h index b415ed3b85..8a3ad6815a 100644 --- a/configs/same70-xplained/src/same70-xplained.h +++ b/configs/same70-xplained/src/same70-xplained.h @@ -368,6 +368,9 @@ #define IRQ_MB1 SAM_IRQ_PA5 #define IRQ_MB2 SAM_IRQ_PA6 +#define MB1_CSNO SPI0_CS0 /* REVISIT PA5 is not one of the NPCS pins */ +#define MB2_CSNO SPI0_CS1 /* REVISIT PA6 is not one of the NPCS pins */ + /* SP chip selects */ #define CLICK_MB1_CS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_SET | \