geerlingguy / raspberry-pi-pcie-devices

Raspberry Pi PCI Express device compatibility database
http://pipci.jeffgeerling.com
GNU General Public License v3.0
1.56k stars 142 forks source link

Test DFRobot CM4 Routerboard #114

Closed geerlingguy closed 3 years ago

geerlingguy commented 3 years ago

See: https://www.dfrobot.com/product-2242.html

DSC00555

More detail to come.

geerlingguy commented 2 years ago

lol, love the conversation the past few hours, and happy to see a driver make it into the default build :)

nexxusty commented 2 years ago

lol, love the conversation the past few hours, and happy to see a driver make it into the default build :)

Jeff brother, I want to thank you for the video you made on the Seed board, and the DFRobot board.

Your video was the reason why I bought the DFRobot version. Very clear and concise. I appreciate it man.

Good news about the 8169 module hmm!? Happy day! LOL.

jimbiggins commented 2 years ago

I'm having an issue with the fact the RTL8111 chipset (eth1) on the DF Robot Router Board will not provide a valid MAC address.

Why is there no valid MAC being returned from the RTL8111 Ethernet Transceiver? Any other ways to permanently change the MAC in a case where the driver is assigning a random MAC on boot up?

I'll answer my own question. I got this response from DFRobot Tech Support: "The chip supplier has not responded to how to manually burn for hardware Mac address." I assume that means they don't know how to burn a MAC into the chip because Realtek hasn't responded with instructions on how to do it. Seems odd.

So I came up with a software workaround that fixes it by reading the "real" MAC on eth0, incrementing it by 1, and assigns it to eth1 using macchanger.

First install macchanger: sudo apt install macchanger -y

Then create this script. I put it in /etc. sudo nano /etc/changemac changemac script:

#!/bin/sh -e
# changemac

#Read the MAC of eth0, increment by 1, assign to eth1:
read realmac </sys/class/net/eth0/address
mac=$(echo $realmac | tr -d ':')
macadd=$(( 0x$mac + 1 ))
macnew=$(printf "%012x" $macadd | sed 's/../&:/g;s/:$//')
sudo macchanger --mac=$macnew eth1

exit 0

Make it executable: sudo chmod +x /etc/changemac

Create a startup service to run it: sudo nano /etc/systemd/system/changemac@.service

Paste the following:

[Unit]
Description=changes mac for %I
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

[Service]
Type=oneshot
ExecStart=/etc/changemac
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Enable the startup service: sudo systemctl enable changemac@eth1.service

Reboot and use ip a to verify MAC of eth1 is one greater than MAC of eth0.

asquelt commented 2 years ago

does anybody have stl with case for this board? it seems producer has removed it from their page, there is only step file with model (body fused with case) available now.

geerlingguy commented 2 years ago

@asquelt - They've never had STL files available, only STEP files, where you have to go in and extract all the component bits of the case into your own STL file exports :(

asquelt commented 2 years ago

@geerlingguy can you recommend a tool to do that? I've opened this step file in FreeCAD and it appears to be fused into one shape. no ungroup button :)

geerlingguy commented 2 years ago

@asquelt - I used Fusion 360.

unquote7083 commented 2 years ago

@asquelt I don't know if there's a better way or not, but in the FreeCAD Part workbench, there is an "Explode compound" option which breaks the pieces into their components.

@geerlingguy are you able to upload the STL files that you made? I know they weren't perfect, but would still be useful. Thanks!

geerlingguy commented 2 years ago

@slmb3 - I put the files up on Thingiverse here: https://www.thingiverse.com/thing:5100208

mzeesimba commented 2 years ago

Well it works . . now to extend, I'd like to shoehorn either pFsense or ipFire (or suggest another Firewall with GUI that's FOSS . . ? ) on to this thing. My first attempt with ipfire, I must have fumble fingered the power connections and fried the Onboard storage . :( Rather bad news as replacement for my board looks to be 6~9 months away??? geeze .. got a 2GB Lite CM4 as a replacement today so ... yay. Can move forward.. it still took 2 months tho.

with two full speed Eth Interfaces, I can maybe move back to a physical firewall and put that the router and the piehole on a UPS .. ;) .

Curious if you ever got pfSense to work on this board? I'd like to switch to it based on form factor so wondering if anyone has actually proved it out on pfSense?

sdwilsh commented 2 years ago

In the video, Jeff had mentioned VyOS testing would be happening soon (and showed runborg/vyos-pi-builder in the video), although also alluded to it not being a usable state yet. It seems like runborg/vyos-pi-builder might be good to use now. Has anybody tried to use VyOS with one of these yet?

moeller0 commented 2 years ago

$ sudo time hping 10.0.100.10 -q -d 36 -i u15 --icmp | tail -n10 ^C --- 10.0.100.10 hping statistic --- 177372 packets tramitted, 174405 packets received, 2% packet loss round-trip min/avg/max = 0.2/0.3/9.2 ms Command terminated abnormally. 4.60 real 0.99 user 2.27 sys

Result:

75,828 pps

Mmmh, silly question, these 64Byte frames will take up effectively 64+38 bytes (measured as byte equivalents on the wire), so 1000^3/((64+38)*8) = 1225490.196 pps is the theoretical maximum. And under saturation each of these should take (1 * 1000^2 micro/unity) / (1000^3 b/sec /((64B+38B)*8b/B)) = 0.816 microseconds each on the wire. Now you requested 15us inter packet gap for a theoretical maximum of 1000^2/15 = 66666.667 pps. IWell possible that I am totally wrong here, but IMHO this test really only shows that hping is not good at keeping time ;)

Also would 177372 packets transmitted in 4.6 seconds wallc clock time not indicate 177372/4.6 = 38559.130 pps? Multiplying by two is only relevant if you compare with bidirectional aggregate throughput, no? Or put differently given the transmitted and received counters the PPS can be calculated per direction. Again, I might be terminally confused and all of this makes tons of sense.

geerlingguy commented 2 years ago

I just wanted to point out that @martin-niklasson posted a nice Gist with instructions for making an up-to-date OpenWRT image for this board: https://gist.github.com/martin-niklasson/6912a7e5ba49b92801d54766f1d7277a

ghost commented 2 years ago

@sdwilsh I compiled runborg/vyos-pi-builder on my M1 Macbook just to see what was in the image and it didn't look like the r8169 kernel module was included.

@mzeesimba pfSense CE is only available for AMD64 and I don't know if anyone has gotten it to work on any ARM device. Netgate has no plans on porting it to any ARM hardware other than their own either. OPNsense had a few ARM builds in the past but seems like the effort has since been abandoned. Vanilla FreeBSD should work out of the box with RTL8111 driver included and would make a great firewall, you just gotta configure pf.conf yourself.

blizzardengle commented 2 years ago

Background

I am thinking of using this as an OpenWRT Router + Firewall but I'm concerned about constant logging wearing out the SD card. I found that I could disable logging altogether (https://forum.openwrt.org/t/how-to-disable-all-logs-on-lede/8001) but I had two other ideas:

  1. Configure logging to save on a USB device attached to the USB 2.0 port.
  2. Add and boot from an NVMe hat of some kind to run OpenWRT from, this way logs are being written to the NVMe.

Question

Does anyone know if option 2 is possible with the DFRobot CM4 Routerboard? Do you have any other suggestions/ input?

danluckner commented 2 years ago

Hi Guys.

I wanted to share a little bit of my findings using the DFRobot router with a CM4.

First of all: I was able to purchase a CM4102032 (Wifi, eMMC 32GB, 2GB of RAM) from seeed studio website (yes, they have it in their stock in China).

Then, I wanted to use the eMMC storage instead of a SD card. I was able to use it and change its partition size so OpenWRT use all space available.

How I achieved this was:

Here comes the tricky part:

Also, I bought DFRobot's case and using the vcgencmd measure_temp command, I'm seeing 54.5 °C of temperature. Not sure if that's high or low for the CM4, but I'm getting all the internet speed I have and with AdGuardHome to prevent ads on some websites.

You can also install luci-app-statics and collectd services with its variations (collectd-mod-thermal for instance) to monitor the temps, and etc.

I hope that helps some of the folks wondering in adventure yourself with this thing.

Best Regards to all.

nexxusty commented 2 years ago

Background

I am thinking of using this as an OpenWRT Router + Firewall but I'm concerned about constant logging wearing out the SD card. I found that I could disable logging altogether (https://forum.openwrt.org/t/how-to-disable-all-logs-on-lede/8001) but I had two other ideas:

  1. Configure logging to save on a USB device attached to the USB 2.0 port.
  2. Add and boot from an NVMe hat of some kind to run OpenWRT from, this way logs are being written to the NVMe.

Question

Does anyone know if option 2 is possible with the DFRobot CM4 Routerboard? Do you have any other suggestions/ input?

I do. Stop being ridiculous. SD Cards are incredibly cheap. This is not 2005. Buy a SanDisk high endurance if this is an actual issue for you.

Furthermore, eMMC is the way to go. Not SD Card. With eMMC, you can wear out the first quarter of the flash and move on to the second quarter and so on. OpenWRT does not use a lot of space. 2GB is fine. Your 8gb flash could last 4x longer if you use it properly.

blizzardengle commented 2 years ago

Stop being ridiculous.

A firewall router combo is a critical network appliance and I want to be proactive in reducing wear on the system. I would hate to be traveling for example and be unable to VPN into my home network because the SD card died from all the firewall logging.

Buy a SanDisk high endurance if this is an actual issue for you.

This is a great idea. Looking up the datasheets for the High Endurance line shows for the 256gb @ ~$40 I could expect probably up to 1-2 years of logging before needing to replace the card to prevent burn out. I'm still concerned it would die at an inopportune time though and the write speed is capped at 40mbs. Not terrible, but it could at a bottle neck to the system/ network if I log large things, like deep packet inspection (DPI).

SD Cards are incredibly cheap.

I don't disagree, but the overall cost of building a firewall on a DFRobot CM4 Routerboard adds up when everything is accounted for. The 256gb SD Card cost roughly the same as the board itself.

OpenWRT does not use a lot of space

Yes, but this will be a firewall as well. I have a lot of additional packages to install and plan to use the entire file system space to accommodate this comfortably.


I think going the NVMe route and booting from an NVMe hat of some kind is the best solution for my use case. It's robust, I can log directly to the same drive as OpenWRT, and I can clone the NVMe if I ever wanted to quickly replace the drive with a new one after several years of service. I just don't know if the DFRobot CM4 Routerboard supports/ plays well with any NVMe hats and would hate to invest what little money I have in trying a bunch out on my own.

Since the DFRobot CM4 Routerboard build would have cost me near ~$200 I decided to get an old HP Elite Desktop 600 or 800 G2 from Ebay for $180. buy an Awow AK34 for < $200; it was on sale recently. Way more processing power and memory than OpenWRT needs, but prefect (and more ideal) for a firewall build.

nexxusty commented 2 years ago

Stop being ridiculous.

A firewall router combo is a critical network appliance and I want to be proactive in reducing wear on the system. I would hate to be traveling for example and be unable to VPN into my home network because the SD card died from all the firewall logging. DF

Buy a SanDisk high endurance if this is an actual issue for you.

This is a great idea. Looking up the datasheets for the High Endurance line shows for the 256gb @ ~$40 I could expect probably up to 1-2 years of logging before needing to replace the card to prevent burn out. I'm still concerned it would die at an inopportune time though and the write speed is capped at 40mbs. Not terrible, but it could at a bottle neck to the system/ network if I log large things, like deep packet inspection (DPI).

SD Cards are incredibly cheap.

I don't disagree, but the overall cost of building a firewall on a DFRobot CM4 Routerboard adds up when everything is accounted for. The 256gb SD Card cost roughly the same as the board itself.

OpenWRT does not use a lot of space

Yes, but this will be a firewall as well. I have a lot of additional packages to install and plan to use the entire file system space to accommodate this comfortably.

I think going the NVMe route and booting from an NVMe hat of some kind is the best solution for my use case. It's robust, I can log directly to the same drive as OpenWRT, and I can clone the NVMe if I ever wanted to quickly replace the drive with a new one after several years of service. I just don't know if the DFRobot CM4 Routerboard supports/ plays well with any NVMe hats and would hate to invest what little money I have in trying a bunch out on my own.

Since the DFRobot CM4 Routerboard build would have cost me near ~$200 ### I decided to get an old HP Elite Desktop 600 or 800 G2 from Ebay for $180. Way more power than OpenWRT needs, but prefect for a firewall build.

Really bad decision, IMO. Will use literally 55x more wattage to accomplish the same thing, just did the math. My DF Robot router board uses 1.5w on average. CM4 with eMMC should have been your choice. My CM4 eMMC will easily last a decade running OpenWRT if I needed it to.

paulwratt commented 2 years ago

@nexxusty

Stop being rediculous

Not helpful, please dont post "opinions" like this is the future (I dont appreciate having to wade through the 250-500 word Essay replys which result from those sorts of comments, thanks all the same).

@blizzardengle

I found that I could disable logging altogether, but I had two other ideas

Did you consider using tmpfs and/or flushing the log when it get over a certain size/age? (sorry I cant remember where I saw this - StackExchange? RPi Forum?)

blizzardengle commented 2 years ago

@paulwratt tmpfs is actually a great idea! I had not thought of that. I was more preoccupied with all the parts and cost adding up for the firewall build. Like I said in my previous post I decided to go a different route:

If anyone wants to build a firewall on the DFRobot CM4 Routerboard still without adding a hat for NVMe (which I still don't know if it would work), a SanDisk High Endurance using tmpfs would work perfectly! You may have to write your own scripts to manage tmpfs though.

EDIT: I originally said theoretically at the end here because I personally have not tested all of this, but I agree with @paulwratt, it should all be very possible to do.

paulwratt commented 2 years ago

If they are "off the shelf" log files, then I believe there is a way to move them at rotatation time.

theoretically

Nah, it works, really well on cheap "xrappy" sd-cards and usb thumb drives (according to some old RPi Forum I read in about 2015).

phitur commented 2 years ago

@paulwratt

Did you consider using tmpfs and/or flushing the log when it get over a certain size/age?

I could be wrong, but doesn't tmpfs use ram? And if it uses ram, then wouldn't that prevent the logs from being persistent on a power loss? All the logs would go away each time the unit is rebooted. If that's ok for the use case, then it would be a great option. However, if logs are needed across power cycles, then it might not be the best approach. He could be back to writing on the card.

@blizzardengle I believe SanDisk's 'max endurance' card has the highest endurance rating if you wanted more write cycles. If you got the 256GB version, it would last a very long time if only capturing log files, depending on how verbose your logs are. It's rated for 6x more write cycles than the 'high endurance' card.

Another great option could be a combination of eMMC and an SD card. You would keep your OS memory space relatively small on the eMMC and it would last forever if you wrote all the logs and any other files outside of the system files to the SD card. Win-win!

paulwratt commented 2 years ago

tmpfs and/or flushing

This implies "write to permanant location". This technique has been used on RaspberryPi's for 10 years by various people to extend the life of an SD-Card, so its well tested.

For example, the logs on my Alpine installation are rotated at 200K, so using tmpfs (even if the log is full) only uses 200K of memory. When the server is getting hammered, it will rotate the logs once every 3 hours, but on average its about once every 3 days.

To extend the life of any SD-Card, place a linux swap partition on it. You dont have to use it as swap space, but that space is then guarenteed for the "wear leveling logic", no matter the OS used (and because its a linux swap partition, Windows, especially, wont use it).

evgeni commented 2 years ago

Out of curiosity, did anyone measure NAT performance of this setup? I'm getting ~760MBit/s on a barebones FreeBSD 13 with iperf3. Wondered if anyone had Linux numbers for comparison ;)

punnypenguins commented 2 years ago

Live site page for this board: https://pipci.jeffgeerling.com/boards_cm/dfrobot-cm4-iot-router.html

satmandu commented 2 years ago

I've been using OpenWRT snapshots with this hardware for the last several months with no problems.

Set eth0 to be WAN, eth1 to be LAN, and run a script at boot to make sure that the kernel modules for the eth1 interface get loaded at first boot after snapshot install thus. I also use hurricane electric's setup for IPv6, so your setup might differ.

#!/bin/sh                                                                                                                                                                              
# Put your custom commands here that should be executed once                                                                                                                           
# the system init finished. By default this file does nothing.                                                                                                                                                                                                                             
opkg update || (sleep 30 ; opkg update )                                                                                                                                               
opkg install curl libcurl luci-app-acme acme luci-theme-openwrt-2020 6in4 jq                                                                                                           
opkg install kmod-r8169 && opkg install kmod-usb-dwc2 kmod-usb-net-rndis usb-modeswitch kmod-nls-base kmod-usb-core kmod-usb-net kmod-usb-net-cdc-ether kmod-usb2

uci set network.wan6=interface                                                                                
uci set network.wan6.proto=6in4        
# Tunnelbroker info is used for this.                                                                                                                                             
# uci set network.wan6.peeraddr=                                                                                                                                      
# uci set network.wan6.ip6addr=                                                                                                                               
# uci set network.wan6.ip6prefix=                                                                                                                                
# uci set network.wan6.tunnelid=                                                                                                                                               
uci commit network                                                                                                                                                                    

uci set firewall.@zone[1].network='wan wan6'                                                                                                                                          
uci commit firewall   

if [ -e /etc/backup/installed_packages.txt ]; then                                                                                                                                    
  echo $opkginstalled | cut -f 1 -d ' ' | sort -u > /tmp/currentpkg && \                                                                                                              
    cat /etc/backup/installed_packages.txt | cut -f 1 | \                                                                                                                             
    sort -u > /tmp/oldpkg && grep -v -F -x -f /tmp/currentpkg /tmp/oldpkg > /tmp/inst                                                                                                 
   if [ -s "/tmp/inst" ]; then                                                                                                                                                        
    opkg install $(cat /tmp/inst | sort -u) && \                                                                                                                                      
      rm /tmp/currentpkg /tmp/oldpkg /tmp/inst /etc/backup/installed_packages.txt                                                                                                     
    echo "installs done"                                                                                                                                                              
   else                                                                                                                                                                               
    echo "no installs needed" && \                                                                                                                                                    
      rm /tmp/currentpkg /tmp/oldpkg /tmp/inst /etc/backup/installed_packages.txt                                                                                                     
   fi                                                                                                                                                                                 
fi                                                                                                                                                                                    

opkg install luci-app-uhttpd luci-ssl liblua lua libuci-lua libubus libubus-lua uhttpd rpcd \
  opkg luci-base liblucihttp liblucihttp-lua luci-lib-ip luci-lib-nixio \
  luci-theme-bootstrap luci-mod-admin-full luci-lib-jsonc luci-mod-status \                                                                                                           
  luci-mod-system luci-mod-network luci-proto-ipv6 luci-theme-openwrt luci-app-wireguard \
  luci-proto-wireguard rpcd-mod-luci luci-app-firewall luci-app-opkg luci-compat \
  libiwinfo libiwinfo-lua irqbalance htop luci-theme-bootstrap diffutils bind-dig 6in4 haproxy luci-app-ttyd \
  nmap bash kmod-usb-net-rndis usb-modeswitch luci-app-mwan3 tmux collectd collectd-mod-thermal \
  luci-app-statistics                                                                                                                   
ip link set 6in4-wan6 type sit local $(ip -o -4  -j address show dev eth0 | jq -r '.[].addr_info[].local') 
/etc/init.d/collectd restart
masip85 commented 2 years ago

Is it possible to install rpi Ubuntu Server to this board?

muse-sisay commented 2 years ago

Hey @geerlingguy Sorry if this is wrong place to ask. I don’t know where else to ask.

I have had this board my sitting in drawer for over 9 months due lack of CM4( yea! chip shortage). Luckily was able to order CM4, finally, last week. So dusted it off and followed the guide on DFRobot's wiki page to flash OpenWRT 21.02.3. When I power on the Pi I am getting the following error. I have the CM4 attached to a PiTray mini.

Thinking it was related to eeprom I followed your guide to update it. (The picture is after I updated eeprom).

The latest Raspbian OS works fine though. In the picture above the firmware is dated as Feb 16 2021. Could that be the issue?

satmandu commented 2 years ago

Looks like you need newer boot firmware files which may not come with that version of OpenWRT.

The snapshot firmware at https://downloads.openwrt.org/snapshots/targets/bcm27xx/bcm2711/ works great on this board for me, but FYI you should be aware of the limitations of using snapshot firmware (for instance luci doesn't come installed.)

satmandu commented 2 years ago

Alternately copy the current .elf and .dat files from https://github.com/raspberrypi/rpi-firmware to the FAT32 boot partition on your boot disk.

muse-sisay commented 2 years ago

@satmandu After replacing start4.elf, start4cd.elf, start4x.elf, fixup4.elf, fixup4cd.elf and fixup4x.elf with the current copy from the GitHub page the pi is stuck at this

Flashing openwrt-bcm27xx-bcm2711-rpi-4-squashfs-factory.img.gz also displays the same output.

Looks like you need newer boot firmware files which may not come with that version of OpenWRT.

I was getting the same error with the OpenWRT I complied myself. It would say start4.elf is not compatible.

satmandu commented 2 years ago

How are you getting a graphical display on the routerboard, which has no graphical output?

muse-sisay commented 2 years ago

I am using PiTray Mini board. I am using it since nothing is displaying over URAT on the router board. Though I can access the serial console over URAT on Raspian OS.

satmandu commented 2 years ago

@muse-sisay This issue is for the DFRobot CM4 Routerboard... You should open a different issue for the board you have.

muse-sisay commented 2 years ago

@satmandu Sorry I mentioned, on my first post, that I was using the PiTray board for debugging. I know this issue if for DFRobot's CM4 Routerboard.

There is no way to get output(as far as I know) from DFRobot's router board; unless you connect using the GPIO pins. So I am using PiTray for debugging.

Raspian OS works fine on both boards.

Would using PiTray stop it from booting?

muse-sisay commented 2 years ago

@satmandu This is embarrassing...It is working over UART on the DFRobot board. I have snapshot firmware flashed on the CM4.

Thank you for the great help.

EDIT: I am able to get DFRobot image working by replacing .elf and .dat files from https://github.com/raspberrypi/rpi-firmware

bit2016 commented 2 years ago

Hi all,

I'm susing the DFRobot module. Quick question: my eth1 yellow LED (NIC port) is not working. Is this a known issue? is this a HW failture? (otherwise the device is fully working)

florincosta commented 1 year ago

Hi all,

I'm susing the DFRobot module. Quick question: my eth1 yellow LED (NIC port) is not working. Is this a known issue? is this a HW failture? (otherwise the device is fully working)

Hi,

It's not a failure, it's a feature :), not kidding, the RTL8111h used by the ETH1 is not configured properly for driving the board LEDs. I'm also developing a Dual ETH CM4 board and banged my head on this problem, I was expecting it to work out of the box and it does not. The RTL8111h has 3 pins that can be used for driving LEDs and they can be configured in all sorts of ways. I can provide more info on the topic if required.

jakobjs commented 1 year ago

⚡ Update november 2022:

To get CM4 with the Router Board working with the latest 22.03.x release you have to generate your own image and flash the eMMC storage with that. The image on the dfrobot website has not been updated to 22.03.

  1. Open https://firmware-selector.openwrt.org/
  2. Select the type: "Raspberry Pi 4B/400/4CM (64bit)"
  3. Expand "Customize installed packages"
  4. Add the following to the list of packages, space seperated: kmod-r8169 kmod-usb-dwc2 bcm27xx-userland
  5. Click "Request build" and then download your ext4 image and flash the eMMC with it

The drivers added are listed here on the Wiki: https://wiki.dfrobot.com/Compute_Module_4_IoT_Router_Board_Mini_SKU_DFR0767

comique-asending commented 1 year ago

⚡ Update november 2022:

To get CM4 with the Router Board working with the latest 22.03.x release you have to generate your own image and flash the eMMC storage with that. The image on the dfrobot website has not been updated to 22.03.

1. Open https://firmware-selector.openwrt.org/

2. Select the type: "Raspberry Pi 4B/400/4CM (64bit)"

3. Expand "Customize installed packages"

4. Add the following to the list of packages, space seperated: `kmod-r8169 kmod-usb-dwc2 bcm27xx-userland`

5. Click "Request build" and then download your ext4 image and flash the eMMC with it

The drivers added are listed here on the Wiki: https://wiki.dfrobot.com/Compute_Module_4_IoT_Router_Board_Mini_SKU_DFR0767

Hey there, I've had the issue that was talked about previously in this thread, where to make the 21.02.3 DFRobot image work I needed to swap the .dat and .elf files with the ones from: https://github.com/raspberrypi/rpi-firmware

Since I'm already building the router, figured I'd also build the software so I've since tried compiling 22.03.2 myself, and also this method you suggested... but am unable to have my board boot properly wether I leave the .dat and .elf files alone, or replace them. I plug into ETH1 and the activity light blinks a few times and nothing. I tried multiple builds of 22.03.2 and all the same issue, I'm certain the necessary packages are included.

Do you have any tips?

Thanks

satmandu commented 1 year ago

I have been using the openwrt snapshot images with my CM4 routerboard.

I plug WAN into ETH0. I plug LAN into ETH1.

This works best because the default kernel image modules support the ethernet card which shows up as ETH0, so when the image first boots, it gets a wan address on ETH0, and you can then run opkg update and get the kernel module needed to support the other ethernet interface!

After you write the image to your routerboard (update the EEPROM while you're at it too) you need to modify your root partition thus: Add a file called /root/update.sh (Make sure it is executable with: chmod +x update.sh)

#!/bin/sh
# Put your custom commands here that should be executed once
# the system init is finished.
opkg update || (sleep 30 ; opkg update )
if [[ $(uname -m) == 'aarch64' ]]; then
  # This gives you the other ethernet interface  on the dfrobot CM4 routerboard.
  opkg install kmod-r8169 kmod-usb-dwc2 bcm27xx-userland
fi
# Give yourself luci & useful utilities
opkg install luci-app-uhttpd luci-ssl liblua lua libuci-lua libubus libubus-lua uhttpd rpcd \
  opkg luci-base liblucihttp liblucihttp-lua luci-lib-ip luci-lib-nixio \
  luci-theme-bootstrap luci-mod-admin-full luci-lib-jsonc luci-mod-status \
  luci-mod-system luci-mod-network luci-proto-ipv6 luci-theme-openwrt luci-app-wireguard \
  luci-proto-wireguard rpcd-mod-luci luci-app-firewall luci-app-opkg luci-compat \
  libiwinfo libiwinfo-lua irqbalance htop luci-theme-bootstrap bind-dig 6in4  luci-app-ttyd \
  bash usb-modeswitch tmux  luci-app-statistics

Now make sure that this is run at boot by editing /etc/rc.local:

# Put your custom commands here that should be executed once
# the system init is finished. By default, this file does nothing.
/root/update.sh 
# Turn off the green LED on the dfrobot CM4 routerboard.
# echo 0 > /sys/class/leds/led0/brightness
exit 0

When you boot it up for the first time, you should be able to ssh root@192.168.0.1 and make further modifications, and set your root password with passwd root so you can also open the web admin page at http://192.168.0.1 .

comique-asending commented 1 year ago

⚡ Update november 2022: To get CM4 with the Router Board working with the latest 22.03.x release you have to generate your own image and flash the eMMC storage with that. The image on the dfrobot website has not been updated to 22.03.

1. Open https://firmware-selector.openwrt.org/

2. Select the type: "Raspberry Pi 4B/400/4CM (64bit)"

3. Expand "Customize installed packages"

4. Add the following to the list of packages, space seperated: `kmod-r8169 kmod-usb-dwc2 bcm27xx-userland`

5. Click "Request build" and then download your ext4 image and flash the eMMC with it

The drivers added are listed here on the Wiki: https://wiki.dfrobot.com/Compute_Module_4_IoT_Router_Board_Mini_SKU_DFR0767

Hey there, I've had the issue that was talked about previously in this thread, where to make the 21.02.3 DFRobot image work I needed to swap the .dat and .elf files with the ones from: https://github.com/raspberrypi/rpi-firmware

Since I'm already building the router, figured I'd also build the software so I've since tried compiling 22.03.2 myself, and also this method you suggested... but am unable to have my board boot properly wether I leave the .dat and .elf files alone, or replace them. I plug into ETH1 and the activity light blinks a few times and nothing. I tried multiple builds of 22.03.2 and all the same issue, I'm certain the necessary packages are included.

Do you have any tips?

Thanks

UPDATE: I figured out my error... needed to add custom config files during compilation (network, dhcp) since it seems WAN and LAN weren't being allocated properly. I still swapped the .dat and .elf files for the ones at https://github.com/raspberrypi/rpi-firmware

Custom config I used was same as DFRobot release.

Now device boots flawlessly on v22.03.2

lawlap commented 1 year ago

@satmandu are you able to clarify this ("and you can then run opkg update and get the kernel module needed to support the other ethernet interface!") when working from a Windows environment? My build using the DFRobot image as well as the update suggested by @jakobjs still seems to only leave ETH0 activated (no activity on ETH1).

satmandu commented 1 year ago

The current openwrt snapshot packages support both interfaces on the DFrobot routerboard out of the box.

You could try burning the ext4 image to it, boot it, and then do a ssh root@192.168.0.1 to continue setup.

Do you need a script to run to setup luci after you ssh in?

satmandu commented 1 year ago

Snapshot packages are here:

https://downloads.openwrt.org/snapshots/targets/bcm27xx/bcm2711/

This is what you write to your SD card or the internal flash depending upon which CM4 you have:

https://downloads.openwrt.org/snapshots/targets/bcm27xx/bcm2711/openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz

You can then do updates using the sys upgrade:. https://downloads.openwrt.org/snapshots/targets/bcm27xx/bcm2711/openwrt-bcm27xx-bcm2711-rpi-4-ext4-sysupgrade.img.gz

Just note that you need to run some sort of script at startup to install all of the packages the snapshots don't have after a snapshot sysupgrade install.

That's easy to do from the GUI after you install luci...

lawlap commented 1 year ago

@satmandu Hmm. Steps taken are: mount the eMMC to windows (via rpiboot); write the ext4 image (via balenaetcher); boot the Pi4... the ETH1 port blinks green roughly 7 times, then nothing. No IP address assigned. SSH via putty fails.

satmandu commented 1 year ago

Seven blinks are kernel.img not found...

Maybe try updating the eeprom too?

Also see what happens on the other Ethernet interface...

lawlap commented 1 year ago

@satmandu Hmmm. After flashing ext4 factory and the sysupgrade images you linked to, ETH0 gives my laptop an ipaddress and I can access WRT as root via ssh (using Putty: 192.168.1.1) (do these images somehow switch the ETH0 and ETH1 functions for WAN and LAN?). I'm not remembering off the top of my head how to activate ETH1 and/or the web GUI from here, but vaguely recall seeing it discussed somewhere... I'll try to hunt it down. Thanks for your feedback on this!

satmandu commented 1 year ago

I would plug eth1 into WAN and run something like this:

opkg update
opkg install luci-app-uhttpd luci-ssl liblua lua libuci-lua libubus libubus-lua uhttpd rpcd \
  opkg luci-base liblucihttp liblucihttp-lua luci-lib-ip luci-lib-nixio \
  luci-theme-bootstrap luci-mod-admin-full luci-lib-jsonc luci-mod-status \
  luci-mod-system luci-mod-network luci-proto-ipv6 luci-theme-openwrt luci-app-wireguard \
  luci-proto-wireguard rpcd-mod-luci luci-app-firewall luci-app-opkg luci-compat \
 luci-theme-bootstrap