Software installation

From Rsewiki
Revision as of 14:00, 24 October 2022 by Jca (Talk | contribs)

Jump to: navigation, search

Back to Regot main page.

Contents

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

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

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)

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, libraries and teensy3 directories,

Links: go into the regbot directory with the Teensy source and Makefile (source code is in the sec subdirectory)

cd regbot
ln -s ~/arduino-1.8.13/hardware/tools .
ln -s ~/arduino-1.8.13/hardware/teensy/avr/cores/teensy3 .
ln -s ~/arduino-1.8.13/hardware/teensy/avr/cores/teensy4 .
ln -s ~/arduino-1.8.13/hardware/teensy/avr/libraries .
ln -s tools/teensy .

The last link is only for convenience to start the teensy loader application.

Teensy 3.2, 3.5 or 4.1

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

cd ~/regbot/regbot
make
make upload

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

Teensy 4.1 special

The Arduino version may have to be correct, especially for Teensy 4.1.

  • Arduino 1.8.13 is OK for Teensy 4.1
  • Arduino 1.8.15 or 1.8.19 are not OK; Teensy 4.1 fails to boot when compiled with these versions (as of 13 Oct 2022)
  • for other hardware versions, all compiles fine.

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

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.13/hardware/teensy/avr/libraries
ln -s ~/git/Adafruit_BusIO
ln -s ~/git/Adafruit-GFX-Library
ln -s ~/git/Adafruit_SSD1306

Compile REGBOT

Compile the source

make

Common errors

Compile error "constexpr"

The ADC library is more modern C++ than the C++ compiler version 9.3 (Linux 20.04), no problem for GCC version 10 (Linux 22.04).

Solution:

In libraries/ADC the following places "constexpr" can be replaced with "inline"

libraries/ADC/settings_defines.h:423:    constexpr uint32_t get_CFG_VERY_LOW_SPEED(uint32_t f_adc_clock)
libraries/ADC/settings_defines.h:448:    constexpr uint32_t get_CFG_LOW_SPEED(uint32_t f_adc_clock)
libraries/ADC/settings_defines.h:473:    constexpr uint32_t get_CFG_HI_SPEED_16_BITS(uint32_t f_adc_clock)
libraries/ADC/settings_defines.h:499:    constexpr uint32_t get_CFG_MEDIUM_SPEED(uint32_t f_adc_clock)
libraries/ADC/settings_defines.h:514:    constexpr uint32_t get_CFG_HIGH_SPEED(uint32_t f_adc_clock)
libraries/ADC/settings_defines.h:540:    constexpr uint32_t get_CFG_VERY_HIGH_SPEED(uint32_t f_adc_clock)

And where is say "inline" already, then just remove the "constexpr".

libraries/ADC/settings_defines.h:668:    inline constexpr ADC_ERROR operator|(ADC_ERROR lhs, ADC_ERROR rhs)
libraries/ADC/settings_defines.h:673:    inline constexpr ADC_ERROR operator&(ADC_ERROR lhs, ADC_ERROR rhs)

The same issue is present in other libraries teensyduino too, but these are not used in Regbot.

On the Raspberry, use e.g. the editor:

geany libraries/ADC/settings_defines.h
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 has 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.

Upload to REGBOT

Remember to update and compile with the right 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

Use the teensy loader, 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)

NB! If Regbot runs on battery, then 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, and thus power off the Regbot (and the Raspberry Pi if on the same robot).

If you upload from a Raspberry pi, then this method requires access to a screen, either 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