Spirit: Network driver needs to setup IP address based on configured node address. If no node address is provided, then it will use a default. Also upate a README.
This commit is contained in:
parent
735095d040
commit
1275c3e249
@ -190,9 +190,14 @@ Configurations
|
|||||||
Each B-L475E-IOT01A configuration is maintained in a sub-directory and
|
Each B-L475E-IOT01A configuration is maintained in a sub-directory and
|
||||||
can be selected as follow:
|
can be selected as follow:
|
||||||
|
|
||||||
cd tools
|
tools/configure.sh [-l|c|u|n] /b-l475e-iot01a/<subdir>
|
||||||
./configure.sh b-l475e-iot01a/<subdir>
|
|
||||||
cd -
|
Where:
|
||||||
|
-l selects the Linux (l) host environment. The [-c|u|n] options
|
||||||
|
select one of the Windows environments. Default: Use host setup
|
||||||
|
in the defconfig file
|
||||||
|
[-c|u|n] selects the Windows host and a Windows environment: Cygwin (c),
|
||||||
|
Ubuntu under Windows 10 (u), or Windows native (n). Default Cygwin
|
||||||
|
|
||||||
Before building, make sure that:
|
Before building, make sure that:
|
||||||
|
|
||||||
@ -209,12 +214,8 @@ Configurations
|
|||||||
the make, the nuttx binary will reside in an ELF file called, simply,
|
the make, the nuttx binary will reside in an ELF file called, simply,
|
||||||
nuttx.
|
nuttx.
|
||||||
|
|
||||||
make oldconfig
|
|
||||||
make
|
make
|
||||||
|
|
||||||
Where 'make oldconfig' brings the configuration up to data with the current configuration data and 'make' will compile all of the source
|
|
||||||
files and generate the final binary.
|
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
|
|
||||||
1. These configurations use the mconf-based configuration tool. To
|
1. These configurations use the mconf-based configuration tool. To
|
||||||
@ -227,7 +228,22 @@ Configurations
|
|||||||
reconfiguration process.
|
reconfiguration process.
|
||||||
|
|
||||||
2. Unless stated otherwise, all configurations generate console
|
2. Unless stated otherwise, all configurations generate console
|
||||||
output on USART1 (i.e., for ST-Link Virtual COM port).
|
output on USART1 (i.e., for ST-Link Virtual COM port). The
|
||||||
|
relevant configuration settings are listed below:
|
||||||
|
|
||||||
|
CONFIG_STM32_USART1=y
|
||||||
|
CONFIG_STM32_USART1_SERIALDRIVER=y
|
||||||
|
CONFIG_STM32_USART=y
|
||||||
|
|
||||||
|
CONFIG_USART1_SERIALDRIVER=y
|
||||||
|
CONFIG_USART1_SERIAL_CONSOLE=y
|
||||||
|
|
||||||
|
CONFIG_USART1_RXBUFSIZE=256
|
||||||
|
CONFIG_USART1_TXBUFSIZE=256
|
||||||
|
CONFIG_USART1_BAUD=115200
|
||||||
|
CONFIG_USART1_BITS=8
|
||||||
|
CONFIG_USART1_PARITY=0
|
||||||
|
CONFIG_USART1_2STOP=0
|
||||||
|
|
||||||
3. All of these configurations are set up to build under Windows using the
|
3. All of these configurations are set up to build under Windows using the
|
||||||
"GNU Tools for ARM Embedded Processors" that is maintained by ARM
|
"GNU Tools for ARM Embedded Processors" that is maintained by ARM
|
||||||
@ -247,3 +263,14 @@ Configurations
|
|||||||
|
|
||||||
Configuration sub-directories
|
Configuration sub-directories
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
|
nsh:
|
||||||
|
|
||||||
|
Configures the NuttShell (nsh) located at examples/nsh. This
|
||||||
|
configuration is focused on low level, command-line driver testing.
|
||||||
|
|
||||||
|
spirit-6lowpan
|
||||||
|
|
||||||
|
This is another NSH configuration that differs from the 'nsh'
|
||||||
|
configuration in that it has 6LoWPAN networking enabled for the
|
||||||
|
on-board Spirit1 SPSGRF-915 part.
|
||||||
|
@ -98,6 +98,10 @@
|
|||||||
# define CONFIG_SPIRIT_PKTLEN 96
|
# define CONFIG_SPIRIT_PKTLEN 96
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Default node address */
|
||||||
|
|
||||||
|
#define SPIRIT_NODE_ADDR 0x34
|
||||||
|
|
||||||
/* 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 SPIRIT_WDDELAY (1*CLK_TCK)
|
#define SPIRIT_WDDELAY (1*CLK_TCK)
|
||||||
@ -150,7 +154,8 @@ struct spirit_driver_s
|
|||||||
static void spirit_lock(FAR struct spirit_driver_s *priv);
|
static void spirit_lock(FAR struct spirit_driver_s *priv);
|
||||||
#define spirit_unlock(priv) sem_post(&priv->exclsem);
|
#define spirit_unlock(priv) sem_post(&priv->exclsem);
|
||||||
|
|
||||||
static int spirit_set_readystate(FAR struct spirit_driver_s *priv);
|
static void spirit_set_ipaddress(FAR struct net_driver_s *dev);
|
||||||
|
static int spirit_set_readystate(FAR struct spirit_driver_s *priv);
|
||||||
|
|
||||||
/* TX-related logic */
|
/* TX-related logic */
|
||||||
|
|
||||||
@ -265,7 +270,7 @@ static const struct spirit_csma_init_s g_csma_init =
|
|||||||
static struct pktbasic_addr_s g_addrinit =
|
static struct pktbasic_addr_s g_addrinit =
|
||||||
{
|
{
|
||||||
S_DISABLE, /* Disable filtering on node address */
|
S_DISABLE, /* Disable filtering on node address */
|
||||||
0x34, /* Note address (Temporary, until assigned) */
|
SPIRIT_NODE_ADDR /* Note address (Temporary, until assigned) */
|
||||||
S_DISABLE, /* Disable filtering on multicast address */
|
S_DISABLE, /* Disable filtering on multicast address */
|
||||||
0xee, /* Multicast address */
|
0xee, /* Multicast address */
|
||||||
S_DISABLE, /* Disable filtering on broadcast address */
|
S_DISABLE, /* Disable filtering on broadcast address */
|
||||||
@ -275,7 +280,7 @@ static struct pktbasic_addr_s g_addrinit =
|
|||||||
static struct pktbasic_addr_s g_addrinit =
|
static struct pktbasic_addr_s g_addrinit =
|
||||||
{
|
{
|
||||||
S_ENABLE, /* Enable filtering on node address */
|
S_ENABLE, /* Enable filtering on node address */
|
||||||
0x34, /* Note address (Temporary, until assigned) */
|
SPIRIT_NODE_ADDR, /* Note address (Temporary, until assigned) */
|
||||||
#ifdef CONFIG_SPIRIT_MULTICAST
|
#ifdef CONFIG_SPIRIT_MULTICAST
|
||||||
S_ENABLE, /* Enable filtering on multicast address */
|
S_ENABLE, /* Enable filtering on multicast address */
|
||||||
#else
|
#else
|
||||||
@ -317,6 +322,55 @@ static void spirit_lock(FAR struct spirit_driver_s *priv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: spirit_set_ipaddress
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set the advertised node addressing. External logic must set a unique
|
||||||
|
* 8-bit node-address for the radio. We will then derive the IPv6
|
||||||
|
* address for that.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* spirit - Reference to a Spirit library state structure instance
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK on success; a negated errno on a timeout
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void spirit_set_ipaddress(FAR struct net_driver_s *dev)
|
||||||
|
{
|
||||||
|
FAR struct netdev_varaddr_s *addr;
|
||||||
|
|
||||||
|
/* Get a convenient pointer to the PktRadio variable length address struct */
|
||||||
|
|
||||||
|
addr = (FAR struct netdev_varaddr_s *)&dev->d_mac.sixlowpan;
|
||||||
|
|
||||||
|
/* Has a node address been assigned? */
|
||||||
|
|
||||||
|
if (addr->nv_addrlen == 0)
|
||||||
|
{
|
||||||
|
/* No.. Use the default address */
|
||||||
|
|
||||||
|
wlwarn("WARNING: No address assigned. Using %02x\n",
|
||||||
|
SPIRIT_NODE_ADDR);
|
||||||
|
|
||||||
|
addr->nv_addrlen = 1;
|
||||||
|
addr->nv_addr[0] = SPIRIT_NODE_ADDR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Then set the IP address derived from the node address */
|
||||||
|
|
||||||
|
dev->d_ipv6addr[0] = HTONS(0xfe80);
|
||||||
|
dev->d_ipv6addr[1] = 0;
|
||||||
|
dev->d_ipv6addr[2] = 0;
|
||||||
|
dev->d_ipv6addr[3] = 0;
|
||||||
|
dev->d_ipv6addr[4] = 0;
|
||||||
|
dev->d_ipv6addr[5] = HTONS(0x00ff);
|
||||||
|
dev->d_ipv6addr[6] = HTONS(0xfe00);
|
||||||
|
dev->d_ipv6addr[7] = (uint16_t)addr->nv_addr[0] << 8 ^ 0x0200;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: spirit_set_readystate
|
* Name: spirit_set_readystate
|
||||||
*
|
*
|
||||||
@ -658,7 +712,7 @@ static void sprit_receive_work(FAR void *arg)
|
|||||||
ret = sixlowpan_input(&priv->radio, iob, (FAR void *)pktmeta);
|
ret = sixlowpan_input(&priv->radio, iob, (FAR void *)pktmeta);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
nerr("ERROR: sixlowpan_input returned %d\n", ret);
|
wlerr("ERROR: sixlowpan_input returned %d\n", ret);
|
||||||
NETDEV_RXERRORS(&priv->radio.r_dev);
|
NETDEV_RXERRORS(&priv->radio.r_dev);
|
||||||
NETDEV_ERRORS(&priv->radio.r_dev);
|
NETDEV_ERRORS(&priv->radio.r_dev);
|
||||||
}
|
}
|
||||||
@ -1183,10 +1237,14 @@ static int spirit_ifup(FAR struct net_driver_s *dev)
|
|||||||
|
|
||||||
if (!priv->ifup)
|
if (!priv->ifup)
|
||||||
{
|
{
|
||||||
ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
|
/* Set the node IP address based on the assigned 8-bit node address */
|
||||||
dev->d_ipv6addr[0], dev->d_ipv6addr[1], dev->d_ipv6addr[2],
|
|
||||||
dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5],
|
spirit_set_ipaddress(dev);
|
||||||
dev->d_ipv6addr[6], dev->d_ipv6addr[7]);
|
|
||||||
|
wlinfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
|
||||||
|
dev->d_ipv6addr[0], dev->d_ipv6addr[1], dev->d_ipv6addr[2],
|
||||||
|
dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5],
|
||||||
|
dev->d_ipv6addr[6], dev->d_ipv6addr[7]);
|
||||||
|
|
||||||
/* Disable spirit interrupts */
|
/* Disable spirit interrupts */
|
||||||
|
|
||||||
@ -1198,6 +1256,7 @@ static int spirit_ifup(FAR struct net_driver_s *dev)
|
|||||||
* about mutual exclusion.
|
* about mutual exclusion.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
wlinfo("Go to the RX state\n");
|
||||||
ret = spirit_command(spirit, CMD_READY);
|
ret = spirit_command(spirit, CMD_READY);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -1227,26 +1286,18 @@ static int spirit_ifup(FAR struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CONFIG_SPIRIT_PROMISCOUS
|
#ifndef CONFIG_SPIRIT_PROMISCOUS
|
||||||
/* Has an address been assigned? If not, we will stick the default
|
/* Instantiate the assigned node address in harsware*/
|
||||||
* address which probably is not what you want.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (dev->d_mac.sixlowpan.nv_addrlen != 0)
|
DEBUGASSERT(dev->d_mac.sixlowpan.nv_addrlen == 1);
|
||||||
|
wlinfo("Set node address to %02x\n",
|
||||||
|
dev->d_mac.sixlowpan.nv_addr[0]);
|
||||||
|
|
||||||
|
ret = spirit_pktcommon_set_nodeaddress(spirit,
|
||||||
|
dev->d_mac.sixlowpan.nv_addr[0]);
|
||||||
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
/* Yes.. Instantiate the assigned node address */
|
wlerr("ERROR: Failed to set node address: %d\n", ret);
|
||||||
|
goto error_with_ifalmostup;
|
||||||
DEBUGASSERT(dev->d_mac.sixlowpan.nv_addrlen == 1);
|
|
||||||
|
|
||||||
ret = spirit_pktcommon_set_nodeaddress(spirit,
|
|
||||||
dev->d_mac.sixlowpan.nv_addr[0]);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
goto error_with_ifalmostup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nwarn("WARNING: No address assigned\n");
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1526,7 +1577,7 @@ static int spirit_ioctl(FAR struct net_driver_s *dev, int cmd,
|
|||||||
/* Add cases here to support the IOCTL commands */
|
/* Add cases here to support the IOCTL commands */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
nerr("ERROR: Unrecognized IOCTL command: %d\n", command);
|
wlerr("ERROR: Unrecognized IOCTL command: %02x\n", cmd);
|
||||||
ret = -ENOTTY; /* Special return value for this case */
|
ret = -ENOTTY; /* Special return value for this case */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1781,7 +1832,7 @@ int spirit_hw_initialize(FAR struct spirit_driver_s *priv,
|
|||||||
|
|
||||||
/* Configures the SPIRIT1 packet handling logic */
|
/* Configures the SPIRIT1 packet handling logic */
|
||||||
|
|
||||||
wlinfo("Configure the basic packets\n");
|
wlinfo("Configure basic packets\n");
|
||||||
ret = spirit_pktbasic_initialize(spirit, &g_pktbasic_init);
|
ret = spirit_pktbasic_initialize(spirit, &g_pktbasic_init);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user