Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32_Programmer.sh not found #63

Closed
bsamadi opened this issue May 2, 2020 · 17 comments
Closed

STM32_Programmer.sh not found #63

bsamadi opened this issue May 2, 2020 · 17 comments

Comments

@bsamadi
Copy link

bsamadi commented May 2, 2020

STM32_Programmer.sh is in /usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin and this folder is added to the path. I can run STM32_Programmer.sh in the terminal with no issues.

However, Arduino IDE complains that STM32_Programmer.sh was not found.

When I checked, the PATH inside stm32CubeProg.sh was different from the one in the terminal.

I even changed $HOME to /usr/local in stm32CubeProg.sh but the error is still the same.

@fpistm
Copy link
Member

fpistm commented May 2, 2020

Seems strange.
Which version of Arduino IDE you used?
Coud you echo the $PATH in the stm32CubeProg.sh

@bsamadi
Copy link
Author

bsamadi commented May 2, 2020

version: 1.8.12
PATH in stm32CubeProg.sh:
/snap/arduino/14/java/bin:/snap/arduino/14/usr/sbin:/snap/arduino/14/usr/bin:/snap/arduino/14/sbin:/snap/arduino/14/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

@fpistm
Copy link
Member

fpistm commented May 2, 2020

So STM32cubeprogrammer is not in the path.
How you launch the IDE?

@bsamadi
Copy link
Author

bsamadi commented May 2, 2020

The PATH that I showed is at the beginning of stm32CubeProg.sh, coming from the echo $PATH command in this picture:

One issue is that this PATH is different from the PATH in the user environment.
The other issue is that I modified stm32CubeProg.sh (see the above picture) and added the installation folder of STM32_Programmer.sh to the PATH. However, I still get this error:

I have installed Arduino IDE through "Software" in Ubuntu and I run it from the start menu. I also tried running it from the terminal. In both cases, the PATH in stm32CubeProg.sh is different from the PATH defined in the user environment. I am wondering where stm32CubeProg.sh gets its PATH.

The command -v STM32_Programmer.sh command works fine in the terminal:

@fpistm
Copy link
Member

fpistm commented May 2, 2020

Try to launch arduino from the terminal.

@fpistm
Copy link
Member

fpistm commented May 2, 2020

From:
https://help.ubuntu.com/community/EnvironmentVariables

Launching desktop application with an environment variable
You can add an environment variable to an application by editing its .desktop file. For example, to run "digiKam" with the environment variable APPMENU_DISPLAY_BOTH=1, find the corresponding digikam.desktop file and add the setting of the variable, via the env command, to the entry "Exec":

Exec=env APPMENU_DISPLAY_BOTH=1 digikam -caption "%c" %i

Lauching from desktop application has a different env.
That's why it's not work. So add it as explained.

@bsamadi
Copy link
Author

bsamadi commented May 2, 2020

It seems that the issue originates from the fact that Ubuntu installs Arduino IDE using snap. This is how PATH is defined in snap (https://snapcraft.io/docs/environment-variables):

If you want to use STM32duino, do not install Arduino IDE through Software in Ubuntu or snap.

Thank you @fpistm for your time!

@fpistm
Copy link
Member

fpistm commented May 2, 2020

Ok , anyway you need to have the cube programmer in the path. There is no bug. This works as expected and warn user that it cannot be found.

@bsamadi
Copy link
Author

bsamadi commented May 2, 2020

It would be great if a new user could follow these steps to use STM32duino:

  • install Arduino IDE through Software in Ubuntu
  • install STM32CubeProg in its default location (/usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer)
  • follow the instructions in Getting Started

Currently, there are two issues with this workflow:

  1. Ubuntu uses snap to install Arduino IDE and snap does not use the default user PATH
  2. If stm32CubeProg.sh doesn't find STM32_Programmer.sh in PATH, it looks for it in $HOME/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin not the default installation path, which is: /usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin.

@fpistm
Copy link
Member

fpistm commented May 4, 2020

@bsamadi

* install [STM32CubeProg](https://www.st.com/en/development-tools/stm32cubeprog.html) in its default location (`/usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer`)

As far as I can tell is this is not the default location.

Ubuntu uses snap to install Arduino IDE and snap does not use the default user PATH

Yes, so up to end user to provide the correct environment.

2\. If `stm32CubeProg.sh` doesn't find `STM32_Programmer.sh` in PATH, it looks for it in `$HOME/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin` not the default installation path, which is: `/usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin`.

Yes, as it is the default path as far as I can tell.

How did you install the CubeProgrammer?

@bsamadi
Copy link
Author

bsamadi commented May 4, 2020

@fpistm, I checked again. You are absolutely right. I had changed the default installation folder. STM32duino works just fine. My main problem was the Arduino IDE installed by snap.

Thank you!

@bsamadi bsamadi closed this as completed May 4, 2020
@fpistm
Copy link
Member

fpistm commented May 4, 2020

Welcome.
Thanks to have checked again.
About snap it is fine to be aware of this issue.

@Diatrix
Copy link

Diatrix commented May 15, 2020

@bsamadi What was your solution then? Uninstall the Arduino IDE and reinstall it though command line?

@bsamadi
Copy link
Author

bsamadi commented May 16, 2020

Yes, I followed the instructions here.

@ggatis
Copy link

ggatis commented Aug 17, 2021

Or change file stm32CubeProg.sh:
line
export PATH="$HOME/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin":$PATH
to
export PATH="/usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin":$PATH

@blaisegassend
Copy link

I noticed that when running from arduino in a snap, HOME is set to:
/home/my_user_name/snap/arduino/85

By installing STMicroelectronics into /home/my_user_name/snap/arduino/85 instead of /home/my_user_name, the snap version of arduino was able to find it just fine.

You can probably do this automatically by running
snap run --shell arduino
and running SetupSTM32CubeProgrammer-2.15.0.linux from there. Or you can just install normally and copy/move.

@rtek1000
Copy link

The problem is caused when installing SetupSTM32CubeProgrammer-x.xx.x.linux using sudo or root. If installed without elevation, it will be installed in the user's home.

Wrong:

sudo ./SetupSTM32CubeProgrammer-2.13.0.linux

Path: /usr/local/STMicroelectronics/STM32Cube/

Correct:

./SetupSTM32CubeProgrammer-2.13.0.linux

Path: /home/user/STMicroelectronics/STM32Cube/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants