Restore BALA2 fire firmware for selfbalancing robot

  • After testing UIFlow (Blockly, MicroPython) on my new BALA2 fire (bought in May 2023, everything worked fine) I tried to restore the firmware for m5stack Fire Bala2. I wanted to come back to the selfbalancing robot.

    I started Arduino 2.1.0, integrated all the necessary files ( and Library M5Stack by M5Stack), selected as Board: M5stack-FIRE and as Port: dev/cu.wchusbserial..., PSRAM: is "Enabled". Then I tried several Arduino-programs from Examples -> M5Stack, for example FactoryTest and IMU. They are all running.

    Finally I came back to my real goal: BALA2 (M5Stack -> Modules -> BALA2). But for the first time I got an error message in imu_filter.cpp: "class IMU has no member named" in
    Line 109 M5. IMU. setFIFOEnable (true);
    Line 110 M5. IMU. RestFIF0 ();
    Line 118 fifo_count = M5. IMU. ReadFIFOCount () ;
    Line 119 M5. IMU. ReadFIFOBuff(fifo_buff, fifo_count);

    When I was running the file IMU.ino all the M5.IMU.get... commands worked well!

    I also tried BALA2.ino with the Board: M5Stack-Core-ESP32 but I got the same error.

    What can I do to restart my BALA2 fire as the self balancing "robot"? Where do I find the missing "members" of class IMU? Or where do I have to insert them in a file (which one)?

    I would be pleased to get an answer because I've been looking for a solution for two weeks and I've no more idea.

    Thanks for your help.


  • Hello @wzemann

    have a look at my PR. I've added the missing functions.

    Note: I do not have a Bala2 so I cannot test if the resulting firmware is correct.


  • Hi Felix,

    thanks a lot for your quick support. Now I have to implement your lines in the BALA2.ino program. I'm not so experienced so it will take a bit of time. There are some differences to your IMU.h and IMU.cpp, but with your help I think I'm on the right track now.


  • Is not the factory Bala code in M5Burner?

  • Hi,

    that would be fine, but ...

    1. m5burner burns only UIFlow_Fire, the base for working with UIFLow ->

    2. UIFlow (desktop-version): there only exists BALA, but no BALA2 and there are important differences between them

    3. UIFlow (web-version): there are two modules
      a) BALA with the option balance loop (but doesn't run with BALA2)
      b) BALA2 but without the option balance loop!

    That's a bit stupid and I don't know why but ...


  • Nope m5 burner burns all know compiled firmwares for devices including factory and user demos

  • Thanks for the answer, but ...

    if I start m5burner, select UIFlow_Fire, configure WLAN and USB-Driver and burn ... I only get the API-Key message, the setup menu and the app menu ( on the display ... nothing else to do.

    I can now start UIFlow and program the device
    with blockly (-> modules -> bala2, there are some commands for the encoder motors ... but not for selfbalancing!)
    or with micro python (but there is no list of the available commands for selfbalancing)

    now back to m5burner:
    I also tried the upper menu
    – Serial Monitor: successfully connects to the device
    – Firmware Exporter: exports an esp32fw.bin file?
    – Refresh Firmwares: nothing happens?!

    After m5burner, UIFlow Blockly, UIFlow Micropython I finally tried Arduino. There is indeed a file FactoryTest (Examples -> M5Stack -> Basic: FactoryTest) and it works but it' s not the program for selfbalancing then I tried bala2.ino (Examples -> M5Stack -> Modules: BALA2) ... and I got the error message above.

    No matter which way I choose I don't succeed in restoring the original (delivery-)code with the self balancing car that's what I mean with restoring the firmware.

    If you have a new idea tell me please.