RZ-G/RZ-G2 Communications

From Renesas.info
Revision as of 02:57, 31 May 2023 by GaryY (talk | contribs)

RZ-G

  • This page is to discuss things about commonly used communication interfaces of RZ/G2 MPU.

RS-485 half-duplex communication

Kernel Networking Configurations

Add iptables support

When using iptables command, below error occurs.

root@smarc-rzg2ul:~# iptables -L
modprobe: FATAL: Module ip_tables not found in directory /lib/modules/5.10.83-cip1-yocto-standard
iptables v1.8.4 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.

Please use below bitbake command to change the kernel configuration:

# command to open the menuconfig tool
$ bitbake linux-renesas -c menuconfig

Please change enable below kernel configuration:

[*] Networking support  --->
    Networking options  --->
        [*] Network packet filtering framework (Netfilter)  --->
            Core Netfilter Configuration  --->
                <*> Netfilter connection tracking support
            IP: Netfilter Configuration  --->
                <*> IP tables support (required for filtering/masq/NAT)
                <*> Packet filtering
                <*>   iptables NAT support
                <*>     MASQUERADE target support

After the kernel configuration was fixed, please use bitbake to start the build progress.

# start the system build with bitbake command
$ bitbake core-image-<minimal/bsp/weston/qt>

Add ip6tables support

If the below error happened when using ip6tables command, users can fix it by changing kernel configuration.

# error logged when using command "ip6tables"
root@smarc-rzg2ul:~# ip6tables -L
modprobe: FATAL: Module ip6_tables not found in directory /lib/modules/5.10.83-cip1-yocto-standard
ip6tables v1.8.4 (legacy): can't initialize ip6tables table `filter': Table does not exist (do you need to insmod?)
Perhaps ip6tables or your kernel needs to be upgraded.

Kernel configuration to support ip6tables.

[*] Networking support  --->
    Networking options  --->
      <*>The IPv6 protocol --->
        [*] Network packet filtering framework (Netfilter)  --->
              IPv6: Netfilter Configuration  --->
                  <*> IP6 tables support (required for filtering)
                      <*>   Packet filtering
                      <*>   ip6tables NAT support
                      <*>     MASQUERADE target support

Add ip support

When using ip command to configure the VLAN on RZ/G device, the below error message may occur.

root@smarc-rzg2ul:~# ip link add link eth0 name eth0.100 type vlan id 100
Error: Unknown device type.

Please change the kernel configuration as below and restart the build progress.

[*] Networking support  --->
        Networking options  --->
            <*> 802.1Q/802.1ad VLAN Support
            [*]   GVRP (GARP VLAN Registration Protocol) support
            [*]   MVRP (Multiple VLAN Registration Protocol) support

Helpful Networking Packages

Following packages can be installed in the system to improve the functionality of networking

DHCP Support

Dynamic Host Configuration Protocol (DHCP) is a network management protocol used on Internet Protocol (IP) networks for automatically assigning IP addresses and other communication parameters to devices.

dhcp

To add dhcp server and client, please add below code to local.conf:

  CORE_IMAGE_EXTRA_INSTALL_append = " dhcp-libs dhcp-server dhcp-server-config dhcp-client dhcp-relay dhcp-omshell "


kea

kea is a successor of ISC-DHCP(Internet Systems Consortium - Dynamic Host Configuration Protocol) for high performance and extensible DHCPv4/DHCPv6 server.

Currently, with ISC DHCP, which is widely used by ISPs and companies, it was necessary to restart the server when changing settings, but with Kea DHCP, changes can be reflected without restarting the server.

To add kea package to rootfs, please add this code to local.conf:

  IMAGE_INSTALL_append = " kea "


bridge-utils

The bridge-utils package contains a utility needed to create and manage bridge devices on RZ/G2 boards.

A bridge is a type of software used to bind multiple network segments together. The bridge acts like a virtual network switch and works transparently (other machines don't need to know it exists). You can connect real devices (eg eth0) and virtual devices (eg tap0) to the bridge.

To install the bridge-utils package, you can add "bridge-utils" to IMAGE_INSTALL_append variable in local.conf.

# in local.conf

IMAGE_INSTALL_append = " bridge-utils "

NOTE: User may need to enable both ethernet ports on an EVK. Please refer chapter "Add ipatbles support".

To enable the support of bridge function, below kernel configuration should be added with command "bitbake linux-renesas -c menuconfig".

$ bitbake linux-renesas -c menuconfig
  [*] Networking support  --->
    Networking options  --->
        [*] Network packet filtering framework (Netfilter)  --->
            <*>     Bridged IP/ARP packets filtering
                  Core Netfilter Configuration  --->
                <*> Netfilter Xtables support (required for ip_tables)
            <*>   Ethernet Bridge tables (ebtables) support  --->
                <*>   ebt: broute table support
                <*>   ebt: filter table support
                <*>   ebt: nat table support
                <*>   ebt: 802.3 filter support
                <*>   ebt: among filter support
                <*>   ebt: ARP filter support
                <*>   ebt: IP filter support
                <*>   ebt: limit match support
                <*>   ebt: mark filter support
                <*>   ebt: packet type filter support
                <*>   ebt: STP filter support
                <*>   ebt: 802.1Q VLAN filter support
                <*>   ebt: arp reply target support
                <*>   ebt: dnat target support
                <*>   ebt: mark target support
                <*>   ebt: redirect target support
                <*>   ebt: snat target support
                <*>   ebt: log support
        <*> 802.1d Ethernet Bridging

When kernel configuration is edited, issue command to enable system build.

bitbake core-image-<minimal/bsp/weston/qt>

Users can set a bridge with the command brctl on EVK.

# set a bridge br0
$ brctl addbr br0

# Add port eth0 and eth1 to bridge br0
$ brctl addif br0 eth0 eth1

# set ip address for br0
$ ifconfig br0 192.168.10.200

rp-pppoe and rp-pppoe-server

RP-PPPoE is a PPPoE client, relay and server for Linux. It can run completely in user-mode or used the Linux kernel's built-in PPPoE support. Here is the homepage of RP-PPPoE project.

You can enable pppoe client and server by adding the code below to local.conf:

# code to enable pppoe client and server in local.conf
IMAGE_INSTALL_append = " rp-pppoe rp-pppoe-server "

To enable pppoe function, following kernel configuration must be enabled.

  Device Drivers  --->
      [*] Network device support  --->
          <*>   PPP (point-to-point protocol) support
          <*>     PPP over Ethernet
          <*>     PPP support for async serial ports
          <*>     PPP BSD-Compress compression
          <*>     PPP Deflate compression
          <*>     PPP support for sync tty ports
      Character devices  --->
          [*]   Non-standard serial port support
              <*>     HDLC line discipline support

Network Manager

NetworkManager is a system service that manages network interfaces and connections based on user or automatic configuration. It supports Ethernet, Bridge, VLAN, Wi-Fi, PPPoE and other devices, and supports a variety of different VPN services.

NOTE: Networkmaneger packages and its dependencies require removing the restriction on GPLv3 and GPLv3+ license.

To enable networkmanager in rootfs image, please add the below code to local.conf.

# add networkmaneger
IMAGE_INSTALL_append = " networkmanager "

# Exclude packages for networkmanager
PACKAGE_EXCLUDE = " connman connman-client connman-tests connman-tools connman-t-online "

# Comment out the restriction on GPLv3 and GPLv3+ license
#INCOMPATIBLE_LICENSE = "GPLv3 GPLv3+"

vlan

VLAN (Virtual LAN) is a technology that creates a virtual LAN segment independent of the physical connection form. VLANs are used to logically divide LAN segments inside the switch. By using VLAN broadcast domains can be divided with L2 switches in the same way as with routers and L3 switches.

To add vlan to rootfs image, please add below code to local.conf.

  IMAGE_INSTALL_append = " vlan "

To enable routing between the different vlans, please run the below command on the evaluation board:

# Enable ip forward to enable routing between vlans
$ echo 1 > /proc/sys/net/ipv4/ip_forward


tcpdump

tcpdump is a powerful command-line packet analyzer. It allows the user to display TCP/IP and other packets being transmitted or received over a network.

To enable this package in rootfs image, please use the below code in local.conf:

IMAGE_INSTALL_append = " tcpdump "

WiFi Support

The following packages are for the Wifi support on RZ/G board.

Enable Wireless in Kernel

On RZ/G2L series board, user will need WiFi adapter the WiFi adapter used by us is BUFFALO WLI-UC-G301N. Wifi adapters requires support from kernel. Please enable the below kernel configuration.

  Device Drivers  --->
     [*] Network device support  --->
        <*>   USB Network Adapters  --->
           <*>   Multi-purpose USB Networking Framework
  Device Drivers  --->
      [*] USB support  --->
          <*>   USB Wireless Device Management support

Please set the wireless configuration as below:

Networking support --->
    [*] Wireless --->
        <*>   cfg80211 - wireless configuration API
        [*]     nl80211 testmode command
        [*]     enable developer warnings
        [*]     enable powersave by default (NEW)
        [*]     cfg80211 DebugFS entries
        [*]     cfg80211 wireless extensions compatibility
        <*>   Generic IEEE 802.11 Networking Stack (mac80211)
              Default rate control algorithm (Minstrel)  --->
        [*]   Enable mac80211 mesh networking support
        [*]   Enable LED triggers
        [*]   Export mac80211 internals in DebugFS
        [*]   Trace all mac80211 debug messages
        [*]   Select mac80211 debugging features  --->   

crda

This is the Central Regulatory Domain Agent for Linux. It serves one purpose: tell Linux kernel what regulatory rules to enforce for 802.11. CRDA searches for available frequency bands in the regulatory information database provided by the wireless-regdb package.

When using Wifi adapter from TP-Link without this package, user will see kernel message:

   cfg80211: failed to load regulatory.db

Please add this package with the code below to remove the above error message:

  IMAGE_INSTALL_append = " crda "

hostapd

hostapd (host access point daemon) is a user space daemon software enabling a network interface card to act as an access point and authentication server.

Let RZ/G board be a Wifi access point. Please add the code in local.conf:

  IMAGE_INSTALL_append = " hostapd "

Please add settings for adapter to hostapd file /etc/hostapd.conf

# in file /etc/hostapd.conf
interface=wlan0
driver=nl80211
ssid=<Wifi SSID>
hw_mode=g
channel=1
wmm_enabled=1
macaddr_acl=0
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
wpa_passphrase=<Wifi password>

To check the setting in file /etc/hostapd.conf, please use the below command. There should be no error message if the setting was correct.

# Check settings in file /etc/hostapd.conf
$ hostapd -dd /etc/hostapd.conf

Users can start/stop hostapd manually with the below command:

# Start the hostapd service
$ systemctl start hostapd

# Stop the hostapd service
$ systemctl stop hostapd

iw (wireless tools)

To offer support for 802.11 standard WLAN settings, iw package is provided as wireless tool and can be installed with the code below in local.conf:

  IMAGE_INSTALL_append = " iw "

linux-firmware

linux-fiemware is a package distributed together with the Linux kernel that contains the firmware binary blobs necessary for the functioning of a particular hardware device.

Use below code to add this package:

  IMAGE_INSTALL_append = " linux-firmware "

wpa-supplicant

wpa_supplicant is a cross-platform supplicant that supports WEP, WPA, WPA2 (IEEE 802.11i / RSN (Robust Secure Network)). It targets desktops, laptops and embedded systems.

Please add this package with below code:

  IMAGE_INSTALL_append = " wpa-supplicant "

Bluetooth Support

Packages for supporting the bluetooth function on RZ/G board. We have tested with bluetooth adapter TP-Link UB500 Bluetooth 5.0.

Bluez5

bluez5: bluetooth protocol stack for Linux system.

Add bluez5 package with code:

  IMAGE_INSTALL_append = " bluez5 "

Bluetooth support requires changing configurations as below:

  Networking support ---> 
      Bluetooth subsystem support --->
          [*]   Bluetooth Classic (BR/EDR) features (NEW)
          <*>     RFCOMM protocol support
          [ ]       RFCOMM TTY support (NEW)
          < >     BNEP protocol support (NEW)
          <*>     HIDP protocol support
          [*]     Bluetooth High Speed (HS) features
          [*]   Bluetooth Low Energy (LE) features (NEW)
          [ ]   Enable LED triggers (NEW)
          [ ]   Enable Microsoft extensions (NEW)
          [*]   Export Bluetooth internals in debugfs (NEW)
          [ ]   Bluetooth self testing support (NEW)
          [ ]   Enable runtime option for debugging statements (NEW)
                Bluetooth device drivers  --->

bluez5 will install bluetoothctl command to system. Bluetooth pairing and connect with this command will be as below:

  # Start bluetoothctl 
  root@smarc-rzfive:~# bluetoothctl
  Agent registered
  [CHG] Controller E8:48:B8:C8:20:00 Pairable: yes

  [bluetooth]# power on
  Changing power on succeeded
  [CHG] Controller E8:48:B8:C8:20:00 Powered: yes

  # Scan bluetooth devices
  [bluetooth]# devices
  Device 10:30:25:EB:6B:xx <Deivce 1>
  Device 10:30:25:F1:28:yy <Device 2>
  Device E4:70:B8:FD:1C:zz <Device 3>
  Device <Device Mac> <Deivce name>

  # Pair device with device Mac
  [bluetooth]# pair 10:30:25:EB:6B:xx
  Attempting to pair with 10:30:25:EB:6B:xx 
  [CHG] Device 10:30:25:EB:6B:xx Connected: yes
  Request confirmation
  [agent] Confirm passkey 028937 (yes/no): yes
  [CHG] Device 10:30:25:EB:6B:xx Connected: no
  [CHG] Device 10:30:25:EB:6B:xx Paired: yes
  Pairing successful
  [bluetooth]#