Segmentation fault when uploading to STM32

Hi, my first post here, so please be kind to me..

From my Linux box (Debian 12) I'd like to program a STM32F103C6T8, also known as a Blue Pill, using the USB connector and from the Arduino IDE.
For this, I first uploaded the HID 2.2.2 bootloader using a FT232 serial device and the STM32CubeProgrammer. No problems there.

Then, trying to upload the Blink sketch from within the Arduino IDE, I was greeted with the message that no upload port could be found, even though the upload method HID was chosen. From what I could find this is a thing that began with IDE 2.x. Workaround is to attach another USB device with DTR, and choose the port for that device.

Now, the IDE does look for the HID device, finds it, but when the upload starts, it fails quickly with an error : Segmentation fault.
I was able to find exactly one post stating that this can be fixed creating a udev rule, making the HID device known and accessible for all users.

I did create that udev rule, rebooted the machine, but..
still the same segmentation fault error.

I'm at my wit's end here.
Anyone knows what else I can do ?

Hi @phloks.

There was a bug like that:

However, that bug has been fixed since Arduino IDE 2.0.1.

I'm going to ask you to post the full verbose output from an upload attempt.


:exclamation: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Uncheck the box next to Show verbose output during: compilation in the "Preferences" dialog.
  3. Check the box next to Show verbose output during: ☐ upload.
  4. Click the "OK" button.
  5. Attempt an upload, as you did before.
  6. Wait for the upload to fail.
  7. You will see a "Upload error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
  8. Open a forum reply here by clicking the "Reply" button.
  9. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block icon on toolbar
  10. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the error output from the upload into the code block.
  11. Move the cursor outside of the code block markup before you add any additional text to your reply.
  12. Click the "Reply" button to post the output.

Hi,
Thanks for picking this up.

Let's focus on the port issue first.
The only error I get when uploading is Sketch uses 24056 bytes (36%) of program storage space. Maximum is 65536 bytes. Global variables use 4416 bytes (21%) of dynamic memory, leaving 16064 bytes for local variables. Maximum is 20480 bytes. Failed uploading: no upload port provided

What I did sofar is:

  1. Completely reinstall Debian 12
  2. On this fresh install I then installed Arduino IDE 1.8.19 and Arduino IDE 2.2.1.
  3. Installed stm32flash from Arduino_STM32/tools/linux64/stm32flash/stm32flash at master · rogerclarkmelbourne/Arduino_STM32 · GitHub
  4. Flashed hid_generic_pc13.bin (from GitHub - Serasidis/STM32_HID_Bootloader: Driverless USB HID bootloader and flashing tool for STM32F10X devices) using stm32flash. Command used was: ./stm32flash -g 0x8000000 -b 115200 -w hid_generic_pc13.bin /dev/ttyUSB0. This was done using a FTDI232 adapter. Looks to be OK.
  5. Started Arduino 2.2.1, and added boards location https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json. Then installed the STM32 package.
  6. With both jumpers on the Bluepill in the 0 position, I tried to upload blink.ino, with upload method set to HID 2.2.

This results in the no upload port error.
I believe I followed all the instructions for using a HID bootloader, but it still does not work.
There are also no further logs available. Not in /var/log/messages, not in dmesg.
So, still no joy... :shushing_face:

Made some progress.
The segmentation fault was, in the end, a problem with my udev rules after all. It turned out that the syntax I had used for my udev rules was slightly different from what was expected in Debian 12.

A fresh install of IDE 2.2.1 still acts strange when uploading for the very first time.
Only after inserting a device that creates a port (/dev/ttyUSB0 or /dev/ttyACM0), this port is seen by the IDE. Although this port is not used when uploading using HID, subseqent uploads work without problems.

Not sure if this is the intended way of working, though, but I can proceed.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.