Software installation

From Rsewiki
(Difference between revisions)
Jump to: navigation, search
(Teensy 3.5 SD-card error)
(Teensy 3.2, 3.5 or 4.1 compile)
 
(51 intermediate revisions by one user not shown)
Line 4: Line 4:
 
==Software installation==
 
==Software installation==
  
Software installation to maintain the REGBOT code on the Teensy3.1/2 platform.
+
Software installation to maintain the REGBOT code on the Teensy platform.
  
The description is tested on Ubuntu Linux 32bit and 64bit - version 14.04 (Long Time Stable (LTS) version)
+
The description is tested on Ubuntu Linux 32bit and 64bit - version 20.04 (Long Time Stable (LTS) version)
 +
 
 +
Parts of this page are deprecated, as all platforms now are modified to use Teensy 4.1 (blue baseboard, version 6.3)
  
 
===Toolchain installation===
 
===Toolchain installation===
Line 12: Line 14:
 
Install (unpack) arduino software from
 
Install (unpack) arduino software from
 
https://www.arduino.cc/en/Main/Software
 
https://www.arduino.cc/en/Main/Software
(tested with version 1.6.9 ... 1.8.5) on 32 bit and 64 bit (k)ubuntu linux and raspberry (noops) - see Teensy page for compatible version)
+
(tested with version 1.6.9 ... 1.8.19) on 32 bit and 64 bit (k)ubuntu linux and raspberry (noops) - see Teensy page for compatible version)
  
 
Unpack with (replase "1.6.9" and "linux32" with the version you installed)
 
Unpack with (replase "1.6.9" and "linux32" with the version you installed)
Line 21: Line 23:
 
https://www.pjrc.com/teensy/td_download.html
 
https://www.pjrc.com/teensy/td_download.html
  
Run the installer - on 32 bit linux it is:
+
It installes (only) as a merge with the Arduino installed directory (arduino-1.6.9).
chmod +x TeensyduinoInstall.linux32 
+
./TeensyduinoInstall.linux32
+
  
It installes (only) as a merge with the arduino installed directory (arduino-1.6.9).
+
(@todo - old part to be removed - next 5 lines)
  
From this installation we need only some hardware parts in
+
NB! Teensyduino version 1.52 uses C++ features that are available in C++17 (constexpr including if statements) - i.e. in GCC compiler version 10 or higher.
 +
Check your GCC version before installing a newer version.
  
  arduino-1.6.9/hardware/tools
+
  gcc -v
arduino-1.6.9/hardware/teensy/avr/cores/teensy3
+
  
====ADC using interrupt====
+
Ubuntu 20.04 uses GCC version 9.6 (as of nov 2020)
 
+
NB! in version installed with arduino 1.8 this library is already included - so skip this part.
+
  
 
===Teensy loader and udev rules===
 
===Teensy loader and udev rules===
 +
 +
@todo add these sections (next 2)
 +
 +
==== Arduino version 2.x ====
 +
 +
* Install the newest Arduino GUI.
 +
* Install Teensyduino as described on this page: https://www.pjrc.com/teensy/td_download.html
 +
* Add the Teensy board support (as described in above link)
 +
* Add these extra libraries:
 +
** Adafruit_BusIO
 +
** Adafruit-GFX-Library
 +
** MPU9250_asukiaaa
 +
 +
For Linux, also download the 00-teensy.rules. From the 'Stand Alone Files' in link https://www.pjrc.com/teensy/td_download.html
 +
and move it to the /etc/udev/rules.d directory.
 +
 +
==== Arduino version 1.8.19 ====
 +
  
 
Teensy loader:
 
Teensy loader:
Get the loader (or the command-line-loader - maybe better on raspberry) - and udev rules - from  
+
Get the loader (or the command-line-loader - maybe better on Raspberry) - and udev rules - from  
 
  https://www.pjrc.com/teensy/loader.html
 
  https://www.pjrc.com/teensy/loader.html
  
The teensy loader needs to be unpacked  - on linux it is:
+
The teensy loader needs to be unpacked  - on Linux it is:
 
  gunzip teensy.gz
 
  gunzip teensy.gz
 
  chmod +x teensy
 
  chmod +x teensy
  
For Linux get also the udev rules, and copy them to /etc/udev/rules.d to get read-write access to the usb connection (/dev/ttyACM0) and others:
+
For Linux get the udev rules and copy them to /etc/udev/rules.d to get read-write access to the USB connection (/dev/ttyACM0) and others:
  
 
  sudo cp 49-teensy.rules /etc/udev/rules.d/
 
  sudo cp 49-teensy.rules /etc/udev/rules.d/
  
 
===Teensy 3.1 memory issues===
 
===Teensy 3.1 memory issues===
 +
 +
@todo (No longer relevant, as we moved to Teensy 4.1)
  
 
The teensy 3.1 using MK20DX256 32 processor from Freescale.
 
The teensy 3.1 using MK20DX256 32 processor from Freescale.
Line 70: Line 88:
 
- se test on this page: http://eleccelerator.com/kinetis-microcontroller-sram-region-hard-faults/
 
- se test on this page: http://eleccelerator.com/kinetis-microcontroller-sram-region-hard-faults/
  
In case of REGBOT, about 35kB of static memory is allocated for data logging, this means
+
In the case of REGBOT, about 35kB of static memory is allocated for data logging; this means
 
that this memory will overlap the boundary at 0x20000000.
 
that this memory will overlap the boundary at 0x20000000.
  
Line 77: Line 95:
  
 
Heap space is used by some libraries, and usually no more than 1.5kB is allocated as heap space.
 
Heap space is used by some libraries, and usually no more than 1.5kB is allocated as heap space.
this leaves about 20kB as stack space. It is not tested how much of this is used.
+
This leaves about 20kB as stack space. How much of this is used has not been tested.
  
 
===Regbot software===
 
===Regbot software===
 
   
 
   
Then get the regbot software (from SVN repository on previous page)
+
Then get the regbot software  
  
It consist of a series of directories but is missing the ''tools'', ''Snooze'' and ''teensy3'' directories,
+
From a command prompt in either Linux or Windows with SVN (Subversion (Apache)):
  
Copy (or link) the ''arduino-1.0.6/hardware/tools'', ''arduino-1.0.6/libraries/Snooze'' and ''arduino-1.0.6/hardware/teensy/cores/teensy3'' directory to the regbot directory,
+
$ svn checkout svn://repos.gbar.dtu.dk/jcan/regbot
or set the ''TOOLSPATH'' and ''COREPATH'' in the regbot ''Makefile''.
+
- in my Makefile I have added the special teensy library path as "libteensy", as in the 4th libe below.
+
  
Links: go into the regbot directory with the source
+
Thye regbot firmware is in a further 'regbot' subdirectory
cd regbot
+
ln -s ~/arduino-1.6.13/hardware/tools .
+
ln -s ~/arduino-1.6.13/hardware/teensy/avr/cores/teensy3 .
+
ln -s ~/arduino-1.6.13/hardware/teensy/avr/libraries libteensy 
+
ln -s tools/teensy .
+
  
The last link is only for convenience to start the teensy loader application.
+
$ cd regbot/regbot
Ther arduino version is probably different.
+
  
====Compile REGBOT====
+
The makefile need to be modified for the path to the Arduino libraries.
  
Compile the source
+
====Modify Makefile====
make
+
  
====Common errors====
+
If svn version is older than 1561, then see the next section.
  
===== * multiple main =====
+
Modify the Makefile (in regbot/regbot, regbot/regbot/4.1, regbot/regbot/3.5 as needed)
  
You probably get:
+
Modify the BASEPATH to the Arduino/Teensyduino library about line 31 of the Makefile (for Robobot it should work as is):
make
+
...
+
.../regbot/teensy3/main.cpp:4: multiple definition of `main'
+
.../regbot/build/src/main.o:/.../regbot/src/main.cpp:434: first defined here
+
collect2: error: ld returned 1 exit status
+
make: *** [regbot.elf] Fejl 1
+
  
Then rename the teensy3 main file from the compile set
+
ARDUINO_ROBOBOT := $(shell ls -d /home/local/Downloads/arduino-1.8.19/hardware 2>/dev/null)
 +
ifeq ($(ARDUINO_ROBOBOT),)
 +
  # '''home installation''' - modify as needed
 +
  BASEPATH := '''/home/chr/Downloads/arduino/arduino-1.8.19/hardware'''
 +
else
 +
  # raspberry pi based RoboBot
 +
  BASEPATH := /home/local/Downloads/arduino-1.8.19/hardware
 +
endif
  
mv teensy3/main.cpp teensy3/main.cpp.not_used
+
This change is actuated, as my development tool (Kdevelop) failed to work with the previous symbolic links, but it is also a more standard solution.
  
===== Teensy 3.5 SD-card error =====
+
====Teensy 4.1 special ====
  
Compiling to teensy 3.5 (3.6) with SD card support fails,
 
  
These 2 files has an include error:
+
Additional libraries from Ardufruit are needed for the small display:
 +
* Adafruit_BusIO to get additional services from the I2C interface
 +
* Adafruit-GFX-Library to get the paint functions for the display
 +
* Adafruit_SSD1306 to get the specifics for the used display
 +
git clone https://github.com/adafruit/Adafruit_BusIO.git
 +
git clone https://github.com/adafruit/Adafruit_SSD1306.git
 +
git clone https://github.com/adafruit/Adafruit-GFX-Library
 +
git clone https://github.com/pfeerick/elapsedMillis.git
 +
git clone https://github.com/asukiaaa/MPU9250_asukiaaa.git (@todo add this line)
  
nano libteensy/SD/utility/SdFile.cpp
+
The obtained libraries should be included in the Arduino/Teensyduino library list, e.g. if the GIT repositories are in a ~/git directory:
nano libteensy/SD/utility/SdVolume.cpp
+
  
In these files, change '#include <SdFat.h>' to '#include "SdFat.h"' in one of the first code lines.
+
cd Arduino-1.8.19/hardware/teensy/avr/libraries
 +
ln -s ~/git/Adafruit_BusIO
 +
ln -s ~/git/Adafruit-GFX-Library
 +
ln -s ~/git/Adafruit_SSD1306
 +
ln -s ~/git/elapsedMillis
 +
ln -s ~/git/MPU9250_asukiaaa (@todo add this line)
  
===Upload to REGBOT===
+
==== Teensy 3.2, 3.5 or 4.1 compile ====
  
Use the teensy loader, point it to the regbot.hex file and upload/auto. Then press the small button on the Teensy.
+
To compile for the Teensy 3.2-based boards, compile from the base directory
 +
cd ~/regbot/regbot
 +
make
 +
make upload
  
./teensy
+
An alternative to "make upload" that requires an X-display is teensy_loader_cli (Teensy command-line loader).
 +
A compiled version of teensy_loader_cli is available (compiled for Raspberry Pi and a teensy_loader_cli_ubuntu compiled for Ubuntu).
  
NB! If Regbot runs on battery, then PRESS and HOLD the (red) "on" button BEFORE and DURING the teensy programming.  
+
To compile for the Teensy 3.5 board
During programming the pin that keeps the Regbot ON will be disabled, and thus power off the Regbot (and the Raspberry Pi if on the same robot).
+
cd ~/regbot/regbot/3.5
 +
make
 +
make upload
 +
To compile for the Teensy 4.1 board
 +
cd ~/regbot/regbot/4.1
 +
make
 +
make upload
  
===Python packages===
+
NB! for Teensy 4.1 the produced regbot.hex file fails to work when compiled on Raspberry using the Makefile, but it works OK using Arduino GUI (also on Raspberry). Use the regbot.hex provided in the repository:
  
Additional python packages used
+
cd ~/regbot/regbot/4.1
 +
svn revert regbot.hex
 +
teensy upload
  
* python-pyqtgraph
+
NB2! Remember to press and hold the "power" button during the "make upload" command. The Teensy will make all ports input-pins, which is the same as powering off.
* python-qt4-gl
+
* python-serial
+
* python-scipy
+
  
sudo apt install python-pyqtgraph python-qt4-gl python-serial python-scipy
+
Make runs faster if the number of CPU cores is increased. On Raspberry with little memory (1GB or less) or a small cooling plate, then use 3 CPU cores or less:
  
 +
make -j3
  
=====* no python-pyqtgraph =====
+
====Common errors====
  
On my 14.04 32 bit ubuntu the python-pyqtgraph package was not found using apt-get, so I
+
===== Teensy 3.5 SD-card error =====
  
downloaded from http://www.pyqtgraph.org/
+
Earlier than version 1.8.16 of Arduino:
the debian package ''python-pyqtgraph_0.9.10-1_all.deb'' and installed using:
+
Compiling to teensy 3.5 (3.6) with SD card support fails,
  
sudo dpkg -i python-pyqtgraph_0.9.10-1_all.deb
+
These 2 files have an include error:
  
===Kdevelop===
+
nano libraries/SD/utility/SdFile.cpp
 +
nano libraries/SD/utility/SdVolume.cpp
  
To use Kdevelop as integrated development tool, install the following packges
+
In these files, change '#include <SdFat.h>' to '#include "SdFat.h"' in one of the first code lines.
  
kdevelop
+
===Upload to REGBOT===
kdev-python
+
sudo apt install kdevelop kdev-python
+
  
===QT designer===
+
Remember to update and compile with the proper makefile.
 +
 
 +
Regbot board with Teensy 3.2 (green board)
 +
 
 +
cd regbot
 +
svn up
 +
make
 +
 
 +
Regbot board with Teensy 3.5 (red mainboard), you need to use the makefile in the 3.5 subdirectory.
 +
 
 +
cd regbot/3.5
 +
make
 +
 
 +
Regbot board with Teensy 4.1 (purple mainboard), you need to use the makefile in the 4.1 subdirectory.
 +
 
 +
cd regbot/4.1
 +
make
  
To use QT dialog designer (editing regbot.ui) use the qt4-designer and to convert the ui file to python use qtuic4 command, install the packages
+
Use the teensy loader, and point it to the regbot.hex file and upload/auto. Then press the small button on the Teensy.
  
  qt4-designer
+
  ./teensy
pyqt4-dev-tools
+
  
To convert the regbot.ui to regbotdesign.py use the command
+
Select the correct regbot.hex, either
 +
regbot/regbot.hex        - for Teensy 3.2 (green boards)
 +
regbot/3.5/regbot.hex    - for Teensy 3.5 (red board)
 +
regbot/4.1/regbot.hex    - for Teensy 4.1 (purple and blue board)
  
pyuic4 regbot.ui -o regbotdesign.py
+
NB! If Regbot runs on battery, PRESS and HOLD the (red) "power" button BEFORE and DURING the teensy programming.  
 +
During programming, the pin that keeps the Regbot ON will be disabled, thus powering off the Regbot (and the Raspberry Pi if on the same robot).
  
And to convert the dialog_control.ui use
+
If you upload from a Raspberry Pi, this method requires access to a screen directly on the Raspberry or using x-forwarding (ssh -X local@...).
  
  pyuic4 dialog_control.ui -o dialog_control.py
+
To upload, you can use
 +
  make upload

Latest revision as of 11:35, 26 May 2024

Back to Regot main page.

Contents

[edit] Software installation

Software installation to maintain the REGBOT code on the Teensy platform.

The description is tested on Ubuntu Linux 32bit and 64bit - version 20.04 (Long Time Stable (LTS) version)

Parts of this page are deprecated, as all platforms now are modified to use Teensy 4.1 (blue baseboard, version 6.3)

[edit] Toolchain installation

Install (unpack) arduino software from https://www.arduino.cc/en/Main/Software (tested with version 1.6.9 ... 1.8.19) on 32 bit and 64 bit (k)ubuntu linux and raspberry (noops) - see Teensy page for compatible version)

Unpack with (replase "1.6.9" and "linux32" with the version you installed)

tar xf arduino-1.6.9-linux32.tar.xz

This makes a directory called arduino-1.6.9

Then get and install the teensey tool installer from (this page also shows which version of arduino that is compatible): https://www.pjrc.com/teensy/td_download.html

It installes (only) as a merge with the Arduino installed directory (arduino-1.6.9).

(@todo - old part to be removed - next 5 lines)

NB! Teensyduino version 1.52 uses C++ features that are available in C++17 (constexpr including if statements) - i.e. in GCC compiler version 10 or higher. Check your GCC version before installing a newer version.

gcc -v

Ubuntu 20.04 uses GCC version 9.6 (as of nov 2020)

[edit] Teensy loader and udev rules

@todo add these sections (next 2)

[edit] Arduino version 2.x

  • Install the newest Arduino GUI.
  • Install Teensyduino as described on this page: https://www.pjrc.com/teensy/td_download.html
  • Add the Teensy board support (as described in above link)
  • Add these extra libraries:
    • Adafruit_BusIO
    • Adafruit-GFX-Library
    • MPU9250_asukiaaa

For Linux, also download the 00-teensy.rules. From the 'Stand Alone Files' in link https://www.pjrc.com/teensy/td_download.html and move it to the /etc/udev/rules.d directory.

[edit] Arduino version 1.8.19

Teensy loader: Get the loader (or the command-line-loader - maybe better on Raspberry) - and udev rules - from

https://www.pjrc.com/teensy/loader.html

The teensy loader needs to be unpacked - on Linux it is:

gunzip teensy.gz
chmod +x teensy

For Linux get the udev rules and copy them to /etc/udev/rules.d to get read-write access to the USB connection (/dev/ttyACM0) and others:

sudo cp 49-teensy.rules /etc/udev/rules.d/

[edit] Teensy 3.1 memory issues

@todo (No longer relevant, as we moved to Teensy 4.1)

The teensy 3.1 using MK20DX256 32 processor from Freescale. It has 64kB of RAM, but it is divided into 2 x 32kByte.

0x20007fff  top of RAM <- stack starts here

    32kB Upper part of memory

            <- Heap starts just after static variable allocation
0x20000000    |
0x1fffffff    |  REGBOT uses about 40kB of static allocated RAM
              |
    32kB Lower part of memory
              |
0x1fff8000  Start of RAM <- static variables allocated from here

A variable placed in memory overlapping the boundary between upper and lower memory is not allowed - se test on this page: http://eleccelerator.com/kinetis-microcontroller-sram-region-hard-faults/

In the case of REGBOT, about 35kB of static memory is allocated for data logging; this means that this memory will overlap the boundary at 0x20000000.

This is handled when data is added or retrieved from the log, the chunk of data overlapping the boundary is left unused. The result is that one less line of logged data is available, but there is no gap in the data stream.

Heap space is used by some libraries, and usually no more than 1.5kB is allocated as heap space. This leaves about 20kB as stack space. How much of this is used has not been tested.

[edit] Regbot software

Then get the regbot software

From a command prompt in either Linux or Windows with SVN (Subversion (Apache)):

$ svn checkout svn://repos.gbar.dtu.dk/jcan/regbot

Thye regbot firmware is in a further 'regbot' subdirectory

$ cd regbot/regbot

The makefile need to be modified for the path to the Arduino libraries.

[edit] Modify Makefile

If svn version is older than 1561, then see the next section.

Modify the Makefile (in regbot/regbot, regbot/regbot/4.1, regbot/regbot/3.5 as needed)

Modify the BASEPATH to the Arduino/Teensyduino library about line 31 of the Makefile (for Robobot it should work as is):

ARDUINO_ROBOBOT := $(shell ls -d /home/local/Downloads/arduino-1.8.19/hardware 2>/dev/null)
ifeq ($(ARDUINO_ROBOBOT),)
  # home installation - modify as needed
  BASEPATH := /home/chr/Downloads/arduino/arduino-1.8.19/hardware
else
  # raspberry pi based RoboBot
  BASEPATH := /home/local/Downloads/arduino-1.8.19/hardware
endif

This change is actuated, as my development tool (Kdevelop) failed to work with the previous symbolic links, but it is also a more standard solution.

[edit] Teensy 4.1 special

Additional libraries from Ardufruit are needed for the small display:

  • Adafruit_BusIO to get additional services from the I2C interface
  • Adafruit-GFX-Library to get the paint functions for the display
  • Adafruit_SSD1306 to get the specifics for the used display
git clone https://github.com/adafruit/Adafruit_BusIO.git
git clone https://github.com/adafruit/Adafruit_SSD1306.git
git clone https://github.com/adafruit/Adafruit-GFX-Library
git clone https://github.com/pfeerick/elapsedMillis.git
git clone https://github.com/asukiaaa/MPU9250_asukiaaa.git (@todo add this line)

The obtained libraries should be included in the Arduino/Teensyduino library list, e.g. if the GIT repositories are in a ~/git directory:

cd Arduino-1.8.19/hardware/teensy/avr/libraries
ln -s ~/git/Adafruit_BusIO
ln -s ~/git/Adafruit-GFX-Library
ln -s ~/git/Adafruit_SSD1306
ln -s ~/git/elapsedMillis
ln -s ~/git/MPU9250_asukiaaa (@todo add this line)

[edit] Teensy 3.2, 3.5 or 4.1 compile

To compile for the Teensy 3.2-based boards, compile from the base directory

cd ~/regbot/regbot
make
make upload

An alternative to "make upload" that requires an X-display is teensy_loader_cli (Teensy command-line loader). A compiled version of teensy_loader_cli is available (compiled for Raspberry Pi and a teensy_loader_cli_ubuntu compiled for Ubuntu).

To compile for the Teensy 3.5 board

cd ~/regbot/regbot/3.5
make
make upload

To compile for the Teensy 4.1 board

cd ~/regbot/regbot/4.1
make
make upload

NB! for Teensy 4.1 the produced regbot.hex file fails to work when compiled on Raspberry using the Makefile, but it works OK using Arduino GUI (also on Raspberry). Use the regbot.hex provided in the repository:

cd ~/regbot/regbot/4.1
svn revert regbot.hex
teensy upload

NB2! Remember to press and hold the "power" button during the "make upload" command. The Teensy will make all ports input-pins, which is the same as powering off.

Make runs faster if the number of CPU cores is increased. On Raspberry with little memory (1GB or less) or a small cooling plate, then use 3 CPU cores or less:

make -j3

[edit] Common errors

[edit] Teensy 3.5 SD-card error

Earlier than version 1.8.16 of Arduino: Compiling to teensy 3.5 (3.6) with SD card support fails,

These 2 files have an include error:

nano libraries/SD/utility/SdFile.cpp 
nano libraries/SD/utility/SdVolume.cpp

In these files, change '#include <SdFat.h>' to '#include "SdFat.h"' in one of the first code lines.

[edit] Upload to REGBOT

Remember to update and compile with the proper makefile.

Regbot board with Teensy 3.2 (green board)

cd regbot
svn up
make

Regbot board with Teensy 3.5 (red mainboard), you need to use the makefile in the 3.5 subdirectory.

cd regbot/3.5
make

Regbot board with Teensy 4.1 (purple mainboard), you need to use the makefile in the 4.1 subdirectory.

cd regbot/4.1
make

Use the teensy loader, and point it to the regbot.hex file and upload/auto. Then press the small button on the Teensy.

./teensy 

Select the correct regbot.hex, either

regbot/regbot.hex        - for Teensy 3.2 (green boards)
regbot/3.5/regbot.hex    - for Teensy 3.5 (red board)
regbot/4.1/regbot.hex    - for Teensy 4.1 (purple and blue board)

NB! If Regbot runs on battery, PRESS and HOLD the (red) "power" button BEFORE and DURING the teensy programming. During programming, the pin that keeps the Regbot ON will be disabled, thus powering off the Regbot (and the Raspberry Pi if on the same robot).

If you upload from a Raspberry Pi, this method requires access to a screen directly on the Raspberry or using x-forwarding (ssh -X local@...).

To upload, you can use

make upload
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox