mnbbrown
Posts: 2
Joined: Wed Feb 21, 2024 5:27 pm

Change when HAT overlay is applied

Wed Feb 21, 2024 5:37 pm

I have an off the shelf bit of kit based on the CM 3+ that uses the HAT overlay to set the MAC address for two LAN9512s. It does this by using a custom `device_tree` in config.txt that includes the two LAN9512's. This means that the HAT overlay can successfully be merged with this custom device_tree.

I'm hoping to change that slightly to use the original raspberry pi device tree from raspberrypi/firmware + a custom overlay to define the two LAN9512's but this means that when the HAT overlay is applied the LAN9512 targets don't exist year.

Is it possible to change when the bootloader applies the HAT overlay based on some custom `config.txt`?

Basically I want the overlay apply order to be:

Code: Select all

device_tree
overlay_with_lan9512
hat_overlay
whereas currently it's:

Code: Select all

device_tree
hat_overlay # fails because the targets don't exist
overlay_with_lan9512

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

Re: Change when HAT overlay is applied

Wed Feb 21, 2024 6:43 pm

We can't change the order without breaking quite a few things, so it's not going to happen. Since you already have a custom overlay, would it not work if you disable the HAT overlay and just make it a regular overlay instead? This is easily achieved by making "dtoverlay=" the first dt directive in the file.

mnbbrown
Posts: 2
Joined: Wed Feb 21, 2024 5:27 pm

Re: Change when HAT overlay is applied

Thu Feb 22, 2024 1:48 pm

I thought that might be the case. This is what I've ended up with:

Code: Select all

# Disable HAT overlay
dtoverlay=
# Apply BSP overlay (generic to bsp)
dtoverlay=bsp
# Apply MAC address overlay (unique per device)
dtoverlay=bsp-macs
Thanks!

Return to “Device Tree”