Introduction

Compute Module 4 IoT Router Carrier Board Mini is an internet expansion board based on the Raspberry Pi Compute Module 4. When connecting with a gigabit network card via PCle, 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. Besides, with a mini size of 55 x62mm, the board still retains the characteristic GPIO pin header of Raspberry Pi, which makes it applicable for connecting other actuators, sensors, and smart cooling fan. Furthermore, there is also a USB2.0 interface that can be connected to mobile hard drives, printers, WIFI modules, LTF modules, etc.

Compute Module 4 IoT Router Carrier Board Mini now 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.

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 LTE Internet 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.

For router usage scenarios, CM4001000 module is recommended.

CM4 IoT Router Board Spec

Name CM4 IoT Router Mini
Module Compatible Compute Module 4
ETH Ports 2
ETH Speed 1000BASE-T
NIC 1 CM4 Built-in
NIC 2 RTL8111
Power Port USB-C
Power Supply 5V 3A
USB 1x USB-C (USB 2.0)
GPIO 26Pin
Size 55 x 61.5mm

Hardware Diagram

Hardware Diagram

No. Interface Description
1 USB-C Power input only
2 RST Reset Button
3 USB-C USB 2.0
4 PRiBOOT eMMC version CM4 burning switch
5 EEPROM_WP CM4 built-in EEPROM write protection
6 GPIO 26Pin GPIO, the same as Raspberry Pi 2B
7 MicroSD Storage card slot, invalid when using eMMC version CM4
8 ETH0 RJ45 Gigabit Ethernet port, connect to CM4 built-in network card
9 ETH1 RJ45 Gigabit Ethernet port, connect to PCIe network card

Tutorial

Requirements

System

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

SD Card Installation

Suitable for Compute Module 4 Lite without eMMC version.

  1. Requirements
  1. Use 7-Zip to decompress the system mirror compression package, get the img image file
  2. Use rufus to open the decompressed img file, and select the corresponding drive letter of the card reader to write.

eMMC Installation

Suitable for Compute Module 4 with eMMC version.

  1. Requirements

  2. Enter Boot Mode

    1. Toggle RPiBOOT on the CM4 router to side 1, and disable eMMC startup
    2. Use the USB-C data cable to connect the computer and the USB data port of the CM4 router, and then connect the CM4 router to the power supply
    3. Install and run the rpiboot tool on the computer, you can see that eMMC has been displayed as a disk
  3. Use 7-Zip to decompress the system mirror compression package, get the img image file

  4. Use rufus to open the decompressed img file, and select the corresponding drive letter of the card reader to write.

OpenWRT Basic Settings

  1. Install Compute Module 4 and insert the microSD card (eMMC version does not require an SD card)

  2. Connect the network cable as shown below.

    • ETH0 to Internet
    • ETH1 to PC or LAN switch
    • A. Only one PC
    • B. Connect more devices by ethernet switch
    • ETH0 and ETH1 are defined by software. It is easy to change them function by edit setting, and export more port by VLAN.
  3. Power on the CM4 router, wait for the startup is complete, you can access the 192.168.1.1 through the computer to enter the management interface.

    • default account: root
    • default password: None
  4. At this point, you should be able to connect to the Internet. If you need to perform advanced network settings, or install more features, please refer to OpenWRT official documentation.

Other Settings

CM4 turns off the USB controller by default to reduce power consumption. To enable USB, you need to manually edit the config file.

The tutorial is to use vi editing in the OpenWRT system. If you use CM4 Lite with a removable SD card, you can also insert the SD card into your computer and use Notepad to modify the content. The modified content is the same.

  1. Edit the config.txt file
root@OpenWrt:~# vi /boot/config.txt
  1. Press a to enter edit mode.

  2. Add dtoverlay=dwc2,dr_mode=host at the end.

    ################################################################################
    # Bootloader configuration - config.txt
    ################################################################################

    ################################################################################
    # For overclocking and various other settings, see:
    # https://www.raspberrypi.org/documentation/configuration/config-txt/README.md
    ################################################################################

    # OpenWrt config
    include distroconfig.txt

    [all]
    # Place your custom settings here.
    dtoverlay=dwc2,dr_mode=host
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    ~
    I /boot/config.txt 15/15 100%
  1. Press Esc to exit the edit mode, the lower left corner I becomes -.

  2. Type :wq and press Enter, save and exit.

  3. After restarting, the USB interface can be used.

Adjust OpenWRT root Partition

In order to be compatible with small-capacity devices, OpenWRT generally only allocates a limited space for the root partition. If you need to use more space to install software or store files, you need to manually adjust the size of the root partition.

  1. Prepare a computer or virtual machine with any Linux distribution

    • CM4 Lite: Take out the microSD, connect to the computer by a card reader
    • CM4: Disable eMMC, enter boot mode, and drive as hard disk through rpiboot
  2. Install fdisk and resize2fs

  3. Use fdisk to view the partition table

    DFRobot@Ubuntu:~$ sudo fdisk /dev/sdb

    Welcome to fdisk (util-linux 2.32).                                                                                                                                                                                                                                                                                                                  
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.


    Command (m for help): p
    Disk /dev/sdb: 7.2 GiB, 7751073792 bytes, 15138816 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes 
    Disklabel type: dos
    Disk identifier: 0xcbad8a62

    Device     Boot Start    End Sectors  Size Id Type
    /dev/sdb1  *      512  33279   32768   16M 83 Linux
    /dev/sdb2       33792 558079  524288  256M 83 Linux
  1. Write down the starting sector address of /dev/sdb2 (root partition).

  2. Use fdisk to delete partition 2 (which is sdb2), do not write the changes to the disk.

    Command (m for help): d
    Partition number (1,2, default 2): 

    Partition 2 has been deleted.
  1. Use fdisk to create a new partition 2, choose/type the starting sector address you wrote down earlier (as by default it will try to place it somewhere else), and leave the default end sector address (this means the partition will now use all available space).

  2. Write the partition table changes to disk. It may complain about partition signatures already present, write n to proceed without removing the partition signature.

    Command (m for help): n
    Partition type
       p   primary (1 primary, 0 extended, 3 free)
       e   extended (container for logical partitions)
    Select (default p): p
    Partition number (2-4, default 2): 2
    First sector (33280-15138815, default 34816): 33792
    Last sector, +sectors or +size{K,M,G,T,P} (33792-15138815, default 15138815): 

    Created a new partition 2 of type 'Linux' and of size 7.2 GiB.
    Partition #2 contains a ext4 signature.

    Do you want to remove the signature? [Y]es/[N]o: n

    Command (m for help): w

    The partition table has been altered.
    Syncing disks.
  1. Write resize2fs /dev/sdb2 to enlarge the actual file system to fill the larger partition size.
    DFRobot@Ubuntu:~$ sudo resize2fs /dev/sdb2

Use serial terminal to debug CM4 router

If the settings are wrong, the CM4 router cannot be accessed through the network, you can use the serial port terminal to debug the CM4 router.

  1. Requirements

  2. Insert the SD card into the computer and edit config.txt, use Notepad to edit, add a line enable_uart=1 at the end.

  3. Connect USB2TTL to CM4 Router Board.

    • USB Serial TX - GPIO 10
    • USB Serial RX - GPIO 8
    • USB Serial GND - Ground
    • ⚠: Do not connect to 5V, it may cause hardware damage.

GPIO Connection

  1. Install and open PuTTY, set as shown and open the terminal

    • Connection Type: Serial
    • Serial line: Depend on your computer
    • Speed: 115200
  2. Power on the CM4 router. After a while, the serial port terminal will start to scroll the system log. After the startup is complete, press Enter to enter the BasyBox terminal.

    BusyBox v1.31.1 () built-in shell (ash)

      _______                     ________        __
     |       |.-----.-----.-----.|  |  |  |.----.|  |_
     |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
     |_______||   __|_____|__|__||________||__|  |____|
              |__| W I R E L E S S   F R E E D O M
     -----------------------------------------------------
     OpenWrt SNAPSHOT, r15224-afd4bf08bc
     -----------------------------------------------------

    root@OpenWrt:~# 
  1. If there is no display on the serial port terminal, please check whether the config.txt setting or the system mirror is damaged.

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents

DFshopping_car1.png Get Compute Model 4 IoT Router Broad Mini from DFRobot Store or DFRobot Distributor.