Skip to content

Commit e5da620

Browse files
committed
fault, temp: add new helpers for automatic restart support
Some BMR do not support an automatic restart. The workaround can be to generate a fault that leads to a shutdown until the fault is cleared. For instance, we can set the fault on the temperature.
1 parent 3108bb4 commit e5da620

File tree

8 files changed

+1040
-3
lines changed

8 files changed

+1040
-3
lines changed

README.md

Lines changed: 138 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,144 @@ Lock NVM while allowing live control:
573573
bmr ... write-protect set --ctrl
574574
```
575575

576-
---
576+
## temp — Temperature limits & live sensors
577+
578+
```bash
579+
bmr ... temp get [all|ot|ut|warn]
580+
bmr ... temp set [--ot-fault <C>] [--ut-fault <C>] [--ot-warn <C>] [--ut-warn <C>]
581+
bmr ... temp read [all|t1|t2|t3]
582+
```
583+
584+
### What it does
585+
586+
Reads and programs the **OT/UT FAULT/WARN** temperature limits and reads live
587+
temperatures. All limits and readings use **PMBus Linear11** (5-bit signed
588+
exponent, 11-bit signed mantissa) and are converted to °C in the JSON output.
589+
Inputs accept **C (default), K, or F** (e.g., `110`, `358K`, `185F`).
590+
591+
### Key options
592+
593+
* `temp get all|ot|ut|warn` — dump FAULT/WARN limits (decoded °C + raw LIN11).
594+
* `temp set ...` — write one or more limits; values converted from C/K/F to
595+
LIN11 with readback verification.
596+
* `temp read all|t1|t2|t3` — read `READ_TEMPERATURE_1/2/(3 if present)` and
597+
decode to °C.
598+
599+
### Use case
600+
601+
Set typical limits and verify live sensors:
602+
603+
```bash
604+
# Program limits
605+
bmr --bus /dev/i2c-1 --addr 0x40 temp set --ot-fault 110 --ot-warn 100 --ut-warn -20 --ut-fault -40
606+
607+
# Persist if desired (device NVM):
608+
bmr --bus /dev/i2c-1 --addr 0x40 user-data set --store
609+
610+
# Read back limits and live temps
611+
bmr --bus /dev/i2c-1 --addr 0x40 temp get all
612+
bmr --bus /dev/i2c-1 --addr 0x40 temp read all
613+
```
614+
615+
## fault — Fault-response policy (OT/UT/VIN/VOUT/TON_MAX/IOUT)
616+
617+
```bash
618+
bmr ... fault get [all|temp|vin|vout|tonmax|iout]
619+
bmr ... fault temp set \
620+
[--ot-delay 16s|32s|2^n] [--ot-mode ignore|delay-retry|disable-retry|disable-until-clear] [--ot-retries 0..6|cont] \
621+
[--ut-delay 16s|32s|2^n] [--ut-mode ignore|delay-retry|disable-retry|disable-until-clear] [--ut-retries 0..6|cont]
622+
```
623+
624+
### What it does
625+
626+
Programs and reads the **PMBus FAULT RESPONSE** bytes (PMBus Part II, Table 4).
627+
Each response byte packs three fields:
628+
629+
* **Mode** (bits 7:6):
630+
* `00` **ignore** — report status only.
631+
* `01` **delay-then-retry** — wait delay, then apply retry policy.
632+
* `10` **disable-and-retry** — disable output immediately, then retry after delay.
633+
* `11` **disable-until-fault-clears** (latch-off).
634+
635+
* **Retries** (bits 5:3): `0..6`, `7=continuous`.
636+
* **Delay** (bits 2:0): time base depends on command family:
637+
* **Temperature (OT/UT)**: seconds = `2^n` (n in 0..7) → `n=4`=16 s, `n=5`=32 s.
638+
* **VIN/VOUT/TON_MAX/IOUT**: typically **10 ms/LSB** on BMR45x (see device spec).
639+
640+
`fault get` decodes mode/retries/delay with proper units per family.
641+
`fault temp set` programs the **OT/UT** response bytes with friendly arguments.
642+
643+
### Use case — 1s off, single retry on OT/UT (with temperature thresholds)
644+
645+
The fault response defines what to do when a fault happens; you still need
646+
temperature limits to create the fault. Below sets both:
647+
648+
**Program the OT/UT fault-response policy** (disable, wait 16s, retry once):
649+
```bash
650+
bmr --bus /dev/i2c-1 --addr 0x40 fault temp set \
651+
--ot-mode disable-retry --ot-retries 1 --ot-delay 16s \
652+
--ut-mode disable-retry --ut-retries 1 --ut-delay 16s
653+
```
654+
655+
**Set temperature thresholds** (example production-style values; adjust to your design):
656+
657+
```bash
658+
bmr --bus /dev/i2c-1 --addr 0x40 temp set \
659+
--ot-fault 110 --ot-warn 100 \
660+
--ut-warn -20 --ut-fault -40
661+
```
662+
663+
**Persist to NVM** (optional, if you want the policy/limits after power cycle):
664+
665+
```bash
666+
bmr --bus /dev/i2c-1 --addr 0x40 user-data set --store
667+
```
668+
669+
**Verify**:
670+
671+
```bash
672+
# Check fault temperature policy
673+
bmr --bus /dev/i2c-1 --addr 0x40 fault get temp
674+
675+
# Check limits
676+
bmr --bus /dev/i2c-1 --addr 0x40 temp get all
677+
```
678+
679+
#### Use case - restart trigger (enforce the 16s OFF + single retry)
680+
681+
Read the live temperature to know your baseline:
682+
683+
```bash
684+
bmr --bus /dev/i2c-1 --addr 0x40 temp read t1
685+
```
686+
687+
Force a fault immediately (pick one):
688+
689+
```bash
690+
# Force OT now (set OT below current temp, e.g., if T1 ~ 25 °C):
691+
bmr --bus /dev/i2c-1 --addr 0x40 temp set --ot-fault 20
692+
693+
# or, Force UT now (set UT above current temp):
694+
bmr --bus /dev/i2c-1 --addr 0x40 temp set --ut-fault 30
695+
696+
# Persist to NVM if you want the policy to survive power cycles
697+
#bmr --bus /dev/i2c-1 --addr 0x40 user-data set --store
698+
```
699+
700+
The rail shall shutdown, wait 16s, retry once, then:
701+
702+
* If the condition cleared (e.g., OT cooled), it recovers.
703+
* If the condition persists (e.g., UT still above ambient), it stays off.
704+
705+
Restore your real thresholds after testing:
706+
707+
```bash
708+
bmr --bus /dev/i2c-1 --addr 0x40 temp set \
709+
--ot-fault 110 --ot-warn 100 --ut-warn -20 --ut-fault -40
710+
711+
# Persist to NVM if you want the policy to survive power cycles
712+
bmr --bus /dev/i2c-1 --addr 0x40 user-data set --store
713+
```
577714

578715
## Notes & best practices
579716

0 commit comments

Comments
 (0)