jrrk
Posts: 1
Joined: Fri Apr 16, 2021 12:51 pm

Getting Started with the Compute Module 4

Fri Apr 16, 2021 1:08 pm

The RPI is meant to be simple to use right ? I did not find it so when I purchased a compute module-4 and I/O board. First of all the SSD slot is inactive (which I was warned about), and the eMMC memory was blank, but the instructions for flashing that were quite good and clear.

But looking at the documentation in more detail (only after it did not work, naturally) I find that:

1. There is no mention of UARTs being brought out
2. The USB keyboard/mouse is disabled by default (to save power!)
3. The sshd server is disabled by default (for security)

All is very secure when you cannot connect at all by any method. Then I hit on the idea of mounting the eMMC disk on Linux (it cannot be easily done on Windows), and modifying the config to enable the USB. This then allows the keyboard to work, which then enables raspi-config and everything else falls out. Each time you go round the houses the eMMC enable link has to be toggled.

Is it just me getting old, or would it not be simpler to supply a disk image that enables USB by default, for the benefit of people who don't have a PhD in Computer Science ?

stuartclark
Posts: 77
Joined: Wed Nov 07, 2012 12:41 pm

Re: Getting Started with the Compute Module 4

Sat Apr 17, 2021 3:18 pm

The Compute Module is designed for industry use/more advanced hobbyists rather than being "simple" - the normal Pi & Pi400 are really for the education/hobby market. The huge advantage the compute module has is that it is a blank slate - you have access to lower level features than the normal Pi (e.g. PCIe instead of USB3) as well as there being no connectors other than the board-to-board pair (allowing you to decide if you want USB, HDMI, Ethernet or not).

As a result of that it doesn't make sense to enable lots of things by default (as is done in the normal Pi) because you might not have and USB ports (so enabling USB would just waste power & confuse things). It would be expected that users would flash the eMMC (or have their own eMMC/SD card if using the lite version) and enable exactly what they need, based on the functionality on their custom base board (the CMIO for industrial users is really just an example of what is possible, with the expectation that products would have their own custom PCBs to do exactly what they wanted).

If you want a simple Pi that "just works" for USB, network, video, audio, etc. the best option would be the standard Pi rather than the compute module (it's cheaper too!).

aBUGSworstnightmare
Posts: 2780
Joined: Tue Jun 30, 2015 1:35 pm

Re: Getting Started with the Compute Module 4

Sat Apr 17, 2021 7:13 pm

jrrk wrote:
Fri Apr 16, 2021 1:08 pm
... First of all the SSD slot is inactive (which I was warned about), and the eMMC memory was blank ...
But looking at the documentation in more detail (only after it did not work, naturally) I find that:

1. There is no mention of UARTs being brought out
2. The USB keyboard/mouse is disabled by default (to save power!)
3. The sshd server is disabled by default (for security)
which SSD slot are you talking about? There is none!
The CM4IO has a PCIe Gen 2 x1 socket; that's not SSD. And .. If your Compute Module has an eMMC you can't use the uSD interface!

To your 'drawbacks':
1: look at https://datasheets.raspberrypi.org/bcm2 ... herals.pdf.
The standard UART is on GPIO13/14 like with every other Pi. As you can see from table 5.3 one can enable/configure more UARTs on different GPIOs. So: where do you need/want to have them and how many? Varies from application to application.

2: as said, no every embedded product will use the USB2.0 interface of the device. That's why it got disabled by default.

3: right, disabled on the OS, so this applies to every Pi!

4: if you're uncomfortable with eMMC use a lite module + uSD to start your development!

... Quoting from the products page..
The power of Raspberry Pi 4 in a compact form factor for deeply embedded applications.

stevend
Posts: 374
Joined: Fri Oct 11, 2013 12:28 pm

Re: Getting Started with the Compute Module 4

Sun Apr 18, 2021 7:54 am

aBUGSworstnightmare wrote:
Sat Apr 17, 2021 7:13 pm
2. The USB keyboard/mouse is disabled by default (to save power!)
I think the issue with this one is that it isn't mentioned at all on what is otherwise a quite detailed page on bringing up a CM4 with EMMC (although it is, I know now, mentioned in other places - with such apparently comprehensive instructions on the rest of the process, my thoughts went initially to having either missed a step in the process, or a hardware problem).

One application for the CM4 + I/O board (which is, I believe, mentioned somewhere in the data) is as a simple alternative for an RPi4; those of us approaching it from that angle maybe have different expectations of how things should work.

I can also empathise with the OP's general point; I'm almost at the end of a project which has to "just work", and in several cases the problem wasn't the difficulty of the task, but identifying the "correct" way to set things up; I've spent hours wading through reams of cruft trying to extract the key nugget of information, which in one case came from a single forum post a couple of years ago on StackOverflow or similar, without any corroboration from else where. And I'm reasonably experienced at this sort of thing! Don't have an answer to this, unfortunately.

On the more positive side, I have learned a lot more about the lower levels of setting up a Pi, and found some potentially interesting capabilities I didn't know existed; my previous projects have mostly been about running standard software and relatively simple programs.

User avatar
Gavinmc42
Posts: 5453
Joined: Wed Aug 28, 2013 3:31 am

Re: Getting Started with the Compute Module 4

Sun Apr 18, 2021 8:28 am

My CM4 and I/O arrives tomorrow.
Been using Pi's since 2012 but this will be my 1st CM of any type.
I expect I will need to read about those jumper options.

CM's were never intended to be simple, they were for experienced embedded users.
RPT made the CM4 I/O PCB more flexible, usable and affordable for us hobbyists types.

Guess I will soon find out how easy they are to use.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

aBUGSworstnightmare
Posts: 2780
Joined: Tue Jun 30, 2015 1:35 pm

Re: Getting Started with the Compute Module 4

Sun Apr 18, 2021 11:53 am

stevend wrote:
aBUGSworstnightmare wrote:
Sat Apr 17, 2021 7:13 pm
2. The USB keyboard/mouse is disabled by default (to save power!)
I think the issue with this one is that it isn't mentioned at all on what is otherwise a quite detailed page on bringing up a CM4 with EMMC (although it is, I know now, mentioned in other places - with such apparently comprehensive instructions on the rest of the process, my thoughts went initially to having either missed a step in the process, or a hardware problem).

One application for the CM4 + I/O board (which is, I believe, mentioned somewhere in the data) is as a simple alternative for an RPi4; those of us approaching it from that angle maybe have different expectations of how things should work.

I can also empathise with the OP's general point; I'm almost at the end of a project which has to "just work", and in several cases the problem wasn't the difficulty of the task, but identifying the "correct" way to set things up; I've spent hours wading through reams of cruft trying to extract the key nugget of information, which in one case came from a single forum post a couple of years ago on StackOverflow or similar, without any corroboration from else where. And I'm reasonably experienced at this sort of thing! Don't have an answer to this, unfortunately.

On the more positive side, I have learned a lot more about the lower levels of setting up a Pi, and found some potentially interesting capabilities I didn't know existed; my previous projects have mostly been about running standard software and relatively simple programs.
page 7 of the CM4 data sheet, in a red box with red letters.
The USB interface is disabled to save power by default on the CM4 . To enable it you need to add dtoverlay=dwc2,dr_mode=host to the config.txt file
Also take note how to enable the external antenna if you want to use one with your WiFi enabled CM4.

https://www.raspberrypi.org/documentati ... tasheet.md

Yes, as the CM4 is intended for professional use (as with the CM3) there is a data sheet. And, as with other devices the user should take note on the content as it has quite some useful information and took some engineers efforts in preparing it.

aBUGSworstnightmare
Posts: 2780
Joined: Tue Jun 30, 2015 1:35 pm

Re: Getting Started with the Compute Module 4

Sun Apr 18, 2021 12:01 pm

Gavinmc42 wrote:
Sun Apr 18, 2021 8:28 am
My CM4 and I/O arrives tomorrow.
Been using Pi's since 2012 but this will be my 1st CM of any type.
I expect I will need to read about those jumper options.

CM's were never intended to be simple, they were for experienced embedded users.
RPT made the CM4 I/O PCB more flexible, usable and affordable for us hobbyists types.

Guess I will soon find out how easy they are to use.
a lite module will work as every standard Pi. Simply make the additions to config.txt for USB after flashing the OS and that's it.
Addressed quite often already, i.e. https://www.jeffgeerling.com/blog/2020/ ... r-overlays

cleverca22
Posts: 3518
Joined: Sat Aug 18, 2012 2:33 pm

Re: Getting Started with the Compute Module 4

Sun Apr 18, 2021 3:42 pm

aBUGSworstnightmare wrote:
Sun Apr 18, 2021 12:01 pm
a lite module will work as every standard Pi. Simply make the additions to config.txt for USB after flashing the OS and that's it.
Addressed quite often already, i.e. https://www.jeffgeerling.com/blog/2020/ ... r-overlays
and for the eMMC models, you can do the exact same changes to config.txt after flashing it (when using usbboot to get it into flashing mode)

User avatar
Gavinmc42
Posts: 5453
Joined: Wed Aug 28, 2013 3:31 am

Re: Getting Started with the Compute Module 4

Mon Apr 19, 2021 12:21 am

Thanks guys, these tips will come in handy.
Been using USBboot for years on Zero's so that's known to me.
Compiled it for Windows, x86 Linux and Pi's :D
I noticed some new changes in USBboot recently for CM4.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

cleverca22
Posts: 3518
Joined: Sat Aug 18, 2012 2:33 pm

Re: Getting Started with the Compute Module 4

Mon Apr 19, 2021 4:29 am

also of note, usbboot works on the rpi4 and rpi400, just like it does on the pi0!

main complication, is that those models lack an nrpiboot jumper to force it into usbboot mode, and the onboard spi flash has a higher priority

Code: Select all

[all]
BOOT_UART=1
WAKE_ON_GPIO=1
POWER_OFF_ON_HALT=0
DHCP_TIMEOUT=45000
DHCP_REQ_TIMEOUT=4000
TFTP_FILE_TIMEOUT=30000
TFTP_IP=192.168.2.15
TFTP_PREFIX=0
SD_BOOT_MAX_RETRIES=3
NET_BOOT_MAX_RETRIES=5

gpio=21=ip,pu

[gpio21=0]
BOOT_ORDER=0x3

[gpio21=1]
BOOT_ORDER=0x5241

[none]
FREEZE_VERSION=1
you can configure the BOOT_ORDER in the spi flash to support loading /boot over usbboot, like you could with a pi0
in the above example, i'm also using gpio conditionals to allow changing the BOOT_ORDER via a jumper, without having to reflash

User avatar
Gavinmc42
Posts: 5453
Joined: Wed Aug 28, 2013 3:31 am

Re: Getting Started with the Compute Module 4

Mon Apr 19, 2021 9:13 am

Got the 2GB CM4 with 8GB eMMC, not much choice, that's all they had in the lower price range;)

1st lesson, only the Lite versions without eMMC will use the uSD?
It would not boot from a uSD.
I thought the jumper would disable the eMMC and boot from uSD.

2nd lesson, USB stick booting works.

It's alive :D
Not too painful.
No idea how to flash the eMMC yet.
Not even sure what OS to put on it.
What do people use on CM4?

3rd lesson, no USB3 so no speed benefit to using a USB3 SSD.

4th? Pi4 - so using two cameras will require using the V4L2 driver?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

aBUGSworstnightmare
Posts: 2780
Joined: Tue Jun 30, 2015 1:35 pm

Re: Getting Started with the Compute Module 4

Mon Apr 19, 2021 9:35 am

Gavinmc42 wrote:
Mon Apr 19, 2021 9:13 am
Got the 2GB CM4 with 8GB eMMC, not much choice, that's all they had in the lower price range;)

1st lesson, only the Lite versions without eMMC will use the uSD?
It would not boot from a uSD.
I thought the jumper would disable the eMMC and boot from uSD.

2nd lesson, USB stick booting works.

It's alive :D
Not too painful.
No idea how to flash the eMMC yet.
Not even sure what OS to put on it.
What do people use on CM4?

3rd lesson, no USB3 so no speed benefit to using a USB3 SSD.

4th? Pi4 - so using two cameras will require using the V4L2 driver?
5th lesson : read the specs https://www.raspberrypi.org/documentati ... tasheet.md and this on flashing https://www.raspberrypi.org/documentati ... lashing.md ! Where should USB3.0 come from all of a sudden?

You can either have uSD or eMMC, if you thought it is different you should have made lesson 5 the first one.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11019
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Getting Started with the Compute Module 4

Mon Apr 19, 2021 9:49 am

Gavinmc42 wrote:
Mon Apr 19, 2021 9:13 am
4th? Pi4 - so using two cameras will require using the V4L2 driver?
No such requirement.
https://www.raspberrypi.org/documentati ... -camera.md
The supplied camera applications raspivid and raspistill have the -cs (--camselect) option to specify which camera should be used.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
Gavinmc42
Posts: 5453
Joined: Wed Aug 28, 2013 3:31 am

Re: Getting Started with the Compute Module 4

Mon Apr 19, 2021 10:20 am

he supplied camera applications raspivid and raspistill have the -cs (--camselect) option to specify which camera should be used.
Thanks for link.
Would that be 32 bit only at the moment?

Going to need some longer Pi Zero camera cables, only have short ones.
Got many standard camera cables up to 2m.

Was aware of the PCIe and USB3.
I was just pointing that out as my Pi4's and Pi400 all mostly use USB3 booting now, it's what I have been used too.
Know about those cards that plug into the PCIe slot for USB3.
But thanks for the USBboot CM4 programming link, saved me trying to find it.
You can either have uSD or eMMC, if you thought it is different you should have made lesson 5 the first one.
Reading manuals is NOT the same as experiencing things.
This is about getting started not knowing everything before getting started.

Already downloaded those manuals and datasheets.
Somewhat light on how to get started, more like "this thing has these features", not like " here is how to use the features".
But this is targeted at a different market, mostly those who have probably already used CM's and CM3's?

Anyway, it boots so I have started ;)
Now what I can use it for?
Is there a CM4 showcase page?
What do people use the CM4 for apart from Digital Display Signage?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 5453
Joined: Wed Aug 28, 2013 3:31 am

Re: Getting Started with the Compute Module 4

Mon Apr 19, 2021 11:03 am

Lesson 6 - CM4 with Rpi-imager can write PiCore to a uSD card in a SD card reader in a Pi Keyboard USB slot.

Lesson 7 - CM4 will boot from PiCore in the SD card reader. (useful for those without OS on USB stick)

Lesson 8 - Rpi-imager can write piCore to the eMMC :D

Lesson 9 - CM4 will boot PiCore from eMMC.

Lesson 10 - USB keyboard not working, circle round to OP's first post.

Anyway a 84MB PCore image won't wear out the eMMC, and it boots fast, about 10secs.

Lesson 11 - Ethernet on PiCore works, can SSH in to fix things?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 5453
Joined: Wed Aug 28, 2013 3:31 am

Re: Getting Started with the Compute Module 4

Mon Apr 19, 2021 11:50 am

Now I will have to agree with the OP, disabled USB is a pain.

Raspberry Pi OS has no problems, it seems to re enable them
PiCore does not like the config.txt change "dtover.... "
It made no difference.

So far no need to use USB boot mode :D
Yet.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

cleverca22
Posts: 3518
Joined: Sat Aug 18, 2012 2:33 pm

Re: Getting Started with the Compute Module 4

Mon Apr 19, 2021 4:18 pm

the bcm2711 has 2 internal usb controllers

the old dwc2 controller from past models, host/device capable
and a new broadcom xhci controller, host only

both are usb2.0 max, and share the same D+/D- pins

for an OS to be able to use the usb controller, it must correctly respect the device-tree the firmware passed in
any overlays your selecting with dtoverlay= must also exist in /boot/overlays!

the firmware will also force using the xhci controller if you boot from xhci

User avatar
Gavinmc42
Posts: 5453
Joined: Wed Aug 28, 2013 3:31 am

Re: Getting Started with the Compute Module 4

Tue Apr 20, 2021 3:31 am

This seems to indicate my CM4 has the newer bootloader as it did boot from a USB stick/reader with uSD.
https://www.raspberrypi.org/documentati ... _config.md

A handy boot option would be if a GPIO pin is held low on boot it boots from USB stick before eMMC.
Useful on the CM I/O board.
Will need to test BOOT_ORDER=0xf15, see it that works.

This page looks relevant.
https://www.raspberrypi.org/documentati ... teeprom.md

Starting to read the manual now ;)
The RESOURCES are intended for skilled users with suitable levels of design knowledge. Users are solely responsible for
their selection and use of the RESOURCES and any application of the products described in them.
I think I will be getting spare CM4s.
They come in a cute little box too.
A few spare ones in a drawer might get hard to find.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

cleverca22
Posts: 3518
Joined: Sat Aug 18, 2012 2:33 pm

Re: Getting Started with the Compute Module 4

Tue Apr 20, 2021 4:20 am

Gavinmc42 wrote:
Tue Apr 20, 2021 3:31 am
A handy boot option would be if a GPIO pin is held low on boot it boots from USB stick before eMMC.

Code: Select all

[clever@amd-nixos:~]$ cat apps/rpi/rpi-eeprom/firmware/beta/bootconf.txt
[all]
BOOT_UART=1
WAKE_ON_GPIO=1
POWER_OFF_ON_HALT=0
DHCP_TIMEOUT=45000
DHCP_REQ_TIMEOUT=4000
TFTP_FILE_TIMEOUT=30000
TFTP_IP=192.168.2.15
TFTP_PREFIX=0
SD_BOOT_MAX_RETRIES=3
NET_BOOT_MAX_RETRIES=5

gpio=21=ip,pu

[gpio21=0]
BOOT_ORDER=0x3

[gpio21=1]
BOOT_ORDER=0x5241

[none]
FREEZE_VERSION=1
gpio conditionals work within the bootconf.txt file in the SPI flash
so you can change anything (such as BOOT_ORDER) based on the state of a gpio pin

User avatar
Gavinmc42
Posts: 5453
Joined: Wed Aug 28, 2013 3:31 am

Re: Getting Started with the Compute Module 4

Tue Apr 20, 2021 7:32 am

gpio conditionals work within the bootconf.txt file in the SPI flash
so you can change anything (such as BOOT_ORDER) based on the state of a gpio pin
Playing catchup.
So potentially I could boot from eMMC, USB 2 connector - USB stick or uSD card in reader or NMVe?
Not including the USBboot mode or Network.

If I had a PCIe USB3 adapter card that would be default like the PC4/400?

Just connect a rotary switch to change GPIO inputs via resistors?
Hmm, that USB option could be on those that USB header for the extra 2 USBs.

Any NVMe known not to work?
They seem the fastest option?
Never used them before, prices seem to have fallen since the last time I checked.
Do they just plug into that PCIe slot?

Ok found how to read the boot order.
https://www.raspberrypi.org/documentati ... teeprom.md
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 5453
Joined: Wed Aug 28, 2013 3:31 am

Re: Getting Started with the Compute Module 4

Tue Apr 20, 2021 11:00 am

Bootloader config is f2541.

The 5 is USB A port boot, but there is no USB power, it looks like U7 has not enabled the power.
I know USB is turned off to save power but if USB MSD boot option is enabled shouldn't the power be turned on too?

What am I missing?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 5453
Joined: Wed Aug 28, 2013 3:31 am

Re: Getting Started with the Compute Module 4

Thu Apr 22, 2021 10:50 am

dtoverlay=dwc2,dr_mode=host

Checked it so many time, still no power to the USB ports on the CM I/O board.
There are the same dwc2 and cm4 overlay files in the overlay folder that Raspberry Pi OS has.
Raspberry OS must do something else that PiCore does not.

This is very strange as there was power there before when a blank eMMC booted from USB stick and ran Raspberry OS and used the Pi Keyboard and mouse.

Now have a full PiCore x11 Desktop installed via ssh remote.
Cannot use it without mouse and keyboard.

Has anyone used other OS's on CM4?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 5453
Joined: Wed Aug 28, 2013 3:31 am

Re: Getting Started with the Compute Module 4

Thu Apr 22, 2021 11:08 am

From dmesg

Code: Select all

    0.139887] usbcore: registered new interface driver usbfs
[    0.139946] usbcore: registered new interface driver hub
[    0.140017] usbcore: registered new device driver usb
[    0.140366] usb_phy_generic phy: supply vcc not found, using dummy regulator
Bit further down.

Code: Select all

usbcore: registered new interface driver r8152
[    2.363799] usbcore: registered new interface driver lan78xx
[    2.363870] usbcore: registered new interface driver smsc95xx
[    2.364414] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[    2.364700] dwc_otg: FIQ enabled
[    2.364714] dwc_otg: NAK holdoff enabled
[    2.364728] dwc_otg: FIQ split-transaction FSM enabled
[    2.364746] Module dwc_common_port init
[    2.365233] usbcore: registered new interface driver uas
[    2.365296] usbcore: registered new interface driver usb-storage
It looks like the USB power is enabled by the USB hub chip?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 5453
Joined: Wed Aug 28, 2013 3:31 am

Re: Getting Started with the Compute Module 4

Fri Apr 23, 2021 7:59 am

Very interesting.

Got the 8GB eMMC version, so the uSD socket is not used.
But there is 5V on it but no 5V on the USB A connectors.

Used Windows USBboot and imager for flash PiCore and Raspberry OS.
Tried PiCore twice and Raspberry OS once, both flashed ok

Raspberry Pi OS outputs a PCIe error on boot.
It probably expects a VL805 chip.
If you want to use Raspberry OS on the CM I suggest getting a compatible PCIe USB3 card.
Ethernet works but SSH is disabled.

PiCore is better as SSH is enabled by default and allows you to access the CM I/O board via the network.
It's also much smaller and images faster.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 5453
Joined: Wed Aug 28, 2013 3:31 am

Re: Getting Started with the Compute Module 4

Sun Apr 25, 2021 2:37 am

Last lesson in getting started?

Powering up the USB A ports for keyboard and mouse.
Put this in config.txt to enable power on the CM4 I/O board

Code: Select all

[cm4]
otg_mode=1
Phew, not a fried PCB.
Wish this was in the manual.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Return to “Compute Module”