sudar / Arduino-Makefile

Makefile for Arduino sketches. It defines the workflows for compiling code, flashing it to Arduino and even communicating through Serial.
http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile
GNU Lesser General Public License v2.1
2.01k stars 449 forks source link

delay() seems to be hanging ATmega644 #348

Closed kautzz closed 9 years ago

kautzz commented 9 years ago

First things first: Thanks a bunch for putting so much work into this project. It's very straightforward to use and just what I'm looking for.

I have an ATmega644 with Ethernet connectivity (enc20j60 via spi) that will be master on a RS485 bus. The controller uses the e6 ftftp bootloader to program itself with a binary from a raspberryPi 2. Software is build on the Pi. It's running Ubuntu 14.04.02 LTS (GNU/Linux 3.18.0-14-rpi2 armv7l). Arduino version is 1.6.3 and I grabbed the latest Arduino-Makefile commit.

I followed http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile and http://hardwarefun.com/tutorials/use-arduino-code-in-non-arduino-avr-microcontroller to create a boards.txt, pinnings_arduino.h and the small project makefile.

So I'm trying to build a little blink example with an RGB LED. Make seems to be running just fine, output looks good as far as I can tell. I can flash the binary over ethernet (checksums ok) and the controller starts the new program.

But as soon as the code hits a delay, the controller seems to freeze.

What could cause this? Did I make a mistake in the pinning_arduino.h? Is there an error in the make output I don't see?

The weird thing is, when I upload a more complex program (program 2500 and data 1399 bytes) the controller seems to be doing exacly as told and delay() appears to be fine.

Is this maybe some kind of compiler optimization bug? (heard those were common with ubuntu)


Expected Output:

LED blue, delay 3s, LED Cyan, delay 3s, LED white

Actual Output:

LED blue

Controller Code master.cpp:

#include <Arduino.h>

#define RS485TX 8
#define RS485RX 9
#define DriverEnable 20
#define ReceiverEnable 10
#define TerminationEnable 21 

#define LOG_RX_PIN 30
#define LOG_TX_PIN 31

#define REDPIN 13
#define GREENPIN 14
#define BLUEPIN 12

void setup()
{
  pinMode(REDPIN, OUTPUT);
  pinMode(GREENPIN, OUTPUT);
  pinMode(BLUEPIN, OUTPUT);
}

void loop()
{
  digitalWrite(BLUEPIN, HIGH);
  delay(3000);

  digitalWrite(GREENPIN, HIGH);
  delay(3000);

  digitalWrite(REDPIN, HIGH);
  delay(3000);

  digitalWrite(REDPIN, LOW);
  delay(3000);
}

Project Makefile

### DISCLAIMER
### This is an example Makefile and it MUST be configured to suit your needs.
### For detailled explanations about all the avalaible options,
### please refer to https://github.com/sudar/Arduino-Makefile/blob/master/arduino-mk-vars.md
### Original project where this Makefile comes from: https://github.com/WeAreLeka/Bare-Arduino-Project

#ARDUINO_LIBS =

ARDUINO_VAR_PATH = /home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants
BOARDS_TXT = /home/ubuntu/sketchbook/hardware/plantsandmachines/avr/boards.txt
BOOTLOADER_PARENT = /home/ubuntu/sketchbook/hardware/plantsandmachines/avr/bootloaders

TFTP_DIR = /tftpboot
TARGET = brain0

ifndef MCU
  MCU = atmega644
endif

ifndef F_CPU
  F_CPU = 16000000
endif

ARCHITECTURE = avr

### This is the path to where you have created/cloned your project
PROJECT_DIR = /home/ubuntu/controller-software/pinning

### Path to the Arduino-Makefile directory.
ARDMK_DIR = /opt/arduino-mk

### Path to the Arduino application and ressources directory.
ARDUINO_DIR = /usr/share/arduino

### ARDUINO_SKETCHBOOK
ARDUINO_SKETCHBOOK = /home/ubuntu/sketchbook

### Path to where the your project's libraries are stored.
USER_LIB_PATH =  /home/ubuntu/sketchbook/libraries

### It must be set to the board you are currently using. (i.e uno, mega2560, etc.)
BOARD_TAG = plantsandmachines_brain_644

### It must be set to Serial baudrate value you are using.
MONITOR_BAUDRATE  = 9800

### Path to the AVR tools directory such as avr-gcc, avr-g++, etc.
AVR_TOOLS_DIR = /usr

### Path to avrdude directory.
AVRDDUDE = /usr/bin/avrdude

### Set the C standard to be used during compilation. Documentation (https://github.com/WeAreLeka/Arduino-Makefile/blob/std-flags/arduino-mk-vars.md#cflags_std)
CFLAGS_STD = -std=gnu99

### Set the C++ standard to be used during compilation. Documentation (https://github.com/WeAreLeka/Arduino-Makefile/blob/std-flags/arduino-mk-vars.md#cxxflags_std)
CXXFLAGS_STD = -std=gnu++11

### Flags you might want to set for debugging purpose. Comment to stop.
CXXFLAGS = -pedantic -Wall -Wextra

### The port your board is connected to. Using an '*' tries all the ports and finds the right one.
MONITOR_PORT = /dev/ttyUSB*

### Do not touch - used for binaries path
CURRENT_DIR = $(shell basename $(CURDIR))

### This is were you put the binaries you just compile using 'make'
OBJDIR = $(PROJECT_DIR)/bin/$(BOARD_TAG)/$(CURRENT_DIR)

### path to Arduino.mk, inside the ARDMK_DIR, don't touch.
include $(ARDMK_DIR)/Arduino.mk

pins_arduino.h

//
// plants & machines pin definition for brain (atmega644) micro-controller
// to be used with arduino 1.6.3 and arduino-mk 1.5
//
// Original Poster:
// Siddharth Sharangpani (sid@bhashatech.com)
// version 1.0.1 dated 15 March 2014

#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <avr/pgmspace.h>

#define NUM_DIGITAL_PINS 32
#define NUM_ANALOG_INPUTS 8

#define analogInputToDigitalPin(p) ((p < NUM_ANALOG_INPUTS) ? (p) + 24 : -1)

//set pwm pins
#define digitalPinHasPWM(p) ((p) == 3 || (p) == 4 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15)

//set special pins
static const uint8_t SS   = 4;
static const uint8_t MOSI = 5;
static const uint8_t MISO = 6;
static const uint8_t SCK  = 7;

static const uint8_t SDA = 17;
static const uint8_t SCL = 16;

//todo: add rgb led support
static const uint8_t LED = 0;

static const uint8_t A0 = 24;
static const uint8_t A1 = 25;
static const uint8_t A2 = 26;
static const uint8_t A3 = 27;
static const uint8_t A4 = 28;
static const uint8_t A5 = 29;
static const uint8_t A6 = 30;
static const uint8_t A7 = 31;

//map all pins to the PCICR register (Pin Change Interrupt Control Register)
#define digitalPinToPCICR(p) (((p) >= 0 && (p) < NUM_DIGITAL_PINS) ? (&PCICR) : ((uint8_t *)0))
//map pins to PCIE Bits (Pin Change Interrupt Enable) [0...3]
#define digitalPinToPCICRbit(p) (((p) >= 0  && (p) <= 7)  ? 1 : \
                                (((p) >= 8  && (p) <= 15) ? 3 : \
                                (((p) >= 16 && (p) <= 23) ? 2 : \
                                (((p) >= 24 && (p) <= 31) ? 0 : \
                                0))))

//map pins to PCMSK register (Pin Change Mask Register) [PCMSK0...PCMSK3]
#define digitalPinToPCMSK(p)    (((p) >= 0  && (p) <= 7)  ? (&PCMSK1) : \
                                (((p) >= 8  && (p) <= 15) ? (&PCMSK3) : \
                                (((p) >= 16 && (p) <= 23) ? (&PCMSK2) : \
                                (((p) >= 24 && (p) <= 31) ? (&PCMSK0) : \
                                ((uint8_t *)0)))))

//map pins to PCMSK Bits (Pin Change Mask Register Bit) [0...7]
#define digitalPinToPCMSKbit(p) (((p) >= 0  && (p) <= 7)  ? (p)  : \
                                (((p) >= 8  && (p) <= 15) ? ((p) - 8)  : \
                                (((p) >= 16 && (p) <= 23) ? ((p) - 16) : \
                                (((p) >= 24 && (p) <= 31) ? ((p) - 24) : \
                                0))))

#ifdef ARDUINO_MAIN

#define PA 1
#define PB 2
#define PC 3
#define PD 4

const uint16_t PROGMEM port_to_mode_PGM[] =
{
        NOT_A_PORT,
        (uint16_t) &DDRA,
        (uint16_t) &DDRB,
        (uint16_t) &DDRC,
        (uint16_t) &DDRD,
};
const uint16_t PROGMEM port_to_output_PGM[] =
{
        NOT_A_PORT,
        (uint16_t) &PORTA,
        (uint16_t) &PORTB,
        (uint16_t) &PORTC,
        (uint16_t) &PORTD,
};

const uint16_t PROGMEM port_to_input_PGM[] =
{
        NOT_A_PORT,
        (uint16_t) &PINA,
        (uint16_t) &PINB,
        (uint16_t) &PINC,
        (uint16_t) &PIND,
};

const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
        PB, /* 0 */
        PB,
        PB,
        PB,
        PB,
        PB,
        PB,
        PB,
        PD, /* 8 */
        PD,
        PD,
        PD,
        PD,
        PD,
        PD,
        PD,
        PC, /* 16 */
        PC,
        PC,
        PC,
        PC,
        PC,
        PC,
        PC,
        PA, /* 24 */
        PA,
        PA,
        PA,
        PA,
        PA,
        PA,
        PA  /* 31 */
};
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
{
        _BV(0), /* 0, port B */
        _BV(1),
        _BV(2),
        _BV(3),
        _BV(4),
        _BV(5),
        _BV(6),
        _BV(7),
        _BV(0), /* 8, port D */
        _BV(1),
        _BV(2),
        _BV(3),
        _BV(4),
        _BV(5),
        _BV(6),
        _BV(7),
        _BV(0), /* 16, port C */
        _BV(1),
        _BV(2),
        _BV(3),
        _BV(4),
        _BV(5),
        _BV(6),
        _BV(7),
        _BV(0), /* 24, port A */
        _BV(1),
        _BV(2),
        _BV(3),
        _BV(4),
        _BV(5),
        _BV(6),
        _BV(7)
};
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
        NOT_ON_TIMER,   /* 0  - PB0 */
        NOT_ON_TIMER,   /* 1  - PB1 */
        NOT_ON_TIMER,   /* 2  - PB2 */
        TIMER0A,        /* 3  - PB3 */
        TIMER0B,        /* 4  - PB4 */
        NOT_ON_TIMER,   /* 5  - PB5 */
        NOT_ON_TIMER,   /* 6  - PB6 */
        NOT_ON_TIMER,   /* 7  - PB7 */
        NOT_ON_TIMER,   /* 8  - PD0 */
        NOT_ON_TIMER,   /* 9  - PD1 */
        NOT_ON_TIMER,   /* 10 - PD2 */
        NOT_ON_TIMER,   /* 11 - PD3 */
        TIMER1B,        /* 12 - PD4 */
        TIMER1A,        /* 13 - PD5 */
        TIMER2B,        /* 14 - PD6 */
        TIMER2A,        /* 15 - PD7 */
        NOT_ON_TIMER,   /* 16 - PC0 */
        NOT_ON_TIMER,   /* 17 - PC1 */
        NOT_ON_TIMER,   /* 18 - PC2 */
        NOT_ON_TIMER,   /* 19 - PC3 */
        NOT_ON_TIMER,   /* 20 - PC4 */
        NOT_ON_TIMER,   /* 21 - PC5 */
        NOT_ON_TIMER,   /* 22 - PC6 */
        NOT_ON_TIMER,   /* 23 - PC7 */
        NOT_ON_TIMER,   /* 24 - PA0 */
        NOT_ON_TIMER,   /* 25 - PA1 */
        NOT_ON_TIMER,   /* 26 - PA2 */
        NOT_ON_TIMER,   /* 27 - PA3 */
        NOT_ON_TIMER,   /* 28 - PA4 */
        NOT_ON_TIMER,   /* 29 - PA5 */
        NOT_ON_TIMER,   /* 30 - PA6 */
        NOT_ON_TIMER    /* 31 - PA7 */
};

#endif // ARDUINO_MAIN

#endif // Pins_Arduino_h
// vim:ai:cin:sts=2 sw=2 ft=cpp

boards.txt


#############################################################
# Additional plants & machines hardware to be used with
# Arduino 1.6.3 and Arduino-mk 1.5
#############################################################

plantsandmachines_brain_644.name=pam brain (644@16MHz)
plantsandmachines_brain_644.upload.protocol=stk500v1
plantsandmachines_brain_644.upload.maximum_size=63488
plantsandmachines_brain_644.upload.speed=115200
plantsandmachines_brain_644.bootloader.low_fuses=0xff
plantsandmachines_brain_644.bootloader.high_fuses=0xd8
plantsandmachines_brain_644.bootloader.extended_fuses=0xff
plantsandmachines_brain_644.bootloader.lock_bits=0x0F
plantsandmachines_brain_644.build.mcu=atmega644
plantsandmachines_brain_644.build.f_cpu=16000000L
plantsandmachines_brain_644.build.core=arduino
plantsandmachines_brain_644.build.variant=brain

############################################################

make output

ubuntu@mrvbot:~/controller-software/pinning$ make
-------------------------
Arduino.mk Configuration:
- [AUTODETECTED]       CURRENT_OS = LINUX 
- [USER]               ARDUINO_DIR = /usr/share/arduino 
- [USER]               ARDMK_DIR = /opt/arduino-mk 
- [DEFAULT]            ARDUINO_VERSION = 100 
- [USER]               ARCHITECTURE = avr 
- [DEFAULT]            VENDOR = arduino 
- [USER]               ARDUINO_SKETCHBOOK = /home/ubuntu/sketchbook 
- [USER]               AVR_TOOLS_DIR = /usr 
- [COMPUTED]           ARDUINO_LIB_PATH = /usr/share/arduino/libraries (from ARDUINO_DIR)
- [USER]               ARDUINO_VAR_PATH = /home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants 
- [USER]               BOARDS_TXT = /home/ubuntu/sketchbook/hardware/plantsandmachines/avr/boards.txt 
- [USER]               USER_LIB_PATH = /home/ubuntu/sketchbook/libraries 
- [DEFAULT]            PRE_BUILD_HOOK = pre-build-hook.sh 
- [USER]               BOARD_TAG = plantsandmachines_brain_644 
- [COMPUTED]           CORE = arduino (from build.core)
- [COMPUTED]           VARIANT = brain (from build.variant)
- [USER]               OBJDIR = /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning 
- [COMPUTED]           ARDUINO_CORE_PATH = /usr/share/arduino/hardware/arduino/avr/cores/arduino (from ARDUINO_DIR, BOARD_TAG and boards.txt)
-                      No .pde or .ino files found. If you are compiling .c or .cpp files then you need to explicitly include Arduino header files
- [USER]               MONITOR_BAUDRATE = 9800 
- [DEFAULT]            OPTIMIZATION_LEVEL = s 
- [DEFAULT]            MCU_FLAG_NAME = mmcu 
- [USER]               CFLAGS_STD = -std=gnu99 
- [USER]               CXXFLAGS_STD = -std=gnu++11 
- [COMPUTED]           DEVICE_PATH = /dev/ttyUSB* (from MONITOR_PORT)
- [DEFAULT]            FORCE_MONITOR_PORT =  
- [AUTODETECTED]       Size utility: AVR-aware for enhanced output
- [USER]               BOOTLOADER_PARENT = /home/ubuntu/sketchbook/hardware/plantsandmachines/avr/bootloaders 
- [COMPUTED]           ARDMK_VERSION = 1.5 
- [COMPUTED]           CC_VERSION = 4.8.2 (avr-gcc)
-------------------------
mkdir -p /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 master.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/master.o
/usr/bin/avr-gcc -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -std=gnu99 /usr/share/arduino/hardware/arduino/avr/cores/arduino/hooks.c -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/hooks.o
/usr/bin/avr-gcc -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -std=gnu99 /usr/share/arduino/hardware/arduino/avr/cores/arduino/WInterrupts.c -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/WInterrupts.o
/usr/bin/avr-gcc -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -std=gnu99 /usr/share/arduino/hardware/arduino/avr/cores/arduino/wiring_analog.c -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/wiring_analog.o
/usr/bin/avr-gcc -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -std=gnu99 /usr/share/arduino/hardware/arduino/avr/cores/arduino/wiring.c -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/wiring.o
/usr/bin/avr-gcc -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -std=gnu99 /usr/share/arduino/hardware/arduino/avr/cores/arduino/wiring_digital.c -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/wiring_digital.o
/usr/bin/avr-gcc -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -std=gnu99 /usr/share/arduino/hardware/arduino/avr/cores/arduino/wiring_pulse.c -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/wiring_pulse.o
/usr/share/arduino/hardware/arduino/avr/cores/arduino/wiring_pulse.c: In function ‘pulseIn’:
/usr/share/arduino/hardware/arduino/avr/cores/arduino/wiring_pulse.c:81:3: warning: #warning "pulseIn() results may not be accurate" [-Wcpp]
  #warning "pulseIn() results may not be accurate"
   ^
/usr/bin/avr-gcc -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -std=gnu99 /usr/share/arduino/hardware/arduino/avr/cores/arduino/wiring_shift.c -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/wiring_shift.o
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/abi.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/abi.o
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/CDC.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/CDC.o
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/HardwareSerial0.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/HardwareSerial0.o
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/HardwareSerial1.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/HardwareSerial1.o
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/HardwareSerial2.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/HardwareSerial2.o
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/HardwareSerial3.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/HardwareSerial3.o
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/HardwareSerial.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/HardwareSerial.o
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/HID.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/HID.o
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/IPAddress.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/IPAddress.o
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/main.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/main.o
/usr/share/arduino/hardware/arduino/avr/cores/arduino/main.cpp:23:5: warning: unused parameter ‘func’ [-Wunused-parameter]
 int atexit(void (*func)()) { return 0; }
     ^
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/new.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/new.o
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/Print.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/Print.o
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Print.cpp: In member function ‘size_t Print::print(const __FlashStringHelper*)’:
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Print.cpp:44:9: warning: ‘prog_char’ is deprecated (declared at /usr/lib/avr/include/avr/pgmspace.h:350): prog_char type is deprecated. [-Wdeprecated-declarations]
   PGM_P p = reinterpret_cast<PGM_P>(ifsh);
         ^
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/Stream.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/Stream.o
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Stream.cpp: In member function ‘int Stream::findMulti(Stream::MultiTarget*, int)’:
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Stream.cpp:268:10: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses]
       if (c == t->str[t->index])
          ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Stream.cpp:297:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < t->index; ++i)
                     ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Stream.cpp:302:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (i == t->index) {
              ^
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/Tone.o
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:245:27: warning: binary constants are a GCC extension [enabled by default]
   uint8_t prescalarbits = 0b001;
                           ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:261:23: warning: binary constants are a GCC extension [enabled by default]
       prescalarbits = 0b001;  // ck/1: same for both timers
                       ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:265:25: warning: binary constants are a GCC extension [enabled by default]
         prescalarbits = 0b010;  // ck/8: same for both timers
                         ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:270:27: warning: binary constants are a GCC extension [enabled by default]
           prescalarbits = 0b011;
                           ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:276:41: warning: binary constants are a GCC extension [enabled by default]
           prescalarbits = _timer == 0 ? 0b011 : 0b100;
                                         ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:276:49: warning: binary constants are a GCC extension [enabled by default]
           prescalarbits = _timer == 0 ? 0b011 : 0b100;
                                                 ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:281:29: warning: binary constants are a GCC extension [enabled by default]
             prescalarbits = 0b101;
                             ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:287:43: warning: binary constants are a GCC extension [enabled by default]
             prescalarbits = _timer == 0 ? 0b100 : 0b110;
                                           ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:287:51: warning: binary constants are a GCC extension [enabled by default]
             prescalarbits = _timer == 0 ? 0b100 : 0b110;
                                                   ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:292:45: warning: binary constants are a GCC extension [enabled by default]
               prescalarbits = _timer == 0 ? 0b101 : 0b111;
                                             ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:292:53: warning: binary constants are a GCC extension [enabled by default]
               prescalarbits = _timer == 0 ? 0b101 : 0b111;
                                                     ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:301:28: warning: binary constants are a GCC extension [enabled by default]
         TCCR0B = (TCCR0B & 0b11111000) | prescalarbits;
                            ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:307:28: warning: binary constants are a GCC extension [enabled by default]
         TCCR2B = (TCCR2B & 0b11111000) | prescalarbits;
                            ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:320:23: warning: binary constants are a GCC extension [enabled by default]
       prescalarbits = 0b001;
                       ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:324:25: warning: binary constants are a GCC extension [enabled by default]
         prescalarbits = 0b011;
                         ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:330:28: warning: binary constants are a GCC extension [enabled by default]
         TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
                            ^
/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp:452:28: warning: binary constants are a GCC extension [enabled by default]
         TCCR2B = (TCCR2B & 0b11111000) | (1 << CS22);
                            ^
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/USBCore.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/USBCore.o
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/WMath.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/WMath.o
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000 -DARDUINO=100 -DARDUINO_ARCH_AVR -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/avr/cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 /usr/share/arduino/hardware/arduino/avr/cores/arduino/WString.cpp -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/WString.o
/usr/bin/avr-ar rcs /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/libcore.a  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/hooks.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/WInterrupts.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/wiring_analog.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/wiring.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/wiring_digital.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/wiring_pulse.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/wiring_shift.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/abi.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/CDC.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/HardwareSerial0.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/HardwareSerial1.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/HardwareSerial2.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/HardwareSerial3.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/HardwareSerial.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/HID.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/IPAddress.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/main.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/new.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/Print.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/Stream.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/Tone.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/USBCore.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/WMath.o  /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/core/WString.o       
/usr/bin/avr-gcc -mmcu=atmega644 -Wl,--gc-sections -Os -o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/brain0.elf /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/master.o /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/libcore.a  -lc -lm
/usr/bin/avr-objcopy -j .eeprom --set-section-flags=.eeprom='alloc,load' \
        --change-section-lma .eeprom=0 -O ihex /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/brain0.elf /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/brain0.eep
/usr/bin/avr-objcopy: --change-section-lma .eeprom=0x00000000 never used
/usr/bin/avr-objcopy -O ihex -R .eeprom /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/brain0.elf /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/brain0.hex

/usr/bin/avr-size --mcu=atmega644 -C --format=avr /home/ubuntu/controller-software/pinning/bin/plantsandmachines_brain_644/pinning/brain0.elf
AVR Memory Usage
----------------
Device: atmega644

Program:    1136 bytes (1.7% Full)
(.text + .data + .bootloader)

Data:          9 bytes (0.2% Full)
(.data + .bss + .noinit)
sej7278 commented 9 years ago

no idea really, could it be something to do with the timer functions?

the makefile seems to think you are using arduino 1.0.0 (which is the raspbian wheezy default) so its not finding the 1.6.3 you say you are using, try defining:

ARDUINO_DIR = /path/to/arduino-1.6.3

i've just received at atmega1284p-pu so if i come across a similar issue (the 644/1284 are similar chips) i'll report back.

have you looked at the sanguino stuff, that was all 644-based.

kautzz commented 9 years ago

The path to arduino is already set:

ARDUINO_DIR = /usr/share/arduino

/usr/share/arduino is a symlink to the arduino git repo I set the Arduino Version manually to 163, no change though.

ARDUINO_VERSION = 163

Yeah, I have been using sanguino before. But the core is sooooooo old ;) Thought I give it a try with the regular arduino core since I've seen some if (mcu == atmega 644) statements in there

do you mean the timer functions in arduino core? Where would they be located?

sej7278 commented 9 years ago

you shouldn't have to set ARDUINO_VERSION, its not being auto-detected for some reason, ah are you using a nightly (or git) instead of a release - as the lib/version.txt says "nightly" in that case instead of a numeric, in which case you do need to set it manually.

anyway, i've just had a play with the mighty-1284p and it doesn't have a problem with blink (with delay) but i did of course have to make set_fuses && make ispload as it was a raw chip and i didn't want to bootload it.

i assume you're using a 16mhz crystal and have set the fuses and/or installed a bootloader?

i can only think its a problem with the timers in pins_arduino.h - it shouldn't be called pinnings_arduino.h btw

other than that you seem to be using @ladislas' BareArduinoProject makefile, and i don't think they've ported our 1.6.x ide support yet.

kautzz commented 9 years ago

yeah, you are right. the nightly doesn't even seem to have $(ARDUINO_DIR)/lib/ so I'll leave it manually set to 163.

I have a 16MHz crystal and my fuses are set to:

sudo avrdude -c avrispmkII -p m644 -P usb -e -B4 -v -U lfuse:w:0xff:m -U hfuse:w:0xd8:m -U efuse:w:0xff:m

After I flash the bootloader via ISP I set the lockbit so it can't overwrite itself

sudo avrdude -c avrispmkII -p m644 -P usb -B4 -v -U lock:w:0x0F:m

Would you please send me your 1284 pins_arduino.h for reference?

Yup, using BareArduinoProject Makefile... is there a example makefile that supports 1.6.x? The ones in https://github.com/sudar/Arduino-Makefile/tree/master/examples seem a bit incomplete/small compared to @ladislas 's one

ladislas commented 9 years ago

I'm working on it :)

sej7278 commented 9 years ago

If you're using the 1.6.4 nightly i'd say forget it, its totally messed up, go back to 1.6.3 release.

@ladislas makefiles are a bit specific, if you're going to use that then i'd suggest reporting it in his issue tracker. this works for me on 1.0.5 and 1.6.3

BOARD_TAG         = mighty_opt
BOARDS_TXT        = $(HOME)/arduino/hardware/mighty-1284p/boards.txt
BOOTLOADER_PARENT = $(HOME)/arduino/hardware/mighty-1284p/bootloaders
BOOTLOADER_PATH   = optiboot
BOOTLOADER_FILE   = optiboot_atmega1284p.hex
ISP_PROG          = usbasp
AVRDUDE_OPTS      = -v
include $(HOME)/Arduino-Makefile/Arduino.mk

https://github.com/wijnen/mighty-1284p/blob/master/variants/standard/pins_arduino.h

kautzz commented 9 years ago

sorry I meant arduino 1.6.3 from github.

Compared the mighty-1284 pins to mine. Found nothing obvious. Tried with a slightly modified version (for the 644) of the 1284 pin_arduino.h No change.

I also tried your makefile:

BOARD_TAG         = plantsandmachines_brain_644                                      
BOARDS_TXT        = $(HOME)/sketchbook/hardware/plantsandmachines/avr/boards.txt     
BOOTLOADER_PARENT = $(HOME)/arduino/hardware/plantsandmachines/avr/bootloaders       

AVRDUDE_OPTS      = -v                                                               

include /opt/arduino-mk/Arduino.mk

With the result of an error:

ubuntu@mrvbot:~/controller-software/pinning$ make 
-------------------------
Arduino.mk Configuration:
- [AUTODETECTED]       CURRENT_OS = LINUX 
- [AUTODETECTED]       ARDUINO_DIR = /usr/share/arduino 
- [COMPUTED]           ARDMK_DIR = /home/ubuntu/external_repos/arduino-mk (relative to Common.mk)
- [DEFAULT]            ARDUINO_VERSION = 100 
- [DEFAULT]            ARCHITECTURE =  
- [DEFAULT]            VENDOR = arduino 
- [DEFAULT]            ARDUINO_SKETCHBOOK = /home/ubuntu/sketchbook 
- [AUTODETECTED]       AVR_TOOLS_DIR = /usr (found in $PATH)
- [COMPUTED]           ARDUINO_LIB_PATH = /usr/share/arduino/libraries (from ARDUINO_DIR)
- [USER]               ARDUINO_VAR_PATH = /home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants 
- [USER]               BOARDS_TXT = /home/ubuntu/sketchbook/hardware/plantsandmachines/avr/boards.txt 
- [DEFAULT]            USER_LIB_PATH = /home/ubuntu/sketchbook/libraries (in user sketchbook)
- [DEFAULT]            PRE_BUILD_HOOK = pre-build-hook.sh 
- [USER]               BOARD_TAG = plantsandmachines_brain_644 
- [COMPUTED]           CORE = arduino (from build.core)
- [COMPUTED]           VARIANT = brain (from build.variant)
- [COMPUTED]           OBJDIR = build-plantsandmachines_brain_644 (from BOARD_TAG)
- [COMPUTED]           ARDUINO_CORE_PATH = /usr/share/arduino/hardware/arduino//cores/arduino (from ARDUINO_DIR, BOARD_TAG and boards.txt)
-                      No .pde or .ino files found. If you are compiling .c or .cpp files then you need to explicitly include Arduino header files
- [ASSUMED]            MONITOR_BAUDRATE = 9600 
- [DEFAULT]            OPTIMIZATION_LEVEL = s 
- [DEFAULT]            MCU_FLAG_NAME = mmcu 
- [DEFAULT]            CFLAGS_STD =  
- [DEFAULT]            CXXFLAGS_STD =  
- [AUTODETECTED]       DEVICE_PATH =  
- [DEFAULT]            FORCE_MONITOR_PORT =  
- [AUTODETECTED]       Size utility: AVR-aware for enhanced output
- [USER]               BOOTLOADER_PARENT = /home/ubuntu/arduino/hardware/plantsandmachines/avr/bootloaders 
- [COMPUTED]           ARDMK_VERSION = 1.5 
- [COMPUTED]           CC_VERSION = 4.8.2 (avr-gcc)
-------------------------
mkdir -p build-plantsandmachines_brain_644
/usr/bin/avr-g++ -MMD -c -mmcu=atmega644 -DF_CPU=16000000L -DARDUINO=100  -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino//cores/arduino -I/home/ubuntu/sketchbook/hardware/plantsandmachines/avr/variants/brain    -Wall -ffunction-sections -fdata-sections -Os -fno-exceptions  master.cpp -o build-plantsandmachines_brain_644/master.o
master.cpp:1:21: fatal error: Arduino.h: No such file or directory
 #include <Arduino.h>
                     ^
compilation terminated.
make: *** [build-plantsandmachines_brain_644/master.o] Error 1

Somehow the ARDUINO_CORE_PATH does not compute?!

sej7278 commented 9 years ago

you'll have to set ARDUINO_VERSION = 163 otherwise it might not be able to find all of the headers, but other than that, i've no idea. i certainly wouldn't use arduino from git or nightly, use a zip.

kautzz commented 9 years ago

okay thanks! Like this: https://github.com/arduino/Arduino/releases/tag/1.6.3 ?

will continue trying :D

ladislas commented 9 years ago

@kautzz I just updated Bare-Arduino-Project to support 1.6.3. At least it's working on my machine.

Could you give it a try and report any issue you might have here. We'll work on it together :)

kautzz commented 9 years ago

Got it running now!

Was messing around with interrupts to see if timers are working... So this runs fine:

#include <avr/interrupt.h>
#include <Arduino.h>

#define RS485TX 8
#define RS485RX 9

#define DriverEnable 20
#define ReceiverEnable 10
#define TerminationEnable 21 

#define LOG_RX_PIN 30
#define LOG_TX_PIN 31

#define REDPIN 13
#define GREENPIN 14
#define BLUEPIN 12

volatile unsigned long seconds = 1;

void setup()
{
  pinMode(REDPIN, OUTPUT);
  pinMode(GREENPIN, OUTPUT);
  pinMode(BLUEPIN, OUTPUT);

  digitalWrite(REDPIN, LOW);
  digitalWrite(GREENPIN, LOW);
  digitalWrite(BLUEPIN, LOW);

  // INITIALIZE TIMER INTERRUPTS

  cli();                      // disable global interrupts
  TCCR1A = 0;                 // set entire TCCR1A register to 0
  TCCR1B = 0;                 // same for TCCR1B

  OCR1A = 15624;              // set compare match register to desired timer count. 16 MHz with 1024 prescaler = 15624 counts/s 

  TCCR1B |= (1 << WGM12);     // turn on CTC mode. clear timer on compare match
  TCCR1B |= (1 << CS10);      // Set CS10 and CS12 bits for 1024 prescaler
  TCCR1B |= (1 << CS12);

  TIMSK1 |= (1 << OCIE1A);    // enable timer compare interrupt

  sei();                      // enable global interrupts
}

void loop()
{
  digitalWrite(REDPIN, HIGH);
  delay(1000);

  digitalWrite(GREENPIN, HIGH);
  delay(1000);

  digitalWrite(BLUEPIN, HIGH);
  delay(1000);

  digitalWrite(BLUEPIN, LOW);
  delay(1000);

  digitalWrite(GREENPIN, LOW);
  delay(1000);

  digitalWrite(REDPIN, LOW);
  delay(1000);
}

ISR(TIMER1_COMPA_vect)
{
  seconds++;
}

I was doing some more tests and figured that if I stop timer/counter1 the code runs fine, too! (TCCR1B Bit 2:0 – CSn2:0: Clock Select to no clock source)

TCCR1B &= ~(1<<0);
TCCR1B &= ~(1<<1);
TCCR1B &= ~(1<<2);

Any idea why this could be happening? I was under the impression that Arduino uses timer0 for delay... so does Arduino set up TCCR1B at all?

@ladislas yeah, great job! Sure, I'll test it later, thanks! This is the makefile I've been using so far:


BOARD_TAG         = plantsandmachines_brain_644
BOARDS_TXT        = $(HOME)/sketchbook/hardware/plantsandmachines/avr/boards.txt
BOOTLOADER_PARENT = $(HOME)/arduino/hardware/plantsandmachines/avr/bootloaders

ARDUINO_VERSION = 163

ARDUINO_CORE_PATH = /usr/share/arduino/hardware/arduino/avr/cores/arduino
ARDUINO_VAR_PATH = $(HOME)/sketchbook/hardware/plantsandmachines/avr/variants

AVRDUDE_OPTS      = -v

TARGET = brain0

include /opt/arduino-mk/Arduino.mk

t:
        make
        avr-objcopy -I ihex -O binary build-plantsandmachines_brain_644/brain0.hex /tftpboot/brain0.bin
kautzz commented 9 years ago

Okay, so @sej7278 was right. It was a timer problem. It was not due to a faulty pins_arduino.h but rather due to hick ups when applying the timer settings Somehow arduino-core messed up setting the right registers for timer0, 1 and 2.

I now set them manually, like so:

cli();
TCCR0A = B00000011;
TCCR0B = B00000011;
TIMSK0 = B00000001;
TCCR1A = B10100001;
TCCR1B = B00000011;
TCCR2A = B00000001;
TCCR2B = B00000100;
TIMSK1 = B00000000;
sei();

delay() and analogWrite() are running like a charm now. I'll go ahead and close this issue because it's probably not an error on the Arduino-Makefile side.

If anyone knows whats going wrong with setting the timer registers through arduino-core, please let me know. :)