Yearly Archives: 2017


g++ not found on Fedora 25

On a Fedora 25 (64bit) we got the error g++ not found.

We could have installed g++ using:


sudo dnf install gcc-c++ -y;

But we wanted to install all common additional development tools that we might need for C/C++ development in the future without going over the list of available packages to find which ones.
To do so, we installed all the packages of the group that is marked to be used for C development using dnf as follows:


sudo dnf group install "C Development Tools and Libraries" -y;


A couple of notes on moving a VirtualBox ‘.vdi’ disk image to a GNOME Boxes virtual machine

Recently we had a CentOS virtual machine on VirtualBox which we wanted to use in GNOME Boxes.
We copied the .vdi disk image and we used it to create a new virtual machine in Boxes.

Note A:

By doing this we realized that the system did not reuse the .vdi image.
It merely created a copy at ~/.local/share/gnome-boxes/images/ that was suitable for GNOME Boxes.
So, be sure to have enough space when doing an import like this.
You will need at least twice the space of the .vdi image to complete the migration.

Note B:

When the guest OS started the window manager crashed and it did not allow us to login.
We assumed that this issue occurred due to the VirtualBox Guest Additions that were installed on the guest OS.
As we could not login with the graphical interface, we could not verify this claim.

Fortunately, CentOS (and many other Linux distributions) allow you to switch to a console login using the key combination alt + ctrl + F3.
(There are more than one valid key combinations to do this. In some systems alt + ctrl + F4 is also valid or alt + ctrl + F1 etc).
We hoped that by trying to login via a console login, the Guest Additions would not start and the system would not crash, which luckily this was the case, and we managed to login through the console!

After we logged in, we had to remove the Guest additions. To do so we had to execute the uninstall script that was located at /opt/VBoxGuestAdditions-X.Y.Z/uninstall.sh
(X.Y.Z is the version number of the installed VirtualBox Guest Additions).

When the removal was complete, we executed sudo reboot to restart the system and unload any VirtualBox services that could be executing at the time.
Once the system completed the restart we were able to login properly from the GUI of GNOME and use our virtual machine properly.


Really rough notes on compiling source code on Fedora 25 for STM32F767 Nucleo-144 (Nucleo-F767ZI)

#eclipse with support for C/C++
sudo dnf install -y eclipse-cdt;
#cross-compiler for arm
sudo dnf install -y arm-none-eabi-gcc arm-none-eabi-gdb arm-none-eabi-binutils arm-none-eabi-newlib arm-none-eabi-gcc-cs-c++;
#manually installing openocd from the repository as the version in the repositories does not support our board (STM32F767 Nucleo-144 (Nucleo-F767ZI))
git clone http://openocd.zylin.com/openocd;
cd openocd/;
./bootstrap;
./configure;
make;
sudo make install;

#download eclipse plugin from https://my.st.com/content/my_st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-configurators-and-code-generators/stsw-stm32095.license%3d1491636351998.html
#install using from menu “Help” > “Install New Software…” > “Add…” > “Archive…”. Find “en.stsw-stm32095.zip” and press OK. Tick new repo and click next.

#add http://gnuarmeclipse.sourceforge.net/updates as a repository in eclipse.  menu “Help” > “Install New Software…” > “Add…”. Type name “GNU arm eclipse” and type address “http://gnuarmeclipse.sourceforge.net/updates”. Press ok. Tick new repo and click next.

# st_nucleo_f7.cfg copy it with the rest of the configuration files e.g. /usr/local/share/openocd/scripts/board/
sudo cp st_nucleo_f7.cfg /usr/local/share/openocd/scripts/board/

Create a new st 7x project and add 2048 of memory

create a C/C++ run application run

create new openosd run to run the elf created by above run and add parameter

-f /usr/local/share/openocd/scripts/board/st_nucleo_f7.cfg

to config options in debugger tab

sudo usermod -a -G root george;
#if you get error on opening the usb device (really ugly hack)

 

Needed packages:

  • sudo dnf install -y arm-none-eabi-gcc arm-none-eabi-gdb arm-none-eabi-binutils arm-none-eabi-newlib
  • Do not install openocd from the repositories, clone the git server as it has a later version which supports our board.
    git clone http://openocd.zylin.com/openocd
    then build it

[download id=”2731″] copy it where you have the rest of the target files
e.g. /usr/share/openocd/scripts/board/st_nucleo_f7.cfg

[download id=”2732″]  copy it with the rest of the configuration files
e.g. /usr/share/openocd/scripts/target/stm32f7x.cfg

The locations for the above files depend on your configuration

You need to download the STM32CubeF7 (https://my.st.com/content/my_st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef7.license%3d1487716364634.html) ~634MB
Extract it.

Navigate to a ready project like the GPIO_IOToggle in STM32Cube_FW_F7_V1.6.0/Projects/STM32F767ZI-Nucleo/Examples/GPIO/GPIO_IOToggle

Compile each .c file using the following command, but fix the paths !!! You also might need ton include the Inc directory of the project
e.g.
arm-none-eabi-gcc -Wall -mcpu=cortex-m7 -mlittle-endian -mthumb -ISTM32Cube_FW_F7_V1.6.0/Drivers/CMSIS/Device/ST/STM32F7xx/Include -ISTM32Cube_FW_F7_V1.6.0/Drivers/CMSIS/Include -ISTM32Cube_FW_F7_V1.6.0/Drivers/STM32F7xx_HAL_Driver/Inc -I. -ISTM32Cube_FW_F7_V1.6.0/Drivers/BSP/STM32F7xx_Nucleo_144 -DSTM32F767xx -Os -c system_stm32f7xx.c -o system_stm32f7xx.o

Merge all .o files into an .elf file

arm-none-eabi-gcc -mcpu=cortex-m7 -mlittle-endian -mthumb -DSTM32F767xx -TSTM32Cube_FW_F7_V1.6.0/Projects/STM32F767ZI-Nucleo/Templates/SW4STM32/STM32F767ZI_Nucleo_AXIM_FLASH/STM32F767ZITx_FLASH.ld -Wl,–gc-sections system_stm32f7xx.o main.o stm32f7xx_it.o -o main.elf

Convert the .elf file to a .hex

arm-none-eabi-objcopy -Oihex main.elf main.hex
Start openocd to attach to the board

sudo ../src/openocd -f /usr/share/openocd/scripts/board/st_nucleo_f7.cfg

Use telnet to control the board

telnet localhost 4444

Flash the board

reset halt
flash write_image erase /home/xeirwn/Downloads/ST/GPIO_IOToggle/Src/main.hex
reset run

 

DONE

 

 

sudo dnf install eclipse-cdt-sdk;

download plugin from here https://my.st.com/content/my_st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-configurators-and-code-generators/stsw-stm32095.license%3d1491636351998.html

 

add http://gnuarmeclipse.sourceforge.net/updates as a repository in eclipse

sudo dnf install -y arm-none-eabi-gcc-cs-c++;

create new openosd run and add parameter

-f /usr/share/openocd/scripts/board/st_nucleo_f7.cfg

to config options in debugger tab

add   RCC_OscInitStruct.PLL.PLLR = 7; to _initialize_hardware.c

 

I hope I did not forget anything

Anyhow, this post will be updated soon

 


Script to clone all git repositories from all projects of a privately hosted Bitbucket server 1

The following script can download all git repositories from all of the projects that you have access to on a privately hosted Bitbucket server.

The execution work-flow of this script is as follows:

  1. It will ask for your username (the one you use to login on the Bitbucket server)
  2. Then it will ask for your password, the password will not be visible on screen as you type because we disabled the echo functionality for that step.
  3. Later, you will be prompted to provide the URL of the server, for this step be sure to define the protocol if it is http or https and the correct port number as well (e.g. https://bitbucket.bytefreaks.net:7990)
  4. Finally, you will be requested to give the location to where the repositories should be cloned to.
  5. Then the script will connect to the server, get the list of projects that you have access to and for each project retrieve the repositories of the project and clone them in the designated folder.

[download id=”2637″]


#!/bin/bash

echo -n "Username: ";
read username;
echo -n "Password: "; 
#Disabling echo, so that password will not be visible on screen
read -s password
#Enabling echo
echo

echo -n "Server (e.g https://repository.bytefreaks.net:7990): ";
read server;
echo -n "Location to clone repositories in: ";
read location;

mkdir -p "$location";
cd "$location";

#Getting all projects
curl --user "$username:$password" "$server/rest/api/1.0/projects/" | \
  grep -oP '"key":"\K\w+' | xargs -I {} -n 1 -I_project -- sh -c \
    "curl --user \"$username:$password\" \"$server/rest/api/1.0/projects/_project/repos\" | grep -o '\"ssh:[^ ,]\+' | xargs -L1 git clone";

exit 0;

[download id=”2637″]

 

Notes for the future:

  • Separate the cloned repositories per project
  • Support for people that have hundreds of projects and/or hundreds of repositories using the paging functionality