N00b: 7 blinks while building simple project with debug print

JimmyJams

New member
Hi everybody,

I'm new to the Teensy board, and I'm trying to learn more about it by tinkering with some Adafruit peripherals.
I was trying to build this in PlatformIO (moving functions to make it compile in C++): https://github.com/adafruit/Adafruit_SSD1327/blob/master/examples/ssd1327_test/ssd1327_test.ino
Without adding TeensyDebug it builds and works nicely, but just adding debug.begin(SerialUSB1); in the setup() function makes the board blink its led 7 times when uploading the binary.
The problem seems to be related if the constructor of Adafruit_SSD1327 is called, either globally or scoped in a function.
The same happens without adding TeensyDebug when I uncomment the define for PRINT_DEBUG_STUFF in packages/framework-arduinoteensy/cores/teensy4/debug/printf.h.

I'm using the latest Visual Studio Code with the latest PlatformIO.

The simplest way I've found to reproduce it on my board is to use the code below.
With the PRINT_DEBUG_STUFF macro not defined, it builds and run. I get seven blinks with the macro enabled.

Any idea what I may be doing wrong?

Code:

Code:
#include <Arduino.h>
#include <TeensyDebug.h>

void setup() {
  Serial.begin(115200);
  debug.begin(SerialUSB1);
}

void loop() {
  Serial.println("Alive and kicking");
  delay(100);
}

platformio.ini
Code:
; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:teensy41]
platform = teensy
board = teensy41
framework = arduino
upload_protocol = teensy-cli
lib_deps =
    https://github.com/ftrias/TeensyDebug

build_type = debug
build_unflags = -DUSB_SERIAL
build_flags = -DUSB_DUAL_SERIAL
debug_port = /dev/cu.usbmodem145015603 
debug_tool = custom
debug_load_mode = manual
debug_server = 
debug_init_cmds =
  target extended-remote $DEBUG_PORT
  $INIT_BREAK
  define pio_reset_run_target
  interrupt
  tbreak loop
  continue
  end
  define pio_restart_target
  echo Restart is undefined for now.
  end

debug_init_break =
 
meaning of blink codes here : pjrc.com/store/ic_mkl02_t4.html

for 7 it shows:
Code:
7 Blinks = ARM JTAG DAP Communication Error
A communication error was detected, but after correctly detecting (4 blinks) and initializing the ARM JTAG DAP (9 blinks). 
Programs which crash or have unusual startup behavior can cause a temporary 7 blink error at startup. With a known-good 
program or blank flash chip, this error may indicate a severe signal quality problem or any of the signal wires shorted to 
other lines which are initially high impedance but become output after a program is running. But these types of hardware
issues are unusual, because hardware trouble for 7 blinks requires first successfully passing tests which would cause
4 or 9 blinks. 7 blinks can also be shown if the processor reboots, either by software write to SCB_AIRCR or due to fault 
or other error handling, while communication is in progress. If you see 7 blinks, program the flash memory with a simple 
known-good code before investigating hardware trouble.

That suggests it could be troubled code.

Not sure what is in TeensyDebug - (use a working simple example and get the debug working) and how the build on PIO is affecting this.

If built with TeensyDuino current ver. 1.59 Beta 3 in the IDE the result might be different. Some changes were made to affect cpp constructors IIRC.
 
Back
Top