Spark 3 hangs every few hours

Does this still happen with today’s firnware release?

Updated last night, no problems so far, looking good.

Forced wifi to change channel and the Spark hung.

If you switched to the earlier experimental release, did you switch back to edge (or ${BREWBLOX_RELEASE})?

Am using the following.

Then we won’t feel silly later at least.

For now I’d recommend keeping a fixed channel, and we’ll continue digging through the Wifi code.
Alternatively, if you have a spare Pi of any kind, I can write a quick guide for setting it up as Wifi to USB repeater. This lets you bypass the Wifi stack on the Spark itself.

The Wifi AP was and still is set to fixed channel.

I have found something. It seems that Particle made a change to the hard fault handler, without ever testing that it still worked. Simply unacceptable.

So this is caused by 2 Particle bugs:

  • An old bug in the wifi stack causes a hard fault (unrecoverable error) when the WiFi is lost. The code that contains the bug is closed-source, so I cannot help them fix it.
  • A recently introduced bug in the hard fault handler causes the device to completely lock up instead of rebooting.

I have created a PR with a fix at Particle:

And reported the WiFi bug again:

The hard fault handler bug is in the system layer, that the Spark 2 and 3 download directly from Particle.
We can build our own system binaries to flash over USB, but not for over-the-air updates. Therefore, I’ll try to push get Particle to do a hotfix release tomorrow.

1 Like

@Bob_Steers @Elco
My spark still having the hiccups, with the latest release.
It is no longer going into freeze, but is using too long time to restart. And when it do, it has to adjust outputs from zero.
Since my fermentation chamber is in my garage and I am living north of the polar circle and the temperature in the garage is below zero, the temperature in the chamber dropps like a stone.
Not so good for my fermentation :frowning:

Would have been nice if the spark could check if it was doing any regulation before it was rebooted and then start with the same outputs again. :astonished:

I am relly looking forward for a final solution on this issue.

Log: https://termbin.com/63qj1

We can have a look at storing and then loading some semi-volatile values, but the reboot is a response to a system crash. At that point, any PID calculations are no longer accessible.

To prevent hiccups until we either find a fix (or a workaround for a bug in system software), we recommend making sure that your wifi router uses a fixed channel, and only has a single access point in range.

If desired, I can do a writeup of instructions for a Pi (any model, including zero W) USB to Wifi bridge. This would prevent hiccups, at the drawback of having an additional Pi attached to your Spark.

I use google wifi mesh and can not set either channel or frequency, so then the only solution will be USB to wifi bridge. For that I need your help. I use RPI4.

Will do. The basic idea is straightforward enough, but I’ll need to double check the required configuration.

In the meantime, I’m trying to set up one of my older routers in fixed channel repeater mode and only 2.4 MHz

Edit: Could not get it right, so I awaits USB solution.

Creating a USB-to-LAN bridge for a Spark 3

To bypass the Spark Wifi, without having to connect your Brewblox server to your Spark over USB, you can use a second Pi as a bridge. This Pi will be discovered as a Wifi Spark, and can be used as such by Spark services.

Required:

  • Pi (any model)
  • USB cable

Installation

First, install the Raspberry Pi OS on your Pi.
After this is done, run:

sudo apt update
sudo apt install -y avahi-daemon socat

You do not need to install Brewblox on this Pi.

Preparation

First, we need to get the Spark device ID. To get this, run brewblox-ctl discover-spark on your Brewblox server, and copy the Device ID value.
Example device ID for a Spark 3: 400032001047383531363134.

Now stop your Brewblox services with brewblox-ctl down.

We want the Spark to no longer connect to Wifi. To clear Wifi credentials, hold the SETUP button until it first blinks dark blue, and then rapidly blinks light blue.

Configuration

We’re creating two configuration files:

  • a systemd service to start the bridge when the Pi starts.
  • an Avahi service to let the Pi be discovered as a Spark.

Create the systemd service file at /etc/systemd/system/spark-bridge.service

[Unit]
Description=Brewblox Spark Bridge

Wants=network.target
After=syslog.target network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/socat tcp-listen:8332,reuseaddr,fork file:/dev/ttyACM0,raw,echo=0,b115200
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target

To load and start the systemd service, run

sudo chmod 640 /etc/systemd/system/spark-bridge.service
sudo systemctl daemon-reload
sudo systemctl enable spark-bridge
sudo systemctl start spark-bridge
sudo systemctl status spark-bridge

Create the Avahi service configuration at /etc/avahi/services/spark-bridge.service

<?xml version="1.0" standalone="no"?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h Spark Bridge</name>
<service>
<type>_brewblox._tcp</type>
<port>8332</port>
<txt-record>ID=${DEVICE_ID}</txt-record>
<txt-record>HW=Spark 3</txt-record>
</service>
</service-group>

Replace ${DEVICE_ID} with the device ID you copied in the Preparation step.

To load and start the service, run

sudo systemctl restart avahi-daemon
sudo systemctl status avahi-daemon

Startup

Now if you run brewblox-ctl discover-spark on your Brewblox server, it should show a LAN Spark 3 with the IP address of your bridge Pi.

Start Brewblox with brewblox-ctl up, and your service should connect as normal.

As a side note: your logs show parsing errors in your tilt calibration files. Could you please copy the contents of your brewblox/tilt/SGCal.csv file?

Can this be installed on a virtual machine?

Your virtual machine would need access to the USB port, and the host network interface.

Black, 1.062, 1.064
Black, 1.042, 1.044
Black, 1.022, 1.024
Black, 1.012, 1.014

Are there any empty lines in the file? It should handle those, but maybe there’s a bug.

Yes, there where 2 of them :smiley:
Have fixed it, thx