UNITY 23.44 baud 250k + PPM bug

We found a bug with latest UNITY firmware. When baud rate is 250k, FOCBOX UNITY stops replying via UART. IMPORTANT, this only happens when PPM is enabled and only with “Current No Reverse with Brake” control mode when brake is fully engaged. We verified it on multiple FOCBOXes and multiple BLE modules.

  • Verified on two UNITYs from beta batch (with metal cover)
  • Verified on UNITY from bioboards with silicon cover
  • Verified with factory UNITY BLE module in internal UART port
  • Verified with Metr Pro UNITY BLE module in internal UART port
  • Verified with Metr Pro BLE module and external UART port
  • Verified with nrf51_vesc BLE module from aliexpress and modified nrf51_vesc (250k baud) firmware and external UART port

Old FOCBOX with latest firmware 3.58 does not have this bug. Only UNITY.

Steps to reproduce:

  1. Enable PPM, set control type to Current No Reverse with Brake
  2. Open any mobile app that requests realtime data every second
  3. Brake
  4. Observe no reply coming from UNITY via BLE

Quick workarounds

  1. Change internal baud rate to 115200 - fixes the problem, but bad solution since all factory BLE modules are configured to 250k and will stop working
  2. Change optimisation level from -O2 to -Ofast. This somehow helps, but I have no idea why. This is more scary. When I disabled optimisations completely -O0, I could no longer upload firmware via USB (it stucks on 20%). I worry that changing optimisation level will impact more stuff, especially ride behaviour. But actually I know very little about VESC firmware so I better not comment on that. I just saw that in previous versions of UNITY firmware it was -Ofast, so maybe it’s a way to go?

I reported this bug to Enertion on Jul 13 in hopes they will fix it. Here is the reply from @Deodand

Thanks for the info. With this data I was able to write a possible fix. If you simply up the IRQ priority of USART Driver 1 in mcu_conf.h:

from:

#define STM32_SERIAL_USART1_PRIORITY        12

To:

#define STM32_SERIAL_USART1_PRIORITY        3

It solves the problem. I think the driver was getting interrupted by other drivers and not functioning correctly.

I would be a bit careful raising UART priority that high, but then again, I don’t have enough knowledge. It just feels wrong to me that UART priority is higher than PPM priority.

Personally I will continue on 115200 baud workaround for now until official firmware with 250k fix will be released. A firmware with 115200 workaround https://www.icloud.com/iclouddrive/0pnwaB-qs0BrIiF6OQYkH00QA#UNITY_23_44_btuart115200

19 Likes

This is for the unity you said obviously, thanks for putting it together and hopefully it will fix the issue. Wanting to use it but was curious as to if you also made a version that will work with the VESC tool instead of the BLDC tool by chance @rpasichnyk

@rpasichnyk

Have you found out if this new 23.44 fw for unity fixes this specific current brake no reverse ppm bug? (new firmware, same ver? Wth )

Something is mentioned in the changelog, but it’s not very specific :wink:

Let us know, when you know.

Thanks again Roman :blush::+1:

Nice versioning BTW.

0cb90dc9431b991b17b1fa2326c31b0eb243723f_2_690x418

2 Likes