Platform.IO: Inconsistent behaviour with B-G431B-ESC1

Hi all!

Past weeks I have been busy with experimentating adding more features to the B-G431B-ESC1. After I2C was working, I spent time with CAN communication. Bi-directional CAN was working last week thanks to code of @Owen_Williams and @erwin74. Also the temperature sensor was working :slight_smile:.

Only after past weekend, Platform.IO starts acting weird again. Codes that worked last week will not work anymore. It looks related to serial. I did not update platform.IO, libraries or drivers. Some codes do work, others not. I tried restarting the computer and cleaning the target. Last time when I had these problems, I just reinstalled Visual Code, but there must be a better solution?

Did somebody experience the same issues I am having? Or maybe have any tips how to solve these kind of problems?

#Edit 1: When I first upload a code without serial and after that upload an old code with serial then it works (for now?). Can it be related that some code remains stuck in memory and that it needs to be “flushed” if possible?

Greetings,

Wittecactus

Hello Wittecactus,

first of all, you have made 2 correct decisions already:

  • first you started with the correct platform
  • secondly you started with the correct code on it
    :wink:
    I don’t know how experienced you are with sw development, especially on low level platforms, but what i can highly recommend from my side is to use some kind of source code versioning tool (e.g. git). With that tool you can identify changes which you have made in the past and which result in such kind of problems, more easily. I do not use Platform.IO, but if you do not trust the process of flashing/erasing, you could also use the STM tool ‘ST-LINK Utility’ for that purpose.

Hi @erwin74,

Haha thanks for your reply. Good to know that I have already set two steps in the right direction. I am still a beginner in software development! Great tip of git!

The only thing is that I did not change code… it just will not upload the code correctly. It is working again now but it still is not that consistent with working codes like an Uno or a Nucleo board. Also sometimes simple code that will run on Nucleo (blinking LED with Serial) will not run on this board. I will take a look at ST-link Utlity!

Thanks for the tips

Greetings,

Wittecactus

I’m not sure how to help you as you haven’t described what happens when things don’t work. Does it fail to upload? Does sensor stop working?

You might want to pin your dependencies to 2.0.2 as 2.1 was a new and big release, but i suspect it isn’t that as it sounds intermittent.

I had problems with the pull-ups on that board which have intermittent issues. The board is hard to solder and easy to break so it could be a lot of things!

Hi @Owen_Williams,

Thanks for your reply! I should have been more clear.

When things do not work I mean that: Code does compile and succesfully upload, but that there is no code running on the device (I check it with a simple blink in the loop).

I have a non soldered board laying around to check if it works on that but than it will also not works so I do not think that it is board related but it is Platform.IO related.

I checked the dependencies and other updates (for example of STM boards) and it are all the same versions from before the weekend. Eventually I could upload the working code from before the weekend, but only after I first put a simple blinking code without serial on the device.

This is what I try to describe with inconsistent behaviour that the same code, on the same device, will always upload, but that not always code is running on the device itself! This is happening since I have had the boards here. With complex and with simple code.

Greetings,

Wittecactus

Hi Wittecactus,

I have these kinds of problems all the time, I don’t know what causes them. Its very frustrating, because you spend hours solving IDE configuration problems rather than working on cool stuff.

One thing I did notice though is that having STM32CubeProgrammer open at the same time as Arduino IDE oder Sloeber leads to intermittent programming errors. I always close all the other IDEs and tools that might be trying to use the same serial port.

I can’t say I’ve seen it claim to successfully program, and then not execute on the MCU in the way you describe… For me it fails during programming, or it succeeds, and then the code runs.

I think executing “old code” on the MCU happens sometimes when the IDE can’t compile or link the code, but somehow runs the programmer anyways, and that winds up loading the binary from the previous build. Can’t say I’ve managed to make this happen repeatably though.

Hi @runger,

Thanks for your reply! It is nice to know that I am not the only one with these inconsistencies! :sweat_smile:

Also thanks for the tips, I am going to pay attention on those things you said! I will report back if it also helps for me.

Tips from my side: It looks when you upload a very simple code (blinking) first and then the complex code, that it has more succes with uploading!

Let me know if you find other “tricks” that can work when struggling running a code on the device.

Greetings,

Wittecactus

Hey you can all have a laugh at me, but I thought I’d mention it anyway in case anyone else has the same problem.
I just resolved a major bug in my brain when using PlatformIO:

The commands on the left (circled in orange) operate on the open project (circled in blue) and not on the open editor (circled in green).

I have been used to Sloeber or the Arduino IDEs, where the Compile and Upload commands act on the current code window… but in PlatformIO the commands act on the current project, which can have nothing to do with the currently open window… doh!
Until I worked this out, it did look a lot like PlatformIO was uploading “old” code… it wasn’t, it was just uploading the current project rather than the code-file I was looking at and editing.

Yes. I’m pretty sure it complains if you have two classes with setup() loop() method so it’s hard to make that mistake. I use ctrl alt U to upload and it’ll choose the project associated with the current file.

Great tips! Thank you :slight_smile:

Small update: For me many inconcistencies have gone away with switching back to Arduino IDE. Platform.io has many advantages, but if you are like me and can not get it to work, then it can be an option to switch back to Arduino IDE. Here a small guide for people having the same struggles.