This is a cache of https://discuss.96boards.org/t/how-to-execute-and-serial-out-arduino-sketches-on-ultra96-v2/8895. It is a snapshot of the page at 2024-10-31T12:05:00.423+0000.
How to Execute and Serial Out Arduino sketches on Ultra96-v2? - Ultra96 - 96Boards Forum

How to Execute and Serial Out Arduino sketches on Ultra96-v2?

I have a small program that I compiled, but don’t know how to execute and how to open the terminal port ?

The code is

cat helloworld.ino
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println (“hello”);
delay(1000);
}

  1. Makefile

cat makefile
MONITOR_PORT=/dev/ttyS2
include /usr/share/arduino/Arduino.mk

  1. make

make
Arduino.mk Configuration:

  • [AUTODETECTED] CURRENT_OS = LINUX
  • [AUTODETECTED] ARDUINO_DIR = /usr/share/arduino
  • [COMPUTED] ARDMK_DIR = /usr/share/arduino (relative to Common.mk)
  • [AUTODETECTED] ARDUINO_VERSION = 105
  • [DEFAULT] ARCHITECTURE =
  • [DEFAULT] ARDMK_VENDOR = arduino
  • [DEFAULT] ARDUINO_SKETCHBOOK =
  • [BUNDLED] AVR_TOOLS_DIR = /usr/share/arduino/hardware/tools/avr (in Arduino distribution)
  • [COMPUTED] ARDUINO_LIB_PATH = /usr/share/arduino/libraries (from ARDUINO_DIR)
  • [COMPUTED] ARDUINO_VAR_PATH = /usr/share/arduino/hardware/arduino//variants (from ARDUINO_DIR)
  • [COMPUTED] BOARDS_TXT = /usr/share/arduino/hardware/arduino//boards.txt (from ARDUINO_DIR)
  • [DEFAULT] USER_LIB_PATH = /libraries (in user sketchbook)
  • [DEFAULT] PRE_BUILD_HOOK = pre-build-hook.sh
  • [DEFAULT] BOARD_TAG = uno
  • [COMPUTED] CORE = arduino (from build.core)
  • [COMPUTED] VARIANT = standard (from build.variant)
  • [COMPUTED] OBJDIR = build-uno (from BOARD_TAG)
  • [COMPUTED] ARDUINO_CORE_PATH = /usr/share/arduino/hardware/arduino//cores/arduino (from ARDUINO_DIR, BOARD_TAG and boards.txt)
  • [DETECTED] MONITOR_BAUDRATE = 9600 (in sketch)
  • [DEFAULT] OPTIMIZATION_LEVEL = s
  • [DEFAULT] MCU_FLAG_NAME = mmcu
  • [DEFAULT] CFLAGS_STD = -std=gnu11 -flto -fno-fat-lto-objects
  • [DEFAULT] CXXFLAGS_STD = -std=gnu++11 -fno-threadsafe-statics -flto
  • [COMPUTED] DEVICE_PATH = /dev/ttyS2 (from MONITOR_PORT)
  • [DEFAULT] FORCE_MONITOR_PORT =
  • [AUTODETECTED] Size utility: AVR-aware for enhanced output
  • [COMPUTED] BOOTLOADER_PARENT = /usr/share/arduino/hardware/arduino//bootloaders (from ARDUINO_DIR)
  • [COMPUTED] ARDMK_VERSION = 1.5
  • [COMPUTED] CC_VERSION = 4.9.2 (avr-gcc)

    mkdir -p build-uno
    /usr/share/arduino/hardware/tools/avr/bin/avr-g++ -x c++ -include Arduino.h -MMD -c -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino//cores/arduino -I/usr/share/arduino/hardware/arduino//variants/standard -Wall -ffunction-sections -fdata-sections -Os -fpermissive -fno-exceptions -std=gnu++11 -fno-threadsafe-statics -flto helloworld.ino -o build-uno/helloworld.ino.o
    /usr/share/arduino/hardware/tools/avr/bin/avr-gcc -mmcu=atmega328p -Wl,–gc-sections -Os -flto -fuse-linker-plugin -o build-uno/helloworld.elf build-uno/helloworld.ino.o build-uno/libcore.a -lc -lm
    /usr/share/arduino/hardware/tools/avr/bin/avr-objcopy -j .eeprom --set-section-flags=.eeprom=‘alloc,load’
    –no-change-warnings --change-section-lma .eeprom=0 -O ihex build-uno/helloworld.elf build-uno/helloworld.eep
    /usr/share/arduino/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom build-uno/helloworld.elf build-uno/helloworld.hex
    /usr/share/arduino/hardware/tools/avr/bin/avr-size --mcu=atmega328p -C --format=avr build-uno/helloworld.elf
    AVR Memory Usage

    Device: atmega328p
    Program: 1636 bytes (5.0% Full)
    (.text + .data + .bootloader)
    Data: 201 bytes (9.8% Full)
    (.data + .bss + .noinit)

The build-ino directory contains

ls
core helloworld.eep helloworld.elf helloworld.hex helloworld.hex.sizeok helloworld.ino.d helloworld.ino.o libcore.a

a) How do I execute it ?
b ) How do I open the /dev/ttyS2 ? ( not sure if I have to use screen )

screen /dev/ttyS2
[screen is terminating]

How have you attached the Arduino or AVR device to the ultra96?

AFAICT ultra96 has only two hardware serial ports and these are attached to the BT module and to the 3 pin UART header. If you have attached the Arudino or AVR to the LS connector then I think the UART pins on that connector are intended to be driven by the programmable logic in the ultra96.