• 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 on RZ/G2L series board and RZ/Five, 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 on RZ/G2L series board and RZ/Five, 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 VLAN 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

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. Packages listed in this section are required by RZ/G2L series board and RZ/Five, if user wants the corresponding Wifi support. For RZ/G2 series board, these packages are not necessary due to they already have Wifi enabled by default.

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-firmware 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]#

CAN/CAN-FD

Below an example to check the basic CAN functionality in Linux. It refers to RZ/G2L but it should work as is also for RZ/G2LC-UL and RZ/V2L.

Inter-channel communication test

devmem2 is used to configure the relevant registers.

Enable Global test mode (GMDC[1:0]=0x2) in the Global Control Register:

 root@smarc-rzg2l:~# devmem2 0x10050088 w 0xA02
 /dev/mem opened.
 Memory mapped at address 0xffff8f046000.
 Read at address  0x10050088 (0xffff8f046088): 0x00000A00
 Write at address 0x10050088 (0xffff8f046088): 0x00000A02, readback 0x00000A02

Enable Inter-Channel Communication Test (CnICBCE = 1) in the Global Test Configuration Register:

 root@smarc-rzg2l:~# devmem2 0x10050468 w 0x3
 /dev/mem opened.
 Memory mapped at address 0xffffb60af000.
 Read at address  0x10050468 (0xffffb60af468): 0x00000000
 Write at address 0x10050468 (0xffffb60af468): 0x00000003, readback 0x00000003

Enable Communication Test between Channels (ICBCTME=1) in the Global Test Control Register:

 root@smarc-rzg2l:~# devmem2 0x1005046C w 0x1
 /dev/mem opened.
 Memory mapped at address 0xffff9f827000.
 Read at address  0x1005046C (0xffff9f82746c): 0x00000000
 Write at address 0x1005046C (0xffff9f82746c): 0x00000001, readback 0x00000001

Configure can0 and can1 (FD enabled):

 root@smarc-rzg2l:~# ip link set can0 type can bitrate 333333 dbitrate 666666 fd on
 root@smarc-rzg2l:~# ip link set can1 type can bitrate 333333 dbitrate 666666 fd on

Disable Global test mode (GMDC[1:0]=0x0) in the Global Control Register:

 root@smarc-rzg2l:~# devmem2 0x10050088 w 0xA00
 /dev/mem opened.
 Memory mapped at address 0xffff9cab3000.
 Read at address  0x10050088 (0xffff9cab3088): 0x00000A02
 Write at address 0x10050088 (0xffff9cab3088): 0x00000A00, readback 0x00000A00

can0 and can1 link up:

 root@smarc-rzg2l:~# ip link set can1 up
 root@smarc-rzg2l:~# ip link set can0 up

Start candump for can0 and can1 to log any can communication:

 root@smarc-rzg2l:~# candump can0 & candump can1 &
 [1] 292
 [2] 293

Send a sample CAN message using can1:

 root@smarc-rzg2l:~# cansend can1 18ff6228#aa55aa55aa55aa55
   can1  18FF6228   [8]  AA 55 AA 55 AA 55 AA 55
   can0  18FF6228   [8]  AA 55 AA 55 AA 55 AA 55

As expected the message is captured by both CAN interfaces.

If you want to send CAN-FD frames just use two "#" followed by a "0" (no increase in bitrate) or "1" (switch to higher bitrate). E.g.

root@smarc-rzg2l:~# cansend can1 18ff6228##1aa55aa55aa55aa55aa55aa55aa55aa55aa55aa55aa55aa55aa55aa55aa55aa55
  can1  18FF6228  [32]  AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55
  can0  18FF6228  [32]  AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55

External loopback test

Note: obviously this test works only if the CAN transceiver is fitted. Many EVKs shipped recently do not have the transceiver populated. First check that IC15 is soldered on the board.

Configure can1 and set up link (as previous section):

root@smarc-rzg2l:~# ip link set can1 type can bitrate 333333 dbitrate 666666 fd on
root@smarc-rzg2l:~# ip link set can1 up

Halt can1 CHMDC[1:0]=0x2 in the Channel 1 Control register:

devmem2 0x10050014 w 0x00A1FF02

Configure self-test mode 0 (external loopback mode) by setting CTMS[1:0]=0x2 as well as CTME=1 in the Channel 1 Control register and set can1 back to Channel communication mode (CHMDC[1:0]=0x0):

devmem2 0x10050014 w 0x05A1FF00

Then candump and cansend similar to previous example:

candump can1 &
cansend can1 18ff6228#55aa55aa55aa55aa
can1  18FF6228   [8]  55 AA 55 AA 55 AA 55 AA
can1  18FF6228   [8]  55 AA 55 AA 55 AA 55 AA

Internal loopback test

Exactly same as External loopback test, the only difference is the CTMS[1:0] configuration (0x3):

devmem2 0x10050014 w 0x07A1FF00


High-speed Linux UART using CM33(~10Mbps)

Virtual UART solution based on CM33 core of RZ/G2L

RZ/G2L基于CM33小核的虚拟串口方案



  • No labels