Skip to content

Conversation

@Concode0
Copy link
Contributor

Description

  • Adds a burst_write_size field to the Bmi270::Config struct, allowing users to specify the chunk size used during the configuration file upload.

Motivation and Context

On devices with limited stack size (such as the ESP32-C3), the default burst write operation during the BMI270 initialization can cause a Stack Protection Fault (Panic).

How has this been tested?

I tested this on an ESP32-C3 where the initialization was previously failing with a stack panic.

  1. Hardware: ESP32-C3 (Revision v0.4)
  2. Environment: ESP-IDF v5.4.3
  3. Test Case:
    • Initialized espp:Bmi270 with default config.
    • Verified that the sensor initializes correctly without triggering a stack overflow panic.

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

[BMI270 Example/I][0.044]: Starting example!
[BMI270 Example/I][0.050]: Found BMI270 at address: 0x68
[Bmi270/I][0.057]: Setting low power mode to disabled
[Bmi270/I][0.061]: Loading BMI270 configuration file (8192 B), this may take some time...
Guru Meditation Error: Core  0 panic'ed (Stack protection fault).

Detected in task "main" at 0x4201ab88
--- 0x4201ab88: espp::BasePeripheral<unsigned char, true, true, true>::write_many_to_register(unsigned char, unsigned char const*, unsigned int, std::error_code&) at /PATH/managed_components/espp__base_peripheral/include/base_peripheral.hpp:606
Stack pointer: 0x3fc92430
Stack bounds: 0x3fc93a08 - 0x3fc94a00

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes. ( manual testing performed )
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

Hardware

  • I have updated the design files (schematic, board, libraries).
  • I have attached the PDFs of the SCH / BRD to this PR
  • I have updated the design output (GERBER, BOM) files.

@github-actions
Copy link

✅Static analysis result - no issues found! ✅

@finger563 finger563 self-requested a review November 30, 2025 20:51
Copy link
Contributor

@finger563 finger563 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the improvement! I've got a minor suggestion to ensure no change in behavior for existing users but once that's changed it looks good!

@finger563 finger563 added bug Something isn't working enhancement New feature or request bmi270 labels Nov 30, 2025
@Concode0 Concode0 force-pushed the fix/bmi270-init-panic branch from 8db49be to 67eb33a Compare November 30, 2025 23:48
@finger563 finger563 requested a review from Copilot December 1, 2025 14:32
Copilot finished reviewing on behalf of finger563 December 1, 2025 14:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a configurable burst_write_size parameter to address stack overflow issues on memory-constrained devices (e.g., ESP32-C3) during BMI270 sensor initialization. The configuration file upload previously used the full 8192-byte size for burst writes, which could exceed stack limits on certain platforms.

Key Changes:

  • Added burst_write_size field to Bmi270::Config struct with default value of 0 (which defaults to full config file size for backward compatibility)
  • Modified constructor to initialize burst_write_size_ member based on config value
  • Updated load_config_file() to use configurable burst size instead of hardcoded full file size

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

finger563 and others added 2 commits December 2, 2025 08:24
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@finger563 finger563 merged commit 242d690 into esp-cpp:main Dec 2, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bmi270 bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants