Updated Firmware to 0,52.0 and not app causes Bus Fault

Just updated to 0.52.0 and running a App that ran fine under 0.51.0 is causing as bus fault:
BMI270 Example 1 - Basic Readings I2C
BMI270 connected!
bmm150 init success!
[00:00:01.196,000] os: ***** BUS FAULT *****
[00:00:01.203,000] os: Precise data bus error
[00:00:01.211,000] os: BFAR Address: 0xd4c2c834
[00:00:01.219,000] os: r0/a1: 0x00008666 r1/a2: 0xd4c2c828 r2/a3: 0x00000003
[00:00:01.230,000] os: r3/a4: 0x7487fde3 r12/ip: 0x46002400 r14/lr: 0x08016f8d
[00:00:01.241,000] os: xpsr: 0x29002c00
[00:00:01.248,000] os: s[ 0]: 0x0000867e s[ 1]: 0x20055ee8 s[ 2]: 0x00000000 s[ 3]: 0x00000003
[00:00:01.261,000] os: s[ 4]: 0x00000002 s[ 5]: 0x08017005 s[ 6]: 0x00000002 s[ 7]: 0x20055ee8
[00:00:01.274,000] os: s[ 8]: 0x00000000 s[ 9]: 0x2001e601 s[10]: 0x20020dba s[11]: 0x00000c30
[00:00:01.286,000] os: s[12]: 0xffffffff s[13]: 0x08017327 s[14]: 0x200221d0 s[15]: 0x00000008
[00:00:01.299,000] os: fpscr: 0x00000000
[00:00:01.306,000] os: Faulting instruction address (r15/pc): 0x08016ec2
[00:00:01.316,000] os: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0
[00:00:01.326,000] os: Current thread: 0x200029d0 (main)
[00:00:01.335,000] os: Halting system

Running my BMI150-BMM270 app: Arduino-Q-Apps/bmm150_bmi270_ahrs at main · mjs513/Arduino-Q-Apps which uses Sparkfun BMI270 and DFRobot BMM150 libraries. The arduino sketch collect data and sends to python and the python sends AHRS data back to the Arduion. It does use the Python AHRS python package.

From the output it looks like it is connecting to both sensors and then crashes so now sure if its a comm issue.

I updated in the ide as well and ran the BMI270 test sketch and it ran fine so guess its something other than i2c.

This is not a good sign.

Hi @Merlin513

Are the modifications you made to the core for adding support for math symbols still in place? Can you try removing them?

Thanks

Hi @Merlin513,

Could you please remove the .cache directory from the app so it performs a clean build?

Also, try forcing the update of the bootloader. From the Uno Q shell, run

arduino-cli burn-bootloader -b arduino:zephyr:unoq -P jlink

Let me know.

Deleted the cache still getting the bus fault.

Also, try forcing the update of the bootloader. From the Uno Q shell, run

Flashed bootloader and deleted cache: Still getting the same bus fault:
BMI270 connected!
bmm150 init success!
[00:00:01.196,000] os: ***** BUS FAULT *****
[00:00:01.203,000] os: Precise data bus error
[00:00:01.211,000] os: BFAR Address: 0xb4c2c834
[00:00:01.219,000] os: r0/a1: 0x00008666 r1/a2: 0xb4c2c828 r2/a3: 0x00000003
[00:00:01.230,000] os: r3/a4: 0x3c93fde3 r12/ip: 0x46002400 r14/lr: 0x08016f8d
[00:00:01.241,000] os: xpsr: 0x29002c00
[00:00:01.248,000] os: s[ 0]: 0x0000867e s[ 1]: 0x20055ee8 s[ 2]: 0x00000000 s[ 3]: 0x00000003
[00:00:01.261,000] os: s[ 4]: 0x00000002 s[ 5]: 0x08017005 s[ 6]: 0x00000002 s[ 7]: 0x20055ee8
[00:00:01.274,000] os: s[ 8]: 0x00000000 s[ 9]: 0x2001e601 s[10]: 0x20020dba s[11]: 0x00000c30
[00:00:01.286,000] os: s[12]: 0xffffffff s[13]: 0x08017327 s[14]: 0x200221d0 s[15]: 0x00000008
[00:00:01.299,000] os: fpscr: 0x00000000
[00:00:01.306,000] os: Faulting instruction address (r15/pc): 0x08016ec2
[00:00:01.316,000] os: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0
[00:00:01.326,000] os: Current thread: 0x200029d0 (main)
[00:00:01.335,000] os: Halting system

As for the math.h changes - supposed to be in then loader directory but I can’t seem to find it:
image

Did a bit more debugging and found that as soon as I do in the Arduino sketch:
Bridge.begin();

it crashes. There are no other bridge calls like Bridge.provide….

Hi @Merlin513

So, if you comment out all the Bridge-related calls, is the sketch working correctly and showing the readings on TX/RX?

Yes is I remove all Bridge calls and remove python script the sketch runs without an issue:

Acceleration in g's     X: -0.000732,   Y: -0.011963,   Z: 0.991943
Rotation in deg/sec     X: 0.122070,    Y: 0.122070,    Z: 0.061035
Mag data in uT  X: 17,  Y: 14,  Z: -1
the angle between the pointing direction and north (counterclockwise) is:50.53

Acceleration in g's     X: -0.000977,   Y: -0.014160,   Z: 0.991699
Rotation in deg/sec     X: 0.061035,    Y: 0.061035,    Z: 0.122070
Mag data in uT  X: 17,  Y: 14,  Z: -1
the angle between the pointing direction and north (counterclockwise) is:50.53

If I add Bridge.begin to setup the error returns:

uart:~$ BMI270 Example 1 - Basic Readings I2C
BMI270 connected!
bmm150 init success!
[00:00:01.196,000] os: ***** BUS FAULT *****
[00:00:01.203,000] os: Precise data bus error
[00:00:01.211,000] os: BFAR Address: 0x20297efc
[00:00:01.219,000] os: r0/a1: 0x20055ee8 r1/a2: 0x20297ef8 r2/a3: 0x00000001
[00:00:01.230,000] os: r3/a4: 0x00046302 r12/ip: 0x46002400 r14/lr: 0x08016ed5
[00:00:01.241,000] os: xpsr: 0x29002c00
[00:00:01.248,000] os: s[ 0]: 0x00000010 s[ 1]: 0x08016ff7 s[ 2]: 0x00000002 s[ 3]: 0x20055ee8
[00:00:01.261,000] os: s[ 4]: 0x00000000 s[ 5]: 0x2001e101 s[ 6]: 0x200208e3 s[ 7]: 0x00000c30
[00:00:01.273,000] os: s[ 8]: 0xffffffff s[ 9]: 0x08017327 s[10]: 0x20021c80 s[11]: 0x00000008
[00:00:01.286,000] os: s[12]: 0x00000000 s[13]: 0x0800adf3 s[14]: 0x0800ade1 s[15]: 0x20021c80
[00:00:01.298,000] os: fpscr: 0x2001d21d
[00:00:01.306,000] os: Faulting instruction address (r15/pc): 0x08016eac
[00:00:01.316,000] os: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0
[00:00:01.326,000] os: Current thread: 0x200029d0 (main)
[00:00:01.335,000] os: Halting system
uart:~$

As I said this started with the release of 0.52.0

As a test which I forgot to do yesterday I ran the example from: Arduino Uno Q and Bridge Tool: any samples and documentation? - UNO Family / UNO Q - Arduino Forum and it worked so not sure what is going on or where the issue is yet

@manchuino is there some sort of tests you want me to add to see whats going on?

1 Like

Hi @Merlin513

I’m thinking about an issue caused by a race condition (the Python script starting the Bridge communication too early, while the sketch isn't yet ready), or by nasty interleaving in the Bridge communication. I have a few test requests for you:

  1. Try moving the Bridge.begin() and the Bridge.provide() at the very start of the sketch, as the first lines of the setup().
  2. Also, I see that in the Python script, you are calling the Bridge.call() inside the callback that gets called by the Sketch. So the Sketch is asked to respond to an RPC call while still waiting for the return from the Bridge.notify(). This is known to cause problems, and a fix is under development. In any case, you should decouple the Bridge.call() in the Python script from the get_data callback. For example, you can store the values received from the Sketch in global variables, a list, or a queue, and process them in the main application loop (see the “Blink LED” example for a user-defined loop example).

Let me know.

@Merlin513 Wondering how hard it would be to setup this sketch that maybe
@manchuino and/or others at Arduino can run it?

Which sensor is it? Probably
SparkFun 6DoF IMU Breakout - BMI270 (Qwiic) - SparkFun Electronics

Will it still run and show the crash if you don't have one plugged in?

I am not sure if I have one, If I do it might take me a while to find it, in my well organized office. :grinning_face: Currently I have some other distractions that will keep me
from doing much here.

Wonder how well it might work with their Modulino sensor?
Amazon.com : modulino

@manchuino - Is it possible to localize down where it is faulting.

That is in the first post I see the address: Faulting instruction address (r15/pc): 0x08016ec2

Now if I were building this using Arduino IDE, and you could locate the build output
files, you could use the addr2line command to find out where that address is.
and/or look at map file. But earlier with ArduinoCore-zephyr builds, you would
simply find out it is in the LTEXT somewhere. However was told that if you built
using the Link Mode = Static, you might actually be able to localize it to the file/line...
I have not yet tried this as the two boards I have done the most with (Giga and Portenta H7) Arduino has not yet added that option. But UNO Q has that option...
But - I have no idea what options are being used by App Lab nor any way to change them.

Ok moved Bridge.begin and removed the Bridge.provide()

void setup()
{
Bridge.begin();
//Bridge.provide("get_euler", get_euler);

// Start serial
Serial.begin(115200);
Serial.println("BMI270 Example 1 - Basic Readings I2C");

going to do it simply first also commented out the //Bridge.provide``("get_euler", get_euler); and just try to print data received from the sketch:

values.append(my)
values.append(mz)
process_values(values)

def process_values(values):
print("Accel: %f.6, %f.6, %f.6" % (values[0], values[1], values[2]))
print("Gyro: %f.6, %f.6, %f.6" % (values[3], values[4], values[5]))
print("Mag: %d, %d, %d" % (values[6], values[7], values[8]))

Update orientation using gyroscope + accelerometer + magnetometer

global q
q = madgwick.updateMARG(q, gyr=[values[3], values[4], values[5]], acc=[values[0], values[1], values[2]], mag=[values[6], values[7], values[8]])

If you don't have magnetometer data, use updateIMU:

q = madgwick.updateIMU(q, gyr=gyro_data, acc=accel_data)

#print("Updated Quaternion:", q)

quaternion_to_euler(q)
print("---------------------------------------")

Note Bridge.notify("get_data", imu.data.accelX, imu.data.accelY, imu.data.accelZ, imu.data.gyroX, imu.data.gyroY, imu.data.gyroZ, magData.x, magData.y, magData.z); is still the sketch loop.

This still got me the same error.

Ok changed Bridge.notify to Bridge.calland still got the bus fault - note this is with not trying to return anything.

@Merlin513

Could you shorten the path from get_data exit so it returns to the sketch early?

Before returning a response to the sketch, it goes through process_values, then to quaternion_to_euler, then back to process_values, and then back to get_data. It is way too long a path: the get_date must behave like an ISR, spending as little time in its body as possible to return control to the callee. You must, at least, move process_values out of get_data and call it in the main loop.

Let me know

Ok shortened the python sketch just as a test
from arduino.app_utils import *

import time
from arduino.app_utils import App, Bridge

def get_data(ax: float, ay: float, az: float, gx: float, gy: float, gz: float, mx: int, my: int, mz: int):
"""Callback invoked by the board sketch via Bridge.notify to send sensor samples.
"""
x_ms2 = ax * 9.81
y_ms2 = ay * 9.81
z_ms2 = az * 9.81
gx_rads = gx * 0.01745329
gy_rads = gy * 0.01745329
gz_rads = gz * 0.01745329
values = []
values.append(x_ms2)
values.append(y_ms2)
values.append(z_ms2)
values.append(gx_rads)
values.append(gy_rads)
values.append(gz_rads)
values.append(mx)
values.append(my)
values.append(mz)
print("Accel: %f.6, %f.6, %f.6" % (values[0], values[1], values[2]))
print("Gyro: %f.6, %f.6, %f.6" % (values[3], values[4], values[5]))
print("Mag: %d, %d, %d" % (values[6], values[7], values[8]))

#Create bridge to arduino

Bridge.provide("get_data", get_data)
print("Starting App...")
App.run()

Sketch not changed - still got the bus error. Not sure I could make it any shorter

Will give it a try. Ok with the sensors not plugged in still getting the bus fault:

[00:00:00.221,000] os: ***** BUS FAULT *****
[00:00:00.228,000] os: Precise data bus error
[00:00:00.236,000] os: BFAR Address: 0x200c014c
[00:00:00.244,000] os: r0/a1: 0x20055ee8 r1/a2: 0x200c0148 r2/a3: 0x00000001
[00:00:00.255,000] os: r3/a4: 0x0000d448 r12/ip: 0x46002400 r14/lr: 0x08016ed5
[00:00:00.266,000] os: xpsr: 0x29002c00
[00:00:00.273,000] os: s[ 0]: 0x00000010 s[ 1]: 0x08016ff7 s[ 2]: 0x00000002 s[ 3]: 0x20055ee8
[00:00:00.286,000] os: s[ 4]: 0x2001e3e1 s[ 5]: 0x00000000 s[ 6]: 0x08094930 s[ 7]: 0x00000c30
[00:00:00.298,000] os: s[ 8]: 0xffffffff s[ 9]: 0x08017327 s[10]: 0x20021f60 s[11]: 0x00000008
[00:00:00.311,000] os: s[12]: 0x2001e3e1 s[13]: 0x0800adf3 s[14]: 0x0800ade1 s[15]: 0x20021f60
[00:00:00.324,000] os: fpscr: 0x2001e3a5
[00:00:00.331,000] os: Faulting instruction address (r15/pc): 0x08016eac
[00:00:00.341,000] os: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0
[00:00:00.351,000] os: Current thread: 0x200029d0 (main)
[00:00:00.360,000] os: Halting system

Seems to happen as soon as Bridge.begin happens. Not sure why that is the case. Know the were playing around with memory areas for 0.52.0.

@manchuino

Is there a way to revert back to using 0.51.0. Also with this looks like you can test as well since you dont need the sensors the librarys and python package

@manchuino - @KurtE

Managed to determine that there seems to be some sort of conflict between Bridge and the SparkFun BMI270 library. If I create an app that just reads and prints magnetometer from the BMM150 it seems to work.
Sketch:

#include <Arduino_RouterBridge.h>
#include "Wire.h"

#include "DFRobot_BMM150.h"
DFRobot_BMM150_I2C bmm150(&Wire1, 0x13); //0x10-nano, 0x13dfrobot

void setup() {
Bridge.begin();
Serial.begin(115200);
delay(2000);

Wire1.begin();
Wire1.setClock(1000000);
while(bmm150.begin()){
Serial.println("bmm150 init failed, Please try again!");
delay(1000);
} Serial.println("bmm150 init success!");
bmm150.setOperationMode(BMM150_POWERMODE_NORMAL);
bmm150.setPresetMode(BMM150_PRESETMODE_HIGHACCURACY);
bmm150.setRate(BMM150_DATA_RATE_25HZ);
bmm150.setMeasurementXYZ();
}

void loop() {
sBmm150MagData_t magData = bmm150.getGeomagneticData();

Serial.print("mag x = "); Serial.print(magData.x); Serial.println(" uT");
Serial.print("mag y = "); Serial.print(magData.y); Serial.println(" uT");
Serial.print("mag z = "); Serial.print(magData.z); Serial.println(" uT");

float compassDegree = bmm150.getCompassDegree();
Serial.print("the angle between the pointing direction and north (counterclockwise) is:");
Serial.println(compassDegree);
Serial.println("--------------------------------");

Bridge.call("get_data", magData.x, magData.y, magData.z);

delay(50);

}

Python

from arduino.app_utils import *

def get_data( mx: int, my: int, mz: int):
"""Callback invoked by the board sketch via Bridge.notify to send sensor samples.
"""
values = []
values.append(mx)
values.append(my)
values.append(mz)
process_values(values)

def process_values(values):
print("Mag: %d, %d, %d" % (values[0], values[1], values[2]))
print("---------------------------------------")

#Create bridge to arduino

Bridge.provide("get_data", get_data)
print("Starting App...")
App.run()

However if I change the sketch and start the BMI270

Then the bus fault appears again
[00:00:00.221,000] os: ***** BUS FAULT *****
[00:00:00.228,000] os: Precise data bus error
[00:00:00.236,000] os: BFAR Address: 0x200c798c
[00:00:00.244,000] os: r0/a1: 0x20055ee8 r1/a2: 0x200c7988 r2/a3: 0x00000001
[00:00:00.255,000] os: r3/a4: 0x0000e328 r12/ip: 0x46002400 r14/lr: 0x08016ed5
[00:00:00.266,000] os: xpsr: 0x29002c00
[00:00:00.273,000] os: s[ 0]: 0x00000010 s[ 1]: 0x08016ff7 s[ 2]: 0x00000002 s[ 3]: 0x20055ee8
[00:00:00.286,000] os: s[ 4]: 0x2001e269 s[ 5]: 0x00000000 s[ 6]: 0x08094930 s[ 7]: 0x00000c30
[00:00:00.298,000] os: s[ 8]: 0xffffffff s[ 9]: 0x08017327 s[10]: 0x20021d68 s[11]: 0x00000008
[00:00:00.311,000] os: s[12]: 0x2001e269 s[13]: 0x0800adf3 s[14]: 0x0800ade1 s[15]: 0x20021d68
[00:00:00.324,000] os: fpscr: 0x2001e22d
[00:00:00.331,000] os: Faulting instruction address (r15/pc): 0x08016eac
[00:00:00.341,000] os: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0
[00:00:00.351,000] os: Current thread: 0x200029d0 (main)
[00:00:00.360,000] os: Halting system

Not really sure why since when I ran it under 0.51.0 there was no issue. See: First App: BMM150/BMI270 IMU/AHRS Test - UNO Family / UNO Q - Arduino Forum

1 Like

@Merlin513

We are investigating.

In the meantime, if you want to switch back to 0.51.0, you can edit the sketch.yaml file in the sketch folder of your App and modify line 5 from:

* platform: arduino:zephyr

to

* platform: arduino:zephyr (0.51.0)

Then you need to install the corresponding bootloader on the MCU. From the Linux shell, execute the following commands:

$ arduino-cli core install arduino:zephyr@0.51.0
$ arduino-cli burn-bootloader -b arduino:zephyr:unoq -P jlink

Let me know

Thanks for the info. Another question if I may. Whats the correct way to install a custom library. Normally I would just add it to the Arduino Libraries folder on my PC. I did notice that the libraries seem to be in the ./cache folder

@manchuino

Since I am a glutton for punishment I ran the sketch portion of the app in IDE 2.3.7 nigthly and to my surprise it worked without issue:

Acceleration in g's     X: 0.014        Y: -0.018       Z: 0.991        Rotation in deg/sec     X: 0.061        Y: 0.061        Z: 0.183
mag x = 18 uT
mag y = 5 uT
mag z = -2 uT
the angle between the pointing direction and north (counterclockwise) is:74.48
--------------------------------
Acceleration in g's     X: 0.014        Y: -0.019       Z: 0.992        Rotation in deg/sec     X: 0.183        Y: -0.061       Z: 0.122
mag x = 18 uT
mag y = 6 uT
mag z = -2 uT
the angle between the pointing direction and north (counterclockwise) is:71.57
--------------------------------
Acceleration in g's     X: 0.014        Y: -0.018       Z: 0.993        Rotation in deg/sec     X: 0.000        Y: 0.061        Z: 0.061
mag x = 18 uT
mag y = 6 uT
mag z = -2 uT
the angle between the pointing direction and north (counterclockwise) is:71.57
--------------------------------
Acceleration in g's     X: 0.013        Y: -0.018       Z: 0.990        Rotation in deg/sec     X: 0.000        Y: 0.183        Z: 0.000
mag x = 18 uT
mag y = 6 uT
mag z = -1 uT
the angle between the pointing direction and north (counterclockwise) is:71.57
--------------------------------
Acceleration in g's     X: 0.014        Y: -0.021       Z: 0.991        Rotation in deg/sec     X: 0.061        Y: 0.183        Z: 0.061
mag x = 19 uT
mag y = 6 uT
mag z = -2 uT
the angle between the pointing direction and north (counterclockwise) is:72.47
--------------------------------
Acceleration in g's     X: 0.013        Y: -0.018       Z: 0.992        Rotation in deg/sec     X: 0.000        Y: 0.061        Z: 0.183
mag x = 18 uT
mag y = 6 uT
mag z = -2 uT
the angle between the pointing direction and north (counterclockwise) is:71.57
--------------------------------
Acceleration in g's     X: 0.014        Y: -0.019       Z: 0.993        Rotation in deg/sec     X: -0.061       Y: 0.122        Z: 0.183
mag x = 18 uT
mag y = 5 uT
mag z = -1 uT
the angle between the pointing direction and north (counterclockwise) is:74.48
--------------------------------

again this is just the Arduino sketch portion.

Also out of curiosity I tried just running the python script from the shell

python3 main.py

and got the following error
arduino@arduinoQ:~/ArduinoApps/copy-of-bmm150_bmi270_ahrs/python$ python3 main.py Traceback (most recent call last): File "/home/arduino/ArduinoApps/copy-of-bmm150_bmi270_ahrs/python/main.py", line 1, in <module> from arduino.app_utils import * ModuleNotFoundError: No module named 'arduino'

Is there anyway around that?

Not at the moment, unfortunately.

The Python source code for the libraries included in the Arduino containers is available here: GitHub - arduino/app-bricks-py: The code of the Arduino App Lab Bricks.

Cheers!