Skip to content

Conversation

alexcekay
Copy link
Member

Solved Problem

  • The Auterion PM starter does some probing that will not scale well in the future with more power modules and especially different shunts on each of them

Solution

  • Auterion PMs have an EEPROM that describe the sensor and shunt of the PM

Changelog Entry

For release notes:

Feature: Auterion PM supports automatic shunt detection via EEPROM

Test coverage

  • Still testing

@alexcekay alexcekay force-pushed the pr-auterion-pm-eeprom branch from 9eff71a to 5bfafea Compare June 30, 2025 16:44
@alexcekay alexcekay requested a review from niklaut June 30, 2025 16:47
Copy link

github-actions bot commented Jun 30, 2025

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 864 byte (0.04 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +864  +0.0%    +864    .text
  [NEW]    +220  [NEW]    +220    PowerMonitorSelectorAuterion::eeprom_read()
  [NEW]    +168  [NEW]    +168    PowerMonitorSelectorAuterion::start_pm()
  [NEW]    +152  [NEW]    +152    PowerMonitorSelectorAuterion::eeprom_read_block()
  [NEW]    +152  [NEW]    +152    PowerMonitorSelectorAuterion::try_eeprom_start()
  [NEW]    +108  [NEW]    +108    PowerMonitorSelectorAuterion::try_probe_start()
  [NEW]     +76  [NEW]     +76    PowerMonitorSelectorAuterion::set_float_param()
   +52%     +56   +52%     +56    PowerMonitorSelectorAuterion::PowerMonitorSelectorAuterion()
  [NEW]     +56  [NEW]     +56    PowerMonitorSelectorAuterion::is_user_configured()
  [NEW]     +56  [NEW]     +56    PowerMonitorSelectorAuterion::set_max_current()
  [NEW]     +56  [NEW]     +56    PowerMonitorSelectorAuterion::set_shunt_value()
  [NEW]     +40  [NEW]     +40    PowerMonitorSelectorAuterion::crc16_update()
  [NEW]     +32  [NEW]     +32    PowerMonitorSelectorAuterion::is_eeprom_header_valid()
  [NEW]     +28  [NEW]     +28    PowerMonitorSelectorAuterion::is_eeprom_block_header_valid()
 -96.1%     +28 -96.1%     +28    [5 Others]
  [NEW]     +24  [NEW]     +24    PowerMonitorSelectorAuterion::get_ina_type()
  [NEW]     +24  [NEW]     +24    PowerMonitorSelectorAuterion::get_start_command()
 -16.0%     -32 -16.0%     -32    PowerMonitorSelectorAuterion::ina226_probe()
  -0.0%     -48  -0.0%     -48    [section .text]
  [DEL]     -96  [DEL]     -96    PowerMonitorSelectorAuterion::init()
  [DEL]    -108  [DEL]    -108    itoa
 -51.6%    -128 -51.6%    -128    PowerMonitorSelectorAuterion::Run()
+0.0%    +182  [ = ]       0    .debug_abbrev
+0.1%     +88  [ = ]       0    .debug_aranges
+0.1%    +412  [ = ]       0    .debug_frame
+0.0% +4.03Ki  [ = ]       0    .debug_info
+0.0% +1.15Ki  [ = ]       0    .debug_line
   +50%      +1  [ = ]       0    [Unmapped]
  +0.0% +1.15Ki  [ = ]       0    [section .debug_line]
+0.0% +1.50Ki  [ = ]       0    .debug_loclists
+0.0%    +199  [ = ]       0    .debug_rnglists
  [NEW]      +2  [ = ]       0    [Unmapped]
  +0.0%    +197  [ = ]       0    [section .debug_rnglists]
+0.1% +2.22Ki  [ = ]       0    .debug_str
+1.3%      +3  [ = ]       0    .shstrtab
+0.1%    +797  [ = ]       0    .strtab
  [NEW]     +10  [ = ]       0    CSWTCH.64
  [NEW]     +10  [ = ]       0    CSWTCH.68
  [NEW]     +55  [ = ]       0    PowerMonitorSelectorAuterion::crc16_update()
  [NEW]     +49  [ = ]       0    PowerMonitorSelectorAuterion::eeprom_read()
  [NEW]     +73  [ = ]       0    PowerMonitorSelectorAuterion::eeprom_read_block()
  [NEW]     +51  [ = ]       0    PowerMonitorSelectorAuterion::get_ina_type()
  [NEW]     +56  [ = ]       0    PowerMonitorSelectorAuterion::get_start_command()
  +2.0%      +1  [ = ]       0    PowerMonitorSelectorAuterion::ina226_probe()
  [DEL]     -41  [ = ]       0    PowerMonitorSelectorAuterion::init()
  [NEW]     +90  [ = ]       0    PowerMonitorSelectorAuterion::is_eeprom_block_header_valid()
  [NEW]     +79  [ = ]       0    PowerMonitorSelectorAuterion::is_eeprom_header_valid()
  [NEW]     +57  [ = ]       0    PowerMonitorSelectorAuterion::is_user_configured()
  [NEW]     +57  [ = ]       0    PowerMonitorSelectorAuterion::set_float_param()
  [NEW]     +55  [ = ]       0    PowerMonitorSelectorAuterion::set_max_current()
  [NEW]     +55  [ = ]       0    PowerMonitorSelectorAuterion::set_shunt_value()
  [NEW]     +49  [ = ]       0    PowerMonitorSelectorAuterion::start_pm()
  [NEW]     +54  [ = ]       0    PowerMonitorSelectorAuterion::try_eeprom_start()
  [NEW]     +53  [ = ]       0    PowerMonitorSelectorAuterion::try_probe_start()
 -147.7%     -21  [ = ]       0    [2 Others]
  -0.0%     -11  [ = ]       0    [section .strtab]
   +25%     +16  [ = ]       0    ___ZN3Ekf20controlGravityFusionERKN9estimator9imuSampleE_veneer
+0.1%    +544  [ = ]       0    .symtab
  [NEW]     +32  [ = ]       0    CSWTCH.64
  [NEW]     +32  [ = ]       0    CSWTCH.68
  [NEW]     +16  [ = ]       0    PowerMonitorSelectorAuterion::crc16_update()
  [NEW]     +64  [ = ]       0    PowerMonitorSelectorAuterion::eeprom_read()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::eeprom_read_block()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::get_ina_type()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::get_start_command()
  [DEL]     -48  [ = ]       0    PowerMonitorSelectorAuterion::init()
  [NEW]     +16  [ = ]       0    PowerMonitorSelectorAuterion::is_eeprom_block_header_valid()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::is_eeprom_header_valid()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::is_user_configured()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::set_float_param()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::set_max_current()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::set_shunt_value()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::start_pm()
  [NEW]     +16  [ = ]       0    PowerMonitorSelectorAuterion::try_eeprom_start()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::try_probe_start()
  -0.5%     -64  [ = ]       0    [section .symtab]
   +67%     +32  [ = ]       0    ___ZN3Ekf20controlGravityFusionERKN9estimator9imuSampleE_veneer
 -40.0%     -32  [ = ]       0    __nxsem_trywait_veneer
 +39% +3.16Ki  [ = ]       0    [Unmapped]
+0.0% +15.1Ki  +0.0%    +864    TOTAL

px4_fmu-v6x [Total VM Diff: 864 byte (0.04 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +864  +0.0%    +864    .text
  [NEW]    +220  [NEW]    +220    PowerMonitorSelectorAuterion::eeprom_read()
  [NEW]    +168  [NEW]    +168    PowerMonitorSelectorAuterion::start_pm()
  [NEW]    +152  [NEW]    +152    PowerMonitorSelectorAuterion::eeprom_read_block()
  [NEW]    +152  [NEW]    +152    PowerMonitorSelectorAuterion::try_eeprom_start()
  [NEW]    +108  [NEW]    +108    PowerMonitorSelectorAuterion::try_probe_start()
  [NEW]     +76  [NEW]     +76    PowerMonitorSelectorAuterion::set_float_param()
   +52%     +56   +52%     +56    PowerMonitorSelectorAuterion::PowerMonitorSelectorAuterion()
  [NEW]     +56  [NEW]     +56    PowerMonitorSelectorAuterion::is_user_configured()
  [NEW]     +56  [NEW]     +56    PowerMonitorSelectorAuterion::set_max_current()
  [NEW]     +56  [NEW]     +56    PowerMonitorSelectorAuterion::set_shunt_value()
  [NEW]     +40  [NEW]     +40    PowerMonitorSelectorAuterion::crc16_update()
  [NEW]     +32  [NEW]     +32    PowerMonitorSelectorAuterion::is_eeprom_header_valid()
  [NEW]     +28  [NEW]     +28    PowerMonitorSelectorAuterion::is_eeprom_block_header_valid()
 -79.7%     +28 -79.7%     +28    [5 Others]
  [NEW]     +24  [NEW]     +24    PowerMonitorSelectorAuterion::get_ina_type()
  [NEW]     +24  [NEW]     +24    PowerMonitorSelectorAuterion::get_start_command()
 -16.0%     -32 -16.0%     -32    PowerMonitorSelectorAuterion::ina226_probe()
  -0.0%     -48  -0.0%     -48    [section .text]
  [DEL]     -96  [DEL]     -96    PowerMonitorSelectorAuterion::init()
  [DEL]    -108  [DEL]    -108    itoa
 -51.6%    -128 -51.6%    -128    PowerMonitorSelectorAuterion::Run()
+0.0%    +182  [ = ]       0    .debug_abbrev
+0.1%     +88  [ = ]       0    .debug_aranges
+0.1%    +412  [ = ]       0    .debug_frame
+0.0% +4.03Ki  [ = ]       0    .debug_info
+0.0% +1.15Ki  [ = ]       0    .debug_line
   +50%      +1  [ = ]       0    [Unmapped]
  +0.0% +1.15Ki  [ = ]       0    [section .debug_line]
+0.0% +1.50Ki  [ = ]       0    .debug_loclists
+0.0%    +197  [ = ]       0    .debug_rnglists
+0.1% +2.23Ki  [ = ]       0    .debug_str
-0.4%      -1  [ = ]       0    .shstrtab
+0.1%    +797  [ = ]       0    .strtab
  [NEW]     +10  [ = ]       0    CSWTCH.64
  [NEW]     +10  [ = ]       0    CSWTCH.68
  [NEW]     +55  [ = ]       0    PowerMonitorSelectorAuterion::crc16_update()
  [NEW]     +49  [ = ]       0    PowerMonitorSelectorAuterion::eeprom_read()
  [NEW]     +73  [ = ]       0    PowerMonitorSelectorAuterion::eeprom_read_block()
  [NEW]     +51  [ = ]       0    PowerMonitorSelectorAuterion::get_ina_type()
  [NEW]     +56  [ = ]       0    PowerMonitorSelectorAuterion::get_start_command()
  +2.0%      +1  [ = ]       0    PowerMonitorSelectorAuterion::ina226_probe()
  [DEL]     -41  [ = ]       0    PowerMonitorSelectorAuterion::init()
  [NEW]     +90  [ = ]       0    PowerMonitorSelectorAuterion::is_eeprom_block_header_valid()
  [NEW]     +79  [ = ]       0    PowerMonitorSelectorAuterion::is_eeprom_header_valid()
  [NEW]     +57  [ = ]       0    PowerMonitorSelectorAuterion::is_user_configured()
  [NEW]     +57  [ = ]       0    PowerMonitorSelectorAuterion::set_float_param()
  [NEW]     +55  [ = ]       0    PowerMonitorSelectorAuterion::set_max_current()
  [NEW]     +55  [ = ]       0    PowerMonitorSelectorAuterion::set_shunt_value()
  [NEW]     +49  [ = ]       0    PowerMonitorSelectorAuterion::start_pm()
  [NEW]     +54  [ = ]       0    PowerMonitorSelectorAuterion::try_eeprom_start()
  [NEW]     +53  [ = ]       0    PowerMonitorSelectorAuterion::try_probe_start()
  -0.0%     -11  [ = ]       0    [section .strtab]
  [DEL]      -5  [ = ]       0    itoa
+0.1%    +544  [ = ]       0    .symtab
  [NEW]     +32  [ = ]       0    CSWTCH.64
  [NEW]     +32  [ = ]       0    CSWTCH.68
  [NEW]     +16  [ = ]       0    PowerMonitorSelectorAuterion::crc16_update()
  [NEW]     +64  [ = ]       0    PowerMonitorSelectorAuterion::eeprom_read()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::eeprom_read_block()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::get_ina_type()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::get_start_command()
  [DEL]     -48  [ = ]       0    PowerMonitorSelectorAuterion::init()
  [NEW]     +16  [ = ]       0    PowerMonitorSelectorAuterion::is_eeprom_block_header_valid()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::is_eeprom_header_valid()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::is_user_configured()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::set_float_param()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::set_max_current()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::set_shunt_value()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::start_pm()
  [NEW]     +16  [ = ]       0    PowerMonitorSelectorAuterion::try_eeprom_start()
  [NEW]     +48  [ = ]       0    PowerMonitorSelectorAuterion::try_probe_start()
 -200.0%     -64  [ = ]       0    [1 Others]
  -0.3%     -32  [ = ]       0    [section .symtab]
   +50%     +16  [ = ]       0    atof
  +100%     +16  [ = ]       0    atol
-16.5%    -864  [ = ]       0    [Unmapped]
+0.0% +11.1Ki  +0.0%    +864    TOTAL

Updated: 2025-08-05T09:29:20

@mrpollo mrpollo force-pushed the pr-auterion-pm-eeprom branch from 5bfafea to 01923a0 Compare June 30, 2025 19:13
@mrpollo
Copy link
Contributor

mrpollo commented Jun 30, 2025

Rebased to load recent fixes to the SITL tests

@dirksavage88
Copy link
Contributor

@alexcekay what is the specific eeprom used? I am working on incorporating eeprom at the px4 platform common layer and then also incorporating a "device discovery" module in src/modules that handles the character device conversion using Cdev. If that works you can technically just call "px4_open("/dev/eeprom0", xx)" and abstract a lot of the low level i2c calls away.

This is only targeting i2c eeproms for now as I am using this nuttx eeprom i2c driver, and you can use this in combination with Cdev to handle the struct file pointers. I guess this is in contrast to manually doing the i2c transfers, but if it works it works.

@alexcekay
Copy link
Member Author

alexcekay commented Jul 2, 2025

Hi @dirksavage88,
we use different I2C EEPROMs, they basically all use the same simple protocol. Only diff between them is if 1 or 2 byte are used for addressing, but in our case we only use ones with 2 byte addressing. If you need one example: CAT24C512.

I think in general abstraction is a really good idea, just note that we already have the MTD abstraction px4_24xxxx_mtd.c that allows to abstract I2C EEPROMs.

In this particular case I did not use this abstraction due to the requirement of dynamically detecting EEPROMs that may or may not be present on the Power Module. The MTD abstraction sort of expects that the EEPROM is actually there.

@alexcekay alexcekay force-pushed the pr-auterion-pm-eeprom branch from 01923a0 to e17f272 Compare July 4, 2025 15:56
@alexcekay alexcekay marked this pull request as ready for review July 4, 2025 15:57
@mrpollo mrpollo force-pushed the pr-auterion-pm-eeprom branch from e17f272 to e2e8b12 Compare July 18, 2025 18:16
@alexcekay alexcekay force-pushed the pr-auterion-pm-eeprom branch 2 times, most recently from 79ea004 to 2212448 Compare August 5, 2025 09:23
@mrpollo mrpollo merged commit 38c7767 into main Aug 5, 2025
139 of 142 checks passed
@mrpollo mrpollo deleted the pr-auterion-pm-eeprom branch August 5, 2025 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants