foxBMS / foxbms-2

foxBMS 2, online documentation at https://docs.foxbms.org
https://foxbms.org
Other
263 stars 121 forks source link

Master crashes when configuring 2 slave strings #61

Closed niktwo17 closed 1 week ago

niktwo17 commented 2 weeks ago

Hi foxBMS-team,

when I set #define BS_NR_OF_STRINGS (2u) (in battery_system_cfg.h) the master instantly crashes, upon startup. Please see the picture below. Tested with both releases 1.6.0 and 1.7.0. No changes made besides number of strings.

image

Edit: I found the issue, the initialization is incorrect causing a nullpointer write when starting SPI driver.

image

@foxBMS Please find a possible fix here #62

Thanks for your support, Niklas

foxBMS commented 1 week ago

Dear @niktwo17,

The BMS software works for multiple strings. You need to adapt the SPI configuration to be able to use multiple strings. If you do not adapt it, then the array containing the SPI configuration is initialized invalid and you will access invalid memory, therefore the BMS chrashes.

We will update the documentation's how-to section in the next release on how to use multiple strings.

Best regards, The foxBMS Team

niktwo17 commented 1 week ago

Thanks for the answer @foxBMS. However, I still think it makes sense to change code in a way where not only the first instance of a struct with configurable size is initialized - this will save others time in the future. And agreed, the solutions I proposed isn't nice, but as written I just wanted to outline a possible solution, and I trust you as maintainers to find a desirable way. When developing and debugging with different BMS setups having to constantly change multiple files is a huge headache.