IDE compiles and uploads but execution fails on STM32

Hello, I used to use the IDE 1.8.12 for all my projects, and all use the STM32 Olimexino board. I have set the configuration to "Generic STM32F1 series" and "Generic F103RBT6 (Blue Button)". This have worked for years, using the board library that was once made available in the website "Arduino for STM32" (a project started more than 10 years ago).
Today I decided to move to the IDE version 2.3.6. I installed the STM32 boards (same references), this time using the board library supplied by Arduino, and tried compiling one of my projects. After correcting a name collision in the library, it could compile and upload to my board. However, the board did not work.
I did then a simple test : on a new board, I compiled the "blink" example program. It did not work either (the LED stayed off). I compiled the same source file on my older IDE, and it works (the LED blinks).
I suspect that the processor and/or board definition is incorrect, despite the name that matched the selection I use to work with in the older IDE.
Any clue?
Thanks in advance.
Jean-Marc (France)

It appears you are correct but that is only a guess on my part as I do not have the items. Is it possible the LED pin has changed either on the board or library? Try blinking several ports and see if you get some results. I tend to use a binary counter and write the bits to port pins, increment it and do that again and again …. With a scope it is easy to find which pins is what bit in the counter. Let us know how you do.

I found this, I do not know if it will help: https://www.youtube.com/watch?v=yssEiMLGH90

This is a little confusing.

  1. I think that you're referring to a board package and not a library.
  2. Arduino does, to the best of my knowledge, not provide a "generic" STM32 board package. Can you post a screenshot of the boards manager that shows what you installed exactly.
    If you used an additional URL in file → preferences, please provide it (as text, no screenshot).
    Just in case, this is what I'm referring to. Scroll till you see what you did install

What collision? Did you correct the board package? Did you correct a library? Or your sketch?

Did you undo the fix for the collision (if it was not your sketch)? If not, I suggest that you do so; does it compile and fix the problem?

I just want to make sure. Are both IDEs installed on the same PC? If on different PCs, which are the operating systems (including information 32 bit / 64 bit)?

In IDE 1.8.12 how did you install the STM32 board package; I hope that you still remember. Was that using the boards manager? Or did you manually install downloading a zip and copying the files.

I don't use STM32 boards but I have some board packages installed.

Can you post a screenshot of IDE 1.8.x when selecting your STM32 board. In below screenshot (IDE 1.8.19) the information in the red rectangle indicates that it was installed in the "hardware" directory of the sketchbook. If you don't have the "in sketchbook" you used a different approach.

If you're using the same PC you should see the same options in IDE 2.x. So I guess it's a different PC.
If you indeed see the "in sketchbook" and you're using the same operating system (including 32 bit / 64 bit) you can copy the "hardware" folder from the from the old PC to the new PC and it should work. Below screenshot for Windows, the name of your STM32 board package might differ.

Below is the screenshot you requested. The package, if I remember correctly, was added by adding in the "preferences" option, in the "Additional board manager urls" box, the following url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
Both installs (IDE 1 and IDE 2) are made on the same PC.
The collision was fixed by changing 2 identifiers from my own library that sadly duplicated 2 identifiers from the file stm32_hal_legacy.h. Now my sketch compiles correctly, but since the board does not work as expected, I am now concentrating on having the Blink example work. I am doing experiments comparing the results between version 1 and version 2 IDE. On version 2 it still does not work, whereas it does on version 1 with an exception : my board implements the serial-over-usb connection by firmware (compile option "CDC generic serial"), to switch between programming mode and execution mode. Since my attempt with version 2, the CDC generic serial id dead, and even after uploading a working sketch using version 1 IDE, it does not work any more. There must have been some corruption. I would be glad to restore this function.
So far, I have checked every output of my board but none shows a changing voltage.

.

I did not request a screenshot :wink: I did just point you to something that might have been relevant.
Can you still find the original that you used to use in that list? Or has it disappeared.

If you can't remember what you used in the past ("Arduino for STM32") and provide a link or instructions how it can be installed it will be difficult (for me) to help further, especially regarding pins.

Regarding CDC may I assume that you found the options below?

One thing that I might have misunderstood.

If you upload a code to control a pin (e.g. blink) using IDE 1.x it, with your current setup, works as expected. And if you upload that same code using IDE 2.x it does not work as expected? Is that correct?

Yes in IDE version 1 the original board is still there. With IDE1 I could successfully upload and run two example sketches (with a small change in each to make it compatible), namely Blink and SerialCallResponseASCII. I also finally could restore the usb serial function of 3 boards of the same type, and fluently upload each example sketch in turn in a reproducible way. So no harm done on my boards. I can now try and find what is wrong in the board package I installed in IDE version 2, which IS NOT the package I used in version 1. The latter package is several years old, and was a kind of temporary solution, and I was hoping that I could finally rely on a stable and sustainable IDE but this is not yet the case.
In IDE2 I did select the CDC(generic serial) option.
Yes, the Blink example sketch does work in IDE1 but not in IDE 2.

IDE 1.x and IDE 2.x share the board package installations (unless IDE 1.x is a portable installation).
I think that it's strange that IDE 2.x does not show entries under boards for your "old board package" while IDE 1.x does if IDE 1.x was not a portable installation.

In IDE 1.x, please enable Verbose output during compilation under File → Preferences.
Next compile with the new board package (upload not needed) and post the results here.
Repeat for the old board package.

Post both results here. Please do not forget to use code tags as described in https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966#use-code-tags.

That way we might be able to find the differences or which old board package you did install in the past.

You are right, I forgot to tell you that IDE1 was installed as a portable version. So maybe you do not need the verbose account?

IDE 2.x can not interfere with a portable installation of IDE 1.x. Did you also install the new board package in IDE 1.x? The only thing might be that installation a board package can update the drivers.

If you want to do that I suggest that you create a new portable install of IDE 1.x (or make a copy of the existing one) and install the new board package in the newly created one.

I have multiple portable installations of IDE 1.8.19, mostly for different architectures as well as for different projects.

I think that it's still useful; I might be able to see what the old board package is that is used in IDE 1.x; you don't seem to be able to tell me (which is OK, I also don't know why and how I installed specific board packages except for the fact that it's to help people on the forum). Once that is known I can try to install it and check for differences.

Actually I know that I am not using on IDE2 the package that I use on IDE1 and that works correctly there. My purpose was to find an up to date version, so in the Additional Board Manager URLs box, I clicked on the link "click for a list of unofficial board support urls". This link leads to Unofficial list of 3rd party boards support urls Unofficial list of 3rd party boards support urls · arduino/Arduino Wiki · GitHub, in which I selected the link https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json and installed the set of packages it contains.
Before compiling on IDE2, I selected :
Board : Generic STM32F1 series
Board part number : Blue button F103RBT
all options are the same as I apply in IDE1, except for the wording that may differ.
The compilation finishes successfully, though with the same library and optimisation options as in IDE1 the memory occupied by the sketch is bigger both for code and data. Then the upload sequence occurs normally, but the board does not restart as expected, and the usb serial port does not work any more.
The usb serial port is recovered if I upload the sketch again using IDE1. For me, there is something wrong in the package, but I do not know how to search for the flaw.

I also don't know. But without knowing the old package it will be difficult to determine what the differences are and possibly fix it. So I would like to try to figure that out and hence the request for the verbose compile output.

If you're convinced that it's the board package and not something that IDE 2.x does with it you can ignore my suggestion about a second portable install.

Did Arduino change the interfaces to the packages in version 2, or are all the packages from version 1 compatible with version 2?

See arduino-cli/docs/platform-specification.md at master · arduino/arduino-cli · GitHub. The current specification is in use since IDE 1.5 so should not affect you.

On my side, I looked at the URL from which I had installed the board package in my IDE1. It is https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json which is exactly what is given in the list of unofficial board support, that is, the same I have put in IDE2, with the exception that in IDE1 the package is in version 1.8, whereas in IDE2 the version is 2.11, and the comments in the github repository state that since core release 2.8.0, only Arduino IDE 2 is supported. So,
1 - Apparently, I have installed the correct package in IDE2, which is the same as the one installed in IDE1, but for the version.
2 - I cannot use the working package (1.8) in IDE2.
The fact that the sketch compiles and uploads in IDE2, but the board is inactive, makes me think that the package is probably correct, but it is the board initialisation mechanism that fails.
At startup it is unable to restore the usb serial port, and maybe crashes there, so it does not even configure the chip i/o ports, as I notice when I measure the voltages at the different digital pins. This feeling, however, does not help me find the solution.

OK, safeguard that stm32duino 1.8 because it seems that it's no longer available. Make backups and store in several places.

At least we now know the difference.

Is that because you can not downgrade the stm32duino package to 1.8 (lowest version seems to be 2.0.0)?

If so, I might be able to help you to get stm32duino 1.8 in IDE 2.x. For that I do need the verbose output of a compile in IDE 1.x.

You can try using this "Additional Boards Manager URL":

https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/cf35bad1a4f1bc31d539cd86d0271cbe9d3d214a/STM32/package_stm_index.json

It has the entry for version 1.8.0. I did a quick check and it appears that the files referenced by that index entry are still available, so I have good hopes that it will install successfully but I didn't actually perform an installation to verify.

How did you find that?

I'm an expert at Git archeology :broom: :laughing:.

I just scanned back through the commit history in the stm32duino/BoardManagerFiles repository that hosts the package index file looking for the point where the older versions were removed. This commit caught my eye:

I then went to the repository at the revision before the package index was removed via the above commit, and navigated to the location of the package index at that revision:

This is the web view of the file in the GitHub repository, but we need the raw file for use in the Arduino IDE preferences, so I clicked the "Raw" button on that page, which loaded this URL:

https://github.com/stm32duino/BoardManagerFiles/blob/cf35bad1a4f1bc31d539cd86d0271cbe9d3d214a/STM32/package_stm_index.json

That does the job, thanks.

I added the URL and installed the platform. Successfully compiled some random sketch.

FQBN: STM32:stm32:GenF1
Using board 'GenF1' from platform in folder: C:\Users\bugge\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0
Using core 'arduino' from platform in folder: C:\Users\bugge\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.

As mentioned I do not have STM32 based boards so can't take it further.

So jeanmarcphono can add that url and install the platform.

And select the desired board