renesasrulz - setting up an application with … · web viewthis is an application for the dk-s7g2...

23
Setting up an Application with Multiple Network Interfaces In NetX and NetX Duo Introduction For Synergy boards with multiple network ports, there are specific steps to configure NetX and NetX Duo for multiple network interfaces. The e2 studio configurator automates much of the work, but there are additional settings and API that are required. This project will lead you through those steps to produce a multiple network interface application. The project for this application note was developed using the Renesas e2 Integrated Solution Development Environment (ISDE). While building applications under the Renesas Synergy Ecosystem is considerably faster than developing similar applications in other environments there is still a learning curve to understand the steps necessary to construct complex multithreaded applications quickly. This application note will walk you through all the steps necessary, including the following: • Board setup • Application Overview • Example scenarios for multiple network interfaces • Inter-thread communication using the Synergy messaging framework • Loading and running the project Target Device Synergy DK-S7G2 V3.1 development board (Synergy S7G2 series MCU) DK-S7G2 Setup The DK-S7G2 board contains a few switch settings which must be configured prior to running the firmware associated with this application note. There are two sets of dip switches on the DK-S7G2 board and should be set as per below:

Upload: others

Post on 25-Dec-2019

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

Setting up an Application with Multiple Network Interfaces In NetX and NetX Duo IntroductionFor Synergy boards with multiple network ports, there are specific steps to configure NetX and NetX Duo for multiple network interfaces. The e2 studio configurator automates much of the work, but there are additional settings and API that are required. This project will lead you through those steps to produce a multiple network interface application.

The project for this application note was developed using the Renesas e2 Integrated Solution Development Environment (ISDE). While building applications under the Renesas Synergy Ecosystem is considerably faster than developing similar applications in other environments there is still a learning curve to understand the steps necessary to construct complex multithreaded applications quickly. This application note will walk you through all the steps necessary, including the following:

• Board setup• Application Overview• Example scenarios for multiple network interfaces• Inter-thread communication using the Synergy messaging framework• Loading and running the project

Target DeviceSynergy DK-S7G2 V3.1 development board (Synergy S7G2 series MCU)

DK-S7G2 Setup

The DK-S7G2 board contains a few switch settings which must be configured prior to running the firmware associated with this application note.

There are two sets of dip switches on the DK-S7G2 board and should be set as per below:

Table 1. S5 dip switch settings for DK-S7G2 Main Board

1 DRAM OFF2 QSPI OFF3 ENET1 ON4 PMOD OFF5 PBs OFF6 JTAG ON7 EXP ON8 BOOT OFF

Table 1. S101 dip switch settings for DK-S7G2 Breakout Board

Page 2: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

1 RS OFF2 CAN OFF3 ENETC ON4 SD OFF5 MMC OFF6 PMODB OFF7 BLE OFF8 CAM OFF

Dip Switches on the main and breakout boards of the DK-S7G2

Application OverviewThe key goal of this application is to demonstrate how to set up multiple network interfaces with a single IP instance. The Synergy build environment by default configures a network application for a single network interface. This is called the primary network interface. In the list of network interfaces saved to the IP instance it is always at index 0. Additional network interfaces are known as secondary interfaces and their index is 1 or higher depending on the order they are attached to the IP instance. This eliminates the need to create multiple IP instances for secondary interfaces.

Note: creating multiple IP instances in a NetX or NetX Duo environment is strongly not recommended.

In the source code for this Application Note project, there are two ethernet interfaces which both require an IP address and therefore will need to run DHCP Client. Both threads (one for the primary interface, one for the secondary interface) check that the interface is initialized before starting the DHCP Client. Although this topic is beyond the realm of this Application Note, a brief explanation is required for running DHCP Client on multiple interfaces.

Page 3: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

DHCP Client on Multiple InterfacesThe DHCP Client is automatically enabled on the primary interface (there are API to explicitly disable it). Therefore, the primary thread can start the DHCP Client directly using the nx_dhcp_interface_start API as soon as it verifies the network link is enabled. The secondary thread, however, must explicitly enable DHCP Client for the secondary interface before DHCP Client can be started on it (also using nx_dhcp_interface_start).

Note: nx_dhcp_start API will start DHCP Client on all interfaces enabled for DHCP Client.

After DHCP Client is started on both interfaces, both threads wait on the nx_ip_interface_status_check with the ADDRESS_RESOLVED command to check if the DHCP Client protocol has successfully completed.

Generally, it makes sense for dual interfaces applications to create two separate threads for managing activity on each of the interfaces, although separate threads are not required.

Examples of Projects with Multiple Physical NetworksIn the following examples, note that the NetX (or NetX Duo in NetX Duo projects) Source component is added. This is necessary to modify the default (prebuilt) NetX library for two physical network interfaces.

Also note there is only one DHCP Client instance. This is because DHCP Client can run on multiple interfaces simultaneously. It is strongly recommended against to create two DHCP Clients, as they would not be thread safe (because of the DHCP Client’s use of global variables)

Page 4: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

Configuration for two ethernet ports on a DK- S7G2 board

This is an application for the DK-S7G2 board which has two ethernet ports. One NetX or NetX Duo IP instance is created, g_ip0. The driver for the primary interface is the NetX Port Ether instance g_sf_el_nx0. The driver for the secondary interface is a second NetX Port Ether instance, g_sf_el_nx1 in the upper right-hand corner. Note there are two threads created. The Second Thread will conduct activity on the secondary interface, while network activity on the primary interface is handled by the Primary Thread.

Configuration for one ethernet port and a Wi-Fi port on an SK- S7G2 board

This is a project on the SK-S7G2 board. It has one IP instance, g_ip0. The primary interface uses the sf_el_nx driver for the NetX Port Ether instance. There is also a Wi-Fi port; this is the secondary interface which uses the sf_sifi_nsal_nx driver.

This is an application for the SK-S7G2 board which has one ethernet port and a wi-fi port. One NetX or NetX Duo IP instance is created, g_ip0. The driver for the primary interface is the NetX Port Ether instance g_sf_el_nx. The driver for the secondary interface is a NetX Port using WiFi instance, g_fisi_nsal_nx in the upper right-hand corner. Again, there are two threads created. The Second Thread will conduct activity on the secondary interface, while network activity on the primary interface is handled by the Primary Thread.

Note again that the NetX (or NetX Duo in NetX Duo projects) Source component is added. This is necessary to modify the default (prebuilt) NetX library for two physical network interfaces.

Page 5: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

Configuration for a NAT application on the DK-S7G2 board

This is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one IP instance, g_ip0, and defines two network interfaces, a primary interface and a secondary interface. Both are attached to the IP instance g_ip0. The primary interface is the global or external network interface, and uses the sf_el_nx_external driver instance of the NetX Ether Port. The secondary interface is the local or private network interface and uses the sf_el_nx driver_private driver instance of the NetX Ether Port.

Software Resources used in the Project*

Resource Revision Description

e2 studio 6.2.0 Integrated Solution Development Environment

SSP 1.5.0 Synergy Software Platform

IAR EW for Renesas Synergy

8.23.1 IAR Embedded Workbench for Renesas Synergy

SSC SSC_v6_2_0_R20180102 Synergy Standalone Configurator

DK-S7G2 v3.0 to v3.1 Starter Kit

*The project for this Application Note should work in older versions of e2 studio, SSP, IAR EW for Renesas Synergy and SSC. Differences with SSP 1.4.0 are noted in this document. The fundamentals of the NetX and NetX Duo IP stack have not changed between releases. NetX and NetX duo API and

Page 6: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

configuration options are never removed so older projects should always compile in a newer a NetX/Duo library, all else being constant.

Configuration Settings for a Multiple Network Interface ProjectThe following tables show the configuration settings for the components in the Application Project that are different from default settings. These settings apply to the Synergy DK S7G2. Other MCUs may have different default values and available configuration settings.

Modified settings (from default value) for the DHCP Client ISDE Property Value DescriptionMaximum DHCP client state records* (interfaces)

2 (Default 1) Number of interfaces (“records”) to enable the DHCP Client on. Must be less than the “Maximum Physical Interfaces” setting in the NetX Duo Source component.

*The name of this property may change slightly after SSP 1.4.0.

Modified settings (from default value) for NetX Port Ether Module on primary interface ISDE Property Value DescriptionParameter Checking Enabled Enable parameter checking

Ethernet Interrupt Priority

Priority 4 Ethernet interrupt priority selection

Channel 1 Channel selectionName g_sf_el_nx0 Name of driver instance on primary

thread

Modified settings (from default value) for NetX Port Ether Module on secondary interface ISDE Property Value DescriptionParameter Checking Enabled Enable parameter checking

Ethernet Interrupt Priority

Priority 4 Ethernet interrupt priority selection

Channel 0 Channel selectionName g_sf_el_nx1 Name of driver instance on secondary

thread

Modified settings (from default value) for NetX and NetX Duo DHCP Client ISDE Property Value DescriptionInternal thread priority 3 DHCP Client thread priorityInternal thread stack size (bytes)

2048 Stack size for DHCP Client thread

Page 7: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

Modified settings (from default value) for the NetX and NetX Duo IP Instance

ISDE Property Value DescriptionIP Helper Thread Stack Size (bytes)

2048 IP Helper Thread Stack Size (bytes) selection

IP Helper Thread Priority 1 IP Helper Thread Priority selection

In some cases, settings other than the defaults for lower level modules can be desirable. For example, it might be useful to select different Ethernet interface pins and resets. The configurable properties for the lower level stack modules are given in the below sections for completeness and as a reference. Note: Most of the property settings for lower level modules are fairly intuitive and usually can be determined by inspection of the associated properties window from the SSP configurator.

[1.] Configuration Settings for the NetX DHCPv4 Client Framework Module Low Level Drivers

Typically, only a small number of settings must be modified from the default for the IP layer and lower level drivers and these are indicated via the red text in the Thread Stack block. Notice that some of the configuration properties must be set to a certain value for proper framework operation and will be locked to prevent user modification. The table below identifies all the settings within the properties section for the module. Table 1: Configuration for the NetX IP Instance

ISDE Property SettingValue DescriptionName g_ip0 Module nameIPv4 Address (use commas for separation)

0,0,0,0 IPv4 Address selection

Subnet Mask (use commas for separation)

255,255,255,0 Subnet Mask selection

IP Helper Thread Stack Size (bytes)

2048 IP Helper Thread Stack Size (bytes) selection

IP Helper Thread Priority 3 IP Helper Thread Priority selectionARP Enable ARP selectionARP Cache Size in Bytes 512 ARP Cache Size in Bytes selectionReverse ARP Enable, Disable

(Default: Disable)Reverse ARP selection

TCP Enable, Disable (Default: Disable)

TCP selection

UDP Enable UDP selectionICMP Enable, Disable

(Default: Disable)ICMP selection

IGMP Enable, Disable (Default: Disable)

IGMP selection

Table 2: Configuration for the NetX DHCP Common

Page 8: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

ISDE Property SettingValue DescriptionType of Service for UDP requests

Normal, Minimum delay, Maximum data, Maximum reliability, Minimum cost (Default: Normal)

Type of service UDP requests selection

Fragmentation option Don't fragment, Fragment okay (Default: Don't fragment)

Fragment option selection

Time to live 128 Time to live selectionPacket Queue depth 5 Packet queue depth selection

Table 3: Configuration for the NetX Common on NetXISDE Property SettingValue DescriptionNo configuration parameters

Modified settings (from default value) for the NetX IP packet poolISDE Property SettingValue DescriptionName g_packet_pool0 Module namePacket Size in Bytes 5121568 Packet size selection. Even though DHCP

packets do not generally exceed 600 bytes, this packet pool also handles incoming packets. Setting packets to this size prevents the need for packet chaining.

Number of Packets in Pool

1648 Number of packets in pool selection. If the Use Application packet pool is enabled for the DHCP Client, this number can be lower (40). Each interface requires 16 packets to be initialized.

Modified settings (from default value) for the NetX Port ETHER on the primary interfaceISDE Property SettingValue DescriptionEthernet Interrupt Priority

Priority 0(highest)-15(lowest), Disabled (Default: Priority 5)

Ethernet interrupt priority selection.

Name g_sf_el_nx0 Module nameChannel 1 Channel selection

Modified settings (from default value) for the NetX Port ETHER on the secondary interfaceISDE Property Value DescriptionEthernet Interrupt Priority

Priority 0(highest)-15(lowest), Disabled (Default: Priority 5)

Ethernet interrupt priority selection.

Name g_sf_el_nx1 Module name (must be different from the name in the primary ethernet port instance.

Channel 0 Channel selection

Page 9: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

NetX DHCPv4 Client Module Clock ConfigurationThe ETHERC peripheral module uses pins on the MCU to communicate to external devices. I/O pins must be selected and configured as required by the external device. Error: Reference source not foundThe first table below illustrates the method for selecting the pins within the SSP configuration window and Error: Reference source not found the following table illustrates an example selection for the I2C pins.

Note that the Operation Mode selection mode determines what peripheral signals are available and thus what MCU pins are required.

Pin Selection Sequence for PeripheralsResource ISDE Tab Pin selection Sequence

ETHERC Pins Select Peripherals > Connectivity:ETHERC > ETHERC1.RMII

ETHERC Pins Select Peripherals > Connectivity:ETHERC > ETHERC0.RMII

Storage:QSPI Pins Disabled

Storage:SDHI Pins Disabled

System:Bus Pins Custom

System:CGC Pins Custom

System: DEBUG Pins JTAG

Note: The above selection sequence assumes ETHERC1 is the desired hardware target for the driver.

Modified settings (from default value) for ETHERC1.RMII Pin Configuration Property

SettingsValue Description

Operation Mode RMII

(Default: Disabled)

Select RMII as the Operation Mode for ETHERC1

Pin Group Selection Mixed, _A only

(Default: _A only)

Pin group selection

REF50CK P701 REF50CK Pin

TXD0 P700 TXD0 Pin

TXD1 P406 TXD1 Pin

TXD_EN P405 TXD_EN Pin

RXD0 P702 RXD0 Pin

RXD1 P703 RXD1 Pin

Page 10: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

RX_ER P704 RX_ER Pin

CRS_DV P705 CRS_DV Pin

MDC P403 MDC Pin

MDIO P404 MDIO Pin

EXOUT P713 EXOUT Pin

LINKSTA PB07 LINKSTA Pin

WOL PB06 WOL Pin

Modified settings (from default value) for ETHERC0.RMII

Pin Configuration Property

Value Description

Operation Mode RMII

(Default: Disabled)

Select RMII as the Operation Mode for ETHERC0

Pin Group Selection _A only

(Default: _A only)

Pin group selection

REF50CK P412 REF50CK Pin

TXD0 P413 TXD0 Pin

TXD1 P414 TXD1 Pin

TXD_EN P415 TXD_EN Pin

RXD0 P411 RXD0 Pin

RXD1 P410 RXD1 Pin

RX_ER P409 RX_ER Pin

CRS_DV P408 CRS_DV Pin

MDC P401 MDC Pin

MDIO P402 MDIO Pin

EXOUT P407 None EXOUT Pin

LINKSTA P206 None LINKSTA Pin

WOL P205 None WOL Pin

Page 11: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

Note: The above example settings are for a project using the Synergy S7G2 and the SDK-S7G2 Kit. Other Synergy Kits and other Synergy MCUs may have different available pin configuration settings.

For the DK-S7G2 board, set the primary interface to channel 1 which corresponds to the com port on the J4 connector, and the secondary interface to channel 0 which corresponds to the com port on J113 connector. This J4 and J113 com ports can swap channels, but cannot both use the same channel.

Note that both channel 0 and channel 1 have almost identical MAC addresses by default. The Channel 0 MAC address Low Bits is off by 1 from the Channel 1 MAC Address Low Bits.

Location of ethernet port connectors on the DK-S7G2 board

Creating Ethernet Driver Instances

When an IP instance is created, the driver for the primary interface is defined. In e2 studio, this is the NetX Port ETHER instance directly tied to the IP instance. The second NetX Port Ether driver is added

Page 12: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

separately to the configurator pane. This is for the secondary interface. When using network media of the same type, e.g. ethernet, the names of the two driver instances must be different. For ethernet drivers, the default name is g_sf_el_nx. If only using one driver, that name is fine. However, if using multiple instances of the same driver, it makes more sense to name them as in an array. Following that reasoning, the primary interface instance is renamed g_sf_el_nx0, and the name of the secondary interface driver (e.g. the name of the second NetX Port Ether instance) logically is g_sf_el_nx1 in this application project.

NetX and NetX Duo Source properties

1. Find the Maximum Physical Interfaces property in the NetX or NetX Duo source list of properties in the e2 studio project pain. Set it to 2 (the default value is 1). Click on Generate Project Content, then rebuild the project to update the NetX or NetX Duo library.

It is not recommended to configure the number of interfaces in the NetX or NetX Duo library by defining the NX_MAX_PHYSICAL_INTERFACES=2 in the project property settings -> C/C++ build -> Settings -> Cross Arm C Compiler -> Preprocessor. If the Maximum Physical Interfaces property of the NetX/NetX Duo source is set to 1, the preprocessor definition is overridden. If using a prebuilt library, the preprocessor will have no effect on the NetX Duo library and the project will not have secondary interface support.

2. If using one packet pool for the two interfaces, set the number of packets to at least 40. Each NetX Port ETHER driver instance requires 16 packets to initialize the driver. And you will want to allow extra packets for the application layer to transmit packets. Alternatively, you can add an additional packet pool for packets transmitted by the application. But you will still need at least double the number of packets as the default (16) IP packet pool with two interfaces. As yet, there is no way to directly set a separate packet pool per network interface in NetX or NetX Duo.

DHCP Client properties

This project uses the DHCP Client application to demonstrate a multiple network application. To configure the DHCP Client to run on more than one interface:

If using SSP 1.4.0 or later, find the property “Maximum DHCP Client state record” or similar (name may change slightly in future releases) of the DHCP Client instance and set it to 2.

If using an older version than SSP 1.5.0, set the NX_DHCP_CLIENT_MAX_RECORDS to the number of DHCP Clients in the project preprocessor settings, in this case, to 2. For SSP 1.5.0 and later, set the “Maximum DHCP Client state record(s) on an interface” property of the DHCP Client instance.

Page 13: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

Attaching a Secondary Interface in NetX and NetX DuoWhen clicking the Generate Project Content, Synergy generates set up code for the underlying drivers and NetX configuration based on the components in the configuration pane. These are the auto-generated files for the pin configuration and files in the synergy_gen folder. The latter automatically create the packet pool and IP instance. The IP thread is started immediately and sends various commands to the driver for primary interface to initialize and enable the link. However, the secondary interface is not initialized or enabled, so it is not valid for network communication as yet. Two steps are required for this:

1. Call the nx_ip_interface_attach API with the correct driver instance for the secondary interface. In Figure 1A, the driver instance is g_sf_el_nx1. For the Wi-Fi example in Figure 1B, the driver instance is sf_wifi_nsal_nx. For Figure 1C for the NAT application the driver instance is g_sf_el_nx_private.

The nx_ip_interface_attach API is as follows**:

status = nx_ip_interface_attach(&g_ip0, "2nd Interface", IP_ADDRESS(192,2,2,68), 0xFFFFFF00, g_sf_el_nx1);

SWIOT-5387 JIRA has an application project for NAT where it attaches a secondary interface. In that project, the nat_thread.c calls the nx_ip_interface_attach in the nat_thread_func function.

Page 14: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

2. Call nx_ip_interface_status_check API on the secondary interface with the INITIALIZE_DONE command to confirm the secondary interface is valid and enabled. This API is the same as the nx_ip_status_check API except it is an extra input to specify the interface index. For the secondary interface, the index is 1

Now the secondary interface is valid and ready to use NetX services.

** In SSP 1.2.0, NetX has an obsolete requirement in the error checking service for nx_ip_interface_attach that the input IP address not be zero. For applications that do not have an IP address at start up, this can be gotten around by simply calling the nx_ip_interface_address_set API with a zero IP address after the nx_ip_interface_attach call:

status = nx_ip_interface_address_set(&g_ip0, 1, 0, 0xFFFFFF00UL);

This problem is corrected in the SSP 1.5.1 and later releases.

Importing the ProjectTo bring the Weather Panel Application into the e2 studio, follow these steps:1. Launch e2 studio ISDE 2. In the workspace launcher browse to the workspace location of your choice3. Close the Welcome window4. In the ISDE go to File > Import5. In the Import Dialog Box pick Existing Projects into Workspace6. Select the Root directory of your workspace (where you placed the project)7. Select the project you wish to import and press Finish.

Program Flow for the Application Note Project

Page 15: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

Primary thread program flow (Pinging the DHCP server is not shown, comes after pinging the DNS server)

Page 16: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

Secondary thread program flow (Pinging the DHCP server is not shown, comes after pinging the DNS server)

The steps performed by the Synergy automatically in a NetX application support are:

1. Initialize the system with nx_system_initialize

2. Create a packet pool g_packet_pool0 with nx_packet_pool_create. This creates the IP default packet pool, to be used by the IP instance and the ethernet driver.

3. Create the IP Instance g_ip0 with nx_ip_create

4. Create a DHCP Client instance with nx_dhcp_create

The steps performed directly by the application on the primary thread to set up and run the DHCP Client are:

1. Check if the network link is initialized with the nx_ip_interface_status_check API.

2. Start the DHCP Client using the nx_dhcp_interface_start API. Note that it could also use nx_dhcp_start, but that function would start DHCP Client on all enabled interfaces, which in this case would probably only be the primary interface. To start DHCP Client on a specific interface, use the nx_dhcp_interface_start API.

3. Check if DHCP Client has successfully completed, by checking if the link IP address is resolved with the nx_ip_interface_status_check API.

4. Extract the DNS Server IP instance using the nx_dhcp_interface_user_option_retrieve API. Most DHCP Server provide this information in their response to DHCP Clients.

5. Verify the primary address is valid by using the nx_icmp_ping API to ping the DNS Server (or any host) on the primary network interface).

6. [Optional] Verify primary address is valid by pinging the DHCP server. Use the nx_dhcp_server_address_get API to get the server IP address and call nx_icmp_ping as above.

The steps performed directly by the application secondary thread to set up and run the DHCP Client are:

1. Check if the network link is initialized with the nx_ip_interface_status_check API.

2. Attach the interface to the IP instance using the nx_ip_interface_attach API. See discussion about using this service in the “Attaching a Secondary Interface in NetX and NetX Duo” in this document.

3. Enable the secondary interface for DHCP Client using the nx_dhcp_interface_enable API. Please see the section DHCP Client Properties for how to configure the DHCP Client for multiple interfaces. This is done at compile time. Enabling the DHCP Client on a specific interface is done at run time.

Page 17: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

4. Start the DHCP Client using the nx_dhcp_interface_start API. As with the primary thread, it could also use nx_dhcp_start, but that function would start DHCP Client on all enabled interfaces. In this case, this would have no effect on the primary interface which is already running DHCP Client.

5. Check if DHCP Client has successfully completed, by checking if the link IP address is resolved with the nx_ip_interface_status_check API.

6. Extract the DNS Server IP instance using the nx_dhcp_interface_user_option_retrieve API.

7. Verify the secondary address is valid by using the nx_icmp_ping to ping the DNS Server (or any host) on that network interface. Even though nx_icmp_ping API does not take an input for interface index, internally NetX or NetX Duo will figure out which interface the ping request goes out on.

8. [Optional] Verify secondary address is valid by pinging the DHCP server. Use the nx_dhcp_interface_server_address_get API to get the server IP address and call nx_icmp_ping as above.

The output should look something like below (the order of execution between primary and secondary interfaces depends on your environment) if both interfaces succeed in obtaining an IPv4 address:

Handling Out of Network and Non-Unicast Packets in a Multihome Environment

Packets for transmission are either On-link (match the interface) or Off-Link (goes to the interface where the default gateway can be reached). The default gateway interface is known when (if) the gateway is set using the nx_ip_gateway_address_set API.

Page 18: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

In most cases, NetX Duo is able to find the most direct interface when sending a packet. For TCP packets, the interface where the SYN packet (connection request) is received must be the outgoing interface. The nx_udp_socket_interface_send or the nx_udp_socket_source_send services are used when the best outgoing interface cannot be derived from the source/destination addresses, for example if the destination is broadcast or multicast.

If static routing entry is used (“IP Static Routing” of the NetX Duo source component), the interface associated with the next hop is used as an outgoing address.

ReferencesSSP User Manual: Available in html format in the SSP distribution package and in pdf format from the Synergy Gallery.

To find the most up-to-date reference materials and their locations, visit the Synergy Knowledge Base and do a search for the module name and include “application notes” in the search. For example, if you are looking for the References for the r_doc module, visit https://en-us.knowledgebase.renesas.com/English_Content/Renesas_Synergy%E2%84%A2_Platform/Renesas_Synergy_Knowledge_Base and enter “Ethernet driver references” in the search bar. The search will bring up a list of results, and the top one will be the References Page for that Module Guide.

ReferencesNetX User Guide for the Renesas Synergy™ PlatformNetX Duo User Guide for the Renesas Synergy™ Platform

PrerequisitesThe following prerequisites should all be satisfied in order for the reader to most efficiently use this guide. References for all the material listed in the prerequisites can be found in the reference section at the end of this document.

A reader who wishes to use this guide as a hands-on method for implementing the application example (as opposed to just a learning reference) will need to have an ISDE (e2 studio or IAR EW for Renesas Synergy with the appropriate version of SSP) installed and running on a computer. The “Getting Started” guide for the Renesas Synergy Platform can be used to help satisfy this prerequisite.

In addition to the ISDE and SSP, a hardware target is needed to see the example project running on a Synergy MCU. To satisfy this prerequisite a kit can be purchased from any Renesas authorized distributor and you can find a kit on a distributor’s website by simply searching for the kit name in the distributor’s search window. Kits targeted by the application example project are:

o DK-S7G2 This guide assumes the reader is familiar with using a Synergy ISDE and the SSP for creating

projects, adding threads, creating stacks, configuring modules, running, and debugging. Reading “Getting Started” guides, (for e2 studio, IAR EW for Renesas Synergy, and SSP) viewing introductory videos, and taking tutorial labs can all be used to satisfy this prerequisite.

Access to two ethernet networks with a DHCP Server; alternatively, use a single ethern network with a DHCP Server on line, and alternate the network connection between com ports.

Page 19: RenesasRulz - Setting up an Application with … · Web viewThis is an application for the DK-S7G2 board. When a NAT instance is added, the configurator automatically creates one

Time to CompleteIt typically takes around 30 minutes to complete this guide (including the hands-on exercises.)