EP-0146: Difference between revisions

From 52Pi Wiki
Jump to navigation Jump to search
Line 45: Line 45:
|[[File:Cm4 router board3.jpg|none|320px]]
|[[File:Cm4 router board3.jpg|none|320px]]
|}
|}
* Circuit Topology Concept
[[File:CM4concept.jpg|left|800px]]
<br style="clear:both;">
* Pin header Details
* Pin header Details
 
[[File:Cm4routerboard.jpg|left|800px]]
<br style="clear:both;">
<pre>
1. USB-C Power Port & Device USB2.0
2. HDMI Output
3. 40Pin Raspberry Pi GPIO
4. DC 5V Fan Pin Header ( Support PWM control Fan Speed)
5. CM4
</pre>
* Product Mechanical Drawing:
* Product Mechanical Drawing:
[[File:Cm4-router-board mechanical drawing.png|left|800px]]
[[File:Cm4-router-board mechanical drawing.png|left|800px]]

Revision as of 12:56, 24 September 2021

CM4 Router Board

Cm4 router board4.jpg

CM4 Router Board is an expansion board based on the Raspberry Pi Compute Module 4. It brings Raspberry Pi CM4 two full-speed gigabit network ports and offers better performance, lower CPU usage, and higher stability for a long time work compared with a USB network card.

The board still retains the characteristic GPIO pin header of Raspberry Pi, which makes it applicable for connecting other hat board such as Pi hats, sensors, and PoE hat board, and cooling fan, etc.

There is also a USB2.0 interface that can be connected to USB flash driver, USB keyboard, printers, WIFI modules,etc.

Besides, there is an OLED(0.91 inch) screen will help you to customize your Router Board's information display style.

It provides OpenWRT open-source router system. After a simple setup, it can be used as a router. It is also compatible with Raspberry OS, Ubuntu Server and other Raspberry Pi systems, even you can make this router board a retrogame machine at home.

The standard HDMI interface can help you configure the device and display operating information conveniently.

The powerful performance of BCM2711 4 core 1.5GHz Cortex-A72 and the rich software support in the Raspberry Pi community make this board a solid foundation for building high-performance gateways, smart routers, and home IoT platforms. It can also be connected to peripherals and used as a mini-NAS, wireless network bridge, or mini server which can be controlled via terminal.

If you need multiple LAN network ports like common routers, it is recommended to use a gigabit switch to expand the network ports, which will not affect its Internet performance.

5V DC Fan interface supports 5V cooling fan, it can alse support PWM protocol, that means you can control the speed of fan blades via PWM signal.

Features & Specifications

  • Compatible Module: Raspberry Pi Compute Module 4 series
  • Support standard Raspberry Pi HAT interface
  • Support POE HAT to supply power to the board
  • Support POE HAT for external power supply
  • Full-speed dual gigabit network interface
  • Master-slave dual USB2.0 interface
  • Micro SD card slot, used to support non-eMMC version of CM4
  • Standard HDIM video output interface
  • 0.91 inch IIC OLED display
  • 5V DC fan interface(Support controlling via PWM signal)
  • Ethernet: high-performance Gigabit ethernet controller RTL8111E chip, JXD 2111x G2406s chip as isolation transformer.
    • Port0: Compute Module 4 Built-In
    • Port1: PCI Express 1000BASE-T NIC
  • GPIO: 40Pin GPIO compatible with Raspberry Pi
  • Power Supply: USB-C(Type-C) 5V/3A interface
  • Operating Temperature: 0℃~80℃
  • Dimension: 146 x 80mm

Gallery

  • Product Outlook
Cm4 router board1.jpg
Cm4 router board2.jpg
Cm4 router board3.jpg
  • Circuit Topology Concept
CM4concept.jpg


  • Pin header Details
Cm4routerboard.jpg


1. USB-C Power Port & Device USB2.0
2. HDMI Output
3. 40Pin Raspberry Pi GPIO
4. DC 5V Fan Pin Header ( Support PWM control Fan Speed)
5. CM4 
  • Product Mechanical Drawing:
Cm4-router-board mechanical drawing.png


Package Includes

  • 1 x CM4 Router Board
  • 1 x Acrylic Case for CM4 Router Board Kit

CM4 Datasheet

How to use

Requirements

  • 1 x Any model of Compute Module 4
  • 1 x 5V@3A USB-C power supply
  • 1 x USB-C cable
  • 1 x MicroSD card (If you use the eMMC model, you don't need a microSD card, but you need to prepare a USB-C cable for editing and burning eMMC)
  • 2 x Cat-6 Ethernet Cable

Operating System

The CM4 router board is compatible with most systems that support Raspberry Pi 4, but most Linux distributions do not optimize the network device scenarios. So OpenWRT and Raspberry Pi OS are recommended.

For Raspberry Pi OS

  • If you are using Raspberry Pi OS.

1. Enable USB2.0 Port: After flash the latest image file to TF card and then modify /boot/config.txt file and add following line to the file.

dtoverlay=dwc2,dr_mode=host

Save it and reboot Raspberry Pi. 2. Enable OLED onboard: 2.1 Enable I2C function, Open a terminal and typing:

sudo raspi-config

Navigate to `Interface Options` -> `I2C` -> `Enable` -> `YES`. 2.2 Download libaraies from github:

 
sudo python -m pip install --upgrade pip setuptools wheel
git clone https://github.com/adafruit/Adafruit_Python_SSD1306.git
cd Adafruit_Python_SSD1306
sudo python setup.py install
pip install Adafruit-BBIO
  • Run example Demo:
cd examples/
python stats.py

For Using OpenWRT

Download Firmware

  • 52Pi Version: Based on the latest development version of OpenWRT, which already includes the web interface and language pack, it is recommended to get started.

OpenWRT Referrence Documentations

  • OpenWRT official snapshot version

The official snapshot is the smallest system, using serial terminal control, you need to manually install the Web console, driver, etc. it is recommended for experienced users.

SD Card Installation

Suitable for Compute Module 4 Lite without eMMC version.

  • 1. Requirements
    • Card Reader
    • Etcher
    • 7-Zip Compressed File Manager
    • OS image file

Flash the image file to MicroSD card by using etcher imaging tool.

Build OpenWRT Customized Firmware

You can build your own firmware by building OpenWRT from source.

  • 1.Prepare Compile Environment
    • Flash the latest version of Raspberry Pi OS to TF card(32GB recommended).
    • Modify /boot/config.txt file and adding the following parameter to enable the USB port function:
 dtoverlay=dwc2,dr_mode=host
    • Insert the TF card into card slot on CM4 Router Board.
    • Connect the power supply(5V/3A) on USB-C port.
    • After booting up the system, please connect to internet and typing following command in a terminal:
sudo apt-get update 
sudo apt-get -y upgrade
    • Install dependencies packages:
 sudo apt-get -y install build-essential asciidoc binutils bzip2 libncurses5-dev flex git-core p7zip p7zip-full 
 sudo apt-get -y install libssl-dev libelf-dev autoconf automake libtool device-tree-compiler gettext libi2c-dev 
 sudo apt-get -y install libz-dev texinfo 
    • After installing, please reboot your Raspberry Pi CM4 by typing:
 sudo sync && sudo reboot 
    • Create a folder and download OpenWRT source code by using git tool:
mkdir openwrt && cd openwrt 
git clone --depth=1 https://github.com/openwrt/openwrt
cd openwrt/
./scripts/feeds update -a
./scripts/feeds install -a
    • Download `luci-app-oled` libraries.
cd ~/openwrt/openwrt/package/feeds/luci/
git clone https://github.com/NateLol/luci-app-oled.git
cd ~/openwrt/openwrt/
./scripts/feeds update -a
./scripts/feeds install -a
** Configure the compile options by typing:
<pre> make menuconfig 

And then select "Target System" and "Target Profile" as following picture:

Openwrt-make-manuconfig-target.png
Openwrt-make-manuconfig-target2.png


Navigate to `kernel modules` and select `kmod-i2c-xxx` as following picutres:

Kernel modules.png
I2csupport.png
I2c selection.png


And then navigate to `USB Support` to add usb2 and usb3 support.

Usb dwc2-3 usbnet usb-hid.png
Usb-2-3-kmod.png


And then select `coreutils` in `Utilites` menu.

Utilities-coreutils.png
Coreutils.png


and enable `libi2c` in `libraries` menu.

Libraries.png
Libi2c.png


Next step is to enable LuCI `Collections` and `applications`.

Luci.png
Collections.png
Luci luci ssl openssl.png


Navigate to `Applications` -> `luci-app-oled` and check it:

Luci-app-oled.png


Save the configuration to `.config` file

Save cofig.png


  • Compile it with following command:
 make V=s -j1 

It may take a while, grap a cup of coffee.

  • Firmware will be generated on location:
 ~/openwrt/openwrt/bin/targets/bcm27xx/ 
    • Factory image file: openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz or openwrt-bcm27xx-bcm2711-rpi-4-squashfs-factory.img.gz
    • Sysupgrade image file: openwrt-bcm27xx-bcm2711-rpi-4-ext4-sysupgrade.img.gz or openwrt-bcm27xx-bcm2711-rpi-4-squashfs-sysupgrade.img.gz
  • Flash the facotory image file to TF card via using `etcher` tool and insert the TF card to CM4_router_board, connect the 5V power supply.
  • After booting, please connect your PC or just using Raspberry Pi to the ethernet cable on CM4 Router Board in `port0` or `port1`, and then open a browser, and typing administration address:
192.168.1.1
    • Account: root
    • Password is not set. please change the password once you login.

Enable I2C device in Customized OpenWRT

  • Modify `/boot/config.txt` file and add this line:
dtoverlay=i2c-gpio,i2c_gpio_sda=2,i2c_gpio_scl=3,i2c_gpio_delay_us=2,bus=1

Save it and reboot Raspberry Pi CM4 Router Board.

  • Change the Permission of `/etc/init.d/oled` file:
chmod 755 /etc/init.d/oled 
/etc/init.d/oled restart 
reboot
  • After reboot, try to test if it can detect the oled's address `0x3C`
Oledaddressdetect.png


  • Login to LuCI interface via browser and enable it, and then you can find the OLED in `service` tab, you can configure it as the notifications.
Luciinterface oled.png


  • Check the checkbox on `enable` and click `save it and apply`.