sdb
Posts: 1
Joined: Fri May 28, 2021 1:55 pm

[CM4] Permanently changing MAC address

Fri May 28, 2021 2:01 pm

I'm attempting to permanently change the MAC address of the RPi CM4 via the program_mac_addr line in config.txt as
outlined in this post: viewtopic.php?t=231700

However, this does not appear to function on the CM4. The force_mac_address= line in config.txt,
however, does. (Verified with `ip a` and the sm95xx.addr= line in /proc/cmdline)

My procedure:
1. Mount a fresh, unflashed CM4 to an IO board
2. Plug in IO board via USB to Windows 10 machine
3. Run rpiboot
4. Run Raspberry Pi flashing utility to flash Ubuntu 20.04LTS server (armhf)
5. When Pi is done flashing and filesystems (but before a reboot) are available to Windows, edit config.txt, add program_mac_addr=12:34:56:78:90:12
6. Eject Pi device from Windows and power cycle RPi
7. On boot, login via serial console, check eth0 MAC with `ip a` and `/proc/cmdline`
8. Check OTP registers via `vcgencmd otp_dump`, look at register 64,65
9. Note all locations show a MAC with an RPi OUI: DC:A6:32:XX:XX:XX

Changing step #5 to use force_mac_address= works as one might expect.

Anyone have any insights? There's really not much on this so perhaps it just was never designed to work on the CM4?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3967
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: [CM4] Permanently changing MAC address

Fri May 28, 2021 2:40 pm

Older Pis algorithmically generate a MAC address based on the serial number, but members of the Pi 4 family have MAC addresses pre-programmed into the OTP. The fact that things written to OTP can't be changed (unless you are very lucky with the bit flips) means you can't program your own MAC address.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 29024
Joined: Sat Jul 30, 2011 7:41 pm

Re: [CM4] Permanently changing MAC address

Fri May 28, 2021 3:04 pm

At least, not permanently. You can change it in software on each boot if you want.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Application's Team.

User avatar
thagrol
Posts: 5253
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: [CM4] Permanently changing MAC address

Fri May 28, 2021 3:52 pm

PhilE wrote:
Fri May 28, 2021 2:40 pm
Older Pis algorithmically generate a MAC address based on the serial number, but members of the Pi 4 family have MAC addresses pre-programmed into the OTP. The fact that things written to OTP can't be changed (unless you are very lucky with the bit flips) means you can't program your own MAC address.
I'm curious, does that mean you can flip any bit of the stored MAC address from zero to one to set a new MAC address? Probably not very useful or easy to do but technically possible?
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 29024
Joined: Sat Jul 30, 2011 7:41 pm

Re: [CM4] Permanently changing MAC address

Fri May 28, 2021 3:53 pm

thagrol wrote:
Fri May 28, 2021 3:52 pm
PhilE wrote:
Fri May 28, 2021 2:40 pm
Older Pis algorithmically generate a MAC address based on the serial number, but members of the Pi 4 family have MAC addresses pre-programmed into the OTP. The fact that things written to OTP can't be changed (unless you are very lucky with the bit flips) means you can't program your own MAC address.
I'm curious, does that mean you can flip any bit of the stored MAC address from zero to one to set a new MAC address? Probably not very useful or easy to do but technically possible?
Correct. It's all one way of course.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Application's Team.

kileyhykawy
Posts: 4
Joined: Thu Feb 04, 2021 1:45 am
Location: Canada

Re: [CM4] Permanently changing MAC address

Fri May 28, 2021 7:10 pm

PhilE wrote:
Fri May 28, 2021 2:40 pm
but members of the Pi 4 family have MAC addresses pre-programmed into the OTP.
You mention Pi 4 family but the question was for Compute Module 4. I wouldn't necessarily call that the Pi4 family as I see that as a Single Board Computer case meant for more consumer applications while Compute Module (system on module) is for commercial/industrial.

I would have expected the Compute Modules to allow for OTP MAC address programming. Not a big deal if it can't as like was explained, it can be set for each boot, just wondering if the commercial/industrial use case was considered - permanence is desirable here.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 29024
Joined: Sat Jul 30, 2011 7:41 pm

Re: [CM4] Permanently changing MAC address

Fri May 28, 2021 7:55 pm

kileyhykawy wrote:
Fri May 28, 2021 7:10 pm
PhilE wrote:
Fri May 28, 2021 2:40 pm
but members of the Pi 4 family have MAC addresses pre-programmed into the OTP.
You mention Pi 4 family but the question was for Compute Module 4. I wouldn't necessarily call that the Pi4 family as I see that as a Single Board Computer case meant for more consumer applications while Compute Module (system on module) is for commercial/industrial.

I would have expected the Compute Modules to allow for OTP MAC address programming. Not a big deal if it can't as like was explained, it can be set for each boot, just wondering if the commercial/industrial use case was considered - permanence is desirable here.
The CM4 is part of the Pi4 family, and as such you cannot permanently change the Mac address. We have considered the ability to pre-program the MAC for specific customers (at the point we program it with our own Mac), but we have no facilities to do so, either from a sales point of view, or in the factory, and it would be quite expensive to set it up.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Application's Team.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3967
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: [CM4] Permanently changing MAC address

Fri May 28, 2021 7:57 pm

Pi 4B, Pi 400 and CM4 are commonly referred to (by us, at least) as the Pi 4 family (being built around the BCM2711 SoC).

kileyhykawy
Posts: 4
Joined: Thu Feb 04, 2021 1:45 am
Location: Canada

Re: [CM4] Permanently changing MAC address

Sat May 29, 2021 10:01 pm

Thanks! It is definitely good to know how Raspberry Pi defines these - the context helps when looking at the documentation and forum.

Return to “Compute Module”