PIC32MX7MMB: Repartition files to match newer configurations. Add support for PROCFS file system. Default is now Pinguino toolchain. Verifty networking.

This commit is contained in:
Gregory Nutt 2017-05-27 09:11:50 -06:00
parent e71472b508
commit 90680e28d4
6 changed files with 131 additions and 367 deletions

View File

@ -149,17 +149,19 @@ PIN CONFIGURATIONS SIGNAL NAME ON-BOARD CONNE
Toolchains
==========
MPLAB/C32
---------
Pinguino mips-elf Toolchain
---------------------------
I am using the free, "Lite" version of the PIC32MX toolchain available
for download from the microchip.com web site. I am using the Windows
version. The MicroChip toolchain is the only toolchain currently
supported in these configurations, but it should be a simple matter to
adapt to other toolchains by modifying the Make.defs file include in
each configuration.
These configurations currently assume the mips-elf toolchain used with the
Pinguino project. This is a relatively current mips-elf GCC and should
provide free C++ support as well. This toolchain can be downloded from the
Pinguino website: http://wiki.pinguino.cc/index.php/Main_Page#Download .
There is some general information about using the Pinguino mips-elf
toolchain in this thread:
https://groups.yahoo.com/neo/groups/nuttx/conversations/messages/1821
C32 Toolchain Options:
It should be a simple matter to adapt to other toolchains by modifying the
Make.defs file include ineach configuration.
CONFIG_MIPS32_TOOLCHAIN_MICROCHIPW - MicroChip full toolchain for Windows
CONFIG_MIPS32_TOOLCHAIN_MICROCHIPL - MicroChip full toolchain for Linux
@ -170,6 +172,14 @@ Toolchains
CONFIG_MIPS32_TOOLCHAIN_MICROCHIPOPENL - Microchip open toolchain for Linux
CONFIG_MIPS32_TOOLCHAIN_GNU_ELF - General mips-elf toolchain for Linux
MPLAB/C32
---------
Previously, I did use the old, obsoleted "Lite" version of the PIC32MX C32
toolchain that was available for download from the microchip.com web site.
That MicroChip toolchain is the only Microchip toolchain currently supported
in these configurations.
NOTE: The "Lite" versions of the toolchain does not support C++. Also
certain optimization levels are not supported by the "Lite" toolchain.
@ -200,26 +210,12 @@ Toolchains
Note that the tools will have the prefix, mypic32- so, for example, the
compiler will be called mypic32-gcc.
Pinguino mips-elf Toolchain
---------------------------
Another option is the mips-elf toolchain used with the Pinguino project. This
is a relatively current mips-elf GCC and should provide free C++ support as
well. This toolchain can be downloded from the Pinguino website:
http://wiki.pinguino.cc/index.php/Main_Page#Download . There is some general
information about using the Pinguino mips-elf toolchain in this thread:
https://groups.yahoo.com/neo/groups/nuttx/conversations/messages/1821
See also configs/mirtoo/README.txt. There is an experimental (untested)
configuration for the Mirtoo platform in that directory.
MPLAB/C32 vs MPLABX/X32
-----------------------
It appears that Microchip is phasing out the MPLAB/C32 toolchain and replacing
it with MPLABX and XC32. At present, the XC32 toolchain is *not* compatible
with the NuttX build scripts. Here are some of the issues that I see when trying
to build with XC32:
Microchip has phased out the MPLAB/C32 toolchain and replacingit with MPLABX and
XC32. At present, the XC32 toolchain is *not* supported for this configuration.
Here are some of the issues that I see when trying to build with XC32:
1) Make.def changes: You have to change the tool prefix:
@ -238,6 +234,15 @@ Toolchains
information. You will have to solve at least this undefined symbol problem if
you want to used the XC32 toolchain.
Update: There have since been several successful uses of XC32 toolchains with
NuttX. XC32 is still not supported for this board, but you can see the README.txt
file and usage in other PIC32 configurations:
$ find . -name xc32-*
./mirtoo/scripts/xc32-debug.ld
./mirtoo/scripts/xc32-release.ld
./pic32mz-starterkit/scripts/xc32-debug.ld
Windows Native Toolchains
-------------------------

View File

@ -34,6 +34,7 @@ CONFIG_INTELHEX_BINARY=y
# CONFIG_MOTOROLA_SREC is not set
# CONFIG_RAW_BINARY is not set
# CONFIG_UBOOT_UIMAGE is not set
# CONFIG_DFU_BINARY is not set
#
# Customize Header Files
@ -96,8 +97,8 @@ CONFIG_ARCH_MIPS_24KC=y
# CONFIG_MIPS32_TOOLCHAIN_GNU_ELF is not set
# CONFIG_MIPS32_TOOLCHAIN_MICROCHIPW_XC32 is not set
# CONFIG_MIPS32_TOOLCHAIN_MICROCHIPW is not set
CONFIG_MIPS32_TOOLCHAIN_MICROCHIPW_LITE=y
# CONFIG_MIPS32_TOOLCHAIN_PINGUINOW is not set
# CONFIG_MIPS32_TOOLCHAIN_MICROCHIPW_LITE is not set
CONFIG_MIPS32_TOOLCHAIN_PINGUINOW=y
# CONFIG_MIPS32_FRAMEPOINTER is not set
#
@ -279,6 +280,8 @@ CONFIG_PIC32MX_VBUSIO=0
# CONFIG_PIC32MX_WDENABLE is not set
CONFIG_PIC32MX_FETHIO=0
CONFIG_PIC32MX_FMIIEN=0
# CONFIG_ARCH_TOOLCHAIN_IAR is not set
CONFIG_ARCH_TOOLCHAIN_GNU=y
#
# Architecture Options
@ -299,6 +302,7 @@ CONFIG_ARCH_HAVE_VFORK=y
# CONFIG_ARCH_HAVE_EXTCLK is not set
# CONFIG_ARCH_HAVE_POWEROFF is not set
# CONFIG_ARCH_HAVE_RESET is not set
# CONFIG_ARCH_HAVE_RTC_SUBSECONDS is not set
# CONFIG_ARCH_IRQPRIO is not set
CONFIG_ARCH_STACKDUMP=y
# CONFIG_ENDIAN_BIG is not set
@ -488,14 +492,6 @@ CONFIG_DEV_NULL=y
#
# Buffering
#
#
# Common I/O Buffer Support
#
CONFIG_MM_IOB=y
CONFIG_IOB_NBUFFERS=24
CONFIG_IOB_BUFSIZE=196
CONFIG_IOB_NCHAINS=8
# CONFIG_DRVR_WRITEBUFFER is not set
# CONFIG_DRVR_READAHEAD is not set
# CONFIG_RAMDISK is not set
@ -736,7 +732,9 @@ CONFIG_USBMSC_SCSI_STACKSIZE=2048
# System Logging
#
# CONFIG_ARCH_SYSLOG is not set
CONFIG_SYSLOG_WRITE=y
# CONFIG_RAMLOG is not set
# CONFIG_SYSLOG_BUFFER is not set
# CONFIG_SYSLOG_INTBUFFER is not set
# CONFIG_SYSLOG_TIMESTAMP is not set
CONFIG_SYSLOG_SERIAL_CONSOLE=y
@ -894,7 +892,17 @@ CONFIG_FAT_MAXFNAME=32
# CONFIG_FS_TMPFS is not set
# CONFIG_FS_SMARTFS is not set
# CONFIG_FS_BINFS is not set
# CONFIG_FS_PROCFS is not set
CONFIG_FS_PROCFS=y
# CONFIG_FS_PROCFS_REGISTER is not set
#
# 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_PROCFS_EXCLUDE_MTD is not set
# CONFIG_FS_UNIONFS is not set
#
@ -910,6 +918,15 @@ CONFIG_MM_REGIONS=1
# CONFIG_ARCH_HAVE_HEAP2 is not set
# CONFIG_GRAN is not set
#
# Common I/O Buffer Support
#
CONFIG_MM_IOB=y
CONFIG_IOB_NBUFFERS=24
CONFIG_IOB_BUFSIZE=196
CONFIG_IOB_NCHAINS=8
CONFIG_IOB_THROTTLE=0
#
# Audio Support
#
@ -918,6 +935,7 @@ CONFIG_MM_REGIONS=1
#
# Wireless Support
#
# CONFIG_WIRELESS is not set
#
# Binary Loader
@ -1255,6 +1273,7 @@ CONFIG_NSH_CMDOPT_DF_H=y
# CONFIG_NSH_CMDOPT_DD_STATS is not set
CONFIG_NSH_CODECS_BUFSIZE=128
CONFIG_NSH_CMDOPT_HEXDUMP=y
CONFIG_NSH_PROC_MOUNTPOINT="/proc"
CONFIG_NSH_FILEIOSIZE=512
#
@ -1274,6 +1293,7 @@ CONFIG_NSH_ARCHINIT=y
# Networking Configuration
#
CONFIG_NSH_NETINIT=y
# CONFIG_NSH_NETLOCAL is not set
# CONFIG_NSH_NETINIT_THREAD is not set
#
@ -1318,12 +1338,14 @@ CONFIG_NSH_IOBUFFER_SIZE=512
#
# CONFIG_SYSTEM_CLE is not set
# CONFIG_SYSTEM_CUTERM is not set
# CONFIG_SYSTEM_DHCPC is not set
# CONFIG_SYSTEM_FLASH_ERASEALL 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_NETDB is not set
# CONFIG_SYSTEM_NTPC is not set
# CONFIG_SYSTEM_RAMTEST is not set
CONFIG_READLINE_HAVE_EXTMATCH=y
CONFIG_SYSTEM_READLINE=y
@ -1351,3 +1373,10 @@ CONFIG_SYSTEM_USBMSC_CMD_PRIORITY=100
#
# Wireless Libraries and NSH Add-Ons
#
#
# IEEE 802.15.4 applications
#
# CONFIG_IEEE802154_LIBMAC is not set
# CONFIG_IEEE802154_LIBUTILS is not set
# CONFIG_IEEE802154_I8SAK is not set

View File

@ -36,7 +36,7 @@
-include $(TOPDIR)/Make.defs
ASRCS =
CSRCS = pic32_boot.c pic32_leds.c pic32_spi.c pic32_mio283qt2.c
CSRCS = pic32_boot.c pic32_bringup.c pic32_leds.c pic32_spi.c pic32_mio283qt2.c
ifeq ($(CONFIG_PIC32MX_USBDEV),y)
CSRCS += pic32_usbdev.c

View File

@ -39,319 +39,14 @@
#include <nuttx/config.h>
#include <stdio.h>
#include <unistd.h>
#include <syslog.h>
#include <errno.h>
#include <assert.h>
#include <sys/types.h>
#include <stdint.h>
#include <nuttx/board.h>
#include <nuttx/spi/spi.h>
#include <nuttx/mmcsd.h>
#include <nuttx/usb/usbhost.h>
#include "pic32mx.h"
#include "pic32mx7mmb.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Assume that we have MMC/SD, USB host (and USB device) */
#define NSH_HAVEMMCSD 1
#define NSH_HAVEUSBHOST 1
/* The Mikroelektronika PIC32MX7 MMB has one SD slot on board, connected to SPI 1. */
#ifndef CONFIG_PIC32MX_MMCSDSPIPORTNO
# define CONFIG_PIC32MX_MMCSDSPIPORTNO 1
#endif
/* Make sure that the configuration will support the SD card */
#ifdef NSH_HAVEMMCSD
/* Make sure that the NSH configuration uses the correct SPI */
# if !defined(CONFIG_NSH_MMCSDSPIPORTNO)
# define CONFIG_NSH_MMCSDSPIPORTNO CONFIG_PIC32MX_MMCSDSPIPORTNO
# elif CONFIG_NSH_MMCSDSPIPORTNO != CONFIG_PIC32MX_MMCSDSPIPORTNO
# warning "CONFIG_PIC32MX_MMCSDSPIPORTNO does not match CONFIG_NSH_MMCSDSPIPORTNO"
# undef CONFIG_NSH_MMCSDSPIPORTNO
# define CONFIG_NSH_MMCSDSPIPORTNO CONFIG_PIC32MX_MMCSDSPIPORTNO
# endif
/* Make sure that the NSH configuration uses slot 0 (there is only one
* SD slot on the Mikroelektronica PIC32MX7 MMB).
*/
# if !defined(CONFIG_NSH_MMCSDSLOTNO)
# define CONFIG_NSH_MMCSDSLOTNO 0
# elif CONFIG_NSH_MMCSDSLOTNO != 0
# warning "The Mikroelektronika PIC32MX7 MMB has only one slot (0)"
# undef CONFIG_NSH_MMCSDSLOTNO
# define CONFIG_NSH_MMCSDSLOTNO 0
# endif
/* Make sure that the correct SPI is enabled in the configuration */
# if CONFIG_PIC32MX_MMCSDSPIPORTNO == 1 && !defined(CONFIG_PIC32MX_SPI1)
# warning "CONFIG_PIC32MX_SPI1 is not enabled"
# undef NSH_HAVEMMCSD
# elif CONFIG_PIC32MX_MMCSDSPIPORTNO == 2 && !defined(CONFIG_PIC32MX_SPI2)
# warning "CONFIG_PIC32MX_SPI2 is not enabled"
# undef NSH_HAVEMMCSD
# elif CONFIG_PIC32MX_MMCSDSPIPORTNO == 3 && !defined(CONFIG_PIC32MX_SPI3)
# warning "CONFIG_PIC32MX_SPI3 is not enabled"
# undef NSH_HAVEMMCSD
# elif CONFIG_PIC32MX_MMCSDSPIPORTNO == 4 && !defined(CONFIG_PIC32MX_SPI4)
# warning "CONFIG_PIC32MX_SPI4 is not enabled"
# undef NSH_HAVEMMCSD
# endif
#endif
/* Can't support MMC/SD features if mountpoints are disabled */
#if defined(CONFIG_DISABLE_MOUNTPOINT)
# undef NSH_HAVEMMCSD
#endif
/* Select /dev/mmcsd0 if no other minor number is provided */
#ifndef CONFIG_NSH_MMCSDMINOR
# define CONFIG_NSH_MMCSDMINOR 0
#endif
/* USB Host */
#ifdef CONFIG_USBHOST
# ifndef CONFIG_PIC32MX_USBHOST
# error "CONFIG_PIC32MX_USBHOST is not selected"
# undef NSH_HAVEUSBHOST
# endif
#endif
#ifdef CONFIG_PIC32MX_USBHOST
# ifndef CONFIG_USBHOST
# warning "CONFIG_USBHOST is not selected"
# undef NSH_HAVEUSBHOST
# endif
#endif
#if !defined(CONFIG_USBHOST) || !defined(CONFIG_PIC32MX_USBHOST)
# undef NSH_HAVEUSBHOST
#endif
#ifdef NSH_HAVEUSBHOST
# ifndef CONFIG_USBHOST_DEFPRIO
# define CONFIG_USBHOST_DEFPRIO 50
# endif
# ifndef CONFIG_USBHOST_STACKSIZE
# ifdef CONFIG_USBHOST_HUB
# define CONFIG_USBHOST_STACKSIZE 1536
# else
# define CONFIG_USBHOST_STACKSIZE 1024
# endif
# endif
#endif
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef NSH_HAVEUSBHOST
static struct usbhost_connection_s *g_usbconn;
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: nsh_waiter
*
* Description:
* Wait for USB devices to be connected.
*
****************************************************************************/
#ifdef NSH_HAVEUSBHOST
static int nsh_waiter(int argc, char *argv[])
{
struct usbhost_hubport_s *hport;
syslog(LOG_INFO, "nsh_waiter: Running\n");
for (;;)
{
/* Wait for the device to change state */
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
syslog(LOG_INFO, "nsh_waiter: %s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
(void)CONN_ENUMERATE(g_usbconn, hport);
}
}
/* Keep the compiler from complaining */
return 0;
}
#endif
/****************************************************************************
* Name: nsh_sdinitialize
*
* Description:
* Initialize SPI-based microSD.
*
****************************************************************************/
#ifdef NSH_HAVEMMCSD
static int nsh_sdinitialize(void)
{
FAR struct spi_dev_s *spi;
int ret;
/* Get the SPI port */
spi = pic32mx_spibus_initialize(CONFIG_NSH_MMCSDSPIPORTNO);
if (!spi)
{
syslog(LOG_ERR, "ERROR: Failed to initialize SPI port %d\n",
CONFIG_NSH_MMCSDSPIPORTNO);
ret = -ENODEV;
goto errout;
}
syslog(LOG_INFO, "Successfully initialized SPI port %d\n",
CONFIG_NSH_MMCSDSPIPORTNO);
/* The SPI should be in 8-bit (default) and mode2: CKP=1, CKE=0.
* The MMC/SD driver will control the SPI frequency. WARNING:
* this is not the right way to do this... this should be done
* the MMC/SD driver: Other device on SPI1 may need other mode
* settings.
*/
SPI_SETMODE(spi, SPIDEV_MODE2);
/* Bind the SPI port to the slot */
ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR,
CONFIG_NSH_MMCSDSLOTNO, spi);
if (ret < 0)
{
syslog(LOG_ERR,
"ERROR: Failed to bind SPI port %d to MMC/SD slot %d: %d\n",
CONFIG_NSH_MMCSDSPIPORTNO,
CONFIG_NSH_MMCSDSLOTNO, ret);
goto errout;
}
syslog(LOG_INFO,
"Successfully bound SPI port %d to MMC/SD slot %d\n",
CONFIG_NSH_MMCSDSPIPORTNO,
CONFIG_NSH_MMCSDSLOTNO);
return OK;
errout:
return ret;
}
#else
# define nsh_sdinitialize() (OK)
#endif
/****************************************************************************
* Name: nsh_usbhostinitialize
*
* Description:
* Initialize SPI-based microSD.
*
****************************************************************************/
#ifdef NSH_HAVEUSBHOST
static int nsh_usbhostinitialize(void)
{
int pid;
int ret;
/* First, register all of the class drivers needed to support the drivers
* that we care about:
*/
syslog(LOG_INFO, "Register class drivers\n");
#ifdef CONFIG_USBHOST_MSC
/* Register the USB host Mass Storage Class */
ret = usbhost_msc_initialize();
if (ret != OK)
{
syslog(LOG_ERR, "ERROR: Failed to register the mass storage class: %d\n", ret);
}
#endif
#ifdef CONFIG_USBHOST_CDCACM
/* Register the CDC/ACM serial class */
ret = usbhost_cdcacm_initialize();
if (ret != OK)
{
syslog(LOG_ERR, "ERROR: Failed to register the CDC/ACM serial class: %d\n", ret);
}
#endif
/* Then get an instance of the USB host interface */
syslog(LOG_INFO, "Initialize USB host\n");
g_usbconn = pic32_usbhost_initialize(0);
if (g_usbconn)
{
/* Start a thread to handle device connection. */
syslog(LOG_INFO, "Start nsh_waiter\n");
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
CONFIG_USBHOST_STACKSIZE,
(main_t)nsh_waiter, (FAR char * const *)NULL);
return pid < 0 ? -ENOEXEC : OK;
}
return -ENODEV;
}
#else
# define nsh_usbhostinitialize() (OK)
#endif
/****************************************************************************
* Name: nsh_usbdevinitialize
*
* Description:
* Initialize SPI-based microSD.
*
****************************************************************************/
#ifdef CONFIG_USBDEV
static int nsh_usbdevinitialize(void)
{
/* The Mikroelektronika PIC32MX7 MMB has no way to know when the USB is
* connected. So we will fake it and tell the USB driver that the USB is
* connected now.
*/
pic32mx_usbattach();
return OK;
}
#else
# define nsh_usbdevinitialize() (OK)
#endif
#ifdef CONFIG_LIB_BOARDCTL
/****************************************************************************
* Public Functions
@ -365,6 +60,13 @@ static int nsh_usbdevinitialize(void)
* called directly from application code, but only indirectly via the
* (non-standard) boardctl() interface using the command BOARDIOC_INIT.
*
* CONFIG_LIB_BOARDCTL=y :
* Called from the NSH library
*
* CONFIG_BOARD_INITIALIZE=y, CONFIG_NSH_LIBRARY=y, &&
* CONFIG_LIB_BOARDCTL=n :
* Called from board_initialize().
*
* Input Parameters:
* arg - The boardctl() argument is passed to the board_app_initialize()
* implementation without modification. The argument has no
@ -384,24 +86,13 @@ static int nsh_usbdevinitialize(void)
int board_app_initialize(uintptr_t arg)
{
int ret;
/* Did we already initialize via board_initialize()? */
/* Initialize SPI-based microSD */
ret = nsh_sdinitialize();
if (ret == OK)
{
/* Initialize USB host */
ret = nsh_usbhostinitialize();
}
if (ret == OK)
{
/* Initialize USB device */
ret = nsh_usbdevinitialize();
}
return ret;
#ifndef CONFIG_BOARD_INITIALIZE
return pic32mx_bringup();
#else
return OK;
#endif
}
#endif /* CONFIG_LIB_BOARDCTL */

View File

@ -1,7 +1,7 @@
/************************************************************************************
* configs/pic32mx7mmb/src/pic32_boot.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -98,3 +98,26 @@ void pic32mx_boardinitialize(void)
pic32mx_led_initialize();
#endif
}
/****************************************************************************
* Name: board_initialize
*
* Description:
* If CONFIG_BOARD_INITIALIZE is selected, then an additional
* initialization call will be performed in the boot-up sequence to a
* function called board_initialize(). board_initialize() will be
* called immediately after up_initialize() is called and just before the
* initial application is started. This additional initialization phase
* may be used, for example, to initialize board-specific device drivers.
*
****************************************************************************/
#ifdef CONFIG_BOARD_INITIALIZE
void board_initialize(void)
{
/* Perform board-specific initialization here if so configured */
(void)pic32mx_bringup();
}
#endif

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/pic32mx7mmb/src/pic32mx7mmb.h
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -145,6 +145,22 @@ void weak_function pic32mx_spidev_initialize(void);
void pic32mx_led_initialize(void);
#endif
/************************************************************************************
* Name: pic32mx_bringup
*
* Description:
* Perform architecture-specific initialization
*
* CONFIG_BOARD_INITIALIZE=y :
* Called from board_initialize().
*
* CONFIG_BOARD_INITIALIZE=y && CONFIG_LIB_BOARDCTL=y :
* Called from the NSH library
*
************************************************************************************/
int pic32mx_bringup(void);
/****************************************************************************
* Name: pic32mx_lcdinitialize
*