From 38999dfe9d77b56754a03d96c93ddd9e1b5bf5b6 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 12 Jul 2016 09:46:09 -0600 Subject: [PATCH 01/15] Fix two incorrectly named header files --- .../chip/{kinetis_k40memormap.h => kinetis_k40memorymap.h} | 0 .../chip/{kinetis_k60memormap.h => kinetis_k60memorymap.h} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename arch/arm/src/kinetis/chip/{kinetis_k40memormap.h => kinetis_k40memorymap.h} (100%) rename arch/arm/src/kinetis/chip/{kinetis_k60memormap.h => kinetis_k60memorymap.h} (100%) diff --git a/arch/arm/src/kinetis/chip/kinetis_k40memormap.h b/arch/arm/src/kinetis/chip/kinetis_k40memorymap.h similarity index 100% rename from arch/arm/src/kinetis/chip/kinetis_k40memormap.h rename to arch/arm/src/kinetis/chip/kinetis_k40memorymap.h diff --git a/arch/arm/src/kinetis/chip/kinetis_k60memormap.h b/arch/arm/src/kinetis/chip/kinetis_k60memorymap.h similarity index 100% rename from arch/arm/src/kinetis/chip/kinetis_k60memormap.h rename to arch/arm/src/kinetis/chip/kinetis_k60memorymap.h From 3bc504b68576091163d0d23ff374d1a89da5071a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 12 Jul 2016 06:58:21 -0600 Subject: [PATCH 02/15] Per comment from David Alession: M_E128 will never be used since it is greater than FLT_MAX. --- libc/math/lib_libexpif.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libc/math/lib_libexpif.c b/libc/math/lib_libexpif.c index 88dd9dd61e..1ab9b90f43 100644 --- a/libc/math/lib_libexpif.c +++ b/libc/math/lib_libexpif.c @@ -49,13 +49,16 @@ #define M_E16 (M_E8 * M_E8) #define M_E32 (M_E16 * M_E16) #define M_E64 (M_E32 * M_E32) -#define M_E128 (M_E64 * M_E64) /**************************************************************************** * Private Data ****************************************************************************/ -static const float g_expif_square_tbl[8] = +/* Values above M_E64 will never be used since it’s larger than FLT_MAX + *(3.402823e+38). + */ + +static const float g_expif_square_tbl[7] = { (float)M_E, /* e^1 */ (float)M_E2, /* e^2 */ @@ -64,7 +67,6 @@ static const float g_expif_square_tbl[8] = (float)M_E16, /* e^16 */ (float)M_E32, /* e^32 */ (float)M_E64, /* e^64 */ - (float)M_E128, /* e^128 */ }; /**************************************************************************** @@ -76,7 +78,7 @@ float lib_expif(size_t n) size_t i; float val; - if (n > 128) + if (n >= 128) { return INFINITY_F; } From c8f053de929fe2cbc5e7ed52f0c10f9c63cfb7d4 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 12 Jul 2016 09:34:16 -0600 Subject: [PATCH 03/15] Kinetis Ethernet: Add support for the KSZ8081 PHY --- arch/arm/src/kinetis/Kconfig | 46 +++++---- arch/arm/src/kinetis/kinetis_enet.c | 153 +++++++++++++++++++++------- include/nuttx/net/mii.h | 2 +- 3 files changed, 140 insertions(+), 61 deletions(-) diff --git a/arch/arm/src/kinetis/Kconfig b/arch/arm/src/kinetis/Kconfig index 55a6930211..2e0ff4ae89 100644 --- a/arch/arm/src/kinetis/Kconfig +++ b/arch/arm/src/kinetis/Kconfig @@ -205,19 +205,22 @@ config KINETIS_UART5 config KINETIS_ENET bool "Ethernet" default n - depends on ARCH_FAMILY_K60 - select NET + depends on ARCH_FAMILY_K60 || ARCH_FAMILY_K64 + select ARCH_HAVE_PHY select ARCH_HAVE_NETDEV_STATISTICS + select NET + select NETDEVICES + select NET_MULTIBUFFER ---help--- - Support Ethernet (K60 only) + Support Ethernet (K6x only) config KINETIS_RNGB bool "Random number generator" default n - depends on ARCH_FAMILY_K60 + depends on ARCH_FAMILY_K60 || ARCH_FAMILY_K64 select ARCH_HAVE_RNG ---help--- - Support the random number generator(K60 only) + Support the random number generator(K6x only) config KINETIS_FLEXCAN0 bool "FlexCAN0" @@ -478,7 +481,7 @@ config KINETIS_FTM2_CHANNEL If FTM2 is enabled for PWM usage, you also need specifies the timer output channel {0,..,1} -comment "Kinetis GPIO Interrupt Configuration" +menu "Kinetis GPIO Interrupt Configuration" config GPIO_IRQ bool "GPIO pin interrupts" @@ -513,55 +516,54 @@ config KINETIS_PORTEINTS Enable support for 32 interrupts from GPIO port E pins endif +endmenu # Kinetis GPIO Interrupt Configuration -if KINETIS_ENET +menu "Kinetis Ethernet Configuration" + depends on KINETIS_ENET -comment "Kinetis Ethernet Configuration" - -config ENET_ENHANCEDBD +config KINETIS_ENETENHANCEDBD bool "Use enhanced buffer descriptors" default n ---help--- Use enhanced, 32-byte buffer descriptors -config ENET_NETHIFS +config KINETIS_ENETNETHIFS int "Number of Ethernet interfaces" default 1 ---help--- Number of Ethernet interfaces supported by the hardware. Must be one for now. -config ENET_NRXBUFFERS +config KINETIS_ENETNRXBUFFERS int "Number of Ethernet Rx buffers" default 6 ---help--- Number of Ethernet Rx buffers to use. The size of one buffer is determined by NET_BUFSIZE -config ENET_NTXBUFFERS +config KINETIS_ENETNTXBUFFERS int "Number of Ethernet Tx buffers" default 2 ---help--- Number of Ethernet Tx buffers to use. The size of one buffer is determined by NET_BUFSIZE -config ENET_PHYADDR +config KINETIS_ENETPHYADDR int "PHY address" default 1 ---help--- MII/RMII address of the PHY -config ENET_USEMII +config KINETIS_ENETUSEMII bool "Use MII interface" default n ---help--- The the MII PHY interface. Default: Use RMII interface -endif +endmenu # Kinetis Ethernet Configuration -if KINETIS_SDHC - -comment "Kinetis SDHC Configuration" +menu "Kinetis SDHC Configuration" + depends on KINETIS_SDHC config KINETIS_SDHC_ABSFREQ bool "Custom transfer frequencies" @@ -611,11 +613,13 @@ config KINETIS_SDHC_DMAPRIO ---help--- SDHC DMA priority -endif +endmenu # Kinetis SDHC Configuration -comment "Kinetis UART Configuration" +menu "Kinetis UART Configuration" config KINETIS_UARTFIFOS bool "Enable UART0 FIFO" default n depends on KINETIS_UART0 + +endmenu # Kinetis UART Configuration diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c index b3364a6bd3..c72c12951b 100644 --- a/arch/arm/src/kinetis/kinetis_enet.c +++ b/arch/arm/src/kinetis/kinetis_enet.c @@ -76,23 +76,23 @@ * Pre-processor Definitions ****************************************************************************/ -/* CONFIG_ENET_NETHIFS determines the number of physical interfaces +/* CONFIG_KINETIS_ENETNETHIFS determines the number of physical interfaces * that will be supported. */ -#if CONFIG_ENET_NETHIFS != 1 -# error "CONFIG_ENET_NETHIFS must be one for now" +#if CONFIG_KINETIS_ENETNETHIFS != 1 +# error "CONFIG_KINETIS_ENETNETHIFS must be one for now" #endif -#if CONFIG_ENET_NTXBUFFERS < 1 +#if CONFIG_KINETIS_ENETNTXBUFFERS < 1 # error "Need at least one TX buffer" #endif -#if CONFIG_ENET_NRXBUFFERS < 1 +#if CONFIG_KINETIS_ENETNRXBUFFERS < 1 # error "Need at least one RX buffer" #endif -#define NENET_NBUFFERS (CONFIG_ENET_NTXBUFFERS+CONFIG_ENET_NRXBUFFERS) +#define NENET_NBUFFERS (CONFIG_KINETIS_ENETNTXBUFFERS+CONFIG_KINETIS_ENETNRXBUFFERS) #ifndef CONFIG_NET_MULTIBUFFER # error "CONFIG_NET_MULTIBUFFER is required in the configuration" @@ -108,14 +108,47 @@ #define MII_MAXPOLLS (0x1ffff) #define LINK_WAITUS (500*1000) -/* PHY hardware specifics. This was copied from the FreeScale code examples. - * this is a vendor specific register and bit settings. I really should - * do the research and find out what this really is. +/* PHY definitions. + * + * The selected PHY must be selected from the drivers/net/Kconfig PHY menu. + * A description of the PHY must be provided here. That description must + * include: + * + * 1. BOARD_PHY_NAME: A PHY name string (for debug output), + * 2. BOARD_PHYID1 and BOARD_PHYID2: The PHYID1 and PHYID2 values (from + * include/nuttx/net/mii.h) + * 3. BOARD_PHY_STATUS: The address of the status register to use when + * querying link status (from include/nuttx/net/mii.h) + * 4. BOARD_PHY_ISDUPLEX: A macro that can convert the status register + * value into a boolean: true=duplex mode, false=half-duplex mode + * 5. BOARD_PHY_10BASET: A macro that can convert the status register + * value into a boolean: true=10Base-T, false=Not 10Base-T + * 6. BOARD_PHY_100BASET: A macro that can convert the status register + * value into a boolean: true=100Base-T, false=Not 100Base-T + * + * The Tower SER board uses a KSZ8041 PHY. + * The Freedom K64F board uses a KSZ8081 PHY */ -#define PHY_STATUS (0x1f) -#define PHY_DUPLEX_STATUS (4 << 2) -#define PHY_SPEED_STATUS (1 << 2) +#if defined(CONFIG_ETH0_PHY_KSZ8041) +# define BOARD_PHY_NAME "KSZ8041" +# define BOARD_PHYID1 MII_PHYID1_KSZ8041 +# define BOARD_PHYID2 MII_PHYID2_KSZ8041 +# define BOARD_PHY_STATUS MII_KSZ8041_PHYCTRL2 +# define BOARD_PHY_ISDUPLEX(s) (((s) & (4 << MII_PHYCTRL2_MODE_SHIFT)) != 0) +# define BOARD_PHY_10BASET(s) (((s) & (1 << MII_PHYCTRL2_MODE_SHIFT)) != 0) +# define BOARD_PHY_100BASET(s) (((s) & (2 << MII_PHYCTRL2_MODE_SHIFT)) != 0) +#elif defined(CONFIG_ETH0_PHY_KSZ8081) +# define BOARD_PHY_NAME "KSZ8081" +# define BOARD_PHYID1 MII_PHYID1_KSZ8081 +# define BOARD_PHYID2 MII_PHYID2_KSZ8081 +# define BOARD_PHY_STATUS MII_KSZ8081_PHYCTRL2 +# define BOARD_PHY_ISDUPLEX(s) (((s) & (4 << MII_PHYCTRL2_MODE_SHIFT)) != 0) +# define BOARD_PHY_10BASET(s) (((s) & (1 << MII_PHYCTRL2_MODE_SHIFT)) != 0) +# define BOARD_PHY_100BASET(s) (((s) & (2 << MII_PHYCTRL2_MODE_SHIFT)) != 0) +#else +# error "Unrecognized or missing PHY selection" +#endif /* Estimate the hold time to use based on the peripheral (bus) clock: * @@ -188,7 +221,7 @@ struct kinetis_driver_s * Private Data ****************************************************************************/ -static struct kinetis_driver_s g_enet[CONFIG_ENET_NETHIFS]; +static struct kinetis_driver_s g_enet[CONFIG_KINETIS_ENETNETHIFS]; /**************************************************************************** * Private Function Prototypes @@ -222,8 +255,8 @@ static int kinetis_interrupt(int irq, FAR void *context); /* Watchdog timer expirations */ -static void kinetis_polltimer(int argc, uint32_t arg, ...); static void kinetis_txtimeout(int argc, uint32_t arg, ...); +static void kinetis_polltimer(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -241,6 +274,10 @@ static int kinetis_ioctl(struct net_driver_s *dev, int cmd, long arg); /* PHY/MII support */ static inline void kinetis_initmii(struct kinetis_driver_s *priv); +static int kinetis_writemii(struct kinetis_driver_s *priv, uint8_t phyaddr, + uint8_t regaddr, uint16_t data); +static int kinetis_readmii(struct kinetis_driver_s *priv, uint8_t phyaddr, + uint8_t regaddr, uint16_t *data); static inline void kinetis_initphy(struct kinetis_driver_s *priv); /* Initialization */ @@ -323,7 +360,7 @@ static bool kinetics_txringfull(FAR struct kinetis_driver_s *priv) */ txnext = priv->txhead + 1; - if (txnext >= CONFIG_ENET_NTXBUFFERS) + if (txnext >= CONFIG_KINETIS_ENETNTXBUFFERS) { txnext = 0; } @@ -375,7 +412,7 @@ static int kinetis_transmit(FAR struct kinetis_driver_s *priv) txdesc = &priv->txdesc[priv->txhead]; priv->txhead++; - if (priv->txhead >= CONFIG_ENET_NTXBUFFERS) + if (priv->txhead >= CONFIG_KINETIS_ENETNTXBUFFERS) { priv->txhead = 0; } @@ -392,7 +429,7 @@ static int kinetis_transmit(FAR struct kinetis_driver_s *priv) */ txdesc->length = kinesis_swap16(priv->dev.d_len); -#ifdef CONFIG_ENET_ENHANCEDBD +#ifdef CONFIG_KINETIS_ENETENHANCEDBD txdesc->bdu = 0x00000000; txdesc->status2 = TXDESC_INT | TXDESC_TS; /* | TXDESC_IINS | TXDESC_PINS; */ #endif @@ -668,7 +705,7 @@ static void kinetis_receive(FAR struct kinetis_driver_s *priv) /* Update the index to the next descriptor */ priv->rxtail++; - if (priv->rxtail >= CONFIG_ENET_NRXBUFFERS) + if (priv->rxtail >= CONFIG_KINETIS_ENETNRXBUFFERS) { priv->rxtail = 0; } @@ -708,7 +745,7 @@ static void kinetis_txdone(FAR struct kinetis_driver_s *priv) /* Yes.. bump up the tail pointer, making space for a new TX descriptor */ priv->txtail++; - if (priv->txtail >= CONFIG_ENET_NTXBUFFERS) + if (priv->txtail >= CONFIG_KINETIS_ENETNTXBUFFERS) { priv->txtail = 0; } @@ -961,7 +998,7 @@ static int kinetis_ifup(struct net_driver_s *dev) /* Select legacy of enhanced buffer descriptor format */ -#ifdef CONFIG_ENET_ENHANCEDBD +#ifdef CONFIG_KINETIS_ENETENHANCEDBD putreg32(ENET_ECR_EN1588, KINETIS_ENET_ECR); #else putreg32(0, KINETIS_ENET_ECR); @@ -1216,7 +1253,7 @@ static int kinetis_ioctl(struct net_driver_s *dev, int cmd, long arg) { struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = CONFIG_ENET_PHYADDR; + req->phy_id = CONFIG_KINETIS_ENETPHYADDR; ret = OK; } break; @@ -1424,13 +1461,41 @@ static inline void kinetis_initphy(struct kinetis_driver_s *priv) { usleep(LINK_WAITUS); phydata = 0xffff; - kinetis_readmii(priv, CONFIG_ENET_PHYADDR, MII_PHYID1, &phydata); + kinetis_readmii(priv, CONFIG_KINETIS_ENETPHYADDR, MII_PHYID1, &phydata); } while (phydata == 0xffff); +#if CONFIG_DEBUG_NET_ERROR + /* Verify PHYID1. Compare OUI bits 3-18 */ + + ninfo("%s: PHYID1: %04x\n", BOARD_PHY_NAME, phydata); + if (phydata != BOARD_PHYID1) + { + nerr("ERROR: PHYID1=%04x incorrect for %s. Expected %04x\n", + phydata, BOARD_PHY_NAME, BOARD_PHYID1); + } + else + { + /* Read PHYID2 */ + + kinetis_readmii(priv, CONFIG_KINETIS_ENETPHYADDR, MII_PHYID2, &phydata); + ninfo("%s: PHYID2: %04x\n", BOARD_PHY_NAME, phydata); + + /* Verify PHYID2: Compare OUI bits 19-24 and the 6-bit model number + * (ignoring the 4-bit revision number). + */ + + if ((phydata & 0xfff0) != (BOARD_PHYID2 & 0xfff0)) + { + nerr("ERROR: PHYID2=%04x incorrect for %s. Expected %04x\n", + (phydata & 0xfff0), BOARD_PHY_NAME, (BOARD_PHYID2 & 0xfff0)); + } + } +#endif + /* Start auto negotiation */ - kinetis_writemii(priv, CONFIG_ENET_PHYADDR, MII_MCR, + kinetis_writemii(priv, CONFIG_KINETIS_ENETPHYADDR, MII_MCR, (MII_MCR_ANRESTART | MII_MCR_ANENABLE)); /* Wait (potentially forever) for auto negotiation to complete */ @@ -1438,21 +1503,24 @@ static inline void kinetis_initphy(struct kinetis_driver_s *priv) do { usleep(LINK_WAITUS); - kinetis_readmii(priv, CONFIG_ENET_PHYADDR, MII_MSR, &phydata); - + kinetis_readmii(priv, CONFIG_KINETIS_ENETPHYADDR, MII_MSR, &phydata); } while ((phydata & MII_MSR_ANEGCOMPLETE) == 0); + ninfo("%s: MII_MSR: %04x\n", BOARD_PHY_NAME, phydata); + /* When we get here we have a link - Find the negotiated speed and duplex. */ phydata = 0; - kinetis_readmii(priv, CONFIG_ENET_PHYADDR, PHY_STATUS, &phydata); + kinetis_readmii(priv, CONFIG_KINETIS_ENETPHYADDR, BOARD_PHY_STATUS, &phydata); + + ninfo("%s: BOARD_PHY_STATUS: %04x\n", BOARD_PHY_NAME, phydata); /* Set up the transmit and receive control registers based on the * configuration and the auto negotiation results. */ -#ifdef CONFIG_ENET_USEMII +#ifdef CONFIG_KINETIS_ENETUSEMII rcr = ENET_RCR_MII_MODE | ENET_RCR_CRCFWD | CONFIG_NET_ETH_MTU << ENET_RCR_MAX_FL_SHIFT | ENET_RCR_MII_MODE; @@ -1468,7 +1536,7 @@ static inline void kinetis_initphy(struct kinetis_driver_s *priv) /* Setup half or full duplex */ - if ((phydata & PHY_DUPLEX_STATUS) != 0) + if (BOARD_PHY_ISDUPLEX(phydata)) { /* Full duplex */ @@ -1481,12 +1549,17 @@ static inline void kinetis_initphy(struct kinetis_driver_s *priv) rcr |= ENET_RCR_DRT; } - if ((phydata & PHY_SPEED_STATUS) != 0) + if (BOARD_PHY_10BASET(phydata)) { /* 10Mbps */ rcr |= ENET_RCR_RMII_10T; } + else if (!BOARD_PHY_100BASET(phydata)) + { + nerr("ERROR: Neither 10- nor 100-BaseT reported: PHY STATUS=%04x\n", + phydata); + } putreg32(rcr, KINETIS_ENET_RCR); putreg32(tcr, KINETIS_ENET_TCR); @@ -1520,7 +1593,7 @@ static void kinetis_initbuffers(struct kinetis_driver_s *priv) /* Get an aligned RX descriptor (array) address */ - addr += CONFIG_ENET_NTXBUFFERS * sizeof(struct enet_desc_s); + addr += CONFIG_KINETIS_ENETNTXBUFFERS * sizeof(struct enet_desc_s); priv->rxdesc = (struct enet_desc_s *)addr; /* Get the beginning of the first aligned buffer */ @@ -1529,12 +1602,12 @@ static void kinetis_initbuffers(struct kinetis_driver_s *priv) /* Then fill in the TX descriptors */ - for (i = 0; i < CONFIG_ENET_NTXBUFFERS; i++) + for (i = 0; i < CONFIG_KINETIS_ENETNTXBUFFERS; i++) { priv->txdesc[i].status1 = 0; priv->txdesc[i].length = 0; priv->txdesc[i].data = (uint8_t *)kinesis_swap32((uint32_t)addr); -#ifdef CONFIG_ENET_ENHANCEDBD +#ifdef CONFIG_KINETIS_ENETENHANCEDBD priv->txdesc[i].status2 = TXDESC_IINS | TXDESC_PINS; #endif addr += KINETIS_BUF_SIZE; @@ -1542,12 +1615,12 @@ static void kinetis_initbuffers(struct kinetis_driver_s *priv) /* Then fill in the RX descriptors */ - for (i = 0; i < CONFIG_ENET_NRXBUFFERS; i++) + for (i = 0; i < CONFIG_KINETIS_ENETNRXBUFFERS; i++) { priv->rxdesc[i].status1 = RXDESC_E; priv->rxdesc[i].length = 0; priv->rxdesc[i].data = (uint8_t *)kinesis_swap32((uint32_t)addr); -#ifdef CONFIG_ENET_ENHANCEDBD +#ifdef CONFIG_KINETIS_ENETENHANCEDBD priv->rxdesc[i].bdu = 0; priv->rxdesc[i].status2 = RXDESC_INT; #endif @@ -1556,8 +1629,8 @@ static void kinetis_initbuffers(struct kinetis_driver_s *priv) /* Set the wrap bit in the last descriptors to form a ring */ - priv->txdesc[CONFIG_ENET_NTXBUFFERS-1].status1 |= TXDESC_W; - priv->rxdesc[CONFIG_ENET_NRXBUFFERS-1].status1 |= RXDESC_W; + priv->txdesc[CONFIG_KINETIS_ENETNTXBUFFERS-1].status1 |= TXDESC_W; + priv->rxdesc[CONFIG_KINETIS_ENETNRXBUFFERS-1].status1 |= RXDESC_W; /* We start with RX descriptor 0 and with no TX descriptors in use */ @@ -1631,7 +1704,7 @@ int kinetis_netinitialize(int intf) /* Get the interface structure associated with this interface number. */ - DEBUGASSERT(intf < CONFIG_ENET_NETHIFS); + DEBUGASSERT(intf < CONFIG_KINETIS_ENETNETHIFS); priv = &g_enet[intf]; /* Enable the ENET clock */ @@ -1646,9 +1719,9 @@ int kinetis_netinitialize(int intf) putreg32(0, KINETIS_MPU_CESR); +#ifdef CONFIG_KINETIS_ENETUSEMII /* Configure all ENET/MII pins */ -#ifdef CONFIG_ENET_USEMII kinetis_pinconfig(PIN_MII0_MDIO); kinetis_pinconfig(PIN_MII0_MDC); kinetis_pinconfig(PIN_MII0_RXDV); @@ -1668,6 +1741,8 @@ int kinetis_netinitialize(int intf) kinetis_pinconfig(PIN_MII0_CRS); kinetis_pinconfig(PIN_MII0_COL); #else + /* Use RMII subset */ + kinetis_pinconfig(PIN_RMII0_MDIO); kinetis_pinconfig(PIN_RMII0_MDC); kinetis_pinconfig(PIN_RMII0_CRS_DV); @@ -1773,7 +1848,7 @@ int kinetis_netinitialize(int intf) * ****************************************************************************/ -#if CONFIG_ENET_NETHIFS == 1 +#if CONFIG_KINETIS_ENETNETHIFS == 1 void up_netinitialize(void) { (void)kinetis_netinitialize(0); diff --git a/include/nuttx/net/mii.h b/include/nuttx/net/mii.h index 9d10beb32f..d595202738 100644 --- a/include/nuttx/net/mii.h +++ b/include/nuttx/net/mii.h @@ -547,7 +547,7 @@ #define MII_KSZ80x1_INT_LU (1 << 0) /* Link up interrupt */ /* KSZ8041 Register 0x1e: PHY Control 1 -- To be provided */ -/* KSZ8041 Register 0x1e: PHY Control 2 */ +/* KSZ8041 Register 0x1f: PHY Control 2 */ #define MII_PHYCTRL2_MDIX (1 << 15) /* Bit 15: Micrel/HP MDI/MDI-X state */ #define MII_PHYCTRL2_MDIX_SEL (1 << 14) /* Bit 14: MDI/MDI-X select */ From de3b8d85a42190b3e0c91c132267e164e9c523e0 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 12 Jul 2016 09:40:49 -0600 Subject: [PATCH 04/15] Freedom K64F: Add a networking NSH configuration. --- configs/freedom-k64f/README.txt | 33 +- configs/freedom-k64f/netnsh/Make.defs | 111 +++ configs/freedom-k64f/netnsh/defconfig | 1142 +++++++++++++++++++++++++ configs/freedom-k64f/netnsh/setenv.sh | 77 ++ 4 files changed, 1362 insertions(+), 1 deletion(-) create mode 100644 configs/freedom-k64f/netnsh/Make.defs create mode 100644 configs/freedom-k64f/netnsh/defconfig create mode 100644 configs/freedom-k64f/netnsh/setenv.sh diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index 87519c37fa..cfdac464d1 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -13,6 +13,9 @@ Contents o Ethernet o Development Environment o GNU Toolchain Options + o Freedom K64F Configuration Options + o Configurations + o Status Kinetis Freedom K64F Features: ============================= @@ -380,6 +383,23 @@ can be selected as follow: Where is one of the following: + netnsh: + ------ + This configuration is identical to the nsh configuration described + below except that networking support is enabled. + + NOTES: + + 1. Most of the notes associated with the nsh configuration apply here + as well (see below). + + 2. Default platform/toolchain: + + CONFIG_HOST_WINDOWS=y : Cygwin under Windows + CONFIG_WINDOWS_CYGWIN=y + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc) + CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary + nsh: --- Configures the NuttShell (nsh) located at apps/examples/nsh using a @@ -401,7 +421,7 @@ Where is one of the following: CONFIG_HOST_LINUX=y : Linux (Cygwin under Windows okay too). CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y : Buildroot (arm-nuttx-elf-gcc) CONFIG_ARMV7M_OABI_TOOLCHAIN=y : The older OABI version - CONFIG_RAW_BINARY=y : Output formats: ELF and raw binary + CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary 3. The Serial Console is provided on UART3 with the correct pin configuration for use with an Arduino Serial Shield. @@ -426,3 +446,14 @@ Where is one of the following: CONFIG_SCHED_WORKQUEUE=y : Enable the NuttX workqueue CONFIG_NSH_ARCHINIT=y : Provide NSH initializeation logic + +Status +====== + + 2016-07-11: Received hardware today and the board came up on the very + first try. That does not happen often. At this point, the very basic + NSH configuration is working and LEDs are working. The only odd + behavior that I see is that pressing SW3 causes an unexpected interrupt + error. + 2016-07-12: Added support for the KSZ8081 PHY and added the netnsh + configuration. Untested as of this writing. diff --git a/configs/freedom-k64f/netnsh/Make.defs b/configs/freedom-k64f/netnsh/Make.defs new file mode 100644 index 0000000000..81ee818d81 --- /dev/null +++ b/configs/freedom-k64f/netnsh/Make.defs @@ -0,0 +1,111 @@ +############################################################################ +# configs/freedom-k64f/netnsh/Make.defs +# +# Copyright (C) 2016 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +include ${TOPDIR}/.config +include ${TOPDIR}/tools/Config.mk +include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + DIRLINK = $(TOPDIR)/tools/copydir.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mkwindeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/flash.ld}" +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/flash.ld +endif + +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +AR = $(CROSSDEV)ar rcs +NM = $(CROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} +ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer +endif + +ARCHCFLAGS = -fno-builtin +ARCHCXXFLAGS = -fno-builtin -fno-exceptions +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHDEFINES = +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +ASMEXT = .S +OBJEXT = .o +LIBEXT = .a +EXEEXT = + +ifneq ($(CROSSDEV),arm-nuttx-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe +HOSTLDFLAGS = + diff --git a/configs/freedom-k64f/netnsh/defconfig b/configs/freedom-k64f/netnsh/defconfig new file mode 100644 index 0000000000..0cb2657d58 --- /dev/null +++ b/configs/freedom-k64f/netnsh/defconfig @@ -0,0 +1,1142 @@ +# +# Automatically generated file; DO NOT EDIT. +# Nuttx/ Configuration +# + +# +# Build Setup +# +# CONFIG_EXPERIMENTAL is not set +# CONFIG_DEFAULT_SMALL is not set +# CONFIG_HOST_LINUX is not set +# CONFIG_HOST_OSX is not set +CONFIG_HOST_WINDOWS=y +# CONFIG_HOST_OTHER is not set +# CONFIG_WINDOWS_NATIVE is not set +CONFIG_WINDOWS_CYGWIN=y +# CONFIG_WINDOWS_MSYS is not set +# CONFIG_WINDOWS_OTHER is not set + +# +# Build Configuration +# +# CONFIG_APPS_DIR="../apps" +CONFIG_BUILD_FLAT=y +# CONFIG_BUILD_2PASS is not set + +# +# Binary Output Formats +# +# CONFIG_RRLOAD_BINARY is not set +CONFIG_INTELHEX_BINARY=y +CONFIG_MOTOROLA_SREC=y +# CONFIG_RAW_BINARY is not set +# CONFIG_UBOOT_UIMAGE is not set + +# +# Customize Header Files +# +# CONFIG_ARCH_STDINT_H is not set +# CONFIG_ARCH_STDBOOL_H is not set +# CONFIG_ARCH_MATH_H is not set +# CONFIG_ARCH_FLOAT_H is not set +# CONFIG_ARCH_STDARG_H is not set +# CONFIG_ARCH_DEBUG_H is not set + +# +# Debug Options +# +CONFIG_DEBUG_ALERT=y +# CONFIG_DEBUG_FEATURES is not set +CONFIG_ARCH_HAVE_STACKCHECK=y +# CONFIG_STACK_COLORATION is not set +# CONFIG_ARCH_HAVE_HEAPCHECK is not set +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ARCH_HAVE_CUSTOMOPT=y +# CONFIG_DEBUG_NOOPT is not set +# CONFIG_DEBUG_CUSTOMOPT is not set +CONFIG_DEBUG_FULLOPT=y + +# +# System Type +# +CONFIG_ARCH_ARM=y +# CONFIG_ARCH_AVR is not set +# CONFIG_ARCH_HC is not set +# CONFIG_ARCH_MIPS is not set +# CONFIG_ARCH_RGMP is not set +# CONFIG_ARCH_SH is not set +# CONFIG_ARCH_SIM is not set +# CONFIG_ARCH_X86 is not set +# CONFIG_ARCH_Z16 is not set +# CONFIG_ARCH_Z80 is not set +CONFIG_ARCH="arm" + +# +# ARM Options +# +# CONFIG_ARCH_CHIP_A1X is not set +# CONFIG_ARCH_CHIP_C5471 is not set +# CONFIG_ARCH_CHIP_CALYPSO is not set +# CONFIG_ARCH_CHIP_DM320 is not set +# CONFIG_ARCH_CHIP_EFM32 is not set +# CONFIG_ARCH_CHIP_IMX1 is not set +# CONFIG_ARCH_CHIP_IMX6 is not set +CONFIG_ARCH_CHIP_KINETIS=y +# CONFIG_ARCH_CHIP_KL is not set +# CONFIG_ARCH_CHIP_LM is not set +# CONFIG_ARCH_CHIP_TIVA is not set +# CONFIG_ARCH_CHIP_LPC11XX is not set +# CONFIG_ARCH_CHIP_LPC17XX is not set +# CONFIG_ARCH_CHIP_LPC214X is not set +# CONFIG_ARCH_CHIP_LPC2378 is not set +# CONFIG_ARCH_CHIP_LPC31XX is not set +# CONFIG_ARCH_CHIP_LPC43XX is not set +# CONFIG_ARCH_CHIP_NUC1XX is not set +# CONFIG_ARCH_CHIP_SAMA5 is not set +# CONFIG_ARCH_CHIP_SAMD is not set +# CONFIG_ARCH_CHIP_SAML is not set +# CONFIG_ARCH_CHIP_SAM34 is not set +# CONFIG_ARCH_CHIP_SAMV7 is not set +# CONFIG_ARCH_CHIP_STM32 is not set +# CONFIG_ARCH_CHIP_STM32F7 is not set +# CONFIG_ARCH_CHIP_STM32L4 is not set +# CONFIG_ARCH_CHIP_STR71X is not set +# CONFIG_ARCH_CHIP_TMS570 is not set +# CONFIG_ARCH_CHIP_MOXART is not set +# CONFIG_ARCH_ARM7TDMI is not set +# CONFIG_ARCH_ARM926EJS is not set +# CONFIG_ARCH_ARM920T is not set +# CONFIG_ARCH_CORTEXM0 is not set +# CONFIG_ARCH_CORTEXM3 is not set +CONFIG_ARCH_CORTEXM4=y +# CONFIG_ARCH_CORTEXM7 is not set +# CONFIG_ARCH_CORTEXA5 is not set +# CONFIG_ARCH_CORTEXA8 is not set +# CONFIG_ARCH_CORTEXA9 is not set +# CONFIG_ARCH_CORTEXR4 is not set +# CONFIG_ARCH_CORTEXR4F is not set +# CONFIG_ARCH_CORTEXR5 is not set +# CONFIG_ARCH_CORTEX5F is not set +# CONFIG_ARCH_CORTEXR7 is not set +# CONFIG_ARCH_CORTEXR7F is not set +CONFIG_ARCH_FAMILY="armv7-m" +CONFIG_ARCH_CHIP="kinetis" +# CONFIG_ARM_TOOLCHAIN_IAR is not set +CONFIG_ARM_TOOLCHAIN_GNU=y +# CONFIG_ARMV7M_USEBASEPRI is not set +CONFIG_ARCH_HAVE_FPU=y +# CONFIG_ARCH_HAVE_DPFPU is not set +# CONFIG_ARCH_FPU is not set +# CONFIG_ARCH_HAVE_TRUSTZONE is not set +CONFIG_ARM_HAVE_MPU_UNIFIED=y +# CONFIG_ARM_MPU is not set + +# +# ARMV7M Configuration Options +# +# CONFIG_ARMV7M_HAVE_ICACHE is not set +# CONFIG_ARMV7M_HAVE_DCACHE is not set +# CONFIG_ARMV7M_HAVE_ITCM is not set +# CONFIG_ARMV7M_HAVE_DTCM is not set +# CONFIG_ARMV7M_TOOLCHAIN_IARW is not set +# CONFIG_ARMV7M_TOOLCHAIN_ATOLLIC is not set +# CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT is not set +# CONFIG_ARMV7M_TOOLCHAIN_CODEREDW is not set +# CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW is not set +# CONFIG_ARMV7M_TOOLCHAIN_DEVKITARM is not set +# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set +CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y +# CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set +# CONFIG_ARMV7M_HAVE_STACKCHECK is not set +# CONFIG_ARMV7M_ITMSYSLOG is not set + +# +# Kinetis Configuration Options +# +# CONFIG_ARCH_CHIP_MK20DN32VLH5 is not set +# CONFIG_ARCH_CHIP_MK20DX32VLH5 is not set +# CONFIG_ARCH_CHIP_MK20DN64VLH5 is not set +# CONFIG_ARCH_CHIP_MK20DX64VLH5 is not set +# CONFIG_ARCH_CHIP_MK20DN128VLH5 is not set +# CONFIG_ARCH_CHIP_MK20DX128VLH5 is not set +# CONFIG_ARCH_CHIP_MK20DX64VLH7 is not set +# CONFIG_ARCH_CHIP_MK20DX128VLH7 is not set +# CONFIG_ARCH_CHIP_MK20DX256VLH7 is not set +# CONFIG_ARCH_CHIP_MK40N512VLQ100 is not set +# CONFIG_ARCH_CHIP_MK40N512VMD100 is not set +# CONFIG_ARCH_CHIP_MK40X128VLQ100 is not set +# CONFIG_ARCH_CHIP_MK40X128VMD100 is not set +# CONFIG_ARCH_CHIP_MK40X256VLQ100 is not set +# CONFIG_ARCH_CHIP_MK40X256VMD100 is not set +# CONFIG_ARCH_CHIP_MK60N256VLQ100 is not set +# CONFIG_ARCH_CHIP_MK60N256VMD100 is not set +# CONFIG_ARCH_CHIP_MK60N512VLL100 is not set +# CONFIG_ARCH_CHIP_MK60N512VLQ100 is not set +# CONFIG_ARCH_CHIP_MK60N512VMD100 is not set +# CONFIG_ARCH_CHIP_MK60X256VLQ100 is not set +# CONFIG_ARCH_CHIP_MK60X256VMD100 is not set +CONFIG_ARCH_CHIP_MK64FN1M0VLL12=y +# CONFIG_ARCH_CHIP_MK64FX512VLL12 is not set +# CONFIG_ARCH_CHIP_MK64FX512VDC12 is not set +# CONFIG_ARCH_CHIP_MK64FN1M0VDC12 is not set +# CONFIG_ARCH_CHIP_MK64FX512VLQ12 is not set +# CONFIG_ARCH_CHIP_MK64FX512VMD12 is not set +# CONFIG_ARCH_CHIP_MK64FN1M0VMD12 is not set +# CONFIG_ARCH_FAMILY_K20 is not set +# CONFIG_ARCH_FAMILY_K40 is not set +# CONFIG_ARCH_FAMILY_K60 is not set +CONFIG_ARCH_FAMILY_K64=y + +# +# Kinetis Peripheral Support +# +# CONFIG_KINETIS_TRACE is not set +# CONFIG_KINETIS_FLEXBUS is not set +# CONFIG_KINETIS_UART0 is not set +# CONFIG_KINETIS_UART1 is not set +# CONFIG_KINETIS_UART2 is not set +CONFIG_KINETIS_UART3=y +# CONFIG_KINETIS_UART4 is not set +# CONFIG_KINETIS_UART5 is not set +CONFIG_KINETIS_ENET=y +# CONFIG_KINETIS_RNGB is not set +# CONFIG_KINETIS_FLEXCAN0 is not set +# CONFIG_KINETIS_FLEXCAN1 is not set +# CONFIG_KINETIS_SPI0 is not set +# CONFIG_KINETIS_SPI1 is not set +# CONFIG_KINETIS_SPI2 is not set +# CONFIG_KINETIS_I2C0 is not set +# CONFIG_KINETIS_I2C1 is not set +# CONFIG_KINETIS_I2S is not set +# CONFIG_KINETIS_DAC0 is not set +# CONFIG_KINETIS_DAC1 is not set +# CONFIG_KINETIS_ADC0 is not set +# CONFIG_KINETIS_ADC1 is not set +# CONFIG_KINETIS_CMP is not set +# CONFIG_KINETIS_VREF is not set +# CONFIG_KINETIS_SDHC is not set +# CONFIG_KINETIS_FTM0 is not set +# CONFIG_KINETIS_FTM1 is not set +# CONFIG_KINETIS_FTM2 is not set +# CONFIG_KINETIS_LPTIMER is not set +# CONFIG_KINETIS_RTC is not set +# CONFIG_KINETIS_EWM is not set +# CONFIG_KINETIS_CMT is not set +# CONFIG_KINETIS_USBOTG is not set +# CONFIG_KINETIS_USBDCD is not set +# CONFIG_KINETIS_LLWU is not set +# CONFIG_KINETIS_TSI is not set +# CONFIG_KINETIS_FTFL is not set +# CONFIG_KINETIS_DMA is not set +# CONFIG_KINETIS_CRC is not set +# CONFIG_KINETIS_PDB is not set +# CONFIG_KINETIS_PIT is not set + +# +# Kinetis GPIO Interrupt Configuration +# +# CONFIG_GPIO_IRQ is not set + +# +# Kinetis Ethernet Configuration +# +# CONFIG_KINETIS_ENETENHANCEDBD is not set +CONFIG_KINETIS_ENETNETHIFS=1 +CONFIG_KINETIS_ENETNRXBUFFERS=6 +CONFIG_KINETIS_ENETNTXBUFFERS=2 +CONFIG_KINETIS_ENETPHYADDR=1 +# CONFIG_KINETIS_ENETUSEMII is not set + +# +# Kinetis UART Configuration +# + +# +# Architecture Options +# +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_VECNOTIRQ is not set +# CONFIG_ARCH_DMA is not set +CONFIG_ARCH_HAVE_IRQPRIO=y +# CONFIG_ARCH_L2CACHE is not set +# CONFIG_ARCH_HAVE_COHERENT_DCACHE is not set +# CONFIG_ARCH_HAVE_ADDRENV is not set +# CONFIG_ARCH_NEED_ADDRENV_MAPPING is not set +# CONFIG_ARCH_HAVE_MULTICPU is not set +CONFIG_ARCH_HAVE_VFORK=y +# CONFIG_ARCH_HAVE_MMU is not set +CONFIG_ARCH_HAVE_MPU=y +# CONFIG_ARCH_NAND_HWECC is not set +# CONFIG_ARCH_HAVE_EXTCLK is not set +# CONFIG_ARCH_HAVE_POWEROFF is not set +CONFIG_ARCH_HAVE_RESET=y +# CONFIG_ARCH_USE_MPU is not set +# CONFIG_ARCH_IRQPRIO is not set +CONFIG_ARCH_STACKDUMP=y +# CONFIG_ENDIAN_BIG is not set +# CONFIG_ARCH_IDLE_CUSTOM is not set +CONFIG_ARCH_HAVE_RAMFUNCS=y +CONFIG_ARCH_RAMFUNCS=y +CONFIG_ARCH_HAVE_RAMVECTORS=y +# CONFIG_ARCH_RAMVECTORS is not set + +# +# Board Settings +# +CONFIG_BOARD_LOOPSPERMSEC=9535 +# CONFIG_ARCH_CALIBRATION is not set + +# +# Interrupt options +# +CONFIG_ARCH_HAVE_INTERRUPTSTACK=y +CONFIG_ARCH_INTERRUPTSTACK=0 +CONFIG_ARCH_HAVE_HIPRI_INTERRUPT=y +# CONFIG_ARCH_HIPRI_INTERRUPT is not set + +# +# Boot options +# +# CONFIG_BOOT_RUNFROMEXTSRAM is not set +CONFIG_BOOT_RUNFROMFLASH=y +# CONFIG_BOOT_RUNFROMISRAM is not set +# CONFIG_BOOT_RUNFROMSDRAM is not set +# CONFIG_BOOT_COPYTORAM is not set + +# +# Boot Memory Configuration +# +CONFIG_RAM_START=0x1fff0000 +CONFIG_RAM_SIZE=131072 +# CONFIG_ARCH_HAVE_SDRAM is not set + +# +# Board Selection +# +CONFIG_ARCH_BOARD_FREEDOM_K64F=y +# CONFIG_ARCH_BOARD_CUSTOM is not set +CONFIG_ARCH_BOARD="freedom-k64f" + +# +# Common Board Options +# +CONFIG_ARCH_HAVE_LEDS=y +CONFIG_ARCH_LEDS=y +CONFIG_ARCH_HAVE_BUTTONS=y +# CONFIG_ARCH_BUTTONS is not set +CONFIG_ARCH_HAVE_IRQBUTTONS=y + +# +# Board-Specific Options +# +# CONFIG_BOARD_CRASHDUMP is not set +# CONFIG_LIB_BOARDCTL is not set + +# +# RTOS Features +# +CONFIG_DISABLE_OS_API=y +# CONFIG_DISABLE_POSIX_TIMERS is not set +# CONFIG_DISABLE_PTHREAD is not set +# CONFIG_DISABLE_SIGNALS is not set +# CONFIG_DISABLE_MQUEUE is not set +# CONFIG_DISABLE_ENVIRON is not set + +# +# Clocks and Timers +# +CONFIG_USEC_PER_TICK=10000 +# CONFIG_SYSTEM_TIME64 is not set +# CONFIG_CLOCK_MONOTONIC is not set +# CONFIG_JULIAN_TIME is not set +CONFIG_START_YEAR=2013 +CONFIG_START_MONTH=3 +CONFIG_START_DAY=25 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_PREALLOC_WDOGS=4 +CONFIG_WDOG_INTRESERVE=0 +CONFIG_PREALLOC_TIMERS=4 + +# +# Tasks and Scheduling +# +# CONFIG_INIT_NONE is not set +CONFIG_INIT_ENTRYPOINT=y +# CONFIG_INIT_FILEPATH is not set +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_RR_INTERVAL=200 +# CONFIG_SCHED_SPORADIC is not set +CONFIG_TASK_NAME_SIZE=0 +CONFIG_MAX_TASKS=16 +# CONFIG_SCHED_HAVE_PARENT is not set +CONFIG_SCHED_WAITPID=y + +# +# Pthread Options +# +# CONFIG_MUTEX_TYPES is not set +CONFIG_NPTHREAD_KEYS=4 + +# +# Performance Monitoring +# +# CONFIG_SCHED_CPULOAD is not set +# CONFIG_SCHED_INSTRUMENTATION is not set + +# +# Files and I/O +# +CONFIG_DEV_CONSOLE=y +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set +CONFIG_SDCLONE_DISABLE=y +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NAME_MAX=32 +# CONFIG_PRIORITY_INHERITANCE is not set + +# +# RTOS hooks +# +# CONFIG_BOARD_INITIALIZE is not set +# CONFIG_SCHED_STARTHOOK is not set +# CONFIG_SCHED_ATEXIT is not set +# CONFIG_SCHED_ONEXIT is not set + +# +# Signal Numbers +# +CONFIG_SIG_SIGUSR1=1 +CONFIG_SIG_SIGUSR2=2 +CONFIG_SIG_SIGALARM=3 +CONFIG_SIG_SIGCONDTIMEDOUT=16 + +# +# POSIX Message Queue Options +# +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_MQ_MAXMSGSIZE=32 +# CONFIG_MODULE is not set + +# +# Work queue support +# +# CONFIG_SCHED_WORKQUEUE is not set +# CONFIG_SCHED_HPWORK is not set +# CONFIG_SCHED_LPWORK is not set + +# +# Stack and heap information +# +CONFIG_IDLETHREAD_STACKSIZE=1024 +CONFIG_USERMAIN_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=2048 +# CONFIG_LIB_SYSCALL is not set + +# +# Device Drivers +# +CONFIG_DISABLE_POLL=y +CONFIG_DEV_NULL=y +# CONFIG_DEV_ZERO is not set +# CONFIG_DEV_LOOP is not set + +# +# Buffering +# +# CONFIG_DRVR_WRITEBUFFER is not set +# CONFIG_DRVR_READAHEAD is not set +# CONFIG_RAMDISK is not set +# CONFIG_CAN is not set +# CONFIG_ARCH_HAVE_PWM_PULSECOUNT is not set +# CONFIG_ARCH_HAVE_PWM_MULTICHAN is not set +# CONFIG_PWM is not set +# CONFIG_ARCH_HAVE_I2CRESET is not set +# CONFIG_I2C is not set +# CONFIG_SPI is not set +# CONFIG_I2S is not set + +# +# Timer Driver Support +# +# CONFIG_TIMER is not set +# CONFIG_RTC is not set +# CONFIG_WATCHDOG is not set +# CONFIG_ANALOG is not set +# CONFIG_AUDIO_DEVICES is not set +# CONFIG_VIDEO_DEVICES is not set +# CONFIG_BCH is not set +# CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# +# CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set + +# +# LCD Driver Support +# +# CONFIG_LCD is not set +# CONFIG_SLCD is not set + +# +# LED Support +# +# CONFIG_USERLED is not set +# CONFIG_RGBLED is not set +# CONFIG_PCA9635PW is not set +# CONFIG_NCP5623C is not set +# CONFIG_MMCSD is not set +# CONFIG_MODEM is not set +# CONFIG_MTD is not set +# CONFIG_EEPROM is not set +CONFIG_NETDEVICES=y + +# +# General Ethernet MAC Driver Options +# +# CONFIG_NETDEV_LOOPBACK is not set +CONFIG_NETDEV_TELNET=y +CONFIG_TELNET_RXBUFFER_SIZE=256 +CONFIG_TELNET_TXBUFFER_SIZE=256 +# CONFIG_NETDEV_MULTINIC is not set +CONFIG_ARCH_HAVE_NETDEV_STATISTICS=y +CONFIG_NETDEV_STATISTICS=y +# CONFIG_NETDEV_LATEINIT is not set + +# +# External Ethernet MAC Device Support +# +# CONFIG_NET_DM90x0 is not set +# CONFIG_ENC28J60 is not set +# CONFIG_ENCX24J600 is not set +# CONFIG_NET_E1000 is not set +# CONFIG_NET_SLIP is not set +# CONFIG_NET_FTMAC100 is not set +# CONFIG_NET_VNET is not set + +# +# External Ethernet PHY Device Support +# +# CONFIG_ARCH_PHY_INTERRUPT is not set +# CONFIG_ETH0_PHY_NONE is not set +# CONFIG_ETH0_PHY_AM79C874 is not set +# CONFIG_ETH0_PHY_KS8721 is not set +# CONFIG_ETH0_PHY_KSZ8041 is not set +# CONFIG_ETH0_PHY_KSZ8051 is not set +# CONFIG_ETH0_PHY_KSZ8061 is not set +CONFIG_ETH0_PHY_KSZ8081=y +# CONFIG_ETH0_PHY_KSZ90x1 is not set +# CONFIG_ETH0_PHY_DP83848C is not set +# CONFIG_ETH0_PHY_LAN8720 is not set +# CONFIG_ETH0_PHY_LAN8740 is not set +# CONFIG_ETH0_PHY_LAN8740A is not set +# CONFIG_ETH0_PHY_LAN8742A is not set +# CONFIG_ETH0_PHY_DM9161 is not set +# CONFIG_PIPES is not set +# CONFIG_PM is not set +# CONFIG_POWER is not set +# CONFIG_SENSORS is not set +# CONFIG_SERCOMM_CONSOLE is not set +CONFIG_SERIAL=y +# CONFIG_DEV_LOWCONSOLE is not set +# CONFIG_SERIAL_REMOVABLE is not set +CONFIG_SERIAL_CONSOLE=y +# CONFIG_16550_UART is not set +# CONFIG_UART_SERIALDRIVER is not set +# CONFIG_UART0_SERIALDRIVER is not set +# CONFIG_UART1_SERIALDRIVER is not set +# CONFIG_UART2_SERIALDRIVER is not set +CONFIG_UART3_SERIALDRIVER=y +# CONFIG_UART4_SERIALDRIVER is not set +# CONFIG_UART5_SERIALDRIVER is not set +# CONFIG_UART6_SERIALDRIVER is not set +# CONFIG_UART7_SERIALDRIVER is not set +# CONFIG_UART8_SERIALDRIVER is not set +# CONFIG_SCI0_SERIALDRIVER is not set +# CONFIG_SCI1_SERIALDRIVER is not set +# CONFIG_USART0_SERIALDRIVER is not set +# CONFIG_USART1_SERIALDRIVER is not set +# CONFIG_USART2_SERIALDRIVER is not set +# CONFIG_USART3_SERIALDRIVER is not set +# CONFIG_USART4_SERIALDRIVER is not set +# CONFIG_USART5_SERIALDRIVER is not set +# CONFIG_USART6_SERIALDRIVER is not set +# CONFIG_USART7_SERIALDRIVER is not set +# CONFIG_USART8_SERIALDRIVER is not set +# CONFIG_OTHER_UART_SERIALDRIVER is not set +CONFIG_MCU_SERIAL=y +CONFIG_STANDARD_SERIAL=y +# CONFIG_SERIAL_IFLOWCONTROL is not set +# CONFIG_SERIAL_OFLOWCONTROL is not set +# CONFIG_SERIAL_DMA is not set +# CONFIG_ARCH_HAVE_SERIAL_TERMIOS is not set +CONFIG_UART3_SERIAL_CONSOLE=y +# CONFIG_OTHER_SERIAL_CONSOLE is not set +# CONFIG_NO_SERIAL_CONSOLE is not set + +# +# UART3 Configuration +# +CONFIG_UART3_RXBUFSIZE=256 +CONFIG_UART3_TXBUFSIZE=256 +CONFIG_UART3_BAUD=115200 +CONFIG_UART3_BITS=8 +CONFIG_UART3_PARITY=0 +CONFIG_UART3_2STOP=0 +# CONFIG_UART3_IFLOWCONTROL is not set +# CONFIG_UART3_OFLOWCONTROL is not set +# CONFIG_UART3_DMA is not set +# CONFIG_USBDEV is not set +# CONFIG_USBHOST is not set +# CONFIG_HAVE_USBTRACE is not set +# CONFIG_DRIVERS_WIRELESS is not set + +# +# System Logging +# +# CONFIG_ARCH_SYSLOG is not set +# CONFIG_RAMLOG is not set +# CONFIG_SYSLOG_INTBUFFER is not set +# CONFIG_SYSLOG_TIMESTAMP is not set +CONFIG_SYSLOG_SERIAL_CONSOLE=y +# CONFIG_SYSLOG_CHAR is not set +CONFIG_SYSLOG_CONSOLE=y +# CONFIG_SYSLOG_NONE is not set +# CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set + +# +# Networking Support +# +CONFIG_ARCH_HAVE_NET=y +CONFIG_ARCH_HAVE_PHY=y +CONFIG_NET=y +# CONFIG_NET_NOINTS is not set +# CONFIG_NET_PROMISCUOUS is not set + +# +# Driver buffer configuration +# +CONFIG_NET_MULTIBUFFER=y +CONFIG_NET_ETH_MTU=590 +CONFIG_NET_ETH_TCP_RECVWNDO=536 +CONFIG_NET_GUARDSIZE=2 + +# +# Data link support +# +# CONFIG_NET_MULTILINK is not set +CONFIG_NET_ETHERNET=y +# CONFIG_NET_LOOPBACK is not set +# CONFIG_NET_TUN is not set + +# +# Network Device Operations +# +CONFIG_NETDEV_PHY_IOCTL=y + +# +# Internet Protocol Selection +# +CONFIG_NET_IPv4=y +# CONFIG_NET_IPv6 is not set + +# +# Socket Support +# +CONFIG_NSOCKET_DESCRIPTORS=8 +CONFIG_NET_NACTIVESOCKETS=16 +CONFIG_NET_SOCKOPTS=y +# CONFIG_NET_SOLINGER is not set + +# +# Raw Socket Support +# +# CONFIG_NET_PKT is not set + +# +# Unix Domain Socket Support +# +# CONFIG_NET_LOCAL is not set + +# +# TCP/IP Networking +# +CONFIG_NET_TCP=y +# CONFIG_NET_TCPURGDATA is not set +CONFIG_NET_TCP_CONNS=8 +CONFIG_NET_MAX_LISTENPORTS=20 +CONFIG_NET_TCP_READAHEAD=y +CONFIG_NET_TCP_WRITE_BUFFERS=y +CONFIG_NET_TCP_NWRBCHAINS=8 +CONFIG_NET_TCP_RECVDELAY=0 +CONFIG_NET_TCPBACKLOG=y +# CONFIG_NET_SENDFILE is not set + +# +# UDP Networking +# +CONFIG_NET_UDP=y +# CONFIG_NET_UDP_CHECKSUMS is not set +CONFIG_NET_UDP_CONNS=8 +CONFIG_NET_BROADCAST=y +# CONFIG_NET_RXAVAIL is not set +CONFIG_NET_UDP_READAHEAD=y + +# +# ICMP Networking Support +# +CONFIG_NET_ICMP=y +CONFIG_NET_ICMP_PING=y + +# +# IGMPv2 Client Support +# +# CONFIG_NET_IGMP is not set + +# +# ARP Configuration +# +CONFIG_NET_ARP=y +CONFIG_NET_ARPTAB_SIZE=16 +CONFIG_NET_ARP_MAXAGE=120 +# CONFIG_NET_ARP_IPIN is not set +CONFIG_NET_ARP_SEND=y +CONFIG_ARP_SEND_MAXTRIES=5 +CONFIG_ARP_SEND_DELAYMSEC=20 + +# +# Network I/O Buffer Support +# +CONFIG_NET_IOB=y +CONFIG_IOB_NBUFFERS=36 +CONFIG_IOB_BUFSIZE=196 +CONFIG_IOB_NCHAINS=8 +CONFIG_IOB_THROTTLE=8 +# CONFIG_NET_ARCH_INCR32 is not set +# CONFIG_NET_ARCH_CHKSUM is not set +CONFIG_NET_STATISTICS=y + +# +# Routing Table Configuration +# +# CONFIG_NET_ROUTE is not set +CONFIG_NET_HOSTNAME="Freedom-K64F" + +# +# Crypto API +# +# CONFIG_CRYPTO is not set + +# +# File Systems +# + +# +# File system configuration +# +# CONFIG_DISABLE_MOUNTPOINT is not set +# CONFIG_FS_AUTOMOUNTER is not set +# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set +CONFIG_FS_READABLE=y +CONFIG_FS_WRITABLE=y +# CONFIG_FS_NAMED_SEMAPHORES is not set +CONFIG_FS_MQUEUE_MPATH="/var/mqueue" +# CONFIG_FS_RAMMAP is not set +CONFIG_FS_FAT=y +# CONFIG_FAT_LCNAMES is not set +# CONFIG_FAT_LFN is not set +# CONFIG_FS_FATTIME is not set +# CONFIG_FAT_FORCE_INDIRECT is not set +# CONFIG_FAT_DMAMEMORY is not set +# CONFIG_FAT_DIRECT_RETRY is not set +# CONFIG_NFS is not set +# CONFIG_FS_NXFFS is not set +# CONFIG_FS_ROMFS is not set +# CONFIG_FS_TMPFS is not set +# CONFIG_FS_SMARTFS is not set +# CONFIG_FS_PROCFS is not set +# CONFIG_FS_UNIONFS is not set + +# +# Graphics Support +# +# CONFIG_NX is not set + +# +# Memory Management +# +# CONFIG_MM_SMALL is not set +CONFIG_MM_REGIONS=1 +# CONFIG_ARCH_HAVE_HEAP2 is not set +# CONFIG_GRAN is not set + +# +# Audio Support +# +# CONFIG_AUDIO is not set + +# +# Wireless Support +# + +# +# Binary Loader +# +# CONFIG_BINFMT_DISABLE is not set +# CONFIG_BINFMT_EXEPATH is not set +# CONFIG_NXFLAT is not set +# CONFIG_ELF is not set +# CONFIG_BUILTIN is not set +# CONFIG_PIC is not set +# CONFIG_SYMTAB_ORDEREDBYNAME is not set + +# +# Library Routines +# + +# +# Standard C Library Options +# +CONFIG_STDIO_BUFFER_SIZE=64 +CONFIG_STDIO_LINEBUFFER=y +CONFIG_NUNGET_CHARS=2 +CONFIG_LIB_HOMEDIR="/" +# CONFIG_LIBM is not set +# CONFIG_NOPRINTF_FIELDWIDTH is not set +# CONFIG_LIBC_FLOATINGPOINT is not set +CONFIG_LIBC_LONG_LONG=y +# CONFIG_LIBC_IOCTL_VARIADIC is not set +CONFIG_LIB_RAND_ORDER=1 +# CONFIG_EOL_IS_CR is not set +# CONFIG_EOL_IS_LF is not set +# CONFIG_EOL_IS_BOTH_CRLF is not set +CONFIG_EOL_IS_EITHER_CRLF=y +# CONFIG_LIBC_EXECFUNCS is not set +CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024 +CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=2048 +# CONFIG_LIBC_STRERROR is not set +# CONFIG_LIBC_PERROR_STDOUT is not set +CONFIG_LIBC_TMPDIR="/tmp" +CONFIG_LIBC_MAX_TMPFILE=32 +CONFIG_ARCH_LOWPUTC=y +# CONFIG_LIBC_LOCALTIME is not set +# CONFIG_TIME_EXTENDED is not set +CONFIG_LIB_SENDFILE_BUFSIZE=512 +# CONFIG_ARCH_ROMGETC is not set +# CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set +CONFIG_ARCH_HAVE_TLS=y +# CONFIG_TLS is not set +CONFIG_LIBC_NETDB=y +# CONFIG_NETDB_HOSTFILE is not set +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDB_DNSCLIENT_ENTRIES=8 +CONFIG_NETDB_DNSCLIENT_NAMESIZE=32 +CONFIG_NETDB_DNSCLIENT_LIFESEC=3600 +CONFIG_NETDB_DNSCLIENT_MAXRESPONSE=96 +# CONFIG_NETDB_RESOLVCONF is not set +# CONFIG_NETDB_DNSSERVER_NOADDR is not set +CONFIG_NETDB_DNSSERVER_IPv4=y +CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x0a000001 + +# +# Non-standard Library Support +# +# CONFIG_LIB_CRC64_FAST is not set +# CONFIG_LIB_KBDCODEC is not set +# CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set + +# +# Basic CXX Support +# +# CONFIG_C99_BOOL8 is not set +# CONFIG_HAVE_CXX is not set + +# +# Application Configuration +# + +# +# CAN Utilities +# + +# +# Examples +# +# CONFIG_EXAMPLES_CHAT is not set +# CONFIG_EXAMPLES_CONFIGDATA is not set +# CONFIG_EXAMPLES_CPUHOG is not set +# CONFIG_EXAMPLES_DHCPD is not set +# CONFIG_EXAMPLES_DISCOVER is not set +# CONFIG_EXAMPLES_ELF is not set +# CONFIG_EXAMPLES_FSTEST is not set +# CONFIG_EXAMPLES_FTPC is not set +# CONFIG_EXAMPLES_FTPD is not set +# CONFIG_EXAMPLES_HELLO is not set +# CONFIG_EXAMPLES_HIDKBD is not set +# CONFIG_EXAMPLES_IGMP is not set +# CONFIG_EXAMPLES_JSON is not set +# CONFIG_EXAMPLES_KEYPADTEST is not set +# CONFIG_EXAMPLES_MEDIA is not set +# CONFIG_EXAMPLES_MM is not set +# CONFIG_EXAMPLES_MODBUS is not set +# CONFIG_EXAMPLES_MOUNT is not set +# CONFIG_EXAMPLES_NETTEST is not set +# CONFIG_EXAMPLES_NRF24L01TERM is not set +CONFIG_EXAMPLES_NSH=y +# CONFIG_EXAMPLES_NULL is not set +# CONFIG_EXAMPLES_NX is not set +# CONFIG_EXAMPLES_NXFFS is not set +# CONFIG_EXAMPLES_NXHELLO is not set +# CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NXLINES is not set +# CONFIG_EXAMPLES_NXTERM is not set +# CONFIG_EXAMPLES_NXTEXT is not set +# CONFIG_EXAMPLES_OSTEST is not set +# CONFIG_EXAMPLES_PCA9635 is not set +# CONFIG_EXAMPLES_PIPE is not set +# CONFIG_EXAMPLES_POLL is not set +# CONFIG_EXAMPLES_POSIXSPAWN is not set +# CONFIG_EXAMPLES_PPPD is not set +# CONFIG_EXAMPLES_RGBLED is not set +# CONFIG_EXAMPLES_RGMP is not set +# CONFIG_EXAMPLES_SENDMAIL is not set +# CONFIG_EXAMPLES_SERIALBLASTER is not set +# CONFIG_EXAMPLES_SERIALRX is not set +# CONFIG_EXAMPLES_SERLOOP is not set +# CONFIG_EXAMPLES_SLCD is not set +# CONFIG_EXAMPLES_SMART is not set +# CONFIG_EXAMPLES_SMP is not set +# CONFIG_EXAMPLES_TCPECHO is not set +# CONFIG_EXAMPLES_TELNETD is not set +# CONFIG_EXAMPLES_TIFF is not set +# CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_UDP is not set +# CONFIG_EXAMPLES_UDPBLASTER is not set +# CONFIG_EXAMPLES_USBTERM is not set +# CONFIG_EXAMPLES_WATCHDOG is not set +# CONFIG_EXAMPLES_WEBSERVER is not set +# CONFIG_EXAMPLES_WGET is not set + +# +# File System Utilities +# +# CONFIG_FSUTILS_INIFILE is not set +# CONFIG_FSUTILS_PASSWD is not set + +# +# GPS Utilities +# +# CONFIG_GPSUTILS_MINMEA_LIB is not set + +# +# Graphics Support +# +# CONFIG_TIFF is not set +# CONFIG_GRAPHICS_TRAVELER is not set + +# +# Interpreters +# +# CONFIG_INTERPRETERS_BAS is not set +# CONFIG_INTERPRETERS_FICL is not set +# CONFIG_INTERPRETERS_MICROPYTHON is not set +# CONFIG_INTERPRETERS_PCODE is not set + +# +# FreeModBus +# +# CONFIG_MODBUS is not set + +# +# Network Utilities +# +# CONFIG_NETUTILS_CODECS is not set +# CONFIG_NETUTILS_DHCPC is not set +# CONFIG_NETUTILS_DHCPD is not set +# CONFIG_NETUTILS_DISCOVER is not set +# CONFIG_NETUTILS_ESP8266 is not set +# CONFIG_NETUTILS_FTPC is not set +# CONFIG_NETUTILS_JSON is not set +CONFIG_NETUTILS_NETLIB=y +# CONFIG_NETUTILS_NTPCLIENT is not set +# CONFIG_NETUTILS_PPPD is not set +# CONFIG_NETUTILS_SMTP is not set +CONFIG_NETUTILS_TELNETD=y +CONFIG_NETUTILS_TFTPC=y +CONFIG_NETUTILS_WEBCLIENT=y +CONFIG_NSH_WGET_USERAGENT="NuttX/6.xx.x (; http://www.nuttx.org/)" +CONFIG_WEBCLIENT_TIMEOUT=10 +# CONFIG_NETUTILS_WEBSERVER is not set +# CONFIG_NETUTILS_XMLRPC is not set + +# +# NSH Library +# +CONFIG_NSH_LIBRARY=y +# CONFIG_NSH_MOTD is not set + +# +# Command Line Configuration +# +CONFIG_NSH_READLINE=y +# CONFIG_NSH_CLE is not set +CONFIG_NSH_LINELEN=64 +# CONFIG_NSH_DISABLE_SEMICOLON is not set +CONFIG_NSH_CMDPARMS=y +CONFIG_NSH_MAXARGUMENTS=6 +CONFIG_NSH_ARGCAT=y +CONFIG_NSH_NESTDEPTH=3 +# CONFIG_NSH_DISABLEBG is not set + +# +# Disable Individual commands +# +# CONFIG_NSH_DISABLE_ADDROUTE is not set +# CONFIG_NSH_DISABLE_ARP is not set +# CONFIG_NSH_DISABLE_BASENAME is not set +# CONFIG_NSH_DISABLE_CAT is not set +# CONFIG_NSH_DISABLE_CD is not set +# CONFIG_NSH_DISABLE_CP is not set +# CONFIG_NSH_DISABLE_CMP is not set +CONFIG_NSH_DISABLE_DATE=y +# CONFIG_NSH_DISABLE_DD is not set +# CONFIG_NSH_DISABLE_DF is not set +# CONFIG_NSH_DISABLE_DELROUTE is not set +# CONFIG_NSH_DISABLE_DIRNAME is not set +# CONFIG_NSH_DISABLE_ECHO is not set +# CONFIG_NSH_DISABLE_EXEC is not set +# CONFIG_NSH_DISABLE_EXIT is not set +# CONFIG_NSH_DISABLE_FREE is not set +# CONFIG_NSH_DISABLE_GET is not set +# CONFIG_NSH_DISABLE_HELP is not set +# CONFIG_NSH_DISABLE_HEXDUMP is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +CONFIG_NSH_DISABLE_IFUPDOWN=y +# CONFIG_NSH_DISABLE_KILL is not set +# CONFIG_NSH_DISABLE_LOSETUP is not set +CONFIG_NSH_DISABLE_LOSMART=y +# CONFIG_NSH_DISABLE_LS is not set +# CONFIG_NSH_DISABLE_MB is not set +# CONFIG_NSH_DISABLE_MKDIR is not set +# CONFIG_NSH_DISABLE_MKFATFS is not set +# CONFIG_NSH_DISABLE_MKFIFO is not set +# CONFIG_NSH_DISABLE_MKRD is not set +# CONFIG_NSH_DISABLE_MH is not set +# CONFIG_NSH_DISABLE_MOUNT is not set +# CONFIG_NSH_DISABLE_MV is not set +# CONFIG_NSH_DISABLE_MW is not set +# CONFIG_NSH_DISABLE_NSLOOKUP is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_NSH_DISABLE_PING is not set +# CONFIG_NSH_DISABLE_PUT is not set +# CONFIG_NSH_DISABLE_PWD is not set +# CONFIG_NSH_DISABLE_RM is not set +# CONFIG_NSH_DISABLE_RMDIR is not set +# CONFIG_NSH_DISABLE_SET is not set +# CONFIG_NSH_DISABLE_SH is not set +# CONFIG_NSH_DISABLE_SLEEP is not set +# CONFIG_NSH_DISABLE_TIME is not set +# CONFIG_NSH_DISABLE_TEST is not set +# CONFIG_NSH_DISABLE_UMOUNT is not set +# CONFIG_NSH_DISABLE_UNAME is not set +# CONFIG_NSH_DISABLE_UNSET is not set +# CONFIG_NSH_DISABLE_USLEEP is not set +# CONFIG_NSH_DISABLE_WGET is not set +# CONFIG_NSH_DISABLE_XD is not set +CONFIG_NSH_MMCSDMINOR=0 + +# +# Configure Command Options +# +CONFIG_NSH_CMDOPT_DF_H=y +CONFIG_NSH_CODECS_BUFSIZE=128 +CONFIG_NSH_CMDOPT_HEXDUMP=y +CONFIG_NSH_FILEIOSIZE=512 + +# +# Scripting Support +# +# CONFIG_NSH_DISABLESCRIPT is not set +# CONFIG_NSH_DISABLE_ITEF is not set +# CONFIG_NSH_DISABLE_LOOPS is not set + +# +# Console Configuration +# +CONFIG_NSH_CONSOLE=y +# CONFIG_NSH_ARCHINIT is not set + +# +# Networking Configuration +# +CONFIG_NSH_NETINIT=y +CONFIG_NSH_NETINIT_THREAD=y +CONFIG_NSH_NETINIT_THREAD_STACKSIZE=1568 +CONFIG_NSH_NETINIT_THREAD_PRIORITY=80 + +# +# IP Address Configuration +# + +# +# IPv4 Addresses +# +CONFIG_NSH_IPADDR=0x0a000002 +CONFIG_NSH_DRIPADDR=0x0a000001 +CONFIG_NSH_NETMASK=0xffffff00 +# CONFIG_NSH_DNS is not set +CONFIG_NSH_NOMAC=y +CONFIG_NSH_SWMAC=y +CONFIG_NSH_MACADDR=0x00e0deadbeef +CONFIG_NSH_MAX_ROUNDTRIP=20 + +# +# Telnet Configuration +# +CONFIG_NSH_TELNET=y +CONFIG_NSH_TELNETD_PORT=23 +CONFIG_NSH_TELNETD_DAEMONPRIO=100 +CONFIG_NSH_TELNETD_DAEMONSTACKSIZE=2048 +CONFIG_NSH_TELNETD_CLIENTPRIO=100 +CONFIG_NSH_TELNETD_CLIENTSTACKSIZE=2048 +CONFIG_NSH_IOBUFFER_SIZE=512 +# CONFIG_NSH_LOGIN is not set +# CONFIG_NSH_CONSOLE_LOGIN is not set +# CONFIG_NSH_TELNET_LOGIN is not set + +# +# NxWidgets/NxWM +# + +# +# Platform-specific Support +# +# CONFIG_PLATFORM_CONFIGDATA is not set + +# +# System Libraries and NSH Add-Ons +# +# CONFIG_SYSTEM_CLE is not set +# CONFIG_SYSTEM_CUTERM is not set +# CONFIG_SYSTEM_FREE is not set +# CONFIG_SYSTEM_HEX2BIN is not set +# CONFIG_SYSTEM_HEXED is not set +# CONFIG_SYSTEM_INSTALL is not set +# CONFIG_SYSTEM_MDIO is not set +# CONFIG_SYSTEM_NETDB is not set +# CONFIG_SYSTEM_RAMTEST is not set +CONFIG_READLINE_HAVE_EXTMATCH=y +CONFIG_SYSTEM_READLINE=y +CONFIG_READLINE_ECHO=y +# CONFIG_READLINE_TABCOMPLETION is not set +# CONFIG_READLINE_CMD_HISTORY is not set +# CONFIG_SYSTEM_SUDOKU is not set +# CONFIG_SYSTEM_UBLOXMODEM is not set +# CONFIG_SYSTEM_VI is not set +# CONFIG_SYSTEM_ZMODEM is not set diff --git a/configs/freedom-k64f/netnsh/setenv.sh b/configs/freedom-k64f/netnsh/setenv.sh new file mode 100644 index 0000000000..c07c4f1607 --- /dev/null +++ b/configs/freedom-k64f/netnsh/setenv.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# configs/freedom-k64f/netnsh/setenv.sh +# +# Copyright (C) 2016 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +if [ "$_" = "$0" ] ; then + echo "You must source this script, not run it!" 1>&2 + exit 1 +fi + +WD=`pwd` +if [ ! -x "setenv.sh" ]; then + echo "This script must be executed from the top-level NuttX build directory" + exit 1 +fi + +if [ -z "${PATH_ORIG}" ]; then + export PATH_ORIG="${PATH}" +fi + +# This is the Cygwin path to the location where I installed the Atmel GCC +# toolchain under Windows. You will also have to edit this if you install +# this toolchain in any other location +#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/Atmel/Atmel Toolchain/ARM GCC/Native/4.7.3.99/arm-gnu-toolchain/bin" + +# This is the Cygwin path to the location where I installed the CodeSourcery +# toolchain under windows. You will also have to edit this if you install +# the CodeSourcery toolchain in any other location +#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery G++ Lite/bin" +#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin" +# export TOOLCHAIN_BIN="/cygdrive/c/Users/MyName/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_EABI/bin" + +# This is the location where I installed the ARM "GNU Tools for ARM Embedded Processors" +# You can this free toolchain here https://launchpad.net/gcc-arm-embedded +export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/bin" + +# This is the path to the location where I installed the devkitARM toolchain +# You can get this free toolchain from http://devkitpro.org/ or http://sourceforge.net/projects/devkitpro/ +#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/devkitARM/bin" + +# This is the Cygwin path to the location where I build the buildroot +# toolchain. +#export TOOLCHAIN_BIN="${WD}/../buildroot/build_arm_nofpu/staging_dir/bin" + +# Add the path to the toolchain to the PATH varialble +export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}" + +echo "PATH : ${PATH}" From 96edfdb4c7ef2cc2a19981375513d23b484989e5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 12 Jul 2016 09:50:32 -0600 Subject: [PATCH 05/15] libm: Fix/improve range checks in lib_expi() and lib_expif(). --- libc/math/lib_libexpi.c | 10 +++++----- libc/math/lib_libexpif.c | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/libc/math/lib_libexpi.c b/libc/math/lib_libexpi.c index bcb5622130..3cd5f8f6d7 100644 --- a/libc/math/lib_libexpi.c +++ b/libc/math/lib_libexpi.c @@ -52,13 +52,12 @@ #define M_E128 (M_E64 * M_E64) #define M_E256 (M_E128 * M_E128) #define M_E512 (M_E256 * M_E256) -#define M_E1024 (M_E512 * M_E512) /**************************************************************************** * Private Data ****************************************************************************/ -static const double g_expi_square_tbl[11] = +static const double g_expi_square_tbl[] = { M_E, /* e^1 */ M_E2, /* e^2 */ @@ -69,8 +68,7 @@ static const double g_expi_square_tbl[11] = M_E64, /* e^64 */ M_E128, /* e^128 */ M_E256, /* e^256 */ - M_E512, /* e^512 */ - M_E1024, /* e^1024 */ + M_E512 /* e^512 */ }; /**************************************************************************** @@ -82,7 +80,9 @@ double lib_expi(size_t n) size_t i; double val; - if (n > 1024) + /* The largest calculable value for n is floor(ln(DBL_MAX)) */ + + if (n > 709) { return INFINITY; } diff --git a/libc/math/lib_libexpif.c b/libc/math/lib_libexpif.c index 1ab9b90f43..22c60f48d1 100644 --- a/libc/math/lib_libexpif.c +++ b/libc/math/lib_libexpif.c @@ -58,7 +58,7 @@ *(3.402823e+38). */ -static const float g_expif_square_tbl[7] = +static const float g_expif_square_tbl[] = { (float)M_E, /* e^1 */ (float)M_E2, /* e^2 */ @@ -66,7 +66,7 @@ static const float g_expif_square_tbl[7] = (float)M_E8, /* e^8 */ (float)M_E16, /* e^16 */ (float)M_E32, /* e^32 */ - (float)M_E64, /* e^64 */ + (float)M_E64 /* e^64 */ }; /**************************************************************************** @@ -78,7 +78,9 @@ float lib_expif(size_t n) size_t i; float val; - if (n >= 128) + /* The largest calculable value for n is floor(ln(FLT_MAX)) */ + + if (n > 88) { return INFINITY_F; } From 0d41a1cd42cf2c168d2f54c0a51cb0e0734bfadc Mon Sep 17 00:00:00 2001 From: Sebastien Lorquet Date: Tue, 12 Jul 2016 10:34:03 -0600 Subject: [PATCH 06/15] Before accessing the sst26 flash, the "Global Unlock" command must me executed, which I do in the sst26 driver. BUT. re-reading the datasheet, the WREN instruction is required to enable the execution of this command. This was not done. I have no idea how the driver currently works except by chance. The writes should never happen at all, the flash is half-enabled! --- drivers/mtd/sst26.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/sst26.c b/drivers/mtd/sst26.c index 51888da063..27648ae91a 100644 --- a/drivers/mtd/sst26.c +++ b/drivers/mtd/sst26.c @@ -245,6 +245,7 @@ static inline void sst26_unlock(FAR struct spi_dev_s *dev); static inline int sst26_readid(struct sst26_dev_s *priv); static void sst26_waitwritecomplete(struct sst26_dev_s *priv); static void sst26_writeenable(struct sst26_dev_s *priv); +static void sst26_writedisable(struct sst26_dev_s *priv); static void sst26_globalunlock(struct sst26_dev_s *priv); static inline void sst26_sectorerase(struct sst26_dev_s *priv, off_t offset, uint8_t type); static inline int sst26_chiperase(struct sst26_dev_s *priv); @@ -427,7 +428,7 @@ static void sst26_globalunlock(struct sst26_dev_s *priv) SPI_SELECT(priv->dev, SPIDEV_FLASH, true); - /* Send "Write Enable (WREN)" command */ + /* Send "Global Unlock (ULBPR)" command */ (void)SPI_SEND(priv->dev, SST26_ULBPR); @@ -459,6 +460,27 @@ static void sst26_writeenable(struct sst26_dev_s *priv) sstinfo("Enabled\n"); } +/************************************************************************************ + * Name: sst26_writedisable + ************************************************************************************/ + +static void sst26_writedisable(struct sst26_dev_s *priv) +{ + /* Select this FLASH part */ + + SPI_SELECT(priv->dev, SPIDEV_FLASH, true); + + /* Send "Write Disable (WRDI)" command */ + + (void)SPI_SEND(priv->dev, SST26_WRDI); + + /* Deselect the FLASH */ + + SPI_SELECT(priv->dev, SPIDEV_FLASH, false); + + sstinfo("Disabled\n"); +} + /************************************************************************************ * Name: sst26_sectorerase (4k) ************************************************************************************/ @@ -939,8 +961,9 @@ FAR struct mtd_dev_s *sst26_initialize_spi(FAR struct spi_dev_s *dev) else { /* Make sure that the FLASH is unprotected so that we can write into it */ - + sst26_writeenable(priv); sst26_globalunlock(priv); + sst26_writedisable(priv); #ifdef CONFIG_MTD_REGISTRATION /* Register the MTD with the procfs system if enabled */ From 74777499bc8c53c797579754645a2b8d85731f08 Mon Sep 17 00:00:00 2001 From: ziggurat29 Date: Tue, 12 Jul 2016 11:46:08 -0500 Subject: [PATCH 07/15] alter the notion of 'blocksize' to be equivalent to 'flash write page size' in order to align with assumptions in the smartfs driver (at least, maybe other things do as well). Correct a bug that was previously masked by having blocksize=eraseblocksize which would cause buffer overflows and delicious hardfaults. Trivial spelling changes in comments, etc. --- drivers/mtd/n25qxxx.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/mtd/n25qxxx.c b/drivers/mtd/n25qxxx.c index 191cc1cd22..38bde4e275 100644 --- a/drivers/mtd/n25qxxx.c +++ b/drivers/mtd/n25qxxx.c @@ -87,7 +87,6 @@ # define CONFIG_N25QXXX_DUMMIES 6 #endif - /* N25QXXX Commands *****************************************************************/ /* Configuration, Status, Erase, Program Commands ***********************************/ /* Command Value Description: */ @@ -98,7 +97,7 @@ * 0x01 | SR */ #define N25QXXX_READ_VOLCFG 0x85 /* Read volatile configuration register: * * 0x85 | VCR */ -#define N25QXXX_WRITE_VOLCFG 0x81 /* Write status register: * +#define N25QXXX_WRITE_VOLCFG 0x81 /* Write svolatile configuration register: * * 0x81 | VCR */ #define N25QXXX_WRITE_ENABLE 0x06 /* Write enable: * * 0x06 */ @@ -123,7 +122,7 @@ /* Command Value Description: */ /* Data sequence */ -/* ID/Security Commands *************************&***********************************/ +/* ID/Security Commands *************************************************************/ /* Command Value Description: */ /* Data sequence */ #define N25QXXX_JEDEC_ID 0x9f /* JEDEC ID: * @@ -141,8 +140,8 @@ /* N25QXXX JEDIC IDs */ -#define N25QXXX3V_JEDEC_DEVICE_TYPE 0xba /* 3v memory device type */ -#define N25QXXX2V_JEDEC_DEVICE_TYPE 0xbb /* 2v memory device type */ +#define N25QXXX3V_JEDEC_DEVICE_TYPE 0xba /* 3v memory device type */ +#define N25QXXX2V_JEDEC_DEVICE_TYPE 0xbb /* 2v memory device type */ #define N25Q016_JEDEC_CAPACITY 0x15 /* N25Q016 (2 MB) memory capacity */ #define N25Q032_JEDEC_CAPACITY 0x16 /* N25Q032 (4 MB) memory capacity */ @@ -168,7 +167,7 @@ #define STATUS_TB_MASK (1 << 5) /* Bit 5: Top / Bottom Protect */ # define STATUS_TB_TOP (0 << 5) /* 0 = BP2-BP0 protect Top down */ # define STATUS_TB_BOTTOM (1 << 5) /* 1 = BP2-BP0 protect Bottom up */ -#define STATUS_BP3_MASK (1 << 5) /* Bit 6: BP3 */ +#define STATUS_BP3_MASK (1 << 5) /* Bit 6: BP3 */ #define STATUS_SRP0_MASK (1 << 7) /* Bit 7: Status register protect 0 */ # define STATUS_SRP0_UNLOCKED (0 << 7) /* 0 = WP# no effect / PS Lock Down */ # define STATUS_SRP0_LOCKED (1 << 7) /* 1 = WP# protect / OTP Lock Down */ @@ -979,7 +978,7 @@ static int n25qxxx_flush_cache(struct n25qxxx_dev_s *priv) ferr("ERROR: n25qxxx_write_page failed: %d\n", ret); } - /* The case is no long dirty and the FLASH is no longer erased */ + /* The cache is no long dirty and the FLASH is no longer erased */ CLR_DIRTY(priv); CLR_ERASED(priv); @@ -1002,7 +1001,7 @@ static FAR uint8_t *n25qxxx_read_cache(struct n25qxxx_dev_s *priv, off_t sector) int ret; /* Convert from the 512 byte sector to the erase sector size of the device. For - * exmample, if the actual erase sector size if 4Kb (1 << 12), then we first + * example, if the actual erase sector size is 4Kb (1 << 12), then we first * shift to the right by 3 to get the sector number in 4096 increments. */ @@ -1218,11 +1217,11 @@ static ssize_t n25qxxx_bread(FAR struct mtd_dev_s *dev, off_t startblock, nbytes >>= N25QXXX_SECTOR512_SHIFT; } #else - nbytes = n25qxxx_read(dev, startblock << priv->sectorshift, - nblocks << priv->sectorshift, buffer); + nbytes = n25qxxx_read(dev, startblock << priv->pageshift, + nblocks << priv->pageshift, buffer); if (nbytes > 0) { - nbytes >>= priv->sectorshift; + nbytes >>= priv->pageshift; } #endif @@ -1253,8 +1252,8 @@ static ssize_t n25qxxx_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, } #else - ret = n25qxxx_write_page(priv, buffer, startblock << priv->sectorshift, - nblocks << priv->sectorshift); + ret = n25qxxx_write_page(priv, buffer, startblock << priv->pageshift, + nblocks << priv->pageshift); if (ret < 0) { ferr("ERROR: n25qxxx_write_page failed: %d\n", ret); @@ -1328,7 +1327,7 @@ static int n25qxxx_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) geo->erasesize = (1 << N25QXXX_SECTOR512_SHIFT); geo->neraseblocks = priv->nsectors << (priv->sectorshift - N25QXXX_SECTOR512_SHIFT); #else - geo->blocksize = (1 << priv->sectorshift); + geo->blocksize = (1 << priv->pageshift); geo->erasesize = (1 << priv->sectorshift); geo->neraseblocks = priv->nsectors; #endif From a45bc22eb59e221935d19bae6485149421b660fc Mon Sep 17 00:00:00 2001 From: ziggurat29 Date: Tue, 12 Jul 2016 12:33:25 -0500 Subject: [PATCH 08/15] update stm32l476 disco to include init code for smartfs and nxffs for cases where those fs are included in build. --- configs/stm32l476vg-disco/src/stm32_appinit.c | 59 +++++++++++++++---- 1 file changed, 49 insertions(+), 10 deletions(-) diff --git a/configs/stm32l476vg-disco/src/stm32_appinit.c b/configs/stm32l476vg-disco/src/stm32_appinit.c index 10eaf1fe88..e242acc67e 100644 --- a/configs/stm32l476vg-disco/src/stm32_appinit.c +++ b/configs/stm32l476vg-disco/src/stm32_appinit.c @@ -210,22 +210,60 @@ FAR struct mtd_dev_s *mtd_temp; g_mtd_fs = mtd_temp; #ifdef CONFIG_MTD_PARTITION - /* Setup a partition of 256KiB for our file system. */ + { + FAR struct mtd_geometry_s geo; + off_t nblocks; -#if defined(CONFIG_N25QXXX_SECTOR512) - mtd_temp = mtd_partition(g_mtd_fs, 0, 512); -#else - mtd_temp = mtd_partition(g_mtd_fs, 0, 64); + /* Setup a partition of 256KiB for our file system. */ + + ret = MTD_IOCTL(g_mtd_fs, MTDIOC_GEOMETRY, (unsigned long)(uintptr_t)&geo); + if (ret < 0) + { + _err("ERROR: MTDIOC_GEOMETRY failed\n"); + return ret; + } + + nblocks = (256*1024) / geo.blocksize; + + mtd_temp = mtd_partition(g_mtd_fs, 0, nblocks); + if (!mtd_temp) + { + _err("ERROR: mtd_partition failed\n"); + return ret; + } + + g_mtd_fs = mtd_temp; + } #endif - if (!g_mtd_fs) + +#ifdef HAVE_N25QXXX_SMARTFS + /* Configure the device with no partition support */ + + ret = smart_initialize(N25QXXX_SMART_MINOR, g_mtd_fs, NULL); + if (ret != OK) { - _err("ERROR: mtd_partition failed\n"); + _err("ERROR: Failed to initialize SmartFS: %d\n", ret); + } + +#elif defined(HAVE_N25QXXX_NXFFS) + /* Initialize to provide NXFFS on the N25QXXX MTD interface */ + + ret = nxffs_initialize(g_mtd_fs); + if (ret < 0) + { + _err("ERROR: NXFFS initialization failed: %d\n", ret); + } + + /* Mount the file system at /mnt/nxffs */ + + ret = mount(NULL, "/mnt/nxffs", "nxffs", 0, NULL); + if (ret < 0) + { + _err("ERROR: Failed to mount the NXFFS volume: %d\n", errno); return ret; } - g_mtd_fs = mtd_temp; -#endif - +#else /* if defined(HAVE_N25QXXX_CHARDEV) */ /* Use the FTL layer to wrap the MTD driver as a block driver */ ret = ftl_initialize(N25QXXX_MTD_MINOR, g_mtd_fs); @@ -256,6 +294,7 @@ FAR struct mtd_dev_s *mtd_temp; _err("ERROR: bchdev_register %s failed: %d\n", chardev, ret); return ret; } +#endif } #endif From 10667bd38af48b5c1b019f3953cf6da761517a94 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 12 Jul 2016 13:46:27 -0600 Subject: [PATCH 09/15] Kinetis Ethernet and Freedcom-K64F: PHY address was wrong. Modified driver to try all PHY addresses and then only fail if the driver cannot find a usable PHY address. MDIO pin must have an internal pull-up on the Freedom-K64F. --- arch/arm/src/kinetis/Kconfig | 21 ++- arch/arm/src/kinetis/chip/kinetis_k60pinmux.h | 14 +- arch/arm/src/kinetis/chip/kinetis_k64pinmux.h | 24 +++- arch/arm/src/kinetis/kinetis_enet.c | 133 +++++++++++++----- configs/freedom-k64f/README.txt | 74 ++++++---- configs/freedom-k64f/include/board.h | 3 +- configs/freedom-k64f/netnsh/defconfig | 15 +- configs/freedom-k64f/nsh/defconfig | 15 +- configs/freedom-k64f/src/k64_bringup.c | 39 ++++- 9 files changed, 258 insertions(+), 80 deletions(-) diff --git a/arch/arm/src/kinetis/Kconfig b/arch/arm/src/kinetis/Kconfig index 2e0ff4ae89..6a0c036765 100644 --- a/arch/arm/src/kinetis/Kconfig +++ b/arch/arm/src/kinetis/Kconfig @@ -548,18 +548,27 @@ config KINETIS_ENETNTXBUFFERS Number of Ethernet Tx buffers to use. The size of one buffer is determined by NET_BUFSIZE -config KINETIS_ENETPHYADDR - int "PHY address" - default 1 - ---help--- - MII/RMII address of the PHY - config KINETIS_ENETUSEMII bool "Use MII interface" default n ---help--- The the MII PHY interface. Default: Use RMII interface +config KINETIS_ENET_MDIOPULLUP + bool "MDIO pull-up" + default n + ---help--- + If there is no on-board pull-up resister on the MII/RMII MDIO line, + then this option may be selected in order to configure an internal + pull-up on MDIO. + +config KINETIS_ENET_NORXER + bool "Suppress RXER" + default n + ---help--- + If selected, then the MII/RMII RXER output will be configured as a + GPIO and pulled low. + endmenu # Kinetis Ethernet Configuration menu "Kinetis SDHC Configuration" diff --git a/arch/arm/src/kinetis/chip/kinetis_k60pinmux.h b/arch/arm/src/kinetis/chip/kinetis_k60pinmux.h index 5cfb3a1aa0..4e7619c18f 100644 --- a/arch/arm/src/kinetis/chip/kinetis_k60pinmux.h +++ b/arch/arm/src/kinetis/chip/kinetis_k60pinmux.h @@ -83,12 +83,12 @@ #define PIN_FTM0_CH1_1 (PIN_ALT3 | PIN_PORTA | PIN4) #define PIN_NMI (PIN_ALT7 | PIN_PORTA | PIN4) #define PIN_FTM0_CH2_1 (PIN_ALT3 | PIN_PORTA | PIN5) -#if 0 +#ifdef CONFIG_KINETIS_ENET_NORXER +# define PIN_RMII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5) +# define PIN_MII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5) +#else # define PIN_RMII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5) # define PIN_MII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5) -#else -# define PIN_RMII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5) -# define PIN_MII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5) #endif #define PIN_CMP2_OUT_1 (PIN_ALT5 | PIN_PORTA | PIN5) #define PIN_I2S0_RX_BCLK_1 (PIN_ALT6 | PIN_PORTA | PIN5) @@ -174,7 +174,11 @@ #define PIN_TSI0_CH0 (PIN_ANALOG | PIN_PORTB | PIN0) #define PIN_I2C0_SCL_1 (PIN_ALT2 | PIN_PORTB | PIN0) #define PIN_FTM1_CH0_3 (PIN_ALT3 | PIN_PORTB | PIN0) -#define PIN_RMII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0) +#ifdef CONFIG_KINETIS_ENET_MDIOPULLUP +# define PIN_RMII0_MDIO (PIN_ALT4_PULLUP | PIN_PORTB | PIN0) +#else +# define PIN_RMII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0) +#endif #define PIN_MII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0) #define PIN_FTM1_QD_PHA_3 (PIN_ALT6 | PIN_PORTB | PIN0) #define PIN_ADC0_SE9 (PIN_ANALOG | PIN_PORTB | PIN1) diff --git a/arch/arm/src/kinetis/chip/kinetis_k64pinmux.h b/arch/arm/src/kinetis/chip/kinetis_k64pinmux.h index 724761a6e8..3479099bf6 100644 --- a/arch/arm/src/kinetis/chip/kinetis_k64pinmux.h +++ b/arch/arm/src/kinetis/chip/kinetis_k64pinmux.h @@ -398,14 +398,22 @@ #define PIN_MII0_COL (PIN_ALT4 | PIN_PORTA | PIN29) #define PIN_MII0_CRS (PIN_ALT4 | PIN_PORTA | PIN27) #define PIN_MII0_MDC (PIN_ALT4 | PIN_PORTB | PIN1) -#define PIN_MII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0) +#ifdef CONFIG_KINETIS_ENET_MDIOPULLUP +# define PIN_MII0_MDIO (PIN_ALT4_PULLUP | PIN_PORTB | PIN0) +#else +# define PIN_MII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0) +#endif #define PIN_MII0_RXCLK (PIN_ALT4 | PIN_PORTA | PIN11) #define PIN_MII0_RXD0 (PIN_ALT4 | PIN_PORTA | PIN13) #define PIN_MII0_RXD1 (PIN_ALT4 | PIN_PORTA | PIN12) #define PIN_MII0_RXD2 (PIN_ALT4 | PIN_PORTA | PIN10) #define PIN_MII0_RXD3 (PIN_ALT4 | PIN_PORTA | PIN9) #define PIN_MII0_RXDV (PIN_ALT4 | PIN_PORTA | PIN14) -#define PIN_MII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5) +#ifdef CONFIG_KINETIS_ENET_NORXER +# define PIN_MII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5) +#else +# define PIN_MII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5) +#endif #define PIN_MII0_TXCLK (PIN_ALT4 | PIN_PORTA | PIN25) #define PIN_MII0_TXD0 (PIN_ALT4 | PIN_PORTA | PIN16) #define PIN_MII0_TXD1 (PIN_ALT4 | PIN_PORTA | PIN17) @@ -427,10 +435,18 @@ #define PIN_RMII0_CRS_DV (PIN_ALT4 | PIN_PORTA | PIN14) #define PIN_RMII0_MDC (PIN_ALT4 | PIN_PORTB | PIN1) -#define PIN_RMII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0) +#ifdef CONFIG_KINETIS_ENET_MDIOPULLUP +# define PIN_RMII0_MDIO (PIN_ALT4_PULLUP | PIN_PORTB | PIN0) +#else +# define PIN_RMII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0) +#endif #define PIN_RMII0_RXD0 (PIN_ALT4 | PIN_PORTA | PIN13) #define PIN_RMII0_RXD1 (PIN_ALT4 | PIN_PORTA | PIN12) -#define PIN_RMII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5) +#ifdef CONFIG_KINETIS_ENET_NORXER +# define PIN_RMII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5) +#else +# define PIN_RMII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5) +#endif #define PIN_RMII0_TXD0 (PIN_ALT4 | PIN_PORTA | PIN16) #define PIN_RMII0_TXD1 (PIN_ALT4 | PIN_PORTA | PIN17) #define PIN_RMII0_TXEN (PIN_ALT4 | PIN_PORTA | PIN15) diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c index c72c12951b..070da795f3 100644 --- a/arch/arm/src/kinetis/kinetis_enet.c +++ b/arch/arm/src/kinetis/kinetis_enet.c @@ -193,6 +193,7 @@ struct kinetis_driver_s uint8_t txtail; /* The oldest busy TX descriptor */ uint8_t txhead; /* The next TX descriptor to use */ uint8_t rxtail; /* The next RX descriptor to use */ + uint8_t phyaddr; /* Selected PHY address */ WDOG_ID txpoll; /* TX poll timer */ WDOG_ID txtimeout; /* TX timeout timer */ struct enet_desc_s *txdesc; /* A pointer to the list of TX descriptor */ @@ -278,7 +279,7 @@ static int kinetis_writemii(struct kinetis_driver_s *priv, uint8_t phyaddr, uint8_t regaddr, uint16_t data); static int kinetis_readmii(struct kinetis_driver_s *priv, uint8_t phyaddr, uint8_t regaddr, uint16_t *data); -static inline void kinetis_initphy(struct kinetis_driver_s *priv); +static inline int kinetis_initphy(struct kinetis_driver_s *priv); /* Initialization */ @@ -954,6 +955,7 @@ static int kinetis_ifup(struct net_driver_s *dev) (FAR struct kinetis_driver_s *)dev->d_private; uint8_t *mac = dev->d_mac.ether_addr_octet; uint32_t regval; + int ret; ninfo("Bringing up: %d.%d.%d.%d\n", dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff, @@ -986,7 +988,12 @@ static int kinetis_ifup(struct net_driver_s *dev) /* Configure the PHY */ - kinetis_initphy(priv); + ret = kinetis_initphy(priv); + if (ret < 0) + { + nerr("ERROR: Failed to configure the PHY: %d\n", ret); + return ret; + } /* Handle promiscuous mode */ @@ -1253,7 +1260,7 @@ static int kinetis_ioctl(struct net_driver_s *dev, int cmd, long arg) { struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = CONFIG_KINETIS_ENETPHYADDR; + req->phy_id = priv->phyaddr; ret = OK; } break; @@ -1418,6 +1425,7 @@ static int kinetis_readmii(struct kinetis_driver_s *priv, uint8_t phyaddr, if (timeout >= MII_MAXPOLLS) { + nerr("ERROR: Timed out waiting for transfer to complete\n"); return -ETIMEDOUT; } @@ -1441,31 +1449,59 @@ static int kinetis_readmii(struct kinetis_driver_s *priv, uint8_t phyaddr, * priv - Reference to the private ENET driver state structure * * Returned Value: - * None + * Zero (OK) returned on success; a negated errno value is returned on any + * failure; * * Assumptions: * ****************************************************************************/ -static inline void kinetis_initphy(struct kinetis_driver_s *priv) +static inline int kinetis_initphy(struct kinetis_driver_s *priv) { uint32_t rcr; uint32_t tcr; uint16_t phydata; + uint8_t phyaddr; + int retries; + int ret; /* Loop (potentially infinitely?) until we successfully communicate with * the PHY. */ - do + for (phyaddr = 0; phyaddr < 32; phyaddr++) { - usleep(LINK_WAITUS); - phydata = 0xffff; - kinetis_readmii(priv, CONFIG_KINETIS_ENETPHYADDR, MII_PHYID1, &phydata); - } - while (phydata == 0xffff); + ninfo("%s: Try phyaddr: %u\n", BOARD_PHY_NAME, phyaddr); + + /* Try to read PHYID1 few times using this address */ + + retries = 0; + do + { + usleep(LINK_WAITUS); + ninfo("%s: Read PHYID1, retries=%d\n", BOARD_PHY_NAME, retries + 1); + phydata = 0xffff; + ret = kinetis_readmii(priv, phyaddr, MII_PHYID1, &phydata); + } + while (ret >= 0 && phydata == 0xffff && ++retries < 3); + + /* If we successfully read anything then break out, using this PHY address */ + + if (retries < 3) + { + break; + } + } + + if (phyaddr >= 32) + { + nerr("ERROR: Failed to read %s PHYID1 at any address\n"); + return -ENOENT; + } + + ninfo("%s: Using PHY address %u\n", BOARD_PHY_NAME, phyaddr); + priv->phyaddr = phyaddr; -#if CONFIG_DEBUG_NET_ERROR /* Verify PHYID1. Compare OUI bits 3-18 */ ninfo("%s: PHYID1: %04x\n", BOARD_PHY_NAME, phydata); @@ -1473,29 +1509,35 @@ static inline void kinetis_initphy(struct kinetis_driver_s *priv) { nerr("ERROR: PHYID1=%04x incorrect for %s. Expected %04x\n", phydata, BOARD_PHY_NAME, BOARD_PHYID1); + return -ENXIO; } - else + + /* Read PHYID2 */ + + ret = kinetis_readmii(priv, phyaddr, MII_PHYID2, &phydata); + if (ret < 0) { - /* Read PHYID2 */ - - kinetis_readmii(priv, CONFIG_KINETIS_ENETPHYADDR, MII_PHYID2, &phydata); - ninfo("%s: PHYID2: %04x\n", BOARD_PHY_NAME, phydata); - - /* Verify PHYID2: Compare OUI bits 19-24 and the 6-bit model number - * (ignoring the 4-bit revision number). - */ - - if ((phydata & 0xfff0) != (BOARD_PHYID2 & 0xfff0)) - { - nerr("ERROR: PHYID2=%04x incorrect for %s. Expected %04x\n", - (phydata & 0xfff0), BOARD_PHY_NAME, (BOARD_PHYID2 & 0xfff0)); - } + nerr("ERROR: Failed to read %s PHYID2: %d\n", BOARD_PHY_NAME, ret); + return ret; + } + + ninfo("%s: PHYID2: %04x\n", BOARD_PHY_NAME, phydata); + + /* Verify PHYID2: Compare OUI bits 19-24 and the 6-bit model number + * (ignoring the 4-bit revision number). + */ + + if ((phydata & 0xfff0) != (BOARD_PHYID2 & 0xfff0)) + { + nerr("ERROR: PHYID2=%04x incorrect for %s. Expected %04x\n", + (phydata & 0xfff0), BOARD_PHY_NAME, (BOARD_PHYID2 & 0xfff0)); + return -ENXIO; } -#endif /* Start auto negotiation */ - kinetis_writemii(priv, CONFIG_KINETIS_ENETPHYADDR, MII_MCR, + ninfo("%s: Start autonegotiation...\n", BOARD_PHY_NAME); + kinetis_writemii(priv, phyaddr, MII_MCR, (MII_MCR_ANRESTART | MII_MCR_ANENABLE)); /* Wait (potentially forever) for auto negotiation to complete */ @@ -1503,16 +1545,30 @@ static inline void kinetis_initphy(struct kinetis_driver_s *priv) do { usleep(LINK_WAITUS); - kinetis_readmii(priv, CONFIG_KINETIS_ENETPHYADDR, MII_MSR, &phydata); + ret = kinetis_readmii(priv, phyaddr, MII_MSR, &phydata); + if (ret < 0) + { + nerr("ERROR: Failed to read %s MII_MSR: %d\n", + BOARD_PHY_NAME, ret); + return ret; + } } while ((phydata & MII_MSR_ANEGCOMPLETE) == 0); + ninfo("%s: Autonegotiation complete\n", BOARD_PHY_NAME); ninfo("%s: MII_MSR: %04x\n", BOARD_PHY_NAME, phydata); /* When we get here we have a link - Find the negotiated speed and duplex. */ phydata = 0; - kinetis_readmii(priv, CONFIG_KINETIS_ENETPHYADDR, BOARD_PHY_STATUS, &phydata); + ret = kinetis_readmii(priv, phyaddr, BOARD_PHY_STATUS, &phydata); + if (ret < 0) + { + nerr("ERROR: Failed to read %s BOARD_PHY_STATUS{%02x]: %d\n", + BOARD_PHY_NAME, BOARD_PHY_STATUS, ret); + return ret; + } + ninfo("%s: BOARD_PHY_STATUS: %04x\n", BOARD_PHY_NAME, phydata); @@ -1540,29 +1596,42 @@ static inline void kinetis_initphy(struct kinetis_driver_s *priv) { /* Full duplex */ + ninfo("%s: Full duplex\n", BOARD_PHY_NAME); tcr |= ENET_TCR_FDEN; } else { /* Half duplex */ + ninfo("%s: Half duplex\n", BOARD_PHY_NAME); rcr |= ENET_RCR_DRT; } if (BOARD_PHY_10BASET(phydata)) { - /* 10Mbps */ + /* 10 Mbps */ + ninfo("%s: 10 Base-T\n", BOARD_PHY_NAME); rcr |= ENET_RCR_RMII_10T; } else if (!BOARD_PHY_100BASET(phydata)) { + /* 100 Mbps */ + + ninfo("%s: 100 Base-T\n", BOARD_PHY_NAME); + } + else + { + /* This might happen if autonegotiation did not complete(?) */ + nerr("ERROR: Neither 10- nor 100-BaseT reported: PHY STATUS=%04x\n", phydata); + return -EIO; } putreg32(rcr, KINETIS_ENET_RCR); putreg32(tcr, KINETIS_ENET_TCR); + return OK; } /**************************************************************************** diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index cfdac464d1..302b37638e 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -134,35 +134,41 @@ Ethernet ------------ ----------------- -------------------------------------------- KSZ8081 Board Signal(s) K64F Pin - Pin Signal Function + Pin Signal Function pinmux Name --- -------- ----------------- -------------------------------------------- - 1 VDD_1V2 VDDPLL_1.2V --- - 2 VDDA_3V3 VDDA_ENET --- - 3 RXM ENET1_RX- --- - 4 RXP ENET1_RX+ --- - 5 TXM ENET1_TX- --- - 6 TXP ENET1_TX+ --- - 7 X0 RMII_XTAL0 --- - 8 XI RMII_XTAL1 --- - 9 REXT --- ---, Apparently not connected - 10 MDIO RMII0_MDIO PTB0/RMII0_MDIO - 11 MDC RMII0_MDC PTB1/RMII0_MDC - 12 RXD1 RMII0_RXD_1 PTA12/RMII0_RXD1 - 13 RXD0 RMII0_RXD_0 PTA13/RMII0_RXD0 - 14 VDDIO VDDIO_ENET --- - 15 CRS_DIV PTA14/RMII0_CRS_DV - 16 REF_CLK RMII_RXCLK PTA18/EXTAL0, PHY clock input - 17 RXER RMII0_RXER PTA5/RMII0_RXER - 18 INTRP RMII0_INT_B, J14 Pin 2, Apparently not available unless jumpered - PHY_INT_1 - 19 TXEN RMII0_TXEN PTA15/RMII0_TXEN - 20 TXD0 RMII0_TXD_0 PTA16/RMII0_TXD0 - 21 TXD1 RMII0_TXD_1 PTA17/RMII0_TXD1 - 22 GND1 --- --- - 24 nRST PHY_RST_B --- - 25 GND2 --- --- + 1 VDD_1V2 VDDPLL_1.2V --- --- + 2 VDDA_3V3 VDDA_ENET --- --- + 3 RXM ENET1_RX- --- --- + 4 RXP ENET1_RX+ --- --- + 5 TXM ENET1_TX- --- --- + 6 TXP ENET1_TX+ --- --- + 7 X0 RMII_XTAL0 --- --- + 8 XI RMII_XTAL1 --- --- + 9 REXT --- ---, Apparently not connected --- + 10 MDIO RMII0_MDIO PTB0/RMII0_MDIO PIN_RMII0_MDIO + 11 MDC RMII0_MDC PTB1/RMII0_MDC PIN_RMII0_MDC + 12 RXD1 RMII0_RXD_1 PTA12/RMII0_RXD1 PIN_RMII0_RXD1 + 13 RXD0 RMII0_RXD_0 PTA13/RMII0_RXD0 PIN_RMII0_RXD0 + 14 VDDIO VDDIO_ENET --- --- + 15 CRS_DIV PTA14/RMII0_CRS_DV PIN_RMII0_CRS_DV + 16 REF_CLK RMII_RXCLK PTA18/EXTAL0, PHY clock input --- + 17 RXER RMII0_RXER PTA5/RMII0_RXER PIN_RMII0_RXER + 18 INTRP RMII0_INT_B, J14 Pin 2, Apparently not --- + PHY_INT_1 available unless jumpered + 19 TXEN RMII0_TXEN PTA15/RMII0_TXEN PIN_RMII0_TXEN + 20 TXD0 RMII0_TXD_0 PTA16/RMII0_TXD0 PIN_RMII0_TXD0 + 21 TXD1 RMII0_TXD_1 PTA17/RMII0_TXD1 PIN_RMII0_TXD1 + 22 GND1 --- --- --- + 24 nRST PHY_RST_B --- --- + 25 GND2 --- --- --- --- -------- ----------------- -------------------------------------------- + No external pullup is available on MDIO signal when MK64FN1M0VLL12 MCU is + requests status of the Ethernet link connection. Internal pullup is required + when port configuration for MDIO signal is enabled: + + CONFIG_KINETIS_ENET_MDIOPULLUP=y + Development Environment ======================= @@ -400,6 +406,12 @@ Where is one of the following: CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc) CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary + 3. No external pullup is available on MDIO signal when MK64FN1M0VLL12 MCU + is requests status of the Ethernet link connection. Internal pullup is + required when port configuration for MDIO signal is enabled: + + CONFIG_KINETIS_ENET_MDIOPULLUP=y + nsh: --- Configures the NuttShell (nsh) located at apps/examples/nsh using a @@ -455,5 +467,13 @@ Status NSH configuration is working and LEDs are working. The only odd behavior that I see is that pressing SW3 causes an unexpected interrupt error. + 2016-07-12: Added support for the KSZ8081 PHY and added the netnsh - configuration. Untested as of this writing. + configuration. The network is basically functional, but a lot more + testing is needed to confirm that. + + In testing, I notice a strange thing. If I run at full optimization the + code runs (albeit with bugs-to-be-solved). But with no optimization or + even at -O1, the system fails to boot. This seems to be related to the + watchdog timer. + diff --git a/configs/freedom-k64f/include/board.h b/configs/freedom-k64f/include/board.h index 7dcb29fc43..a0da55991e 100644 --- a/configs/freedom-k64f/include/board.h +++ b/configs/freedom-k64f/include/board.h @@ -41,8 +41,9 @@ ************************************************************************************/ #include + #ifndef __ASSEMBLY__ -# include +# include #endif /************************************************************************************ diff --git a/configs/freedom-k64f/netnsh/defconfig b/configs/freedom-k64f/netnsh/defconfig index 0cb2657d58..cc59c552c3 100644 --- a/configs/freedom-k64f/netnsh/defconfig +++ b/configs/freedom-k64f/netnsh/defconfig @@ -245,8 +245,9 @@ CONFIG_KINETIS_ENET=y CONFIG_KINETIS_ENETNETHIFS=1 CONFIG_KINETIS_ENETNRXBUFFERS=6 CONFIG_KINETIS_ENETNTXBUFFERS=2 -CONFIG_KINETIS_ENETPHYADDR=1 # CONFIG_KINETIS_ENETUSEMII is not set +CONFIG_KINETIS_ENET_MDIOPULLUP=y +# CONFIG_KINETIS_ENET_NORXER is not set # # Kinetis UART Configuration @@ -759,7 +760,16 @@ CONFIG_FS_FAT=y # CONFIG_FS_ROMFS is not set # CONFIG_FS_TMPFS is not set # CONFIG_FS_SMARTFS is not set -# CONFIG_FS_PROCFS is not set +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y + +# +# Exclude individual procfs entries +# +# CONFIG_FS_PROCFS_EXCLUDE_PROCESS is not set +# CONFIG_FS_PROCFS_EXCLUDE_UPTIME is not set +# CONFIG_FS_PROCFS_EXCLUDE_MOUNTS is not set +# CONFIG_FS_PROCFS_EXCLUDE_NET is not set # CONFIG_FS_UNIONFS is not set # @@ -1057,6 +1067,7 @@ CONFIG_NSH_MMCSDMINOR=0 CONFIG_NSH_CMDOPT_DF_H=y CONFIG_NSH_CODECS_BUFSIZE=128 CONFIG_NSH_CMDOPT_HEXDUMP=y +CONFIG_NSH_PROC_MOUNTPOINT="/proc" CONFIG_NSH_FILEIOSIZE=512 # diff --git a/configs/freedom-k64f/nsh/defconfig b/configs/freedom-k64f/nsh/defconfig index 085afbde09..9da3e6ab0e 100644 --- a/configs/freedom-k64f/nsh/defconfig +++ b/configs/freedom-k64f/nsh/defconfig @@ -192,6 +192,8 @@ CONFIG_ARCH_FAMILY_K64=y CONFIG_KINETIS_UART3=y # CONFIG_KINETIS_UART4 is not set # CONFIG_KINETIS_UART5 is not set +# CONFIG_KINETIS_ENET is not set +# CONFIG_KINETIS_RNGB is not set # CONFIG_KINETIS_FLEXCAN0 is not set # CONFIG_KINETIS_FLEXCAN1 is not set # CONFIG_KINETIS_SPI0 is not set @@ -545,6 +547,7 @@ CONFIG_SYSLOG_SERIAL_CONSOLE=y CONFIG_SYSLOG_CONSOLE=y # CONFIG_SYSLOG_NONE is not set # CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set # # Networking Support @@ -584,7 +587,15 @@ CONFIG_FS_FAT=y # CONFIG_FS_ROMFS is not set # CONFIG_FS_TMPFS is not set # CONFIG_FS_SMARTFS is not set -# CONFIG_FS_PROCFS is not set +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y + +# +# Exclude individual procfs entries +# +# CONFIG_FS_PROCFS_EXCLUDE_PROCESS is not set +# CONFIG_FS_PROCFS_EXCLUDE_UPTIME is not set +# CONFIG_FS_PROCFS_EXCLUDE_MOUNTS is not set # CONFIG_FS_UNIONFS is not set # @@ -829,7 +840,6 @@ CONFIG_NSH_DISABLE_LOSMART=y # CONFIG_NSH_DISABLE_MV is not set # CONFIG_NSH_DISABLE_MW is not set # CONFIG_NSH_DISABLE_PS is not set -# CONFIG_NSH_DISABLE_PSSTACKUSAGE is not set # CONFIG_NSH_DISABLE_PUT is not set # CONFIG_NSH_DISABLE_PWD is not set # CONFIG_NSH_DISABLE_RM is not set @@ -853,6 +863,7 @@ CONFIG_NSH_MMCSDMINOR=0 CONFIG_NSH_CMDOPT_DF_H=y CONFIG_NSH_CODECS_BUFSIZE=128 CONFIG_NSH_CMDOPT_HEXDUMP=y +CONFIG_NSH_PROC_MOUNTPOINT="/proc" CONFIG_NSH_FILEIOSIZE=512 # diff --git a/configs/freedom-k64f/src/k64_bringup.c b/configs/freedom-k64f/src/k64_bringup.c index 0739f95d00..2dfdd963a4 100644 --- a/configs/freedom-k64f/src/k64_bringup.c +++ b/configs/freedom-k64f/src/k64_bringup.c @@ -39,6 +39,7 @@ #include +#include #include #include #include @@ -59,6 +60,25 @@ ****************************************************************************/ /* Configuration ************************************************************/ +/* Automount procfs */ + +#define HAVE_PROC 1 + +#if !defined(CONFIG_FS_PROCFS) +# undef HAVE_PROC +#endif + +#if defined(HAVE_PROC) && defined(CONFIG_DISABLE_MOUNTPOINT) +# warning Mountpoints disabled. No procfs support +# undef HAVE_PROC +#endif + +#if defined(CONFIG_NSH_PROC_MOUNTPOINT) +# define PROCFS_MOUNTPOUNT CONFIG_NSH_PROC_MOUNTPOINT +#else +# define PROCFS_MOUNTPOUNT "/proc" +#endif + /* PORT and SLOT number probably depend on the board configuration */ #ifdef CONFIG_ARCH_BOARD_FREEDOM_K64F @@ -199,9 +219,24 @@ static int k64_cdinterrupt(int irq, FAR void *context) int k64_bringup(void) { -#ifdef NSH_HAVEMMCSD int ret; +#ifdef HAVE_PROC + /* Mount the proc filesystem */ + + syslog(LOG_INFO, "Mounting procfs to /proc\n"); + + ret = mount(NULL, PROCFS_MOUNTPOUNT, "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to mount the PROC filesystem: %d (%d)\n", + ret, errno); + return ret; + } +#endif + +#ifdef NSH_HAVEMMCSD /* Configure GPIO pins */ /* Attached the card detect interrupt (but don't enable it yet) */ @@ -249,6 +284,8 @@ int k64_bringup(void) kinetis_pinirqenable(GPIO_SD_CARDDETECT); #endif + + UNUSED(ret); return OK; } From 6b0b4f9910f3a02cc5b8e47dddaf04b98714ec84 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 12 Jul 2016 14:08:51 -0600 Subject: [PATCH 10/15] Freedom-K64F: Some fixes needed after k64_bringup.c first use. --- configs/freedom-k64f/netnsh/defconfig | 12 +++- configs/freedom-k64f/nsh/defconfig | 12 +++- configs/freedom-k64f/src/freedom-k64f.h | 59 ++++++++++++++++++ configs/freedom-k64f/src/k64_bringup.c | 80 ++----------------------- 4 files changed, 83 insertions(+), 80 deletions(-) diff --git a/configs/freedom-k64f/netnsh/defconfig b/configs/freedom-k64f/netnsh/defconfig index cc59c552c3..05a73a3220 100644 --- a/configs/freedom-k64f/netnsh/defconfig +++ b/configs/freedom-k64f/netnsh/defconfig @@ -332,7 +332,14 @@ CONFIG_ARCH_HAVE_IRQBUTTONS=y # Board-Specific Options # # CONFIG_BOARD_CRASHDUMP is not set -# CONFIG_LIB_BOARDCTL is not set +CONFIG_LIB_BOARDCTL=y +# CONFIG_BOARDCTL_RESET is not set +# CONFIG_BOARDCTL_UNIQUEID is not set +# CONFIG_BOARDCTL_TSCTEST is not set +# CONFIG_BOARDCTL_ADCTEST is not set +# CONFIG_BOARDCTL_PWMTEST is not set +# CONFIG_BOARDCTL_GRAPHICS is not set +# CONFIG_BOARDCTL_IOCTL is not set # # RTOS Features @@ -928,6 +935,7 @@ CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_TOUCHSCREEN is not set # CONFIG_EXAMPLES_UDP is not set # CONFIG_EXAMPLES_UDPBLASTER is not set +# CONFIG_EXAMPLES_USBSERIAL is not set # CONFIG_EXAMPLES_USBTERM is not set # CONFIG_EXAMPLES_WATCHDOG is not set # CONFIG_EXAMPLES_WEBSERVER is not set @@ -1081,7 +1089,7 @@ CONFIG_NSH_FILEIOSIZE=512 # Console Configuration # CONFIG_NSH_CONSOLE=y -# CONFIG_NSH_ARCHINIT is not set +CONFIG_NSH_ARCHINIT=y # # Networking Configuration diff --git a/configs/freedom-k64f/nsh/defconfig b/configs/freedom-k64f/nsh/defconfig index 9da3e6ab0e..7fb687ca4a 100644 --- a/configs/freedom-k64f/nsh/defconfig +++ b/configs/freedom-k64f/nsh/defconfig @@ -314,7 +314,14 @@ CONFIG_ARCH_HAVE_IRQBUTTONS=y # Board-Specific Options # # CONFIG_BOARD_CRASHDUMP is not set -# CONFIG_LIB_BOARDCTL is not set +CONFIG_LIB_BOARDCTL=y +# CONFIG_BOARDCTL_RESET is not set +# CONFIG_BOARDCTL_UNIQUEID is not set +# CONFIG_BOARDCTL_TSCTEST is not set +# CONFIG_BOARDCTL_ADCTEST is not set +# CONFIG_BOARDCTL_PWMTEST is not set +# CONFIG_BOARDCTL_GRAPHICS is not set +# CONFIG_BOARDCTL_IOCTL is not set # # RTOS Features @@ -741,6 +748,7 @@ CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_TELNETD is not set # CONFIG_EXAMPLES_TIFF is not set # CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_USBSERIAL is not set # CONFIG_EXAMPLES_USBTERM is not set # CONFIG_EXAMPLES_WATCHDOG is not set # CONFIG_EXAMPLES_WEBSERVER is not set @@ -878,7 +886,7 @@ CONFIG_NSH_FILEIOSIZE=512 # CONFIG_NSH_CONSOLE=y # CONFIG_NSH_ALTCONDEV is not set -# CONFIG_NSH_ARCHINIT is not set +CONFIG_NSH_ARCHINIT=y # CONFIG_NSH_LOGIN is not set # CONFIG_NSH_CONSOLE_LOGIN is not set diff --git a/configs/freedom-k64f/src/freedom-k64f.h b/configs/freedom-k64f/src/freedom-k64f.h index a253dd3be4..a6758ebb0f 100644 --- a/configs/freedom-k64f/src/freedom-k64f.h +++ b/configs/freedom-k64f/src/freedom-k64f.h @@ -49,6 +49,65 @@ * Pre-processor Definitions ************************************************************************************/ +/* Application Configuration ********************************************************/ + +/* Assume we have everything */ + +#define HAVE_PROC 1 +#define NSH_HAVEUSBDEV 1 +#define NSH_HAVEMMCSD 1 + +/* Automount procfs */ + +#if !defined(CONFIG_FS_PROCFS) +# undef HAVE_PROC +#endif + +#if defined(HAVE_PROC) && defined(CONFIG_DISABLE_MOUNTPOINT) +# warning Mountpoints disabled. No procfs support +# undef HAVE_PROC +#endif + +#if defined(CONFIG_NSH_PROC_MOUNTPOINT) +# define PROCFS_MOUNTPOUNT CONFIG_NSH_PROC_MOUNTPOINT +#else +# define PROCFS_MOUNTPOUNT "/proc" +#endif + +/* SD card support */ + +#define MMCSD_SLOTNO 0 + +/* Can't support MMC/SD features if mountpoints are disabled or if SDHC support + * is not enabled. + */ + +#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_KINETIS_SDHC) +# undef NSH_HAVEMMCSD +#endif + +#ifdef NSH_HAVEMMCSD +# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != 0 +# error "Only one MMC/SD slot, slot 0" +# endif + +/* We expect to receive GPIO interrupts for card insertion events */ + +# ifndef CONFIG_GPIO_IRQ +# error "CONFIG_GPIO_IRQ required for card detect interrupt" +# endif + +# ifndef CONFIG_KINETIS_PORTEINTS +# error "CONFIG_KINETIS_PORTEINTS required for card detect interrupt" +# endif +#endif + +/* Can't support USB features if USB is not enabled */ + +#ifndef CONFIG_USBDEV +# undef NSH_HAVEUSBDEV +#endif + /* How many SPI modules does this chip support? The LM3S6918 supports 2 SPI * modules (others may support more -- in such case, the following must be * expanded). diff --git a/configs/freedom-k64f/src/k64_bringup.c b/configs/freedom-k64f/src/k64_bringup.c index 2dfdd963a4..0cbbb1bb28 100644 --- a/configs/freedom-k64f/src/k64_bringup.c +++ b/configs/freedom-k64f/src/k64_bringup.c @@ -55,77 +55,6 @@ #if defined(CONFIG_LIB_BOARDCTL) || defined(CONFIG_BOARD_INITIALIZE) -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ -/* Configuration ************************************************************/ - -/* Automount procfs */ - -#define HAVE_PROC 1 - -#if !defined(CONFIG_FS_PROCFS) -# undef HAVE_PROC -#endif - -#if defined(HAVE_PROC) && defined(CONFIG_DISABLE_MOUNTPOINT) -# warning Mountpoints disabled. No procfs support -# undef HAVE_PROC -#endif - -#if defined(CONFIG_NSH_PROC_MOUNTPOINT) -# define PROCFS_MOUNTPOUNT CONFIG_NSH_PROC_MOUNTPOINT -#else -# define PROCFS_MOUNTPOUNT "/proc" -#endif - -/* PORT and SLOT number probably depend on the board configuration */ - -#ifdef CONFIG_ARCH_BOARD_FREEDOM_K64F -# define NSH_HAVEUSBDEV 1 -# define NSH_HAVEMMCSD 1 -# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != 0 -# error "Only one MMC/SD slot, slot 0" -# undef CONFIG_NSH_MMCSDSLOTNO -# endif -# ifndef CONFIG_NSH_MMCSDSLOTNO -# define CONFIG_NSH_MMCSDSLOTNO 0 -# endif -#else - /* Add configuration for new Kinetis boards here */ -# error "Unrecognized Kinetis board" -# undef NSH_HAVEUSBDEV -# undef NSH_HAVEMMCSD -#endif - -/* Can't support USB features if USB is not enabled */ - -#ifndef CONFIG_USBDEV -# undef NSH_HAVEUSBDEV -#endif - -/* Can't support MMC/SD features if mountpoints are disabled or if SDHC support - * is not enabled. - */ - -#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_KINETIS_SDHC) -# undef NSH_HAVEMMCSD -#endif - -#ifndef CONFIG_NSH_MMCSDMINOR -# define CONFIG_NSH_MMCSDMINOR 0 -#endif - -/* We expect to receive GPIO interrupts for card insertion events */ - -#ifndef CONFIG_GPIO_IRQ -# error "CONFIG_GPIO_IRQ required for card detect interrupt" -#endif - -#ifndef CONFIG_KINETIS_PORTEINTS -# error "CONFIG_KINETIS_PORTEINTS required for card detect interrupt" -#endif - /**************************************************************************** * Private Types ****************************************************************************/ @@ -246,19 +175,18 @@ int k64_bringup(void) /* Configure the write protect GPIO */ - kinetis_pinconfig(GPIO_SD_WRPROTECT); + //kinetis_pinconfig(GPIO_SD_WRPROTECT); /* Mount the SDHC-based MMC/SD block driver */ /* First, get an instance of the SDHC interface */ - syslog(LOG_INFO, "Initializing SDHC slot %d\n", - CONFIG_NSH_MMCSDSLOTNO); + syslog(LOG_INFO, "Initializing SDHC slot %d\n", MMCSD_SLOTNO); - g_nsh.sdhc = sdhc_initialize(CONFIG_NSH_MMCSDSLOTNO); + g_nsh.sdhc = sdhc_initialize(MMCSD_SLOTNO); if (!g_nsh.sdhc) { syslog(LOG_ERR, "ERROR: Failed to initialize SDHC slot %d\n", - CONFIG_NSH_MMCSDSLOTNO); + MMCSD_SLOTNO); return -ENODEV; } From 0154e300e835a0c1dcf57b5c8b9605b9173a4805 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 12 Jul 2016 15:05:35 -0600 Subject: [PATCH 11/15] Freedom K16F: Correct calculations for SDHC clock --- configs/freedom-k64f/include/board.h | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/configs/freedom-k64f/include/board.h b/configs/freedom-k64f/include/board.h index a0da55991e..198915caa9 100644 --- a/configs/freedom-k64f/include/board.h +++ b/configs/freedom-k64f/include/board.h @@ -69,7 +69,7 @@ * * PLL Input frequency: PLLIN = REFCLK / PRDIV = 50 Mhz / 20 = 2.5 MHz * PLL Output frequency: PLLOUT = PLLIN * VDIV = 2.5 Mhz * 48 = 120 MHz - * MCG Frequency: PLLOUT = 96MHz + * MCG Frequency: PLLOUT = 120 MHz * * PRDIV register value is the divider minus one. So 20 -> 19 * VDIV regiser value is offset by 24. So 28 -> 24 @@ -101,36 +101,37 @@ * SDCLK frequency = (base clock) / (prescaler * divisor) * * The SDHC module is always configure configured so that the core clock is the base - * clock. + * clock. Possible values for presscaler and divisor are: + * + * SDCLKFS: {2, 4, 8, 16, 32, 63, 128, 256} + * DVS: {1..16} */ -/* Identification mode: 400KHz = 96MHz / ( 16 * 15) */ +/* Identification mode: Optimal 400KHz, Actual 120MHz / (32 * 10) = 375 Khz */ -#define BOARD_SDHC_IDMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV16 -#define BOARD_SDHC_IDMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(15) +#define BOARD_SDHC_IDMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV32 +#define BOARD_SDHC_IDMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(10) -/* MMC normal mode: 16MHz = 96MHz / (2 * 3) */ +/* MMC normal mode: Optimal 20MHz, Actual 120MHz / (2 * 3) = 20 MHz */ #define BOARD_SDHC_MMCMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2 #define BOARD_SDHC_MMCMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3) -/* SD normal mode (1-bit): 16MHz = 96MHz / (2 * 3) */ +/* SD normal mode (1-bit): Optimal 20MHz, Actual 120MHz / (2 * 3) = 20 MHz */ #define BOARD_SDHC_SD1MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2 #define BOARD_SDHC_SD1MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3) -/* SD normal mode (4-bit): 24MHz = 96MHz / (2 * 2) (with DMA) - * SD normal mode (4-bit): 16MHz = 96MHz / (2 * 3) (no DMA) +/* SD normal mode (4-bit): Optimal 25MHz, Actual 120MHz / (2 * 3) = 20 MHz (with DMA) + * SD normal mode (4-bit): Optimal 20MHz, Actual 120MHz / (2 * 3) = 20 MHz (no DMA) */ #ifdef CONFIG_SDIO_DMA # define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2 -# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(2) +# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3) #else -//# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2 -//# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3) -# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV16 -# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(15) +# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2 +# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3) #endif /* LED definitions ******************************************************************/ From dee77a5dd9a7830cfe7494efe13393ebbbe64e37 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 12 Jul 2016 16:17:35 -0600 Subject: [PATCH 12/15] Kinetis Ethernet: Add support for CONFIG_NET_NOINTS --- TODO | 1 + arch/arm/src/kinetis/kinetis_enet.c | 463 +++++++++++++++++++++++--- configs/freedom-k64f/netnsh/defconfig | 11 +- 3 files changed, 419 insertions(+), 56 deletions(-) diff --git a/TODO b/TODO index 5c67ae83ac..bbc8f7657a 100644 --- a/TODO +++ b/TODO @@ -937,6 +937,7 @@ o Network (net/, drivers/net) LM3S NO NO TM4C YES YES eZ80 NO NO + Kinetis YES YES (not tested) LPC17xx YES YES (not tested) LPC43xx YES YES (not tested) DMxxx NIC NO NO diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c index 070da795f3..6c30bac415 100644 --- a/arch/arm/src/kinetis/kinetis_enet.c +++ b/arch/arm/src/kinetis/kinetis_enet.c @@ -57,6 +57,10 @@ #include #include +#ifdef CONFIG_NET_NOINTS +# include +#endif + #ifdef CONFIG_NET_PKT # include #endif @@ -76,6 +80,14 @@ * Pre-processor Definitions ****************************************************************************/ +/* If processing is not done at the interrupt level, then high priority + * work queue support is required. + */ + +#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_HPWORK) +# error High priority work queue support is required +#endif + /* CONFIG_KINETIS_ENETNETHIFS determines the number of physical interfaces * that will be supported. */ @@ -92,13 +104,16 @@ # error "Need at least one RX buffer" #endif -#define NENET_NBUFFERS (CONFIG_KINETIS_ENETNTXBUFFERS+CONFIG_KINETIS_ENETNRXBUFFERS) +#define NENET_NBUFFERS \ + (CONFIG_KINETIS_ENETNTXBUFFERS+CONFIG_KINETIS_ENETNRXBUFFERS) #ifndef CONFIG_NET_MULTIBUFFER # error "CONFIG_NET_MULTIBUFFER is required in the configuration" #endif -/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ +/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per + * second. + */ #define KINETIS_WDDELAY (1*CLK_TCK) @@ -196,6 +211,9 @@ struct kinetis_driver_s uint8_t phyaddr; /* Selected PHY address */ WDOG_ID txpoll; /* TX poll timer */ WDOG_ID txtimeout; /* TX timeout timer */ +#ifdef CONFIG_NET_NOINTS + struct work_s work; /* For deferring work to the work queue */ +#endif struct enet_desc_s *txdesc; /* A pointer to the list of TX descriptor */ struct enet_desc_s *rxdesc; /* A pointer to the list of RX descriptors */ @@ -252,22 +270,43 @@ static int kinetis_txpoll(struct net_driver_s *dev); static void kinetis_receive(FAR struct kinetis_driver_s *priv); static void kinetis_txdone(FAR struct kinetis_driver_s *priv); + +static inline void kinetis_interrupt_process(FAR struct kinetis_driver_s *priv); +#ifdef CONFIG_NET_NOINTS +static void kinetis_interrupt_work(FAR void *arg); +#endif static int kinetis_interrupt(int irq, FAR void *context); /* Watchdog timer expirations */ -static void kinetis_txtimeout(int argc, uint32_t arg, ...); -static void kinetis_polltimer(int argc, uint32_t arg, ...); +static inline void kinetis_txtimeout_process(FAR struct kinetis_driver_s *priv); +#ifdef CONFIG_NET_NOINTS +static void kinetis_txtimeout_work(FAR void *arg); +#endif +static void kinetis_txtimeout_expiry(int argc, uint32_t arg, ...); + +static inline void kinetis_poll_process(FAR struct kinetis_driver_s *priv); +#ifdef CONFIG_NET_NOINTS +static void kinetis_poll_work(FAR void *arg); +#endif +static void kinetis_polltimer_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ static int kinetis_ifup(struct net_driver_s *dev); static int kinetis_ifdown(struct net_driver_s *dev); + +static inline void kinetis_txavail_process(FAR struct kinetis_driver_s *priv); +#ifdef CONFIG_NET_NOINTS +static void kinetis_txavail_work(FAR void *arg); +#endif static int kinetis_txavail(struct net_driver_s *dev); + #ifdef CONFIG_NET_IGMP static int kinetis_addmac(struct net_driver_s *dev, FAR const uint8_t *mac); static int kinetis_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac); #endif + #ifdef CONFIG_NETDEV_PHY_IOCTL static int kinetis_ioctl(struct net_driver_s *dev, int cmd, long arg); #endif @@ -464,8 +503,8 @@ static int kinetis_transmit(FAR struct kinetis_driver_s *priv) /* Setup the TX timeout watchdog (perhaps restarting the timer) */ - (void)wd_start(priv->txtimeout, KINETIS_TXTIMEOUT, kinetis_txtimeout, 1, - (uint32_t)priv); + (void)wd_start(priv->txtimeout, KINETIS_TXTIMEOUT, kinetis_txtimeout_expiry, 1, + (wdparm_t)priv); return OK; } @@ -777,28 +816,25 @@ static void kinetis_txdone(FAR struct kinetis_driver_s *priv) } /**************************************************************************** - * Function: kinetis_interrupt + * Function: kinetis_interrupt_process * * Description: - * Three interrupt sources will vector this this function: - * 1. Ethernet MAC transmit interrupt handler - * 2. Ethernet MAC receive interrupt handler - * 3. + * Interrupt processing. This may be performed either within the interrupt + * handler or on the worker thread, depending upon the configuration * * Parameters: - * irq - Number of the IRQ that generated the interrupt - * context - Interrupt register state save info (architecture-specific) + * priv - Reference to the driver state structure * * Returned Value: - * OK on success + * None * * Assumptions: + * The network is locked. * ****************************************************************************/ -static int kinetis_interrupt(int irq, FAR void *context) +static inline void kinetis_interrupt_process(FAR struct kinetis_driver_s *priv) { - register FAR struct kinetis_driver_s *priv = &g_enet[0]; uint32_t pending; /* Get the set of unmasked, pending interrupt. */ @@ -848,33 +884,130 @@ static int kinetis_interrupt(int irq, FAR void *context) putreg32(ENET_RDAR, KINETIS_ENET_RDAR); } +} + +/**************************************************************************** + * Function: kinetis_interrupt_work + * + * Description: + * Perform interrupt related work from the worker thread + * + * Parameters: + * arg - The argument passed when work_queue() was called. + * + * Returned Value: + * OK on success + * + * Assumptions: + * The network is locked. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_NOINTS +static void kinetis_interrupt_work(FAR void *arg) +{ + FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg; + net_lock_t state; + + /* Process pending Ethernet interrupts */ + + state = net_lock(); + kinetis_interrupt_process(priv); + net_unlock(state); + + /* Re-enable Ethernet interrupts */ + +#if 0 + up_enable_irq(KINETIS_IRQ_EMACTMR); +#endif + up_enable_irq(KINETIS_IRQ_EMACTX); + up_enable_irq(KINETIS_IRQ_EMACRX); + up_enable_irq(KINETIS_IRQ_EMACMISC); +} +#endif + +/**************************************************************************** + * Function: kinetis_interrupt + * + * Description: + * Three interrupt sources will vector this this function: + * 1. Ethernet MAC transmit interrupt handler + * 2. Ethernet MAC receive interrupt handler + * 3. + * + * Parameters: + * irq - Number of the IRQ that generated the interrupt + * context - Interrupt register state save info (architecture-specific) + * + * Returned Value: + * OK on success + * + * Assumptions: + * + ****************************************************************************/ + +static int kinetis_interrupt(int irq, FAR void *context) +{ + register FAR struct kinetis_driver_s *priv = &g_enet[0]; + +#ifdef CONFIG_NET_NOINTS + /* Disable further Ethernet interrupts. Because Ethernet interrupts are + * also disabled if the TX timeout event occurs, there can be no race + * condition here. + */ + + up_disable_irq(KINETIS_IRQ_EMACTMR); + up_disable_irq(KINETIS_IRQ_EMACTX); + up_disable_irq(KINETIS_IRQ_EMACRX); + up_disable_irq(KINETIS_IRQ_EMACMISC); + + /* TODO: Determine if a TX transfer just completed */ + + { + /* If a TX transfer just completed, then cancel the TX timeout so + * there will be do race condition between any subsequent timeout + * expiration and the deferred interrupt processing. + */ + + wd_cancel(priv->txtimeout); + } + + /* Cancel any pending poll work */ + + work_cancel(HPWORK, &priv->work); + + /* Schedule to perform the interrupt processing on the worker thread. */ + + work_queue(HPWORK, &priv->work, kinetis_interrupt_work, priv, 0); + +#else + /* Process the interrupt now */ + + kinetis_interrupt_process(priv); +#endif return OK; } /**************************************************************************** - * Function: kinetis_txtimeout + * Function: kinetis_txtimeout_process * * Description: - * Our TX watchdog timed out. Called from the timer interrupt handler. - * The last TX never completed. Reset the hardware and start again. + * Process a TX timeout. Called from the either the watchdog timer + * expiration logic or from the worker thread, depending upon the + * configuration. The timeout means that the last TX never completed. + * Reset the hardware and start again. * * Parameters: - * argc - The number of available arguments - * arg - The first argument + * priv - Reference to the driver state structure * * Returned Value: * None * - * Assumptions: - * Global interrupts are disabled by the watchdog logic. - * ****************************************************************************/ -static void kinetis_txtimeout(int argc, uint32_t arg, ...) +static inline void kinetis_txtimeout_process(FAR struct kinetis_driver_s *priv) { - FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg; - /* Increment statistics and dump debug info */ NETDEV_TXTIMEOUTS(&priv->dev); @@ -892,10 +1025,42 @@ static void kinetis_txtimeout(int argc, uint32_t arg, ...) } /**************************************************************************** - * Function: kinetis_polltimer + * Function: kinetis_txtimeout_work * * Description: - * Periodic timer handler. Called from the timer interrupt handler. + * Perform TX timeout related work from the worker thread + * + * Parameters: + * arg - The argument passed when work_queue() as called. + * + * Returned Value: + * OK on success + * + * Assumptions: + * The network is locked. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_NOINTS +static void kinetis_txtimeout_work(FAR void *arg) +{ + FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg; + net_lock_t state; + + /* Process pending Ethernet interrupts */ + + state = net_lock(); + kinetis_txtimeout_process(priv); + net_unlock(state); +} +#endif + +/**************************************************************************** + * Function: kinetis_txtimeout_expiry + * + * Description: + * Our TX watchdog timed out. Called from the timer interrupt handler. + * The last TX never completed. Reset the hardware and start again. * * Parameters: * argc - The number of available arguments @@ -909,10 +1074,56 @@ static void kinetis_txtimeout(int argc, uint32_t arg, ...) * ****************************************************************************/ -static void kinetis_polltimer(int argc, uint32_t arg, ...) +static void kinetis_txtimeout_expiry(int argc, uint32_t arg, ...) { FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg; +#ifdef CONFIG_NET_NOINTS + /* Disable further Ethernet interrupts. This will prevent some race + * conditions with interrupt work. There is still a potential race + * condition with interrupt work that is already queued and in progress. + */ + + up_disable_irq(KINETIS_IRQ_EMACTMR); + up_disable_irq(KINETIS_IRQ_EMACTX); + up_disable_irq(KINETIS_IRQ_EMACRX); + up_disable_irq(KINETIS_IRQ_EMACMISC); + + /* Cancel any pending poll or interrupt work. This will have no effect + * on work that has already been started. + */ + + work_cancel(HPWORK, &priv->work); + + /* Schedule to perform the TX timeout processing on the worker thread. */ + + work_queue(HPWORK, &priv->work, kinetis_txtimeout_work, priv, 0); +#else + /* Process the timeout now */ + + kinetis_txtimeout_process(priv); +#endif +} + +/**************************************************************************** + * Function: kinetis_poll_process + * + * Description: + * Perform the periodic poll. This may be called either from watchdog + * timer logic or from the worker thread, depending upon the configuration. + * + * Parameters: + * priv - Reference to the driver state structure + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +static inline void kinetis_poll_process(FAR struct kinetis_driver_s *priv) +{ /* Check if there is there is a transmission in progress. We cannot perform * the TX poll if he are unable to accept another packet for transmission. */ @@ -929,7 +1140,89 @@ static void kinetis_polltimer(int argc, uint32_t arg, ...) /* Setup the watchdog poll timer again in any case */ - (void)wd_start(priv->txpoll, KINETIS_WDDELAY, kinetis_polltimer, 1, arg); + (void)wd_start(priv->txpoll, KINETIS_WDDELAY, kinetis_polltimer_expiry, + 1, (wdparm_t)priv); +} + +/**************************************************************************** + * Function: kinetis_poll_work + * + * Description: + * Perform periodic polling from the worker thread + * + * Parameters: + * arg - The argument passed when work_queue() as called. + * + * Returned Value: + * OK on success + * + * Assumptions: + * The network is locked. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_NOINTS +static void kinetis_poll_work(FAR void *arg) +{ + FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg; + net_lock_t state; + + /* Perform the poll */ + + state = net_lock(); + kinetis_poll_process(priv); + net_unlock(state); +} +#endif + +/**************************************************************************** + * Function: kinetis_polltimer_expiry + * + * Description: + * Periodic timer handler. Called from the timer interrupt handler. + * + * Parameters: + * argc - The number of available arguments + * arg - The first argument + * + * Returned Value: + * None + * + * Assumptions: + * Global interrupts are disabled by the watchdog logic. + * + ****************************************************************************/ + +static void kinetis_polltimer_expiry(int argc, uint32_t arg, ...) +{ + FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg; + +#ifdef CONFIG_NET_NOINTS + /* Is our single work structure available? It may not be if there are + * pending interrupt actions. + */ + + if (work_available(&priv->work)) + { + /* Schedule to perform the interrupt processing on the worker thread. */ + + work_queue(HPWORK, &priv->work, kinetis_poll_work, priv, 0); + } + else + { + /* No.. Just re-start the watchdog poll timer, missing one polling + * cycle. + */ + + (void)wd_start(priv->txpoll, KINETIS_WDDELAY, kinetis_polltimer_expiry, + 1, (wdparm_t)arg); + } + +#else + /* Process the interrupt now */ + + kinetis_poll_process(priv); +#endif } /**************************************************************************** @@ -1039,8 +1332,8 @@ static int kinetis_ifup(struct net_driver_s *dev) /* Set and activate a timer process */ - (void)wd_start(priv->txpoll, KINETIS_WDDELAY, kinetis_polltimer, 1, - (uint32_t)priv); + (void)wd_start(priv->txpoll, KINETIS_WDDELAY, kinetis_polltimer_expiry, 1, + (wdparm_t)priv); /* Clear all pending ENET interrupt */ @@ -1115,6 +1408,77 @@ static int kinetis_ifdown(struct net_driver_s *dev) return OK; } +/**************************************************************************** + * Function: kinetis_txavail_process + * + * Description: + * Perform an out-of-cycle poll. + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * + * Returned Value: + * None + * + * Assumptions: + * Called in normal user mode + * + ****************************************************************************/ + +static inline void kinetis_txavail_process(FAR struct kinetis_driver_s *priv) +{ + net_lock_t state; + + /* Ignore the notification if the interface is not yet up */ + + state = net_lock(); + if (priv->bifup) + { + /* Check if there is room in the hardware to hold another outgoing + * packet. + */ + + if (!kinetics_txringfull(priv)) + { + /* No, there is space for another transfer. Poll the network for new + * XMIT data. + */ + + (void)devif_poll(&priv->dev, kinetis_txpoll); + } + } + + net_unlock(state); +} + +/**************************************************************************** + * Function: kinetis_txavail_work + * + * Description: + * Perform an out-of-cycle poll on the worker thread. + * + * Parameters: + * arg - Reference to the NuttX driver state structure (cast to void*) + * + * Returned Value: + * None + * + * Assumptions: + * Called on the higher priority worker thread. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_NOINTS +static void kinetis_txavail_work(FAR void *arg) +{ + FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg; + + /* Perform the poll */ + + kinetis_txavail_process(priv); +} +#endif + /**************************************************************************** * Function: kinetis_txavail * @@ -1138,33 +1502,26 @@ static int kinetis_txavail(struct net_driver_s *dev) { FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)dev->d_private; - irqstate_t flags; - /* Disable interrupts because this function may be called from interrupt - * level processing. +#ifdef CONFIG_NET_NOINTS + /* Is our single work structure available? It may not be if there are + * pending interrupt actions and we will have to ignore the Tx + * availability action. */ - flags = enter_critical_section(); - - /* Ignore the notification if the interface is not yet up */ - - if (priv->bifup) + if (work_available(&priv->work)) { - /* Check if there is room in the hardware to hold another outgoing - * packet. - */ + /* Schedule to serialize the poll on the worker thread. */ - if (!kinetics_txringfull(priv)) - { - /* No, there is space for another transfer. Poll the network for new - * XMIT data. - */ - - (void)devif_poll(&priv->dev, kinetis_txpoll); - } + work_queue(HPWORK, &priv->work, kinetis_txavail_work, priv, 0); } - leave_critical_section(flags); +#else + /* Perform the out-of-cycle poll now */ + + kinetis_txavail_process(priv); +#endif + return OK; } diff --git a/configs/freedom-k64f/netnsh/defconfig b/configs/freedom-k64f/netnsh/defconfig index 05a73a3220..a4a8968bdd 100644 --- a/configs/freedom-k64f/netnsh/defconfig +++ b/configs/freedom-k64f/netnsh/defconfig @@ -411,6 +411,7 @@ CONFIG_NAME_MAX=32 # CONFIG_SCHED_STARTHOOK is not set # CONFIG_SCHED_ATEXIT is not set # CONFIG_SCHED_ONEXIT is not set +# CONFIG_SIG_EVTHREAD is not set # # Signal Numbers @@ -419,6 +420,7 @@ CONFIG_SIG_SIGUSR1=1 CONFIG_SIG_SIGUSR2=2 CONFIG_SIG_SIGALARM=3 CONFIG_SIG_SIGCONDTIMEDOUT=16 +CONFIG_SIG_SIGWORK=17 # # POSIX Message Queue Options @@ -430,8 +432,11 @@ CONFIG_MQ_MAXMSGSIZE=32 # # Work queue support # -# CONFIG_SCHED_WORKQUEUE is not set -# CONFIG_SCHED_HPWORK is not set +CONFIG_SCHED_WORKQUEUE=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=224 +CONFIG_SCHED_HPWORKPERIOD=50000 +CONFIG_SCHED_HPWORKSTACKSIZE=2048 # CONFIG_SCHED_LPWORK is not set # @@ -623,7 +628,7 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set +CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # From 9f72204bb6adb2d4d414185a4ea76e02ff29119d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 12 Jul 2016 16:50:27 -0600 Subject: [PATCH 13/15] Update README --- configs/freedom-k64f/README.txt | 258 +++++++++++++++++++++++++++++++- 1 file changed, 255 insertions(+), 3 deletions(-) diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index 302b37638e..0aaeb99a9c 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -10,7 +10,7 @@ Contents o Freedom K64F Features o Serial Console o LEDs and Buttons - o Ethernet + o Networking Support o Development Environment o GNU Toolchain Options o Freedom K64F Configuration Options @@ -129,9 +129,11 @@ LEDs and Buttons SW2 PTC6/SPI0_SOUT/PD0_EXTRG/I2S0_RX_BCLK/FB_AD9/I2S0_MCLK/LLWU_P10 SW3 PTA4/FTM0_CH1/NMI_b/LLWU_P3 -Ethernet -======== +Networking Support +================== + Ethernet MAC/KSZ8081 PHY + ------------------------ ------------ ----------------- -------------------------------------------- KSZ8081 Board Signal(s) K64F Pin Pin Signal Function pinmux Name @@ -169,6 +171,244 @@ Ethernet CONFIG_KINETIS_ENET_MDIOPULLUP=y + Networking support via the can be added to NSH by selecting the following + configuration options. + + Selecting the EMAC peripheral + ----------------------------- + + System Type -> Kinetis Peripheral Support + CONFIG_KINETIS_ENET=y : Enable the EThernet MAC peripheral + + System Type -> Ethernet Configuration + CONFIG_KINETIS_ENETNETHIFS=1 + CONFIG_KINETIS_ENETNRXBUFFERS=6 + CONFIG_KINETIS_ENETNTXBUFFERS=2 + CONFIG_KINETIS_ENET_MDIOPULLUP=y + + Networking Support + CONFIG_NET=y : Enable Neworking + CONFIG_NET_ETHERNET=y : Support Ethernet data link + CONFIG_NET_NOINTS=y : Should operative at non-interrupt level + CONFIG_NET_SOCKOPTS=y : Enable socket operations + CONFIG_NET_MULTIBUFFER=y : Multi-packet buffer option required + CONFIG_NET_ETH_MTU=590 : Maximum packet size (MTU) 1518 is more standard + CONFIG_NET_ETH_TCP_RECVWNDO=536 : Should be the same as CONFIG_NET_ETH_MTU + CONFIG_NET_ARP=y : Enable ARP + CONFIG_NET_ARPTAB_SIZE=16 : ARP table size + CONFIG_NET_ARP_IPIN=y : Enable ARP address harvesting + CONFIG_NET_ARP_SEND=y : Send ARP request before sending data + CONFIG_NET_TCP=y : Enable TCP/IP networking + CONFIG_NET_TCP_READAHEAD=y : Support TCP read-ahead + CONFIG_NET_TCP_WRITE_BUFFERS=y : Support TCP write-buffering + CONFIG_NET_TCPBACKLOG=y : Support TCP/IP backlog + CONFIG_NET_MAX_LISTENPORTS=20 : + CONFIG_NET_TCP_READAHEAD_BUFSIZE=536 Read-ahead buffer size + CONFIG_NET_UDP=y : Enable UDP networking + CONFIG_NET_BROADCAST=y : Needed for DNS name resolution + CONFIG_NET_ICMP=y : Enable ICMP networking + CONFIG_NET_ICMP_PING=y : Needed for NSH ping command + : Defaults should be okay for other options +f Application Configuration -> Network Utilities + CONFIG_NETDB_DNSCLIENT=y : Enable host address resolution + CONFIG_NETUTILS_TELNETD=y : Enable the Telnet daemon + CONFIG_NETUTILS_TFTPC=y : Enable TFTP data file transfers for get and put commands + CONFIG_NETUTILS_NETLIB=y : Network library support is needed + CONFIG_NETUTILS_WEBCLIENT=y : Needed for wget support + : Defaults should be okay for other options + Application Configuration -> NSH Library + CONFIG_NSH_TELNET=y : Enable NSH session via Telnet + CONFIG_NSH_IPADDR=0x0a000002 : Select a fixed IP address + CONFIG_NSH_DRIPADDR=0x0a000001 : IP address of gateway/host PC + CONFIG_NSH_NETMASK=0xffffff00 : Netmask + CONFIG_NSH_NOMAC=y : Need to make up a bogus MAC address + : Defaults should be okay for other options + + You can also enable enable the DHCPC client for networks that use + dynamically assigned address: + + Application Configuration -> Network Utilities + CONFIG_NETUTILS_DHCPC=y : Enables the DHCP client + + Networking Support + CONFIG_NET_UDP=y : Depends on broadcast UDP + + Application Configuration -> NSH Library + CONFIG_NET_BROADCAST=y + CONFIG_NSH_DHCPC=y : Tells NSH to use DHCPC, not + : the fixed addresses + + Using the network with NSH + -------------------------- + + So what can you do with this networking support? First you see that + NSH has several new network related commands: + + ifconfig, ifdown, ifup: Commands to help manage your network + get and put: TFTP file transfers + wget: HTML file transfers + ping: Check for access to peers on the network + Telnet console: You can access the NSH remotely via telnet. + + You can also enable other add on features like full FTP or a Web + Server or XML RPC and others. There are also other features that + you can enable like DHCP client (or server) or network name + resolution. + + By default, the IP address of the DK-TM4C129X will be 10.0.0.2 and + it will assume that your host is the gateway and has the IP address + 10.0.0.1. + + nsh> ifconfig + eth0 HWaddr 00:e0:de:ad:be:ef at UP + IPaddr:10.0.0.2 DRaddr:10.0.0.1 Mask:255.255.255.0 + + You can use ping to test for connectivity to the host (Careful, + Window firewalls usually block ping-related ICMP traffic). On the + target side, you can: + + nsh> ping 10.0.0.1 + PING 10.0.0.1 56 bytes of data + 56 bytes from 10.0.0.1: icmp_seq=1 time=0 ms + 56 bytes from 10.0.0.1: icmp_seq=2 time=0 ms + 56 bytes from 10.0.0.1: icmp_seq=3 time=0 ms + 56 bytes from 10.0.0.1: icmp_seq=4 time=0 ms + 56 bytes from 10.0.0.1: icmp_seq=5 time=0 ms + 56 bytes from 10.0.0.1: icmp_seq=6 time=0 ms + 56 bytes from 10.0.0.1: icmp_seq=7 time=0 ms + 56 bytes from 10.0.0.1: icmp_seq=8 time=0 ms + 56 bytes from 10.0.0.1: icmp_seq=9 time=0 ms + 56 bytes from 10.0.0.1: icmp_seq=10 time=0 ms + 10 packets transmitted, 10 received, 0% packet loss, time 10100 ms + + NOTE: In this configuration is is normal to have packet loss > 0% + the first time you ping due to the default handling of the ARP + table. + + On the host side, you should also be able to ping the DK-TM4C129X: + + $ ping 10.0.0.2 + + You can also log into the NSH from the host PC like this: + + $ telnet 10.0.0.2 + Trying 10.0.0.2... + Connected to 10.0.0.2. + Escape character is '^]'. + sh_telnetmain: Session [3] Started + + NuttShell (NSH) NuttX-6.31 + nsh> help + help usage: help [-v] [] + + [ echo ifconfig mkdir mw sleep + ? exec ifdown mkfatfs ping test + cat exit ifup mkfifo ps umount + cp free kill mkrd put usleep + cmp get losetup mh rm wget + dd help ls mount rmdir xd + df hexdump mb mv sh + + Builtin Apps: + nsh> + + NOTE: If you enable this networking as described above, you will + experience a delay on booting NSH. That is because the start-up logic + waits for the network connection to be established before starting + NuttX. In a real application, you would probably want to do the + network bringup on a separate thread so that access to the NSH prompt + is not delayed. + + This delay will be especially long if the board is not connected to + a network. On the order of minutes! You will probably think that + NuttX has crashed! And then, when it finally does come up after + numerous timeouts and retries, the network will not be available -- + even if the network cable is plugged in later. + + The long delays can be eliminated by using a separate the network + initialization thread discussed below. Recovering after the network + becomes available requires the network monitor feature, also discussed + below. + + Network Initialization Thread + ----------------------------- + There is a configuration option enabled by CONFIG_NSH_NETINIT_THREAD + that will do the NSH network bring-up asynchronously in parallel on + a separate thread. This eliminates the (visible) networking delay + altogether. This current implementation, however, has some limitations: + + - If no network is connected, the network bring-up will fail and + the network initialization thread will simply exit. There are no + retries and no mechanism to know if the network initialization was + successful (it could perform a network Ioctl to see if the link is + up and it now, keep trying, but it does not do that now). + + - Furthermore, there is currently no support for detecting loss of + network connection and recovery of the connection (similarly, this + thread could poll periodically for network status, but does not). + + Both of these shortcomings could be eliminated by enabling the network + monitor: + + Network Monitor + --------------- + By default the network initialization thread will bring-up the network + then exit, freeing all of the resources that it required. This is a + good behavior for systems with limited memory. + + If the CONFIG_NSH_NETINIT_MONITOR option is selected, however, then the + network initialization thread will persist forever; it will monitor the + network status. In the event that the network goes down (for example, if + a cable is removed), then the thread will monitor the link status and + attempt to bring the network back up. In this case the resources + required for network initialization are never released. + + Pre-requisites: + + - CONFIG_NSH_NETINIT_THREAD as described above. + + - The K64F EMAC block does not support PHY interrupts. The KSZ8081 + PHY interrupt line is brought to a jumper block and it should be + possible to connect that some some interrupt port pin. You would + need to provide some custom logic in the Freedcom K64F + configuration to set up that PHY interrupt. + + - In addtion to the PHY interrupt, the Network Monitor also requires the + following setting: + + CONFIG_NETDEV_PHY_IOCTL. Enable PHY IOCTL commands in the Ethernet + device driver. Special IOCTL commands must be provided by the Ethernet + driver to support certain PHY operations that will be needed for link + management. There operations are not complex and are implemented for + the Atmel SAMA5 family. + + CONFIG_ARCH_PHY_INTERRUPT. This is not a user selectable option. + Rather, it is set when you select a board that supports PHY + interrupts. For the K64F, like most other architectures, the PHY + interrupt must be provided via some board-specific GPIO. In any + event, the board-specific logic must provide support for the PHY + interrupt. To do this, the board logic must do two things: (1) It + must provide the function arch_phy_irq() as described and prototyped + in the nuttx/include/nuttx/arch.h, and (2) it must select + CONFIG_ARCH_PHY_INTERRUPT in the board configuration file to + advertise that it supports arch_phy_irq(). + + And a few other things: UDP support is required (CONFIG_NET_UDP) and + signals must not be disabled (CONFIG_DISABLE_SIGNALS). + + Given those prerequisites, the network monitor can be selected with these + additional settings. + + System Type -> Kinetis Ethernet Configuration + CONFIG_ARCH_PHY_INTERRUPT=y : (auto-selected) + CONFIG_NETDEV_PHY_IOCTL=y : (auto-selected) + + Application Configuration -> NSH Library -> Networking Configuration + CONFIG_NSH_NETINIT_THREAD : Enable the network initialization thread + CONFIG_NSH_NETINIT_MONITOR=y : Enable the network monitor + CONFIG_NSH_NETINIT_RETRYMSEC=2000 : Configure the network monitor as you like + CONFIG_NSH_NETINIT_SIGNO=18 + Development Environment ======================= @@ -412,6 +652,18 @@ Where is one of the following: CONFIG_KINETIS_ENET_MDIOPULLUP=y + 4. Configured to use a fixed IPv4 address: + + CONFIG_NSH_IPADDR=0x0a000002 + CONFIG_NSH_DRIPADDR=0x0a000001 + CONFIG_NSH_NETMASK=0xffffff00 + + And a bogus MAC address: + + CONFIG_NSH_NOMAC=y + CONFIG_NSH_SWMAC=y + CONFIG_NSH_MACADDR=0x00e0deadbeef + nsh: --- Configures the NuttShell (nsh) located at apps/examples/nsh using a From 6be72272eb757383c17f19456bb6fe2d20df327d Mon Sep 17 00:00:00 2001 From: Sebastien Lorquet Date: Tue, 12 Jul 2016 17:18:46 -0600 Subject: [PATCH 14/15] STM32L4: Apply the stm32l4 namespace and FAR qualifiers to the serial driver, also, indentation. --- arch/arm/src/stm32l4/stm32l4_serial.c | 494 +++++++++++++------------- 1 file changed, 256 insertions(+), 238 deletions(-) diff --git a/arch/arm/src/stm32l4/stm32l4_serial.c b/arch/arm/src/stm32l4/stm32l4_serial.c index aa21ada61d..548d1e1957 100644 --- a/arch/arm/src/stm32l4/stm32l4_serial.c +++ b/arch/arm/src/stm32l4/stm32l4_serial.c @@ -90,13 +90,13 @@ # if defined(CONFIG_USART2_RXDMA) || defined(CONFIG_USART3_RXDMA) # ifndef CONFIG_STM32L4_DMA1 -# error STM32 USART2/3 receive DMA requires CONFIG_STM32L4_DMA1 +# error STM32L4 USART2/3 receive DMA requires CONFIG_STM32L4_DMA1 # endif # endif # if defined(CONFIG_UART4_RXDMA) || defined(CONFIG_UART5_RXDMA) # ifndef CONFIG_STM32L4_DMA2 -# error STM32 USART4/5 receive DMA requires CONFIG_STM32L4_DMA2 +# error STM32L4 USART4/5 receive DMA requires CONFIG_STM32L4_DMA2 # endif # endif @@ -216,7 +216,7 @@ * register. It must not collide with USART_CR1_USED_INTS or USART_CR3_EIE * 2) USART_CR3_EIE is also carried in the up_dev_s ie member. * - * See up_restoreusartint where the masking is done. + * See stm32l4serial_restoreusartint where the masking is done. */ #ifdef CONFIG_STM32L4_SERIALBRK_BSDCOMPAT @@ -231,7 +231,7 @@ * Private Types ****************************************************************************/ -struct up_dev_s +struct stm32l4_serial_s { struct uart_dev_s dev; /* Generic UART device */ uint16_t ie; /* Saved interrupt mask bits value */ @@ -302,57 +302,63 @@ struct up_dev_s * Private Function Prototypes ****************************************************************************/ -static void up_set_format(struct uart_dev_s *dev); -static int up_setup(struct uart_dev_s *dev); -static void up_shutdown(struct uart_dev_s *dev); -static int up_attach(struct uart_dev_s *dev); -static void up_detach(struct uart_dev_s *dev); -static int up_interrupt_common(struct up_dev_s *dev); -static int up_ioctl(struct file *filep, int cmd, unsigned long arg); +#ifndef CONFIG_SUPPRESS_UART_CONFIG +static void stm32l4serial_setformat(FAR struct uart_dev_s *dev); +#endif +static int stm32l4serial_setup(FAR struct uart_dev_s *dev); +static void stm32l4serial_shutdown(FAR struct uart_dev_s *dev); +static int stm32l4serial_attach(FAR struct uart_dev_s *dev); +static void stm32l4serial_detach(FAR struct uart_dev_s *dev); +static int up_interrupt_common(FAR struct stm32l4_serial_s *dev); +static int stm32l4serial_ioctl(FAR struct file *filep, int cmd, + unsigned long arg); #ifndef SERIAL_HAVE_ONLY_DMA -static int up_receive(struct uart_dev_s *dev, unsigned int *status); -static void up_rxint(struct uart_dev_s *dev, bool enable); -static bool up_rxavailable(struct uart_dev_s *dev); +static int stm32l4serial_receive(FAR struct uart_dev_s *dev, + FAR unsigned int *status); +static void stm32l4serial_rxint(FAR struct uart_dev_s *dev, bool enable); +static bool stm32l4serial_rxavailable(FAR struct uart_dev_s *dev); #endif #ifdef CONFIG_SERIAL_IFLOWCONTROL -static bool up_rxflowcontrol(struct uart_dev_s *dev, unsigned int nbuffered, - bool upper); +static bool stm32l4serial_rxflowcontrol(FAR struct uart_dev_s *dev, + unsigned int nbuffered, bool upper); #endif -static void up_send(struct uart_dev_s *dev, int ch); -static void up_txint(struct uart_dev_s *dev, bool enable); -static bool up_txready(struct uart_dev_s *dev); +static void stm32l4serial_send(FAR struct uart_dev_s *dev, int ch); +static void stm32l4serial_txint(FAR struct uart_dev_s *dev, bool enable); +static bool stm32l4serial_txready(FAR struct uart_dev_s *dev); #ifdef SERIAL_HAVE_DMA -static int up_dma_setup(struct uart_dev_s *dev); -static void up_dma_shutdown(struct uart_dev_s *dev); -static int up_dma_receive(struct uart_dev_s *dev, unsigned int *status); -static void up_dma_rxint(struct uart_dev_s *dev, bool enable); -static bool up_dma_rxavailable(struct uart_dev_s *dev); +static int stm32l4serial_dmasetup(FAR struct uart_dev_s *dev); +static void stm32l4serial_dmashutdown(FAR struct uart_dev_s *dev); +static int stm32l4serial_dmareceive(FAR struct uart_dev_s *dev, + FAR unsigned int *status); +static void stm32l4serial_dmarxint(FAR struct uart_dev_s *dev, bool enable); +static bool stm32l4serial_dmarxavailable(struct uart_dev_s *dev); -static void up_dma_rxcallback(DMA_HANDLE handle, uint8_t status, void *arg); +static void stm32l4serial_dmarxcallback(DMA_HANDLE handle, uint8_t status, + FAR void *arg); #endif #ifdef CONFIG_PM -static void up_pm_notify(struct pm_callback_s *cb, int domain, - enum pm_state_e pmstate); -static int up_pm_prepare(struct pm_callback_s *cb, int domain, - enum pm_state_e pmstate); +static void stm32l4serial_pmnotify(FAR struct pm_callback_s *cb, int domain, + enum pm_state_e pmstate); +static int stm32l4serial_pmprepare(FAR struct pm_callback_s *cb, int domain, + enum pm_state_e pmstate); #endif #ifdef CONFIG_STM32L4_USART1 -static int up_interrupt_usart1(int irq, void *context); +static int up_interrupt_usart1(int irq, FAR void *context); #endif #ifdef CONFIG_STM32L4_USART2 -static int up_interrupt_usart2(int irq, void *context); +static int up_interrupt_usart2(int irq, FAR void *context); #endif #ifdef CONFIG_STM32L4_USART3 -static int up_interrupt_usart3(int irq, void *context); +static int up_interrupt_usart3(int irq, FAR void *context); #endif #ifdef CONFIG_STM32L4_UART4 -static int up_interrupt_uart4(int irq, void *context); +static int up_interrupt_uart4(int irq, FAR void *context); #endif #ifdef CONFIG_STM32L4_UART5 -static int up_interrupt_uart5(int irq, void *context); +static int up_interrupt_uart5(int irq, FAR void *context); #endif /**************************************************************************** @@ -362,42 +368,42 @@ static int up_interrupt_uart5(int irq, void *context); #ifndef SERIAL_HAVE_ONLY_DMA static const struct uart_ops_s g_uart_ops = { - .setup = up_setup, - .shutdown = up_shutdown, - .attach = up_attach, - .detach = up_detach, - .ioctl = up_ioctl, - .receive = up_receive, - .rxint = up_rxint, - .rxavailable = up_rxavailable, + .setup = stm32l4serial_setup, + .shutdown = stm32l4serial_shutdown, + .attach = stm32l4serial_attach, + .detach = stm32l4serial_detach, + .ioctl = stm32l4serial_ioctl, + .receive = stm32l4serial_receive, + .rxint = stm32l4serial_rxint, + .rxavailable = stm32l4serial_rxavailable, #ifdef CONFIG_SERIAL_IFLOWCONTROL - .rxflowcontrol = up_rxflowcontrol, + .rxflowcontrol = stm32l4serial_rxflowcontrol, #endif - .send = up_send, - .txint = up_txint, - .txready = up_txready, - .txempty = up_txready, + .send = stm32l4serial_send, + .txint = stm32l4serial_txint, + .txready = stm32l4serial_txready, + .txempty = stm32l4serial_txready, }; #endif #ifdef SERIAL_HAVE_DMA static const struct uart_ops_s g_uart_dma_ops = { - .setup = up_dma_setup, - .shutdown = up_dma_shutdown, - .attach = up_attach, - .detach = up_detach, - .ioctl = up_ioctl, - .receive = up_dma_receive, - .rxint = up_dma_rxint, - .rxavailable = up_dma_rxavailable, + .setup = stm32l4serial_dmasetup, + .shutdown = stm32l4serial_dmashutdown, + .attach = stm32l4serial_attach, + .detach = stm32l4serial_detach, + .ioctl = stm32l4serial_ioctl, + .receive = stm32l4serial_dmareceive, + .rxint = stm32l4serial_dmarxint, + .rxavailable = stm32l4serial_dmarxavailable, #ifdef CONFIG_SERIAL_IFLOWCONTROL - .rxflowcontrol = up_rxflowcontrol, + .rxflowcontrol = stm32l4serial_rxflowcontrol, #endif - .send = up_send, - .txint = up_txint, - .txready = up_txready, - .txempty = up_txready, + .send = stm32l4serial_send, + .txint = stm32l4serial_txint, + .txready = stm32l4serial_txready, + .txempty = stm32l4serial_txready, }; #endif @@ -446,7 +452,7 @@ static char g_uart5rxfifo[RXDMA_BUFFER_SIZE]; /* This describes the state of the STM32 USART1 ports. */ #ifdef CONFIG_STM32L4_USART1 -static struct up_dev_s g_usart1priv = +static struct stm32l4_serial_s g_usart1priv = { .dev = { @@ -508,7 +514,7 @@ static struct up_dev_s g_usart1priv = /* This describes the state of the STM32 USART2 port. */ #ifdef CONFIG_STM32L4_USART2 -static struct up_dev_s g_usart2priv = +static struct stm32l4_serial_s g_usart2priv = { .dev = { @@ -570,7 +576,7 @@ static struct up_dev_s g_usart2priv = /* This describes the state of the STM32 USART3 port. */ #ifdef CONFIG_STM32L4_USART3 -static struct up_dev_s g_usart3priv = +static struct stm32l4_serial_s g_usart3priv = { .dev = { @@ -632,7 +638,7 @@ static struct up_dev_s g_usart3priv = /* This describes the state of the STM32 UART4 port. */ #ifdef CONFIG_STM32L4_UART4 -static struct up_dev_s g_uart4priv = +static struct stm32l4_serial_s g_uart4priv = { .dev = { @@ -698,7 +704,7 @@ static struct up_dev_s g_uart4priv = /* This describes the state of the STM32 UART5 port. */ #ifdef CONFIG_STM32L4_UART5 -static struct up_dev_s g_uart5priv = +static struct stm32l4_serial_s g_uart5priv = { .dev = { @@ -763,7 +769,7 @@ static struct up_dev_s g_uart5priv = /* This table lets us iterate over the configured USARTs */ -static struct up_dev_s * const uart_devs[STM32L4_NUSART] = +FAR static struct stm32l4_serial_s * const uart_devs[STM32L4_NUSART] = { #ifdef CONFIG_STM32L4_USART1 [0] = &g_usart1priv, @@ -785,8 +791,8 @@ static struct up_dev_s * const uart_devs[STM32L4_NUSART] = #ifdef CONFIG_PM static struct pm_callback_s g_serialcb = { - .notify = up_pm_notify, - .prepare = up_pm_prepare, + .notify = stm32l4serial_pmnotify, + .prepare = stm32l4serial_pmprepare, }; #endif @@ -795,28 +801,31 @@ static struct pm_callback_s g_serialcb = ****************************************************************************/ /**************************************************************************** - * Name: up_serialin + * Name: stm32l4serial_getreg ****************************************************************************/ -static inline uint32_t up_serialin(struct up_dev_s *priv, int offset) +static inline uint32_t stm32l4serial_getreg(FAR struct stm32l4_serial_s *priv, + int offset) { return getreg32(priv->usartbase + offset); } /**************************************************************************** - * Name: up_serialout + * Name: stm32l4serial_putreg ****************************************************************************/ -static inline void up_serialout(struct up_dev_s *priv, int offset, uint32_t value) +static inline void stm32l4serial_putreg(FAR struct stm32l4_serial_s *priv, + int offset, uint32_t value) { putreg32(value, priv->usartbase + offset); } /**************************************************************************** - * Name: up_restoreusartint + * Name: stm32l4serial_restoreusartint ****************************************************************************/ -static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie) +static void stm32l4serial_restoreusartint(FAR struct stm32l4_serial_s *priv, + uint16_t ie) { uint32_t cr; @@ -826,22 +835,23 @@ static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie) /* And restore the interrupt state (see the interrupt enable/usage table above) */ - cr = up_serialin(priv, STM32L4_USART_CR1_OFFSET); + cr = stm32l4serial_getreg(priv, STM32L4_USART_CR1_OFFSET); cr &= ~(USART_CR1_USED_INTS); cr |= (ie & (USART_CR1_USED_INTS)); - up_serialout(priv, STM32L4_USART_CR1_OFFSET, cr); + stm32l4serial_putreg(priv, STM32L4_USART_CR1_OFFSET, cr); - cr = up_serialin(priv, STM32L4_USART_CR3_OFFSET); + cr = stm32l4serial_getreg(priv, STM32L4_USART_CR3_OFFSET); cr &= ~USART_CR3_EIE; cr |= (ie & USART_CR3_EIE); - up_serialout(priv, STM32L4_USART_CR3_OFFSET, cr); + stm32l4serial_putreg(priv, STM32L4_USART_CR3_OFFSET, cr); } /**************************************************************************** - * Name: up_disableusartint + * Name: stm32l4serial_disableusartint ****************************************************************************/ -static inline void up_disableusartint(struct up_dev_s *priv, uint16_t *ie) +static inline void stm32l4serial_disableusartint(FAR struct stm32l4_serial_s *priv, + FAR uint16_t *ie) { if (ie) { @@ -866,8 +876,8 @@ static inline void up_disableusartint(struct up_dev_s *priv, uint16_t *ie) * USART_CR3_CTSIE USART_ISR_CTS CTS flag (not used) */ - cr1 = up_serialin(priv, STM32L4_USART_CR1_OFFSET); - cr3 = up_serialin(priv, STM32L4_USART_CR3_OFFSET); + cr1 = stm32l4serial_getreg(priv, STM32L4_USART_CR1_OFFSET); + cr3 = stm32l4serial_getreg(priv, STM32L4_USART_CR3_OFFSET); /* Return the current interrupt mask value for the used interrupts. Notice * that this depends on the fact that none of the used interrupt enable bits @@ -879,11 +889,11 @@ static inline void up_disableusartint(struct up_dev_s *priv, uint16_t *ie) /* Disable all interrupts */ - up_restoreusartint(priv, 0); + stm32l4serial_restoreusartint(priv, 0); } /**************************************************************************** - * Name: up_dma_nextrx + * Name: stm32l4serial_dmanextrx * * Description: * Returns the index into the RX FIFO where the DMA will place the next @@ -892,7 +902,7 @@ static inline void up_disableusartint(struct up_dev_s *priv, uint16_t *ie) ****************************************************************************/ #ifdef SERIAL_HAVE_DMA -static int up_dma_nextrx(struct up_dev_s *priv) +static int stm32l4serial_dmanextrx(FAR struct stm32l4_serial_s *priv) { size_t dmaresidual; @@ -903,7 +913,7 @@ static int up_dma_nextrx(struct up_dev_s *priv) #endif /**************************************************************************** - * Name: up_set_format + * Name: stm32l4serial_setformat * * Description: * Set the serial line format and speed. @@ -911,9 +921,9 @@ static int up_dma_nextrx(struct up_dev_s *priv) ****************************************************************************/ #ifndef CONFIG_SUPPRESS_UART_CONFIG -static void up_set_format(struct uart_dev_s *dev) +static void stm32l4serial_setformat(FAR struct uart_dev_s *dev) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; uint32_t regval; /* This first implementation is for U[S]ARTs that support oversampling @@ -942,7 +952,7 @@ static void up_set_format(struct uart_dev_s *dev) /* Use oversamply by 8 only if the divisor is small. But what is small? */ - cr1 = up_serialin(priv, STM32L4_USART_CR1_OFFSET); + cr1 = stm32l4serial_getreg(priv, STM32L4_USART_CR1_OFFSET); if (usartdiv8 > 100) { /* Use usartdiv16 */ @@ -966,12 +976,12 @@ static void up_set_format(struct uart_dev_s *dev) cr1 |= USART_CR1_OVER8; } - up_serialout(priv, STM32L4_USART_CR1_OFFSET, cr1); - up_serialout(priv, STM32L4_USART_BRR_OFFSET, brr); + stm32l4serial_putreg(priv, STM32L4_USART_CR1_OFFSET, cr1); + stm32l4serial_putreg(priv, STM32L4_USART_BRR_OFFSET, brr); /* Configure parity mode */ - regval = up_serialin(priv, STM32L4_USART_CR1_OFFSET); + regval = stm32l4serial_getreg(priv, STM32L4_USART_CR1_OFFSET); regval &= ~(USART_CR1_PCE | USART_CR1_PS | USART_CR1_M0 | USART_CR1_M1); if (priv->parity == 1) /* Odd parity */ @@ -1008,11 +1018,11 @@ static void up_set_format(struct uart_dev_s *dev) * 1 start, 8 data (no parity), n stop. */ - up_serialout(priv, STM32L4_USART_CR1_OFFSET, regval); + stm32l4serial_putreg(priv, STM32L4_USART_CR1_OFFSET, regval); /* Configure STOP bits */ - regval = up_serialin(priv, STM32L4_USART_CR2_OFFSET); + regval = stm32l4serial_getreg(priv, STM32L4_USART_CR2_OFFSET); regval &= ~(USART_CR2_STOP_MASK); if (priv->stopbits2) @@ -1020,11 +1030,11 @@ static void up_set_format(struct uart_dev_s *dev) regval |= USART_CR2_STOP2; } - up_serialout(priv, STM32L4_USART_CR2_OFFSET, regval); + stm32l4serial_putreg(priv, STM32L4_USART_CR2_OFFSET, regval); /* Configure hardware flow control */ - regval = up_serialin(priv, STM32L4_USART_CR3_OFFSET); + regval = stm32l4serial_getreg(priv, STM32L4_USART_CR3_OFFSET); regval &= ~(USART_CR3_CTSE | USART_CR3_RTSE); #if defined(CONFIG_SERIAL_IFLOWCONTROL) && !defined(CONFIG_STM32L4_FLOWCONTROL_BROKEN) @@ -1041,12 +1051,12 @@ static void up_set_format(struct uart_dev_s *dev) } #endif - up_serialout(priv, STM32L4_USART_CR3_OFFSET, regval); + stm32l4serial_putreg(priv, STM32L4_USART_CR3_OFFSET, regval); } #endif /* CONFIG_SUPPRESS_UART_CONFIG */ /**************************************************************************** - * Name: up_set_apb_clock + * Name: stm32l4serial_setapbclock * * Description: * Enable or disable APB clock for the USART peripheral @@ -1057,9 +1067,9 @@ static void up_set_format(struct uart_dev_s *dev) * ****************************************************************************/ -static void up_set_apb_clock(struct uart_dev_s *dev, bool on) +static void stm32l4serial_setapbclock(FAR struct uart_dev_s *dev, bool on) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; uint32_t rcc_en; uint32_t regaddr; @@ -1114,7 +1124,7 @@ static void up_set_apb_clock(struct uart_dev_s *dev, bool on) } /**************************************************************************** - * Name: up_setup + * Name: stm32l4serial_setup * * Description: * Configure the USART baud, bits, parity, etc. This method is called the @@ -1122,9 +1132,9 @@ static void up_set_apb_clock(struct uart_dev_s *dev, bool on) * ****************************************************************************/ -static int up_setup(struct uart_dev_s *dev) +static int stm32l4serial_setup(FAR struct uart_dev_s *dev) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; #ifndef CONFIG_SUPPRESS_UART_CONFIG uint32_t regval; @@ -1135,7 +1145,7 @@ static int up_setup(struct uart_dev_s *dev) /* Enable USART APB1/2 clock */ - up_set_apb_clock(dev, true); + stm32l4serial_setapbclock(dev, true); /* Configure pins for USART use */ @@ -1174,7 +1184,7 @@ static int up_setup(struct uart_dev_s *dev) /* Configure CR2 */ /* Clear STOP, CLKEN, CPOL, CPHA, LBCL, and interrupt enable bits */ - regval = up_serialin(priv, STM32L4_USART_CR2_OFFSET); + regval = stm32l4serial_getreg(priv, STM32L4_USART_CR2_OFFSET); regval &= ~(USART_CR2_STOP_MASK | USART_CR2_CLKEN | USART_CR2_CPOL | USART_CR2_CPHA | USART_CR2_LBCL | USART_CR2_LBDIE); @@ -1185,33 +1195,34 @@ static int up_setup(struct uart_dev_s *dev) regval |= USART_CR2_STOP2; } - up_serialout(priv, STM32L4_USART_CR2_OFFSET, regval); + stm32l4serial_putreg(priv, STM32L4_USART_CR2_OFFSET, regval); /* Configure CR1 */ /* Clear TE, REm and all interrupt enable bits */ - regval = up_serialin(priv, STM32L4_USART_CR1_OFFSET); + regval = stm32l4serial_getreg(priv, STM32L4_USART_CR1_OFFSET); regval &= ~(USART_CR1_TE | USART_CR1_RE | USART_CR1_ALLINTS); - up_serialout(priv, STM32L4_USART_CR1_OFFSET, regval); + stm32l4serial_putreg(priv, STM32L4_USART_CR1_OFFSET, regval); /* Configure CR3 */ /* Clear CTSE, RTSE, and all interrupt enable bits */ - regval = up_serialin(priv, STM32L4_USART_CR3_OFFSET); - regval &= ~(USART_CR3_CTSIE | USART_CR3_CTSE | USART_CR3_RTSE | USART_CR3_EIE); + regval = stm32l4serial_getreg(priv, STM32L4_USART_CR3_OFFSET); + regval &= ~(USART_CR3_CTSIE | USART_CR3_CTSE | USART_CR3_RTSE | + USART_CR3_EIE); - up_serialout(priv, STM32L4_USART_CR3_OFFSET, regval); + stm32l4serial_putreg(priv, STM32L4_USART_CR3_OFFSET, regval); /* Configure the USART line format and speed. */ - up_set_format(dev); + stm32l4serial_setformat(dev); /* Enable Rx, Tx, and the USART */ - regval = up_serialin(priv, STM32L4_USART_CR1_OFFSET); + regval = stm32l4serial_getreg(priv, STM32L4_USART_CR1_OFFSET); regval |= (USART_CR1_UE | USART_CR1_TE | USART_CR1_RE); - up_serialout(priv, STM32L4_USART_CR1_OFFSET, regval); + stm32l4serial_putreg(priv, STM32L4_USART_CR1_OFFSET, regval); #endif /* CONFIG_SUPPRESS_UART_CONFIG */ @@ -1222,7 +1233,7 @@ static int up_setup(struct uart_dev_s *dev) } /**************************************************************************** - * Name: up_dma_setup + * Name: stm32l4serial_dmasetup * * Description: * Configure the USART baud, bits, parity, etc. This method is called the @@ -1231,9 +1242,9 @@ static int up_setup(struct uart_dev_s *dev) ****************************************************************************/ #ifdef SERIAL_HAVE_DMA -static int up_dma_setup(struct uart_dev_s *dev) +static int stm32l4serial_dmasetup(FAR struct uart_dev_s *dev) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; int result; uint32_t regval; @@ -1241,7 +1252,7 @@ static int up_dma_setup(struct uart_dev_s *dev) if (!dev->isconsole) { - result = up_setup(dev); + result = stm32l4serial_setup(dev); if (result != OK) { return result; @@ -1283,9 +1294,9 @@ static int up_dma_setup(struct uart_dev_s *dev) /* Enable receive DMA for the UART */ - regval = up_serialin(priv, STM32L4_USART_CR3_OFFSET); + regval = stm32l4serial_getreg(priv, STM32L4_USART_CR3_OFFSET); regval |= USART_CR3_DMAR; - up_serialout(priv, STM32L4_USART_CR3_OFFSET, regval); + stm32l4serial_putreg(priv, STM32L4_USART_CR3_OFFSET, regval); #ifdef CONFIG_SERIAL_IFLOWCONTROL if (priv->iflow) @@ -1295,7 +1306,8 @@ static int up_dma_setup(struct uart_dev_s *dev) * in and DMA transfer is stopped. */ - stm32l4_dmastart(priv->rxdma, up_dma_rxcallback, (void *)priv, false); + stm32l4_dmastart(priv->rxdma, stm32l4serial_dmarxcallback, + (void *)priv, false); } else #endif @@ -1305,7 +1317,8 @@ static int up_dma_setup(struct uart_dev_s *dev) * worth of time to claim bytes before they are overwritten. */ - stm32l4_dmastart(priv->rxdma, up_dma_rxcallback, (void *)priv, true); + stm32l4_dmastart(priv->rxdma, stm32l4serial_dmarxcallback, + (void *)priv, true); } return OK; @@ -1313,7 +1326,7 @@ static int up_dma_setup(struct uart_dev_s *dev) #endif /**************************************************************************** - * Name: up_shutdown + * Name: stm32l4serial_shutdown * * Description: * Disable the USART. This method is called when the serial @@ -1321,24 +1334,24 @@ static int up_dma_setup(struct uart_dev_s *dev) * ****************************************************************************/ -static void up_shutdown(struct uart_dev_s *dev) +static void stm32l4serial_shutdown(FAR struct uart_dev_s *dev) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; uint32_t regval; /* Disable all interrupts */ - up_disableusartint(priv, NULL); + stm32l4serial_disableusartint(priv, NULL); /* Disable USART APB1/2 clock */ - up_set_apb_clock(dev, false); + stm32l4serial_setapbclock(dev, false); /* Disable Rx, Tx, and the UART */ - regval = up_serialin(priv, STM32L4_USART_CR1_OFFSET); + regval = stm32l4serial_getreg(priv, STM32L4_USART_CR1_OFFSET); regval &= ~(USART_CR1_UE | USART_CR1_TE | USART_CR1_RE); - up_serialout(priv, STM32L4_USART_CR1_OFFSET, regval); + stm32l4serial_putreg(priv, STM32L4_USART_CR1_OFFSET, regval); /* Release pins. "If the serial-attached device is powered down, the TX * pin causes back-powering, potentially confusing the device to the point @@ -1374,7 +1387,7 @@ static void up_shutdown(struct uart_dev_s *dev) } /**************************************************************************** - * Name: up_dma_shutdown + * Name: stm32l4serial_dmashutdown * * Description: * Disable the USART. This method is called when the serial @@ -1383,13 +1396,13 @@ static void up_shutdown(struct uart_dev_s *dev) ****************************************************************************/ #ifdef SERIAL_HAVE_DMA -static void up_dma_shutdown(struct uart_dev_s *dev) +static void stm32l4serial_dmashutdown(FAR struct uart_dev_s *dev) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; /* Perform the normal UART shutdown */ - up_shutdown(dev); + stm32l4serial_shutdown(dev); /* Stop the DMA channel */ @@ -1403,7 +1416,7 @@ static void up_dma_shutdown(struct uart_dev_s *dev) #endif /**************************************************************************** - * Name: up_attach + * Name: stm32l4serial_attach * * Description: * Configure the USART to operation in interrupt driven mode. This method is @@ -1417,9 +1430,9 @@ static void up_dma_shutdown(struct uart_dev_s *dev) * ****************************************************************************/ -static int up_attach(struct uart_dev_s *dev) +static int stm32l4serial_attach(FAR struct uart_dev_s *dev) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; int ret; /* Attach and enable the IRQ */ @@ -1437,7 +1450,7 @@ static int up_attach(struct uart_dev_s *dev) } /**************************************************************************** - * Name: up_detach + * Name: stm32l4serial_detach * * Description: * Detach USART interrupts. This method is called when the serial port is @@ -1446,9 +1459,9 @@ static int up_attach(struct uart_dev_s *dev) * ****************************************************************************/ -static void up_detach(struct uart_dev_s *dev) +static void stm32l4serial_detach(FAR struct uart_dev_s *dev) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; up_disable_irq(priv->irq); irq_detach(priv->irq); } @@ -1465,7 +1478,7 @@ static void up_detach(struct uart_dev_s *dev) * ****************************************************************************/ -static int up_interrupt_common(struct up_dev_s *priv) +static int up_interrupt_common(FAR struct stm32l4_serial_s *priv) { int passes; bool handled; @@ -1487,7 +1500,7 @@ static int up_interrupt_common(struct up_dev_s *priv) /* Get the masked USART status word. */ - priv->sr = up_serialin(priv, STM32L4_USART_ISR_OFFSET); + priv->sr = stm32l4serial_getreg(priv, STM32L4_USART_ISR_OFFSET); /* USART interrupts: * @@ -1522,7 +1535,7 @@ static int up_interrupt_common(struct up_dev_s *priv) (priv->ie & USART_CR1_TXEIE) == 0) { stm32l4_gpiowrite(priv->rs485_dir_gpio, !priv->rs485_dir_polarity); - up_restoreusartint(priv, priv->ie & ~USART_CR1_TCIE); + stm32l4serial_restoreusartint(priv, priv->ie & ~USART_CR1_TCIE); } #endif @@ -1548,8 +1561,8 @@ static int up_interrupt_common(struct up_dev_s *priv) * interrupt clear register (ICR). */ - up_serialout(priv, STM32L4_USART_ICR_OFFSET, - (USART_ICR_NCF | USART_ICR_ORECF | USART_ICR_FECF)); + stm32l4serial_putreg(priv, STM32L4_USART_ICR_OFFSET, + (USART_ICR_NCF | USART_ICR_ORECF | USART_ICR_FECF)); } /* Handle outgoing, transmit bytes */ @@ -1567,22 +1580,23 @@ static int up_interrupt_common(struct up_dev_s *priv) } /**************************************************************************** - * Name: up_ioctl + * Name: stm32l4serial_ioctl * * Description: * All ioctl calls will be routed through this method * ****************************************************************************/ -static int up_ioctl(struct file *filep, int cmd, unsigned long arg) +static int stm32l4serial_ioctl(FAR struct file *filep, int cmd, + unsigned long arg) { #if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_SERIAL_TIOCSERGSTRUCT) \ || defined(CONFIG_STM32F7_SERIALBRK_BSDCOMPAT) - struct inode *inode = filep->f_inode; - struct uart_dev_s *dev = inode->i_private; + FAR struct inode *inode = filep->f_inode; + FAR struct uart_dev_s *dev = inode->i_private; #endif #if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_STM32F7_SERIALBRK_BSDCOMPAT) - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; #endif int ret = OK; @@ -1591,14 +1605,14 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) #ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { - struct up_dev_s *user = (struct up_dev_s *)arg; + FAR struct stm32l4_serial_s *user = (FAR struct stm32l4_serial_s *)arg; if (!user) { ret = -EINVAL; } else { - memcpy(user, dev, sizeof(struct up_dev_s)); + memcpy(user, dev, sizeof(struct stm32l4_serial_s)); } } break; @@ -1611,7 +1625,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) * half-duplex mode. */ - uint32_t cr = up_serialin(priv, STM32L4_USART_CR3_OFFSET); + uint32_t cr = stm32l4serial_getreg(priv, STM32L4_USART_CR3_OFFSET); #if defined(CONFIG_STM32L4_STM32F10XX) if (arg == SER_SINGLEWIRE_ENABLED) @@ -1637,7 +1651,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } #endif - up_serialout(priv, STM32L4_USART_CR3_OFFSET, cr); + stm32l4serial_putreg(priv, STM32L4_USART_CR3_OFFSET, cr); } break; #endif @@ -1645,7 +1659,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) #ifdef CONFIG_SERIAL_TERMIOS case TCGETS: { - struct termios *termiosp = (struct termios *)arg; + FAR struct termios *termiosp = (FAR struct termios *)arg; if (!termiosp) { @@ -1677,7 +1691,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) case TCSETS: { - struct termios *termiosp = (struct termios *)arg; + FAR struct termios *termiosp = (FAR struct termios *)arg; if (!termiosp) { @@ -1732,7 +1746,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) * TCSADRAIN / TCSAFLUSH */ - up_set_format(dev); + stm32l4serial_setformat(dev); } break; #endif /* CONFIG_SERIAL_TERMIOS */ @@ -1750,7 +1764,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) priv->ie |= USART_CR1_IE_BREAK_INPROGRESS; - up_txint(dev, false); + stm32l4serial_txint(dev, false); /* Configure TX as a GPIO output pin and Send a break signal*/ @@ -1775,7 +1789,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) /* Enable further tx activity */ - up_txint(dev, true); + stm32l4serial_txint(dev, true); leave_critical_section(flags); } @@ -1787,8 +1801,8 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) irqstate_t flags; flags = enter_critical_section(); - cr1 = up_serialin(priv, STM32_USART_CR1_OFFSET); - up_serialout(priv, STM32_USART_CR1_OFFSET, cr1 | USART_CR1_SBK); + cr1 = stm32l4serial_getreg(priv, STM32_USART_CR1_OFFSET); + stm32l4serial_putreg(priv, STM32_USART_CR1_OFFSET, cr1 | USART_CR1_SBK); leave_critical_section(flags); } break; @@ -1799,8 +1813,8 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) irqstate_t flags; flags = enter_critical_section(); - cr1 = up_serialin(priv, STM32_USART_CR1_OFFSET); - up_serialout(priv, STM32_USART_CR1_OFFSET, cr1 & ~USART_CR1_SBK); + cr1 = stm32l4serial_getreg(priv, STM32_USART_CR1_OFFSET); + stm32l4serial_putreg(priv, STM32_USART_CR1_OFFSET, cr1 & ~USART_CR1_SBK); leave_critical_section(flags); } break; @@ -1816,7 +1830,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } /**************************************************************************** - * Name: up_receive + * Name: stm32l4serial_receive * * Description: * Called (usually) from the interrupt level to receive one @@ -1826,14 +1840,15 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) ****************************************************************************/ #ifndef SERIAL_HAVE_ONLY_DMA -static int up_receive(struct uart_dev_s *dev, unsigned int *status) +static int stm32l4serial_receive(FAR struct uart_dev_s *dev, + FAR unsigned int *status) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; uint32_t rdr; /* Get the Rx byte */ - rdr = up_serialin(priv, STM32L4_USART_RDR_OFFSET); + rdr = stm32l4serial_getreg(priv, STM32L4_USART_RDR_OFFSET); /* Get the Rx byte plux error information. Return those in status */ @@ -1847,7 +1862,7 @@ static int up_receive(struct uart_dev_s *dev, unsigned int *status) #endif /**************************************************************************** - * Name: up_rxint + * Name: stm32l4serial_rxint * * Description: * Call to enable or disable RX interrupts @@ -1855,9 +1870,9 @@ static int up_receive(struct uart_dev_s *dev, unsigned int *status) ****************************************************************************/ #ifndef SERIAL_HAVE_ONLY_DMA -static void up_rxint(struct uart_dev_s *dev, bool enable) +static void stm32l4serial_rxint(FAR struct uart_dev_s *dev, bool enable) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; irqstate_t flags; uint16_t ie; @@ -1899,13 +1914,13 @@ static void up_rxint(struct uart_dev_s *dev, bool enable) /* Then set the new interrupt state */ - up_restoreusartint(priv, ie); + stm32l4serial_restoreusartint(priv, ie); leave_critical_section(flags); } #endif /**************************************************************************** - * Name: up_rxavailable + * Name: stm32l4serial_rxavailable * * Description: * Return true if the receive register is not empty @@ -1913,15 +1928,15 @@ static void up_rxint(struct uart_dev_s *dev, bool enable) ****************************************************************************/ #ifndef SERIAL_HAVE_ONLY_DMA -static bool up_rxavailable(struct uart_dev_s *dev) +static bool stm32l4serial_rxavailable(FAR struct uart_dev_s *dev) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; - return ((up_serialin(priv, STM32L4_USART_ISR_OFFSET) & USART_ISR_RXNE) != 0); + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; + return ((stm32l4serial_getreg(priv, STM32L4_USART_ISR_OFFSET) & USART_ISR_RXNE) != 0); } #endif /**************************************************************************** - * Name: up_rxflowcontrol + * Name: stm32l4serial_rxflowcontrol * * Description: * Called when Rx buffer is full (or exceeds configured watermark levels @@ -1944,10 +1959,10 @@ static bool up_rxavailable(struct uart_dev_s *dev) ****************************************************************************/ #ifdef CONFIG_SERIAL_IFLOWCONTROL -static bool up_rxflowcontrol(struct uart_dev_s *dev, - unsigned int nbuffered, bool upper) +static bool stm32l4serial_rxflowcontrol(FAR struct uart_dev_s *dev, + unsigned int nbuffered, bool upper) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; #if defined(CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS) && \ defined(CONFIG_STM32L4_FLOWCONTROL_BROKEN) @@ -2001,7 +2016,7 @@ static bool up_rxflowcontrol(struct uart_dev_s *dev, #endif /**************************************************************************** - * Name: up_dma_receive + * Name: stm32l4serial_dmareceive * * Description: * Called (usually) from the interrupt level to receive one @@ -2011,12 +2026,13 @@ static bool up_rxflowcontrol(struct uart_dev_s *dev, ****************************************************************************/ #ifdef SERIAL_HAVE_DMA -static int up_dma_receive(struct uart_dev_s *dev, unsigned int *status) +static int stm32l4serial_dmareceive(FAR struct uart_dev_s *dev, + FAR unsigned int *status) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; int c = 0; - if (up_dma_nextrx(priv) != priv->rxdmanext) + if (stm32l4serial_dmanextrx(priv) != priv->rxdmanext) { c = priv->rxfifo[priv->rxdmanext]; @@ -2043,7 +2059,7 @@ static int up_dma_receive(struct uart_dev_s *dev, unsigned int *status) #endif /**************************************************************************** - * Name: up_dma_reenable + * Name: stm32l4serial_dmareenable * * Description: * Call to re-enable RX DMA. @@ -2051,7 +2067,7 @@ static int up_dma_receive(struct uart_dev_s *dev, unsigned int *status) ****************************************************************************/ #if defined(SERIAL_HAVE_DMA) && defined(CONFIG_SERIAL_IFLOWCONTROL) -static void up_dma_reenable(struct up_dev_s *priv) +static void stm32l4serial_dmareenable(FAR struct stm32l4_serial_s *priv) { /* Configure for non-circular DMA reception into the RX fifo */ @@ -2072,12 +2088,13 @@ static void up_dma_reenable(struct up_dev_s *priv) * DMA transfer is stopped. */ - stm32l4_dmastart(priv->rxdma, up_dma_rxcallback, (void *)priv, false); + stm32l4_dmastart(priv->rxdma, stm32l4serial_dmarxcallback, (FAR void *)priv, + false); } #endif /**************************************************************************** - * Name: up_dma_rxint + * Name: stm32l4serial_dmarxint * * Description: * Call to enable or disable RX interrupts @@ -2085,9 +2102,9 @@ static void up_dma_reenable(struct up_dev_s *priv) ****************************************************************************/ #ifdef SERIAL_HAVE_DMA -static void up_dma_rxint(struct uart_dev_s *dev, bool enable) +static void stm32l4serial_dmarxint(FAR struct uart_dev_s *dev, bool enable) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; /* En/disable DMA reception. * @@ -2104,14 +2121,14 @@ static void up_dma_rxint(struct uart_dev_s *dev, bool enable) { /* Re-enable RX DMA. */ - up_dma_reenable(priv); + stm32l4serial_dmareenable(priv); } #endif } #endif /**************************************************************************** - * Name: up_dma_rxavailable + * Name: stm32l4serial_dmarxavailable * * Description: * Return true if the receive register is not empty @@ -2119,29 +2136,29 @@ static void up_dma_rxint(struct uart_dev_s *dev, bool enable) ****************************************************************************/ #ifdef SERIAL_HAVE_DMA -static bool up_dma_rxavailable(struct uart_dev_s *dev) +static bool stm32l4serial_dmarxavailable(FAR struct uart_dev_s *dev) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; /* Compare our receive pointer to the current DMA pointer, if they * do not match, then there are bytes to be received. */ - return (up_dma_nextrx(priv) != priv->rxdmanext); + return (stm32l4serial_dmanextrx(priv) != priv->rxdmanext); } #endif /**************************************************************************** - * Name: up_send + * Name: stm32l4serial_send * * Description: * This method will send one byte on the USART * ****************************************************************************/ -static void up_send(struct uart_dev_s *dev, int ch) +static void stm32l4serial_send(FAR struct uart_dev_s *dev, int ch) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; #ifdef HAVE_RS485 if (priv->rs485_dir_gpio != 0) @@ -2150,20 +2167,20 @@ static void up_send(struct uart_dev_s *dev, int ch) } #endif - up_serialout(priv, STM32L4_USART_TDR_OFFSET, (uint32_t)ch); + stm32l4serial_putreg(priv, STM32L4_USART_TDR_OFFSET, (uint32_t)ch); } /**************************************************************************** - * Name: up_txint + * Name: stm32l4serial_txint * * Description: * Call to enable or disable TX interrupts * ****************************************************************************/ -static void up_txint(struct uart_dev_s *dev, bool enable) +static void stm32l4serial_txint(FAR struct uart_dev_s *dev, bool enable) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; irqstate_t flags; /* USART transmit interrupts: @@ -2201,7 +2218,7 @@ static void up_txint(struct uart_dev_s *dev, bool enable) } # endif - up_restoreusartint(priv, ie); + stm32l4serial_restoreusartint(priv, ie); /* Fake a TX interrupt here by just calling uart_xmitchars() with * interrupts disabled (note this may recurse). @@ -2214,24 +2231,24 @@ static void up_txint(struct uart_dev_s *dev, bool enable) { /* Disable the TX interrupt */ - up_restoreusartint(priv, priv->ie & ~USART_CR1_TXEIE); + stm32l4serial_restoreusartint(priv, priv->ie & ~USART_CR1_TXEIE); } leave_critical_section(flags); } /**************************************************************************** - * Name: up_txready + * Name: stm32l4serial_txready * * Description: * Return true if the transmit data register is empty * ****************************************************************************/ -static bool up_txready(struct uart_dev_s *dev) +static bool stm32l4serial_txready(FAR struct uart_dev_s *dev) { - struct up_dev_s *priv = (struct up_dev_s *)dev->priv; - return ((up_serialin(priv, STM32L4_USART_ISR_OFFSET) & USART_ISR_TXE) != 0); + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv; + return ((stm32l4serial_getreg(priv, STM32L4_USART_ISR_OFFSET) & USART_ISR_TXE) != 0); } /**************************************************************************** @@ -2243,42 +2260,42 @@ static bool up_txready(struct uart_dev_s *dev) ****************************************************************************/ #ifdef CONFIG_STM32L4_USART1 -static int up_interrupt_usart1(int irq, void *context) +static int up_interrupt_usart1(int irq, FAR void *context) { return up_interrupt_common(&g_usart1priv); } #endif #ifdef CONFIG_STM32L4_USART2 -static int up_interrupt_usart2(int irq, void *context) +static int up_interrupt_usart2(int irq, FAR void *context) { return up_interrupt_common(&g_usart2priv); } #endif #ifdef CONFIG_STM32L4_USART3 -static int up_interrupt_usart3(int irq, void *context) +static int up_interrupt_usart3(int irq, FAR void *context) { return up_interrupt_common(&g_usart3priv); } #endif #ifdef CONFIG_STM32L4_UART4 -static int up_interrupt_uart4(int irq, void *context) +static int up_interrupt_uart4(int irq, FAR void *context) { return up_interrupt_common(&g_uart4priv); } #endif #ifdef CONFIG_STM32L4_UART5 -static int up_interrupt_uart5(int irq, void *context) +static int up_interrupt_uart5(int irq, FAR void *context) { return up_interrupt_common(&g_uart5priv); } #endif /**************************************************************************** - * Name: up_dma_rxcallback + * Name: stm32l4serial_dmarxcallback * * Description: * This function checks the current DMA state and calls the generic @@ -2287,11 +2304,12 @@ static int up_interrupt_uart5(int irq, void *context) ****************************************************************************/ #ifdef SERIAL_HAVE_DMA -static void up_dma_rxcallback(DMA_HANDLE handle, uint8_t status, void *arg) +static void stm32l4serial_dmarxcallback(DMA_HANDLE handle, uint8_t status, + FAR void *arg) { - struct up_dev_s *priv = (struct up_dev_s *)arg; + FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)arg; - if (priv->rxenable && up_dma_rxavailable(&priv->dev)) + if (priv->rxenable && stm32l4serial_dmarxavailable(&priv->dev)) { uart_recvchars(&priv->dev); @@ -2301,7 +2319,7 @@ static void up_dma_rxcallback(DMA_HANDLE handle, uint8_t status, void *arg) { /* Re-enable RX DMA. */ - up_dma_reenable(priv); + stm32l4serial_dmareenable(priv); } #endif } @@ -2309,7 +2327,7 @@ static void up_dma_rxcallback(DMA_HANDLE handle, uint8_t status, void *arg) #endif /**************************************************************************** - * Name: up_pm_notify + * Name: stm32l4serial_pmnotify * * Description: * Notify the driver of new power state. This callback is called after @@ -2331,8 +2349,8 @@ static void up_dma_rxcallback(DMA_HANDLE handle, uint8_t status, void *arg) ****************************************************************************/ #ifdef CONFIG_PM -static void up_pm_notify(struct pm_callback_s *cb, int domain, - enum pm_state_e pmstate) +static void stm32l4serial_pmnotify(FAR struct pm_callback_s *cb, int domain, + enum pm_state_e pmstate) { switch (pmstate) { @@ -2372,7 +2390,7 @@ static void up_pm_notify(struct pm_callback_s *cb, int domain, #endif /**************************************************************************** - * Name: up_pm_prepare + * Name: stm32l4serial_pmprepare * * Description: * Request the driver to prepare for a new power state. This is a warning @@ -2405,8 +2423,8 @@ static void up_pm_notify(struct pm_callback_s *cb, int domain, ****************************************************************************/ #ifdef CONFIG_PM -static int up_pm_prepare(struct pm_callback_s *cb, int domain, - enum pm_state_e pmstate) +static int stm32l4serial_pmprepare(FAR struct pm_callback_s *cb, int domain, + enum pm_state_e pmstate) { /* Logic to prepare for a reduced power state goes here. */ @@ -2428,7 +2446,7 @@ static int up_pm_prepare(struct pm_callback_s *cb, int domain, * Description: * Performs the low level USART initialization early in debug so that the * serial console will be available during bootup. This must be called - * before up_serialinit. + * before stm32l4serial_getregit. * ****************************************************************************/ @@ -2444,21 +2462,21 @@ void up_earlyserialinit(void) { if (uart_devs[i]) { - up_disableusartint(uart_devs[i], NULL); + stm32l4serial_disableusartint(uart_devs[i], NULL); } } /* Configure whichever one is the console */ #if CONSOLE_UART > 0 - up_setup(&uart_devs[CONSOLE_UART - 1]->dev); + stm32l4serial_setup(&uart_devs[CONSOLE_UART - 1]->dev); #endif #endif /* HAVE UART */ } #endif /**************************************************************************** - * Name: up_serialinit + * Name: stm32l4serial_getregit * * Description: * Register serial console and serial ports. This assumes @@ -2466,7 +2484,7 @@ void up_earlyserialinit(void) * ****************************************************************************/ -void up_serialinit(void) +void stm32l4serial_getregit(void) { #ifdef HAVE_UART char devname[16]; @@ -2501,7 +2519,7 @@ void up_serialinit(void) #ifdef SERIAL_HAVE_CONSOLE_DMA /* If we need to re-initialise the console to enable DMA do that here. */ - up_dma_setup(&uart_devs[CONSOLE_UART - 1]->dev); + stm32l4serial_dmasetup(&uart_devs[CONSOLE_UART - 1]->dev); #endif #endif /* CONSOLE_UART > 0 */ @@ -2536,7 +2554,7 @@ void up_serialinit(void) } /**************************************************************************** - * Name: stm32l4_serial_dma_poll + * Name: stm32l4serial_dmapoll * * Description: * Checks receive DMA buffers for received bytes that have not accumulated @@ -2547,7 +2565,7 @@ void up_serialinit(void) ****************************************************************************/ #ifdef SERIAL_HAVE_DMA -void stm32l4_serial_dma_poll(void) +void stm32l4serial_dmapoll(void) { irqstate_t flags; @@ -2556,35 +2574,35 @@ void stm32l4_serial_dma_poll(void) #ifdef CONFIG_USART1_RXDMA if (g_usart1priv.rxdma != NULL) { - up_dma_rxcallback(g_usart1priv.rxdma, 0, &g_usart1priv); + stm32l4serial_dmarxcallback(g_usart1priv.rxdma, 0, &g_usart1priv); } #endif #ifdef CONFIG_USART2_RXDMA if (g_usart2priv.rxdma != NULL) { - up_dma_rxcallback(g_usart2priv.rxdma, 0, &g_usart2priv); + stm32l4serial_dmarxcallback(g_usart2priv.rxdma, 0, &g_usart2priv); } #endif #ifdef CONFIG_USART3_RXDMA if (g_usart3priv.rxdma != NULL) { - up_dma_rxcallback(g_usart3priv.rxdma, 0, &g_usart3priv); + stm32l4serial_dmarxcallback(g_usart3priv.rxdma, 0, &g_usart3priv); } #endif #ifdef CONFIG_UART4_RXDMA if (g_uart4priv.rxdma != NULL) { - up_dma_rxcallback(g_uart4priv.rxdma, 0, &g_uart4priv); + stm32l4serial_dmarxcallback(g_uart4priv.rxdma, 0, &g_uart4priv); } #endif #ifdef CONFIG_UART5_RXDMA if (g_uart5priv.rxdma != NULL) { - up_dma_rxcallback(g_uart5priv.rxdma, 0, &g_uart5priv); + stm32l4serial_dmarxcallback(g_uart5priv.rxdma, 0, &g_uart5priv); } #endif @@ -2603,10 +2621,10 @@ void stm32l4_serial_dma_poll(void) int up_putc(int ch) { #if CONSOLE_UART > 0 - struct up_dev_s *priv = uart_devs[CONSOLE_UART - 1]; + struct stm32l4_serial_s *priv = uart_devs[CONSOLE_UART - 1]; uint16_t ie; - up_disableusartint(priv, &ie); + stm32l4serial_disableusartint(priv, &ie); /* Check for LF */ @@ -2618,7 +2636,7 @@ int up_putc(int ch) } up_lowputc(ch); - up_restoreusartint(priv, ie); + stm32l4serial_restoreusartint(priv, ie); #endif return ch; } From b616918e0f1186cddf7575c4b4516e97006d0ba1 Mon Sep 17 00:00:00 2001 From: Ken Pettit Date: Tue, 12 Jul 2016 17:28:06 -0600 Subject: [PATCH 15/15] SmartFS: Fix a 32-byte memory leak --- fs/smartfs/smartfs_smart.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/smartfs/smartfs_smart.c b/fs/smartfs/smartfs_smart.c index c5390d4201..c269031d27 100644 --- a/fs/smartfs/smartfs_smart.c +++ b/fs/smartfs/smartfs_smart.c @@ -1691,6 +1691,11 @@ static int smartfs_unlink(struct inode *mountpt, const char *relpath) ret = OK; errout_with_semaphore: + if (entry.name != NULL) + { + kmm_free(entry.name); + } + smartfs_semgive(fs); return ret; } @@ -1856,6 +1861,11 @@ int smartfs_rmdir(struct inode *mountpt, const char *relpath) ret = OK; errout_with_semaphore: + if (entry.name != NULL) + { + kmm_free(entry.name); + } + smartfs_semgive(fs); return ret; }