Software installation: Difference between revisions

From Rsewiki
Line 122: Line 122:
===== Teensy 3.5 SD-card error =====
===== Teensy 3.5 SD-card error =====


Compiling to teensy 3.5 (3.6) with SD card support fails, 2 files has an include error:
Compiling to teensy 3.5 (3.6) with SD card support fails,  
 
These 2 files has an include error:


libteenst/SD/utility/SdFile.cpp  
libteenst/SD/utility/SdFile.cpp  
Line 128: Line 130:
libteensy/SD/utility/SdVolume.cpp
libteensy/SD/utility/SdVolume.cpp


include <SdFat.h> should be #include "SdFat.h"
In these files, change '#include <SdFat.h>' to '#include "SdFat.h"'


===Upload to REGBOT===
===Upload to REGBOT===

Revision as of 10:04, 24 October 2018

Back to Regot main page.

Software installation

Software installation to maintain the REGBOT code on the Teensy3.1/2 platform.

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

Toolchain installation

Install (unpack) arduino software from 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)

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

Run the installer - on 32 bit linux it is:

chmod +x TeensyduinoInstall.linux32  
./TeensyduinoInstall.linux32

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

From this installation we need only some hardware parts in

arduino-1.6.9/hardware/tools
arduino-1.6.9/hardware/teensy/avr/cores/teensy3

ADC using interrupt

NB! in version installed with arduino 1.8 this library is already included - so skip this part.

Teensy loader and udev rules

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 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:

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

Teensy 3.1 memory issues

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 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. It is not tested how much of this is used.

Regbot software

Then get the regbot software (from SVN repository on previous page)

It consist of a series of directories but is missing the tools, Snooze and teensy3 directories,

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, 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

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. Ther arduino version is probably different.

Compile REGBOT

Compile the source

make

Common errors

* multiple main

You probably get:

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

mv teensy3/main.cpp teensy3/main.cpp.not_used
Teensy 3.5 SD-card error

Compiling to teensy 3.5 (3.6) with SD card support fails,

These 2 files has an include error:

libteenst/SD/utility/SdFile.cpp

libteensy/SD/utility/SdVolume.cpp

In these files, change '#include <SdFat.h>' to '#include "SdFat.h"'

Upload to REGBOT

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

./teensy

NB! If Regbot runs on battery, then PRESS and HOLD the (red) "on" button BEFORE and DURING the teensy programming. 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).

Python packages

Additional python packages used

  • python-pyqtgraph
  • python-qt4-gl
  • python-serial
  • python-scipy
sudo apt install python-pyqtgraph python-qt4-gl python-serial python-scipy


* no python-pyqtgraph

On my 14.04 32 bit ubuntu the python-pyqtgraph package was not found using apt-get, so I

downloaded from http://www.pyqtgraph.org/ the debian package python-pyqtgraph_0.9.10-1_all.deb and installed using:

sudo dpkg -i python-pyqtgraph_0.9.10-1_all.deb

Kdevelop

To use Kdevelop as integrated development tool, install the following packges

kdevelop
kdev-python
sudo apt install kdevelop kdev-python

QT designer

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

qt4-designer
pyqt4-dev-tools

To convert the regbot.ui to regbotdesign.py use the command

pyuic4 regbot.ui -o regbotdesign.py

And to convert the dialog_control.ui use

pyuic4 dialog_control.ui -o dialog_control.py