yaml: add back support for empty LED groups

The old script had support for empty LED groups. I tried removing the
empty "bmc_booted" LED group, but that caused systemd to never "finish"
booting (systemctl is-system-running returned "starting" because it was
blocked waiting for the "bmc_booted" LED service to start).

This adds back support for empty LED groups.

Tested:
Confirmed that with an empty "bmc_booted" LED group, the firmware will
build successfully and systemd doesn't get blocked waiting for the
"bmc_booted" LED service.

Change-Id: I11d7c50696cd50d989a4eaef28f8e5c43473ce6e
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
4 files changed
tree: 7d86650688457e305797abaff4ec144a8ab6b8ff
  1. configs/
  2. example/
  3. fault-monitor/
  4. manager/
  5. scripts/
  6. subprojects/
  7. test/
  8. .clang-format
  9. .clang-tidy
  10. .gitignore
  11. .linter-ignore
  12. .prettierrc.yaml
  13. .shellcheck
  14. led.yaml
  15. LICENSE
  16. meson.build
  17. meson.options
  18. OWNERS
  19. pyproject.toml
  20. README.md
  21. utils.cpp
  22. utils.hpp
README.md

phosphor-led-manager

This project manages LED groups on dbus. Sometimes many LEDs must be driven together to indicate some system state.

For example, there can be multiple identify LEDs. When the user wants to identify the system, they should all light up together.

Configuration

The configuration can happen via json or yaml.

Configuration: LED Priority

Each LED can have "Priority" as "Blink", "Off" or "On". If this property is defined, it should be defined on each instance of the LED in the config.

When multiple LED groups are asserted and contain the same LED, "Priority" determines the state of the LED.

For example, Group 1 says LED1 should be "Blink", and Group 2 says it should be "On". LED1 will then have the state declared in "Priority".

Configuration: LED Group Priority

Using LED Priority is fine for simple configurations, but when group state needs to always be consistent, Group Priority can be used to enforce the consistent representation.

The Group Priority is optional and a higher priority means that when 2 groups are asserted, the one with highest Priority will be represented consistently. Meaning all its LEDs will have the state as per the configuration.

Configuration Example with Group Priorities (JSON)

Here we prioritize the locating group above the fault group since locating may be required to fix the fault.

So independent of the order that these groups are asserted, if both are asserted, "sys_id" should be in "Blink" state.

The "unrelated" group will have the default group priority of 0.

{
  "leds": [
    {
      "group": "enclosure_identify",
      "Priority": 2,
      "members": [
        {
          "Name": "sys_id",
          "Action": "Blink"
        },
        {
          "Name": "rear_id",
          "Action": "Blink"
        }
      ]
    },
    {
      "group": "fault",
      "Priority": 1,
      "members": [
        {
          "Name": "sys_id",
          "Action": "On"
        },
        {
          "Name": "fault",
          "Action": "On"
        }
      ]
    },
    {
      "group": "unrelated",
      "members": [
        {
          "Name": "rear_id",
          "Action": "On"
        }
      ]
    }
  ]
}

Configuration Example (JSON)

This is our configuration file. It describes 2 LEDs for the 'enclosure_identify' group, with their respective states and duty cycles.

{
  "leds": [
    {
      "group": "enclosure_identify",
      "members": [
        {
          "Name": "pca955x_front_sys_id0",
          "Action": "On",
          "DutyOn": 50,
          "Period": 0,
          "Priority": "Blink"
        },
        {
          "Name": "led_rear_enc_id0",
          "Action": "On",
          "DutyOn": 50,
          "Period": 0,
          "Priority": "Blink"
        }
      ]
    }
  ]
}

Then start the program with

~# ./phosphor-led-manager --config example.json

Dbus interface

When starting the program, our LED group shows up on dbus. Usually there will be many more groups.

$ busctl tree xyz.openbmc_project.LED.GroupManager
`- /xyz
  `- /xyz/openbmc_project
    `- /xyz/openbmc_project/led
      `- /xyz/openbmc_project/led/groups
        `- /xyz/openbmc_project/led/groups/enclosure_identify


$ busctl introspect xyz.openbmc_project.LED.GroupManager /xyz/openbmc_project/led/groups/enclosure_identify
NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS
...
xyz.openbmc_project.Led.Group       interface -         -            -
.Asserted                           property  b         false        emits-change writable

In the above output, the usual org.freedesktop.* interfaces have been removed to keep it readable.

We can now drive the entire group by setting it's 'Asserted' property on dbus.

$ busctl set-property \
xyz.openbmc_project.LED.GroupManager \
/xyz/openbmc_project/led/groups/enclosure_identify \
xyz.openbmc_project.Led.Group Asserted b true

The program can then use the xyz.openbmc_project.Led.Physical dbus interface exposed by phosphor-led-sysfs to set each LED state.

How to Build

meson setup build
cd build
ninja