Difference between revisions of "EP-0146"
(→Enable I2C device in Customized OpenWRT)
|Line 54:||Line 54:|
* 1 x CM4 Router Board
* 1 x CM4 Router Board
* 1 x Acrylic Case for CM4 Router Board Kit
* 1 x Acrylic Case for CM4 Router Board Kit
==How to use==
==How to use==
Revision as of 16:31, 18 September 2021
- 1 CM4 Router Board
- 2 Features & Specifications
- 3 Gallery
- 4 Package Includes
- 5 CM4 Datasheet
- 6 How to use
CM4 Router Board
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
- Product Outlook
- Pin header Details
- Product Mechanical Drawing:
- 1 x CM4 Router Board
- 1 x Acrylic Case for CM4 Router Board Kit
- CM4 Datasheet: [[ https://datasheets.raspberrypi.org/cm4/cm4-datasheet.pdf ]]
How to use
- 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
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.
Save it and reboot Raspberry Pi. 2. Enable OLED onboard: 2.1 Enable I2C function, Open a terminal and typing:
Navigate to `Interface Options` -> `I2C` -> `Enable` -> `YES`. 2.2 Download libaraies from github:
- Open a terminal and Download demo code from: [ https://github.com/adafruit/Adafruit_Python_SSD1306 ]
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
- 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.
- 52Pi Official OpenWRT firmware [ https://github.com/geeekpi/cm4routerboard ]
- 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.
- OpenWRT official website: [ https://openwrt.org/ ]
- OpenWRT Develop Guide: [ https://openwrt.org/docs/guide-developer/source-code/start ]
- OpenWRT User Guide: [ https://openwrt.org/docs/guide-user/start ]
- OpenWRT forum: [ https://openwrt.org/contact#forum ]
- OpenWRT on Raspberry Pi CM4: [ https://openwrt.org/toh/hwdata/raspberry_pi_foundation/raspberry_pi_foundation_raspberry_pi_cm4 ]
- OpenWRT Raspberry Pi Foundation: [ https://openwrt.org/toh/raspberry_pi_foundation/raspberry_pi ]
- OpenWRT Use BuildSystem: [ https://openwrt.org/docs/guide-developer/build-system/use-buildsystem ]
- OpenWRT Build-System: [ https://openwrt.org/docs/guide-developer/build-system/install-buildsystem ]
SD Card Installation
Suitable for Compute Module 4 Lite without eMMC version.
- 1. Requirements
- Card Reader
- 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:
- 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:
Navigate to `kernel modules` and select `kmod-i2c-xxx` as following picutres:
And then navigate to `USB Support` to add usb2 and usb3 support.
And then select `coreutils` in `Utilites` menu.
and enable `libi2c` in `libraries` menu.
Next step is to enable LuCI `Collections` and `applications`.
Navigate to `Applications` -> `luci-app-oled` and check it:
Save the configuration to `.config` file
- 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:
- 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:
- 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:
Save it and reboot Raspberry Pi CM4 Router Board.
- After reboot, try to test if it can detect the oled's address `0x3C`
- 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.
- Check the checkbox on `enable` and click `save it and apply`.