Hi
My issue is that the i2c1 is not seen on my device in nixos.
I have tried adding the overlay to the tree but it does not add the overlay it compiles with some warnings, and adds my uart3 and uart5 the mdio fix and the emmc fix and adds ads1113 device.
The objective is to turn on the i2c and get access to the adc i2c chip.
here is my config based in the dwc2 fix.
I also tried splitting out into a seperate i2c.nix file with exactly the same results.
boot.kernelPackages = pkgs.linuxPackages_rpi4;
hardware.deviceTree.enable = true;
hardware.deviceTree.filter = "bcm2711-rpi-*.dtb";
hardware.raspberry-pi."4".dwc2.enable = true; # also enable uart3 ,uart5, mdio ,emmc Wave share io board.
hardware.raspberry-pi."4".dwc2.dr_mode = "host";
hardware.i2c.enable=true;
# Required for the Wireless firmware
hardware.enableRedistributableFirmware = true;
and the dwc2.nix that hangs it all together.
{ config, lib, pkgs, ... }:
let
cfg = config.hardware.raspberry-pi."4".dwc2;
in
{
options.hardware = {
raspberry-pi."4".dwc2 = {
enable = lib.mkEnableOption ''
Enable the UDC controller to support USB OTG gadget functions.
In order to verify that this works, connect the Raspberry Pi with
another computer via the USB C cable, and then do one of:
- `modprobe g_serial`
- `modprobe g_mass_storage file=/path/to/some/iso-file.iso`
On the Raspberry Pi, `dmesg` should then show success-indicating output
that is related to the dwc2 and g_serial/g_mass_storage modules.
On the other computer, a serial/mass-storage device should pop up in
the system logs.
For more information about what gadget functions exist along with handy
guides on how to test them, please refer to:
https://www.kernel.org/doc/Documentation/usb/gadget-testing.txt
'';
dr_mode = lib.mkOption {
type = lib.types.enum [ "host" "peripheral" "otg" ];
default = "otg";
description = ''
Dual role mode setting for the dwc2 USB controller driver.
'';
};
};
};
config = lib.mkIf cfg.enable {
# Configure for modesetting in the device tree
hardware.deviceTree = {
overlays = [
# this *should* be equivalent to (which doesn't work):
# https://github.com/raspberrypi/linux/blob/bad3872df40dd9a4ba7ff239c17288a7a84a80f9/arch/arm/boot/dts/overlays/dwc2-overlay.dts
# but actually it's obtained using
# dtc -I dtb -O dts ${config.hardware.deviceTree.kernelPackage}/dtbs/overlays/dwc2.dtbo
# (changes: modified top-level "compatible" field)
# which is slightly different and works
{
name = "dwc2-overlay";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target = <&usb>;
#address-cells = <0x01>;
#size-cells = <0x01>;
__overlay__ {
compatible = "brcm,bcm2835-usb";
dr_mode = "${cfg.dr_mode}";
g-np-tx-fifo-size = <0x20>;
g-rx-fifo-size = <0x22e>;
g-tx-fifo-size = <0x200 0x200 0x200 0x200 0x200 0x100 0x100>;
status = "okay";
phandle = <0x01>;
};
};
};
'';
}
{ name = "uart3-overlay";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target = <0xffffffff>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <0xffffffff>;
status = "okay";
};
};
fragment@1 {
target = <0xffffffff>;
__dormant__ {
brcm,pins = <0x04 0x05 0x06 0x07>;
brcm,pull = <0x00 0x02 0x02 0x00>;
};
};
__overrides__ {
ctsrts = [00 00 00 00 3d 31 00];
};
__fixups__ {
uart3 = "/fragment@0:target:0";
uart3_pins = "/fragment@0/__overlay__:pinctrl-0:0\0/fragment@1:target:0";
};
};
'';
}
{ name = "uart5-overlay";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target = <0xffffffff>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <0xffffffff>;
status = "okay";
};
};
fragment@1 {
target = <0xffffffff>;
__dormant__ {
brcm,pins = <0x0c 0x0d 0x0e 0x0f>;
brcm,pull = <0x00 0x02 0x02 0x00>;
};
};
__overrides__ {
ctsrts = [00 00 00 00 3d 31 00];
};
__fixups__ {
uart5 = "/fragment@0:target:0";
uart5_pins = "/fragment@0/__overlay__:pinctrl-0:0\0/fragment@1:target:0";
};
};
'';
}
{ name = "mdio-overlay";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target = <&phy1>;
__overlay__ {
reg = <0x00>;
};
};
};
'';
}
{ name = "emmc-overlay";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target = <&emmc2bus>;
__overlay__ {
compatible = "simple-bus";
dma-ranges = <0x00 0x00000000 0x00 0x00 0xfc000000>;
};
};
};
'';
}
{ name ="i2c1-overlay";
dtsText =''
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target = <0xffffffff>;
__overlay__ {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <0xffffffff>;
};
};
fragment@1 {
target = <0xffffffff>;
__overlay__ {
brcm,pins = <0x02 0x03>;
brcm,function = <0x04>;
phandle = <0x01>;
};
};
fragment@2 {
target = <0xffffffff>;
__dormant__ {
brcm,pins = <0x2c 0x2d>;
brcm,function = <0x06>;
phandle = <0x02>;
};
};
fragment@3 {
target = <0xffffffff>;
__dormant__ {
compatible = "brcm,bcm2708-i2c";
};
};
__overrides__ {
pins_2_3 = [00 00 00 00 3d 31 21 32 00];
pins_44_45 = [00 00 00 00 21 31 3d 32 00];
combine = [00 00 00 00 21 33 00];
};
__symbols__ {
pins1 = "/fragment@1/__overlay__";
pins2 = "/fragment@2/__dormant__";
};
__fixups__ {
i2c1 = "/fragment@0:target:0\0/fragment@3:target:0";
i2c1_pins = "/fragment@0/__overlay__:pinctrl-0:0\0/fragment@1:target:0\0/fragment@2:target:0";
};
};
'';
}
{ name = "ads1113-overlay";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target = < 0xffffffff >;
__overlay__ {
#address-cells = < 0x01 >;
#size-cells = < 0x00 >;
status = "okay";
ads1115 {
compatible = "ti,ads1113";
status = "okay";
#address-cells = < 0x01 >;
#size-cells = < 0x00 >;
reg = < 0x48 >;
phandle = < 0x01 >;
};
};
};
fragment@1 {
target = < 0x01 >;
__dormant__ {
#address-cells = < 0x01 >;
#size-cells = < 0x00 >;
channel_a {
reg = < 0x04 >;
ti,gain = < 0x01 >;
ti,datarate = < 0x07 >;
phandle = < 0x02 >;
};
};
};
fragment@2 {
target = < 0x01 >;
__dormant__ {
#address-cells = < 0x01 >;
#size-cells = < 0x00 >;
channel_b {
reg = < 0x05 >;
ti,gain = < 0x01 >;
ti,datarate = < 0x07 >;
phandle = < 0x03 >;
};
};
};
fragment@3 {
target = < 0x01 >;
__dormant__ {
#address-cells = < 0x01 >;
#size-cells = < 0x00 >;
channel_c {
reg = < 0x06 >;
ti,gain = < 0x01 >;
ti,datarate = < 0x07 >;
phandle = < 0x04 >;
};
};
};
fragment@4 {
target = < 0x01 >;
__dormant__ {
#address-cells = < 0x01 >;
#size-cells = < 0x00 >;
channel_d {
reg = < 0x07 >;
ti,gain = < 0x01 >;
ti,datarate = < 0x07 >;
phandle = < 0x05 >;
};
};
};
__overrides__ {
addr = [ 00 00 00 01 72 65 67 3a 30 00 ];
cha_enable = [ 00 00 00 00 3d 31 00 ];
cha_cfg = [ 00 00 00 02 72 65 67 3a 30 00 ];
cha_gain = [ 00 00 00 02 74 69 2c 67 61 69 6e 3a 30 00 ];
cha_datarate = [ 00 00 00 02 74 69 2c 64 61 74 61 72 61 74 65 3a 30 00 ];
chb_enable = [ 00 00 00 00 3d 32 00 ];
chb_cfg = [ 00 00 00 03 72 65 67 3a 30 00 ];
chb_gain = [ 00 00 00 03 74 69 2c 67 61 69 6e 3a 30 00 ];
chb_datarate = [ 00 00 00 03 74 69 2c 64 61 74 61 72 61 74 65 3a 30 00 ];
chc_enable = [ 00 00 00 00 3d 33 00 ];
chc_cfg = [ 00 00 00 04 72 65 67 3a 30 00 ];
chc_gain = [ 00 00 00 04 74 69 2c 67 61 69 6e 3a 30 00 ];
chc_datarate = [ 00 00 00 04 74 69 2c 64 61 74 61 72 61 74 65 3a 30 00 ];
chd_enable = [ 00 00 00 00 3d 34 00 ];
chd_cfg = [ 00 00 00 05 72 65 67 3a 30 00 ];
chd_gain = [ 00 00 00 05 74 69 2c 67 61 69 6e 3a 30 00 ];
chd_datarate = [ 00 00 00 05 74 69 2c 64 61 74 61 72 61 74 65 3a 30 00 ];
};
__symbols__ {
ads1113 = "/fragment@0/__overlay__/ads1113";
channel_a = "/fragment@1/__dormant__/channel_a";
channel_b = "/fragment@2/__dormant__/channel_b";
channel_c = "/fragment@3/__dormant__/channel_c";
channel_d = "/fragment@4/__dormant__/channel_d";
};
__fixups__ {
i2c_arm = "/fragment@0:target:0";
};
__local_fixups__ {
fragment@1 {
target = < 0x00 >;
};
fragment@2 {
target = < 0x00 >;
};
fragment@3 {
target = < 0x00 >;
};
fragment@4 {
target = < 0x00 >;
};
__overrides__ {
addr = < 0x00 >;
cha_cfg = < 0x00 >;
cha_gain = < 0x00 >;
cha_datarate = < 0x00 >;
chb_cfg = < 0x00 >;
chb_gain = < 0x00 >;
chb_datarate = < 0x00 >;
chc_cfg = < 0x00 >;
chc_gain = < 0x00 >;
chc_datarate = < 0x00 >;
chd_cfg = < 0x00 >;
chd_gain = < 0x00 >;
chd_datarate = < 0x00 >;
};
};
};
'';
}
];
};
};
}