From 230064362d8b6d88e3c2bdd8a49a71e92f8edde1 Mon Sep 17 00:00:00 2001 From: nara Date: Sun, 11 Feb 2018 01:04:19 -0700 Subject: [PATCH 1/4] Guide for Flashing LEDs on STM32 using Fedora --- STM32Resources/README.adoc | 66 ++++++++++++++++++++++++++++++++++++++ STM32Resources/install.sh | 27 +++++++++++----- 2 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 STM32Resources/README.adoc diff --git a/STM32Resources/README.adoc b/STM32Resources/README.adoc new file mode 100644 index 0000000..21bf4f7 --- /dev/null +++ b/STM32Resources/README.adoc @@ -0,0 +1,66 @@ += Compiling and Flashing STM Board on Fedora + +. Go to UCSolarCarTeam repo > Recruit Resources, and clone. + +. Navigate to STM32F4Discovery-Resources and run the auto installer using `sudo ./install.sh`. +This should download STLink, gcc4mbed, and CubeMX2Makefile and add them all to the path. + +. http://www.st.com/en/development-tools/stm32cubemx.html[Go to the download page of the official ST website by clicking this link^]. + +. Scroll to the bottom of the page to the *GET SOFTWARE* section and click *Get Software*. + +. Follow the instructions and download CubeMX. + +. Extract files from `.zip` file using a preferred method. +For example, use `unzip file.zip`. + +. Navigate to the directory the files were extracted to. + +. Run *SetupSTM32CubeMX-VERSION.linux* using `./SetupSTM32CubeMX-{var}.linux` where {var} is the version of CubeMx that is being installed. + +. Follow the instructions in the Installation Wizard. + + +== Generating Code with CubeMX + +. Open CubeMX. The default path is `~/STM32CubeMX`. + +. Select New Project. + +. Click on the Board Selector Tab and scroll to STM32F4DISCOVERY then click OK. + +. Go to Project > Settings. + +. Name the project, set the project location, and change the Toolchain/IDE to SW4STM32. +*If this isn't done, CubeMX2Makefile won't work!* +CubeMX2Makefile looks for an SW4STM32 project which was created by CubeMX. +If the Toolchain/IDE is not set to SW4STM32, it will be in the format of a different IDE, not CubeMX. +For example, EWARM is for the IAR Embedded Workbench IDE and CubeMX2Makefile will not know what to do with that format. + +. Make note of the Toolchain Folder Location, which will also be the project folder location. + +. Click OK and download any dependencies that are needed, then click OK again. + +. Make pin assignments then go to Project > Generate Code, and then save project. + + +== Generating a Makefile and Compiling + +. Create the makefile using `CubeMX2Makefile /path/to/project/folder`. + +. Go to the directory that the Makefile was made then compile using `make`. +* Need to double check that the right compiler is being used. In our case, this would be `arm-none-eabi-g++`. +** If your system has different type of arm compilers installed, they should be removed using `sudo dnf remove compilername` to prevent ambiguity + +. Navigate to the build directory and there should be a `.bin` file. Where `` is the project name. + +== Flashing +Flashing is how the `.bin` that was made is put onto the board. This is how the processor on the board is able to carry out the instructions that were generated from the code. + +To flash the board use `st-flash write /path/to/project/build/.bin 0x8000000`. + +If a board isn't connected, and it ran successfully, the output should be: +---- +st-flash 1.3.0-dev +DATE/TIME WARN /opt/stlink/src/usb.c: Couldn't find any ST-Link/V2 devices +---- diff --git a/STM32Resources/install.sh b/STM32Resources/install.sh index 4a3cd44..23c87d2 100644 --- a/STM32Resources/install.sh +++ b/STM32Resources/install.sh @@ -6,7 +6,17 @@ if [[ $UID != 0 ]]; then exit 1 fi -apt-get -y install build-essential git libsane:i386 ia32-libs-multiarch autoconf libusb-1.0-0-dev lib32ncurses5 libncurses5:i386 software-properties-common pkg-config cmake + +# Install necessary 32-bit compliant packages +dnf install --skip-broken glibc.i686 arts.i686 audiofile.i686 bzip2-libs.i686 cairo.i686 cyrus-sasl-lib.i686 dbus-libs.i686 directfb.i686 esound-libs.i686 fltk.i686 freeglut.i686 gtk2.i686 hal-libs.i686 imlib.i686 lcms-libs.i686 lesstif.i686 libacl.i686 libao.i686 libattr.i686 libcap.i686 libdrm.i686 libexif.i686 libgnomecanvas.i686 libICE.i686 libieee1284.i686 libsigc++20.i686 libSM.i686 libtool-ltdl.i686 libusb.i686 libwmf.i686 libwmf-lite.i686 libX11.i686 libXau.i686 libXaw.i686 libXcomposite.i686 libXdamage.i686 libXdmcp.i686 libXext.i686 libXfixes.i686 libxkbfile.i686 libxml2.i686 libXmu.i686 libXp.i686 libXpm.i686 libXScrnSaver.i686 libxslt.i686 libXt.i686 libXtst.i686 libXv.i686 libXxf86vm.i686 lzo.i686 mesa-libGL.i686 mesa-libGLU.i686 nas-libs.i686 nss_ldap.i686 cdk.i686 openldap.i686 pam.i686 popt.i686 pulseaudio-libs.i686 sane-backends-libs-gphoto2.i686 sane-backends-libs.i686 SDL.i686 svgalib.i686 unixODBC.i686 zlib.i686 compat-expat1.i686 compat-libstdc++-33.i686 openal-soft.i686 alsa-oss-libs.i686 redhat-lsb.i686 alsa-plugins-pulseaudio.i686 alsa-plugins-oss.i686 alsa-lib.i686 nspluginwrapper.i686 libXv.i686 libXScrnSaver.i686 qt.i686 qt-x11.i686 pulseaudio-libs.i686 pulseaudio-libs-glib2.i686 alsa-plugins-pulseaudio.i686 + + +# Install cmake +dnf install cmake + +# Install libusb library +dnf install libusbx-devel-1.0.21-2.fc26.x86_64 #This is a 64 bit compliant package +dnf install libusbx-devel-1.0.21-2.fc26.i686 #This is a 32 bit compliant package # Install STLink if ! type "st-flash" > /dev/null; then @@ -17,10 +27,11 @@ if ! type "st-flash" > /dev/null; then ln -s /opt/stlink/build/st-flash /usr/local/bin/st-flash ln -s /opt/stlink/build/st-info /usr/local/bin/st-info ln -s /opt/stlink/build/src/gdbserver/st-util /usr/local/bin/st-util - echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/stlink/build" >> ~/.profile + echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/stlink/build" >> ~/.bashrc export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/stlink/build - echo "export PATH=\$PATH:/opt/stlink/build" >> ~/.profile + echo "export PATH=\$PATH:/opt/stlink/build" >> ~/.bashrc export PATH=$PATH:/opt/stlink/build + cp ~/.bashrc /root/ else echo "*** ST Link already installed" fi @@ -34,7 +45,7 @@ if ! type "CubeMX2Makefile" > /dev/null; then echo "ABS_PATH=\"\$(readlink -f \$1)\"" >> /usr/local/bin/CubeMX2Makefile echo "(cd /opt/CubeMX2Makefile && python CubeMX2Makefile.py \$ABS_PATH)" >> /usr/local/bin/CubeMX2Makefile chmod +x /usr/local/bin/CubeMX2Makefile - echo "export PATH=\$PATH:/opt/CubeMX2Makefile" >> ~/.profile + echo "export PATH=\$PATH:/opt/CubeMX2Makefile" >> ~/.bashrc export PATH=$PATH:/opt/CubeMX2Makefile else echo "*** CubeMX2Makefile already installed" @@ -48,13 +59,13 @@ if [ ! -d "/opt/gcc4mbed" ]; then chmod +x linux_install && \ sed -i '108d;109d;110d;147d' linux_install && \ ./linux_install) - if ! grep "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" ~/.profile; then - echo "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" >> ~/.profile + if ! grep "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" ~/.bashrc; then + echo "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" >> ~/.bashrc fi export PATH=$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/ else echo "*** ARM compiler already installed" fi -# Sourcing Profile -source ~/.profile +# Sourcing bashrc +source ~/.bashrc From a52ced9ab7d294adc502fbed7edefc7688c84860 Mon Sep 17 00:00:00 2001 From: nara Date: Tue, 20 Feb 2018 23:24:13 -0700 Subject: [PATCH 2/4] STM32 installation guide for Linux --- STM32Resources/README.adoc | 6 ++-- STM32Resources/install.sh | 64 +++++++++++++++++++++++++++----------- 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/STM32Resources/README.adoc b/STM32Resources/README.adoc index 21bf4f7..f685261 100644 --- a/STM32Resources/README.adoc +++ b/STM32Resources/README.adoc @@ -1,8 +1,8 @@ -= Compiling and Flashing STM Board on Fedora += Compiling and Flashing STM Board on Linux -. Go to UCSolarCarTeam repo > Recruit Resources, and clone. +. Go to StudentOrganisationForAerospaceResearch repo > DevelopmentResources, and clone. -. Navigate to STM32F4Discovery-Resources and run the auto installer using `sudo ./install.sh`. +. Navigate to STM32Resources and run the auto installer using `sudo ./install.sh`. This should download STLink, gcc4mbed, and CubeMX2Makefile and add them all to the path. . http://www.st.com/en/development-tools/stm32cubemx.html[Go to the download page of the official ST website by clicking this link^]. diff --git a/STM32Resources/install.sh b/STM32Resources/install.sh index 23c87d2..ea65a87 100644 --- a/STM32Resources/install.sh +++ b/STM32Resources/install.sh @@ -6,17 +6,24 @@ if [[ $UID != 0 ]]; then exit 1 fi +# Install files according to Linux distribution that the user has +if [ "$(. /etc/os-release; echo $NAME)" = "Ubuntu" ]; then + apt-get -y install build-essential git libsane:i386 ia32-libs-multiarch autoconf libusb-1.0-0-dev lib32ncurses5 libncurses5:i386 software-properties-common pkg-config cmake -# Install necessary 32-bit compliant packages -dnf install --skip-broken glibc.i686 arts.i686 audiofile.i686 bzip2-libs.i686 cairo.i686 cyrus-sasl-lib.i686 dbus-libs.i686 directfb.i686 esound-libs.i686 fltk.i686 freeglut.i686 gtk2.i686 hal-libs.i686 imlib.i686 lcms-libs.i686 lesstif.i686 libacl.i686 libao.i686 libattr.i686 libcap.i686 libdrm.i686 libexif.i686 libgnomecanvas.i686 libICE.i686 libieee1284.i686 libsigc++20.i686 libSM.i686 libtool-ltdl.i686 libusb.i686 libwmf.i686 libwmf-lite.i686 libX11.i686 libXau.i686 libXaw.i686 libXcomposite.i686 libXdamage.i686 libXdmcp.i686 libXext.i686 libXfixes.i686 libxkbfile.i686 libxml2.i686 libXmu.i686 libXp.i686 libXpm.i686 libXScrnSaver.i686 libxslt.i686 libXt.i686 libXtst.i686 libXv.i686 libXxf86vm.i686 lzo.i686 mesa-libGL.i686 mesa-libGLU.i686 nas-libs.i686 nss_ldap.i686 cdk.i686 openldap.i686 pam.i686 popt.i686 pulseaudio-libs.i686 sane-backends-libs-gphoto2.i686 sane-backends-libs.i686 SDL.i686 svgalib.i686 unixODBC.i686 zlib.i686 compat-expat1.i686 compat-libstdc++-33.i686 openal-soft.i686 alsa-oss-libs.i686 redhat-lsb.i686 alsa-plugins-pulseaudio.i686 alsa-plugins-oss.i686 alsa-lib.i686 nspluginwrapper.i686 libXv.i686 libXScrnSaver.i686 qt.i686 qt-x11.i686 pulseaudio-libs.i686 pulseaudio-libs-glib2.i686 alsa-plugins-pulseaudio.i686 +elif [ "$(. /etc/os-release; echo $NAME)" = "Fedora" ]; then + # Install necessary 32-bit compliant packages + dnf install --skip-broken glibc.i686 arts.i686 audiofile.i686 bzip2-libs.i686 cairo.i686 cyrus-sasl-lib.i686 dbus-libs.i686 directfb.i686 esound-libs.i686 fltk.i686 freeglut.i686 gtk2.i686 hal-libs.i686 imlib.i686 lcms-libs.i686 lesstif.i686 libacl.i686 libao.i686 libattr.i686 libcap.i686 libdrm.i686 libexif.i686 libgnomecanvas.i686 libICE.i686 libieee1284.i686 libsigc++20.i686 libSM.i686 libtool-ltdl.i686 libusb.i686 libwmf.i686 libwmf-lite.i686 libX11.i686 libXau.i686 libXaw.i686 libXcomposite.i686 libXdamage.i686 libXdmcp.i686 libXext.i686 libXfixes.i686 libxkbfile.i686 libxml2.i686 libXmu.i686 libXp.i686 libXpm.i686 libXScrnSaver.i686 libxslt.i686 libXt.i686 libXtst.i686 libXv.i686 libXxf86vm.i686 lzo.i686 mesa-libGL.i686 mesa-libGLU.i686 nas-libs.i686 nss_ldap.i686 cdk.i686 openldap.i686 pam.i686 popt.i686 pulseaudio-libs.i686 sane-backends-libs-gphoto2.i686 sane-backends-libs.i686 SDL.i686 svgalib.i686 unixODBC.i686 zlib.i686 compat-expat1.i686 compat-libstdc++-33.i686 openal-soft.i686 alsa-oss-libs.i686 redhat-lsb.i686 alsa-plugins-pulseaudio.i686 alsa-plugins-oss.i686 alsa-lib.i686 nspluginwrapper.i686 libXv.i686 libXScrnSaver.i686 qt.i686 qt-x11.i686 pulseaudio-libs.i686 pulseaudio-libs-glib2.i686 alsa-plugins-pulseaudio.i686 + # Install cmake + dnf install cmake -# Install cmake -dnf install cmake - -# Install libusb library -dnf install libusbx-devel-1.0.21-2.fc26.x86_64 #This is a 64 bit compliant package -dnf install libusbx-devel-1.0.21-2.fc26.i686 #This is a 32 bit compliant package + # Install libusb library + dnf install libusbx-devel-1.0.21-2.fc26.x86_64 #This is a 64 bit compliant package + dnf install libusbx-devel-1.0.21-2.fc26.i686 #This is a 32 bit compliant package +else + echo "Sorry, your system is not supported!" + exit 1 +fi # Install STLink if ! type "st-flash" > /dev/null; then @@ -27,11 +34,18 @@ if ! type "st-flash" > /dev/null; then ln -s /opt/stlink/build/st-flash /usr/local/bin/st-flash ln -s /opt/stlink/build/st-info /usr/local/bin/st-info ln -s /opt/stlink/build/src/gdbserver/st-util /usr/local/bin/st-util - echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/stlink/build" >> ~/.bashrc - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/stlink/build - echo "export PATH=\$PATH:/opt/stlink/build" >> ~/.bashrc - export PATH=$PATH:/opt/stlink/build - cp ~/.bashrc /root/ + if [ "$(. /etc/os-release; echo $NAME)" = "Ubuntu" ]; then + echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/stlink/build" >> ~/.profile + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/stlink/build + echo "export PATH=\$PATH:/opt/stlink/build" >> ~/.profile + export PATH=$PATH:/opt/stlink/build + elif [ "$(. /etc/os-release; echo $NAME)" = "Fedora" ]; then + echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/stlink/build" >> ~/.bashrc + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/stlink/build + echo "export PATH=\$PATH:/opt/stlink/build" >> ~/.bashrc + export PATH=$PATH:/opt/stlink/build + cp ~/.bashrc /root/ + fi else echo "*** ST Link already installed" fi @@ -45,7 +59,11 @@ if ! type "CubeMX2Makefile" > /dev/null; then echo "ABS_PATH=\"\$(readlink -f \$1)\"" >> /usr/local/bin/CubeMX2Makefile echo "(cd /opt/CubeMX2Makefile && python CubeMX2Makefile.py \$ABS_PATH)" >> /usr/local/bin/CubeMX2Makefile chmod +x /usr/local/bin/CubeMX2Makefile - echo "export PATH=\$PATH:/opt/CubeMX2Makefile" >> ~/.bashrc + if [ "$(. /etc/os-release; echo $NAME)" = "Ubuntu" ]; then + echo "export PATH=\$PATH:/opt/CubeMX2Makefile" >> ~/.profile + elif [ "$(. /etc/os-release; echo $NAME)" = "Fedora" ]; then + echo "export PATH=\$PATH:/opt/CubeMX2Makefile" >> ~/.bashrc + fi export PATH=$PATH:/opt/CubeMX2Makefile else echo "*** CubeMX2Makefile already installed" @@ -59,13 +77,23 @@ if [ ! -d "/opt/gcc4mbed" ]; then chmod +x linux_install && \ sed -i '108d;109d;110d;147d' linux_install && \ ./linux_install) - if ! grep "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" ~/.bashrc; then - echo "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" >> ~/.bashrc + if [ "$(. /etc/os-release; echo $NAME)" = "Ubuntu" ]; then + if ! grep "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" ~/.profile; then + echo "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" >> ~/.profile + fi + elif [ "$(. /etc/os-release; echo $NAME)" = "Fedora" ]; then + if ! grep "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" ~/.bashrc; then + echo "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" >> ~/.bashrc + fi fi export PATH=$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/ else echo "*** ARM compiler already installed" fi -# Sourcing bashrc -source ~/.bashrc +# Sourcing +if [ "$(. /etc/os-release; echo $NAME)" = "Ubuntu" ]; then + source ~/.profile #sourcing profile +elif [ "$(. /etc/os-release; echo $NAME)" = "Fedora" ]; then + source ~/.bashrc #sourcing bashrc +fi From 536e760a9b4acdcea86267c1ded6399f797b13ca Mon Sep 17 00:00:00 2001 From: nara Date: Sat, 24 Feb 2018 20:14:33 -0700 Subject: [PATCH 3/4] Improved install.sh in terms of readability --- STM32Resources/install.sh | 60 ++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/STM32Resources/install.sh b/STM32Resources/install.sh index ea65a87..e4b0b6d 100644 --- a/STM32Resources/install.sh +++ b/STM32Resources/install.sh @@ -6,11 +6,14 @@ if [[ $UID != 0 ]]; then exit 1 fi +# Determine what distribution of Linux the user has +DISTRO = $(. /etc/os-release; echo $NAME) + # Install files according to Linux distribution that the user has -if [ "$(. /etc/os-release; echo $NAME)" = "Ubuntu" ]; then +if [ "$DISTRO" = "Ubuntu" ]; then apt-get -y install build-essential git libsane:i386 ia32-libs-multiarch autoconf libusb-1.0-0-dev lib32ncurses5 libncurses5:i386 software-properties-common pkg-config cmake -elif [ "$(. /etc/os-release; echo $NAME)" = "Fedora" ]; then +elif [ "$DISTRO" = "Fedora" ]; then # Install necessary 32-bit compliant packages dnf install --skip-broken glibc.i686 arts.i686 audiofile.i686 bzip2-libs.i686 cairo.i686 cyrus-sasl-lib.i686 dbus-libs.i686 directfb.i686 esound-libs.i686 fltk.i686 freeglut.i686 gtk2.i686 hal-libs.i686 imlib.i686 lcms-libs.i686 lesstif.i686 libacl.i686 libao.i686 libattr.i686 libcap.i686 libdrm.i686 libexif.i686 libgnomecanvas.i686 libICE.i686 libieee1284.i686 libsigc++20.i686 libSM.i686 libtool-ltdl.i686 libusb.i686 libwmf.i686 libwmf-lite.i686 libX11.i686 libXau.i686 libXaw.i686 libXcomposite.i686 libXdamage.i686 libXdmcp.i686 libXext.i686 libXfixes.i686 libxkbfile.i686 libxml2.i686 libXmu.i686 libXp.i686 libXpm.i686 libXScrnSaver.i686 libxslt.i686 libXt.i686 libXtst.i686 libXv.i686 libXxf86vm.i686 lzo.i686 mesa-libGL.i686 mesa-libGLU.i686 nas-libs.i686 nss_ldap.i686 cdk.i686 openldap.i686 pam.i686 popt.i686 pulseaudio-libs.i686 sane-backends-libs-gphoto2.i686 sane-backends-libs.i686 SDL.i686 svgalib.i686 unixODBC.i686 zlib.i686 compat-expat1.i686 compat-libstdc++-33.i686 openal-soft.i686 alsa-oss-libs.i686 redhat-lsb.i686 alsa-plugins-pulseaudio.i686 alsa-plugins-oss.i686 alsa-lib.i686 nspluginwrapper.i686 libXv.i686 libXScrnSaver.i686 qt.i686 qt-x11.i686 pulseaudio-libs.i686 pulseaudio-libs-glib2.i686 alsa-plugins-pulseaudio.i686 @@ -34,18 +37,16 @@ if ! type "st-flash" > /dev/null; then ln -s /opt/stlink/build/st-flash /usr/local/bin/st-flash ln -s /opt/stlink/build/st-info /usr/local/bin/st-info ln -s /opt/stlink/build/src/gdbserver/st-util /usr/local/bin/st-util - if [ "$(. /etc/os-release; echo $NAME)" = "Ubuntu" ]; then - echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/stlink/build" >> ~/.profile - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/stlink/build - echo "export PATH=\$PATH:/opt/stlink/build" >> ~/.profile - export PATH=$PATH:/opt/stlink/build - elif [ "$(. /etc/os-release; echo $NAME)" = "Fedora" ]; then - echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/stlink/build" >> ~/.bashrc - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/stlink/build - echo "export PATH=\$PATH:/opt/stlink/build" >> ~/.bashrc - export PATH=$PATH:/opt/stlink/build - cp ~/.bashrc /root/ + if [ "$DISTRO" = "Ubuntu" ]; then + BASH_PROFILE = "~./profile" + elif [ "$DISTRO" = "Fedora" ]; then + BASH_PROFILE = "~./bashrc" fi + echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/stlink/build" >> $BASH_PROFILE + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/stlink/build + echo "export PATH=\$PATH:/opt/stlink/build" >> $BASH_PROFILE + export PATH=$PATH:/opt/stlink/build + cp ~/.bashrc /root/ else echo "*** ST Link already installed" fi @@ -59,11 +60,12 @@ if ! type "CubeMX2Makefile" > /dev/null; then echo "ABS_PATH=\"\$(readlink -f \$1)\"" >> /usr/local/bin/CubeMX2Makefile echo "(cd /opt/CubeMX2Makefile && python CubeMX2Makefile.py \$ABS_PATH)" >> /usr/local/bin/CubeMX2Makefile chmod +x /usr/local/bin/CubeMX2Makefile - if [ "$(. /etc/os-release; echo $NAME)" = "Ubuntu" ]; then - echo "export PATH=\$PATH:/opt/CubeMX2Makefile" >> ~/.profile - elif [ "$(. /etc/os-release; echo $NAME)" = "Fedora" ]; then - echo "export PATH=\$PATH:/opt/CubeMX2Makefile" >> ~/.bashrc + if [ "$DISTRO" = "Ubuntu" ]; then + BASH_PROFILE = "~./profile" + elif [ "$DISTRO" = "Fedora" ]; then + BASH_PROFILE = "~./bashrc" fi + echo "export PATH=\$PATH:/opt/CubeMX2Makefile" >> $BASH_PROFILE export PATH=$PATH:/opt/CubeMX2Makefile else echo "*** CubeMX2Makefile already installed" @@ -77,14 +79,13 @@ if [ ! -d "/opt/gcc4mbed" ]; then chmod +x linux_install && \ sed -i '108d;109d;110d;147d' linux_install && \ ./linux_install) - if [ "$(. /etc/os-release; echo $NAME)" = "Ubuntu" ]; then - if ! grep "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" ~/.profile; then - echo "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" >> ~/.profile - fi - elif [ "$(. /etc/os-release; echo $NAME)" = "Fedora" ]; then - if ! grep "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" ~/.bashrc; then - echo "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" >> ~/.bashrc - fi + if [ "$DISTRO" = "Ubuntu" ]; then + BASH_PROFILE = "~./profile" + elif [ "$DISTRO" = "Fedora" ]; then + BASH_PROFILE = "~./bashrc" + fi + if ! grep "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" $BASH_PROFILE; then + echo "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" >> $BASH_PROFILE fi export PATH=$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/ else @@ -92,8 +93,9 @@ else fi # Sourcing -if [ "$(. /etc/os-release; echo $NAME)" = "Ubuntu" ]; then - source ~/.profile #sourcing profile -elif [ "$(. /etc/os-release; echo $NAME)" = "Fedora" ]; then - source ~/.bashrc #sourcing bashrc +if [ "$DISTRO" = "Ubuntu" ]; then + BASH_PROFILE = "~./profile" +elif [ "$DISTRO" = "Fedora" ]; then + BASH_PROFILE = "~./bashrc" fi +source $BASH_PROFILE #sourcing the appropriate profile From 944f507eaa0462154995a766a2bf990cec4ed299 Mon Sep 17 00:00:00 2001 From: nara Date: Mon, 26 Feb 2018 13:44:51 -0700 Subject: [PATCH 4/4] install.sh modified to get rid of redundant statements --- STM32Resources/install.sh | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/STM32Resources/install.sh b/STM32Resources/install.sh index e4b0b6d..e17f78f 100644 --- a/STM32Resources/install.sh +++ b/STM32Resources/install.sh @@ -7,13 +7,16 @@ if [[ $UID != 0 ]]; then fi # Determine what distribution of Linux the user has -DISTRO = $(. /etc/os-release; echo $NAME) +DISTRO= $(. /etc/os-release; echo $NAME) # Install files according to Linux distribution that the user has if [ "$DISTRO" = "Ubuntu" ]; then + BASH_PROFILE = "~./profile" # set bash profile apt-get -y install build-essential git libsane:i386 ia32-libs-multiarch autoconf libusb-1.0-0-dev lib32ncurses5 libncurses5:i386 software-properties-common pkg-config cmake elif [ "$DISTRO" = "Fedora" ]; then + BASH_PROFILE = "~./bashrc" # set bash profile + # Install necessary 32-bit compliant packages dnf install --skip-broken glibc.i686 arts.i686 audiofile.i686 bzip2-libs.i686 cairo.i686 cyrus-sasl-lib.i686 dbus-libs.i686 directfb.i686 esound-libs.i686 fltk.i686 freeglut.i686 gtk2.i686 hal-libs.i686 imlib.i686 lcms-libs.i686 lesstif.i686 libacl.i686 libao.i686 libattr.i686 libcap.i686 libdrm.i686 libexif.i686 libgnomecanvas.i686 libICE.i686 libieee1284.i686 libsigc++20.i686 libSM.i686 libtool-ltdl.i686 libusb.i686 libwmf.i686 libwmf-lite.i686 libX11.i686 libXau.i686 libXaw.i686 libXcomposite.i686 libXdamage.i686 libXdmcp.i686 libXext.i686 libXfixes.i686 libxkbfile.i686 libxml2.i686 libXmu.i686 libXp.i686 libXpm.i686 libXScrnSaver.i686 libxslt.i686 libXt.i686 libXtst.i686 libXv.i686 libXxf86vm.i686 lzo.i686 mesa-libGL.i686 mesa-libGLU.i686 nas-libs.i686 nss_ldap.i686 cdk.i686 openldap.i686 pam.i686 popt.i686 pulseaudio-libs.i686 sane-backends-libs-gphoto2.i686 sane-backends-libs.i686 SDL.i686 svgalib.i686 unixODBC.i686 zlib.i686 compat-expat1.i686 compat-libstdc++-33.i686 openal-soft.i686 alsa-oss-libs.i686 redhat-lsb.i686 alsa-plugins-pulseaudio.i686 alsa-plugins-oss.i686 alsa-lib.i686 nspluginwrapper.i686 libXv.i686 libXScrnSaver.i686 qt.i686 qt-x11.i686 pulseaudio-libs.i686 pulseaudio-libs-glib2.i686 alsa-plugins-pulseaudio.i686 @@ -37,11 +40,6 @@ if ! type "st-flash" > /dev/null; then ln -s /opt/stlink/build/st-flash /usr/local/bin/st-flash ln -s /opt/stlink/build/st-info /usr/local/bin/st-info ln -s /opt/stlink/build/src/gdbserver/st-util /usr/local/bin/st-util - if [ "$DISTRO" = "Ubuntu" ]; then - BASH_PROFILE = "~./profile" - elif [ "$DISTRO" = "Fedora" ]; then - BASH_PROFILE = "~./bashrc" - fi echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/stlink/build" >> $BASH_PROFILE export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/stlink/build echo "export PATH=\$PATH:/opt/stlink/build" >> $BASH_PROFILE @@ -60,11 +58,6 @@ if ! type "CubeMX2Makefile" > /dev/null; then echo "ABS_PATH=\"\$(readlink -f \$1)\"" >> /usr/local/bin/CubeMX2Makefile echo "(cd /opt/CubeMX2Makefile && python CubeMX2Makefile.py \$ABS_PATH)" >> /usr/local/bin/CubeMX2Makefile chmod +x /usr/local/bin/CubeMX2Makefile - if [ "$DISTRO" = "Ubuntu" ]; then - BASH_PROFILE = "~./profile" - elif [ "$DISTRO" = "Fedora" ]; then - BASH_PROFILE = "~./bashrc" - fi echo "export PATH=\$PATH:/opt/CubeMX2Makefile" >> $BASH_PROFILE export PATH=$PATH:/opt/CubeMX2Makefile else @@ -79,11 +72,6 @@ if [ ! -d "/opt/gcc4mbed" ]; then chmod +x linux_install && \ sed -i '108d;109d;110d;147d' linux_install && \ ./linux_install) - if [ "$DISTRO" = "Ubuntu" ]; then - BASH_PROFILE = "~./profile" - elif [ "$DISTRO" = "Fedora" ]; then - BASH_PROFILE = "~./bashrc" - fi if ! grep "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" $BASH_PROFILE; then echo "export PATH=\$PATH:/opt/gcc4mbed/gcc-arm-none-eabi/bin/" >> $BASH_PROFILE fi @@ -93,9 +81,4 @@ else fi # Sourcing -if [ "$DISTRO" = "Ubuntu" ]; then - BASH_PROFILE = "~./profile" -elif [ "$DISTRO" = "Fedora" ]; then - BASH_PROFILE = "~./bashrc" -fi source $BASH_PROFILE #sourcing the appropriate profile