Can't compile code for Atmega328

I have code that’s been running fine on Arduino Mega. I have breadboarded an Atmega328 and successfully put the bootloader in it using Board:Minicore Atmega328. When compiling my code to run on the standalone chip I get loads of compilation errors. Presumably this is the right board to compile for as the bootloader download process worked. Can someone please let me know what I’m doing wrong? Thanks.

Arduino: 1.8.5 (Windows 10), Board: “ATmega328, No, 328 / 328A, 2.7v, Disabled (default), 8 MHz internal”

Warning: Board breadboard:avr:atmega328bb doesn’t define a ‘build.board’ preference. Auto-set to: AVR_ATMEGA328BB
Build options changed, rebuilding all
In file included from F:\Documents\Arduino\Rack_1\Rack_1.ino:13:0:

F:\Documents\Arduino\libraries\NTOOLS/XLCD.h:88:17: note: #pragma message: USING OLED64_ADA

#pragma message “USING OLED64_ADA”

^

In file included from F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.h:30:0,

from F:\Documents\Arduino\Rack_1\Rack_1.ino:8:

Rack_1:93: error: ‘Serial1’ was not declared in this scope

MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);

^

F:\Documents\Arduino\libraries\arduino_841278\src/midi_Defs.h:215:43: note: in definition of macro ‘MIDI_CREATE_INSTANCE’

midi::MidiInterface Name((Type&)SerialPort);

^

F:\Documents\Arduino\Rack_1\Rack_1.ino: In function ‘void loop()’:

Rack_1:260: error: invalid conversion from ‘byte {aka unsigned char}’ to ‘midi::MidiType’ [-fpermissive]

portLo);

^

In file included from F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.h:258:0,

from F:\Documents\Arduino\Rack_1\Rack_1.ino:8:

F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.hpp:133:6: note: initializing argument 1 of ‘void midi::MidiInterface<SerialPort, _Settings>::send(midi::MidiType, midi::DataByte, midi::DataByte, midi::Channel) [with SerialPort = HardwareSerial; _Settings = midi::DefaultSettings; midi::DataByte = unsigned char; midi::Channel = unsigned char]’

void MidiInterface<SerialPort, Settings>::send(MidiType inType,

^

Rack_1:268: error: invalid conversion from ‘byte {aka unsigned char}’ to ‘midi::MidiType’ [-fpermissive]

7);

^

In file included from F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.h:258:0,

from F:\Documents\Arduino\Rack_1\Rack_1.ino:8:

F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.hpp:133:6: note: initializing argument 1 of ‘void midi::MidiInterface<SerialPort, _Settings>::send(midi::MidiType, midi::DataByte, midi::DataByte, midi::Channel) [with SerialPort = HardwareSerial; _Settings = midi::DefaultSettings; midi::DataByte = unsigned char; midi::Channel = unsigned char]’

void MidiInterface<SerialPort, Settings>::send(MidiType inType,

^

Rack_1:279: error: invalid conversion from ‘byte {aka unsigned char}’ to ‘midi::MidiType’ [-fpermissive]

portHi);

^

Multiple libraries were found for “button.h”
Used: F:\Documents\Arduino\libraries\NTOOLS
Not used: F:\Documents\Arduino\libraries\NControls
Not used: F:\Documents\Arduino\libraries\NControls
Not used: F:\Documents\Arduino\libraries\NControls
Not used: F:\Documents\Arduino\libraries\NControls
exit status 1
‘Serial1’ was not declared in this scope

(deleted)

Thanks. I’ve changed it to Serial but still get all the other errors :frowning:

Arduino: 1.8.5 (Windows 10), Board: “ATmega328, No, 328 / 328A, 2.7v, Disabled (default), 8 MHz internal”

Warning: Board breadboard:avr:atmega328bb doesn’t define a ‘build.board’ preference. Auto-set to: AVR_ATMEGA328BB
In file included from F:\Documents\Arduino\Rack_1\Rack_1.ino:13:0:

F:\Documents\Arduino\libraries\NTOOLS/XLCD.h:88:17: note: #pragma message: USING OLED64_ADA

#pragma message “USING OLED64_ADA”

^

F:\Documents\Arduino\Rack_1\Rack_1.ino: In function ‘void loop()’:

Rack_1:260: error: invalid conversion from ‘byte {aka unsigned char}’ to ‘midi::MidiType’ [-fpermissive]

portLo);

^

In file included from F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.h:258:0,

from F:\Documents\Arduino\Rack_1\Rack_1.ino:8:

F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.hpp:133:6: note: initializing argument 1 of ‘void midi::MidiInterface<SerialPort, _Settings>::send(midi::MidiType, midi::DataByte, midi::DataByte, midi::Channel) [with SerialPort = HardwareSerial; _Settings = midi::DefaultSettings; midi::DataByte = unsigned char; midi::Channel = unsigned char]’

void MidiInterface<SerialPort, Settings>::send(MidiType inType,

^

Rack_1:268: error: invalid conversion from ‘byte {aka unsigned char}’ to ‘midi::MidiType’ [-fpermissive]

7);

^

In file included from F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.h:258:0,

from F:\Documents\Arduino\Rack_1\Rack_1.ino:8:

F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.hpp:133:6: note: initializing argument 1 of ‘void midi::MidiInterface<SerialPort, _Settings>::send(midi::MidiType, midi::DataByte, midi::DataByte, midi::Channel) [with SerialPort = HardwareSerial; _Settings = midi::DefaultSettings; midi::DataByte = unsigned char; midi::Channel = unsigned char]’

void MidiInterface<SerialPort, Settings>::send(MidiType inType,

^

Rack_1:279: error: invalid conversion from ‘byte {aka unsigned char}’ to ‘midi::MidiType’ [-fpermissive]

portHi);

^

In file included from F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.h:258:0,

from F:\Documents\Arduino\Rack_1\Rack_1.ino:8:

F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.hpp:133:6: note: initializing argument 1 of ‘void midi::MidiInterface<SerialPort, _Settings>::send(midi::MidiType, midi::DataByte, midi::DataByte, midi::Channel) [with SerialPort = HardwareSerial; _Settings = midi::DefaultSettings; midi::DataByte = unsigned char; midi::Channel = unsigned char]’

void MidiInterface<SerialPort, Settings>::send(MidiType inType,

^

Rack_1:285: error: invalid conversion from ‘byte {aka unsigned char}’ to ‘midi::MidiType’ [-fpermissive]

7);

^

In file included from F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.h:258:0,

from F:\Documents\Arduino\Rack_1\Rack_1.ino:8:

F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.hpp:133:6: note: initializing argument 1 of ‘void midi::MidiInterface<SerialPort, _Settings>::send(midi::MidiType, midi::DataByte, midi::DataByte, midi::Channel) [with SerialPort = HardwareSerial; _Settings = midi::DefaultSettings; midi::DataByte = unsigned char; midi::Channel = unsigned char]’

void MidiInterface<SerialPort, Settings>::send(MidiType inType,

^

Rack_1:298: error: invalid conversion from ‘byte {aka unsigned char}’ to ‘midi::MidiType’ [-fpermissive]

portT); //for notes, portT is set according to which side of the split the note is. For CCs, portT is set to portHi in switch statement above at “case midi::Stop”

^

In file included from F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.h:258:0,

from F:\Documents\Arduino\Rack_1\Rack_1.ino:8:

F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.hpp:133:6: note: initializing argument 1 of ‘void midi::MidiInterface<SerialPort, _Settings>::send(midi::MidiType, midi::DataByte, midi::DataByte, midi::Channel) [with SerialPort = HardwareSerial; _Settings = midi::DefaultSettings; midi::DataByte = unsigned char; midi::Channel = unsigned char]’

void MidiInterface<SerialPort, Settings>::send(MidiType inType,

^

Rack_1:305: error: invalid conversion from ‘byte {aka unsigned char}’ to ‘midi::MidiType’ [-fpermissive]

7);

^

In file included from F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.h:258:0,

from F:\Documents\Arduino\Rack_1\Rack_1.ino:8:

F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.hpp:133:6: note: initializing argument 1 of ‘void midi::MidiInterface<SerialPort, _Settings>::send(midi::MidiType, midi::DataByte, midi::DataByte, midi::Channel) [with SerialPort = HardwareSerial; _Settings = midi::DefaultSettings; midi::DataByte = unsigned char; midi::Channel = unsigned char]’

void MidiInterface<SerialPort, Settings>::send(MidiType inType,

^

Rack_1:335: error: invalid conversion from ‘byte {aka unsigned char}’ to ‘midi::MidiType’ [-fpermissive]

7);

^

In file included from F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.h:258:0,

from F:\Documents\Arduino\Rack_1\Rack_1.ino:8:

F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.hpp:133:6: note: initializing argument 1 of ‘void midi::MidiInterface<SerialPort, _Settings>::send(midi::MidiType, midi::DataByte, midi::DataByte, midi::Channel) [with SerialPort = HardwareSerial; _Settings = midi::DefaultSettings; midi::DataByte = unsigned char; midi::Channel = unsigned char]’

void MidiInterface<SerialPort, Settings>::send(MidiType inType,

^

Rack_1:342: error: invalid conversion from ‘byte {aka unsigned char}’ to ‘midi::MidiType’ [-fpermissive]

portHi);

^

In file included from F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.h:258:0,

from F:\Documents\Arduino\Rack_1\Rack_1.ino:8:

F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.hpp:133:6: note: initializing argument 1 of ‘void midi::MidiInterface<SerialPort, _Settings>::send(midi::MidiType, midi::DataByte, midi::DataByte, midi::Channel) [with SerialPort = HardwareSerial; _Settings = midi::DefaultSettings; midi::DataByte = unsigned char; midi::Channel = unsigned char]’

void MidiInterface<SerialPort, Settings>::send(MidiType inType,

^

Does it still compile for a MEGA2560?
Does it compile for an Uno?
It's possible that the 328bb board definition are out-of-sync enough that things are missing.
(for example, who knows what "Warning: Board breadboard:avr:atmega328bb doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328BB" causes to be left out...)

Yes it compiles perfectly for Mega2560 and Uno, although the latter gives low memory warnings. Could this be my problem with the Atmega - does it have less memory than even an Uno? It also compiles fine for 'Atmega328 on breadboard (8MHz internal clock)' which I got from here https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard
but I can't install the bootloader with this - I think because it's for a 328P and mine is a 328? Now that I have the bootloader installed using Minicore, I'll try compiling and downloading the code using 'Atmega328 on breadboard (8MHz internal clock)' but suspect it'll reject the 328 again...

Uno Compiler says:"Sketch uses 19348 bytes (59%) of program storage space. Maximum is 32256 bytes.
Global variables use 1942 bytes (94%) of dynamic memory, leaving 106 bytes for local variables. Maximum is 2048 bytes.
Low memory available, stability problems may occur."

Could this be my problem with the Atmega - does it have less memory than even an Uno?

No; the 328 and 328p have the same memories. They are in fact nearly identical, so it's particularly mysterious to have lots of failures with one, over the other. Are you running recently versions of the IDE, MiniCore, and Midi Library?

Warning: Board breadboard:avr:atmega328bb doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328BB

This is a red herring; you're not using the AVR_ATMEGA328BB board type (that's a pre-Minicore method of doing breadboard installs.) I think. It's possible that having the old atmega328bb is interfering with minicore...

In file included from F:\Documents\Arduino\Rack_1\Rack_1.ino:13:0:

F:\Documents\Arduino\libraries\NTOOLS/XLCD.h:88:17: note: #pragma message: USING OLED64_ADA
#pragma message "USING OLED64_ADA"

This is just a message being printed, as it's supposed to.

In file included from F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.h:258:0,

That's a very weird directory name to be including the midi library files from...
I don't think I can tell anything else without seeing the whole sketch and "verbose" compilation output.
Can you successfully compile any of the MIDI examples?

Thanks for your help westfw.

I’m running IDE 1.8.5, minicore 2.0.1 (from GitHub - MCUdude/MiniCore: Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB) and midi (Forty Seven Effects) 4.3.1

If I delete the hardware folder containing the ATMEGA328BB breadboard files, I lose the board type warning. The first part of the compiler errors is:

"
In file included from F:\Documents\Arduino\Rack_1\Rack_1.ino:13:0:

F:\Documents\Arduino\libraries\NTOOLS/XLCD.h:88:17: note: #pragma message: USING OLED64_ADA

#pragma message “USING OLED64_ADA”

^

F:\Documents\Arduino\Rack_1\Rack_1.ino: In function ‘void loop()’:

Rack_1:260: error: invalid conversion from ‘byte {aka unsigned char}’ to ‘midi::MidiType’ [-fpermissive]

portLo);

^

In file included from F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.h:258:0,

from F:\Documents\Arduino\Rack_1\Rack_1.ino:8:

F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.hpp:133:6: note: initializing argument 1 of ‘void midi::MidiInterface<SerialPort, _Settings>::send(midi::MidiType, midi::DataByte, midi::DataByte, midi::Channel) [with SerialPort = HardwareSerial; _Settings = midi::DefaultSettings; midi::DataByte = unsigned char; midi::Channel = unsigned char]’

void MidiInterface<SerialPort, Settings>::send(MidiType inType,

^

Rack_1:268: error: invalid conversion from ‘byte {aka unsigned char}’ to ‘midi::MidiType’ [-fpermissive]

7);

^

In file included from F:\Documents\Arduino\libraries\arduino_841278\src/MIDI.h:258:0,"

If I put the BB files back and try to use ‘Atmega328 on breadboard (8MHz internal clock)’ type, it compiles perfectly but won’t download. This is the error:

Arduino: 1.8.5 (Windows 10), Board: “ATmega328 on a breadboard (8 MHz internal clock)”

Warning: Board breadboard:avr:atmega328bb doesn’t define a ‘build.board’ preference. Auto-set to: AVR_ATMEGA328BB
In file included from F:\Documents\Arduino\Rack_1\Rack_1.ino:13:0:

F:\Documents\Arduino\libraries\NTOOLS/XLCD.h:88:17: note: #pragma message: USING OLED64_ADA

#pragma message “USING OLED64_ADA”

^

Sketch uses 19348 bytes (62%) of program storage space. Maximum is 30720 bytes.
Global variables use 1942 bytes of dynamic memory.
C:\Users\steve\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/bin/avrdude -CC:\Users\steve\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/etc/avrdude.conf -v -patmega328p -carduino -PCOM4 -b57600 -D -Uflash:w:C:\Users\steve\AppData\Local\Temp\arduino_build_785120/Rack_1.ino.hex:i

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is “C:\Users\steve\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/etc/avrdude.conf”

Using Port : COM4
Using Programmer : arduino
Overriding Baud Rate : 57600
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xbb
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xbb
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x1c

avrdude done. Thank you.

Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

westfw:
That's a very weird directory name to be including the midi library files from...
I don't think I can tell anything else without seeing the whole sketch and "verbose" compilation output.
Can you successfully compile any of the MIDI examples?

Is that a weird place? A friend who got me started on Arduino set it all up initially along with lots of adafruit files for the oled I'm using. I don't really understand all this library stuff - or at least how it gets where it should get.... Maybe he screwed something up? I have three arduino_nnnnnn folders, all with midi and adafruit stuff in there. Is there an official midi file I should get and put in the right place?

Yes it all compiles nicely in all cases except for the minicore board.

More than happy to post verbose compiler output but it's longer than the forum's allowed size - even the full non-verbose error wouldn't fit! Here is the first part in verbose:

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\steve\AppData\Local\Arduino15\packages -hardware F:\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\steve\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries F:\Documents\Arduino\libraries -fqbn=MiniCore:avr:328:bootloader=true,variant=modelNonP,BOD=2v7,LTO=Os,clock=8MHz_internal -vid-pid=0X2341_0X0042 -ide-version=10805 -build-path C:\Users\steve\AppData\Local\Temp\arduino_build_785120 -warnings=none -build-cache C:\Users\steve\AppData\Local\Temp\arduino_cache_507204 -prefs=build.warn_data_percentage=75 -verbose F:\Documents\Arduino\Rack_1\Rack_1.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\steve\AppData\Local\Arduino15\packages -hardware F:\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\steve\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries F:\Documents\Arduino\libraries -fqbn=MiniCore:avr:328:bootloader=true,variant=modelNonP,BOD=2v7,LTO=Os,clock=8MHz_internal -vid-pid=0X2341_0X0042 -ide-version=10805 -build-path C:\Users\steve\AppData\Local\Temp\arduino_build_785120 -warnings=none -build-cache C:\Users\steve\AppData\Local\Temp\arduino_cache_507204 -prefs=build.warn_data_percentage=75 -verbose F:\Documents\Arduino\Rack_1\Rack_1.ino
Using board '328' from platform in folder: C:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1
Using core 'MCUdude_corefiles' from platform in folder: C:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1
Warning: Board breadboard:avr:atmega328bb doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328BB
Detecting libraries used...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega328 -DF_CPU=8000000L -DARDUINO=10805 -DARDUINO_AVR_ATmega328 -DARDUINO_ARCH_AVR "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\cores\MCUdude_corefiles" "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\variants\standard" "C:\Users\steve\AppData\Local\Temp\arduino_build_785120\sketch\Rack_1.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega328 -DF_CPU=8000000L -DARDUINO=10805 -DARDUINO_AVR_ATmega328 -DARDUINO_ARCH_AVR "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\cores\MCUdude_corefiles" "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\variants\standard" "-IF:\Documents\Arduino\libraries\arduino_841278\src" "C:\Users\steve\AppData\Local\Temp\arduino_build_785120\sketch\Rack_1.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega328 -DF_CPU=8000000L -DARDUINO=10805 -DARDUINO_AVR_ATmega328 -DARDUINO_ARCH_AVR "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\cores\MCUdude_corefiles" "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\variants\standard" "-IF:\Documents\Arduino\libraries\arduino_841278\src" "-IF:\Documents\Arduino\libraries\NTOOLS" "C:\Users\steve\AppData\Local\Temp\arduino_build_785120\sketch\Rack_1.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega328 -DF_CPU=8000000L -DARDUINO=10805 -DARDUINO_AVR_ATmega328 -DARDUINO_ARCH_AVR "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\cores\MCUdude_corefiles" "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\variants\standard" "-IF:\Documents\Arduino\libraries\arduino_841278\src" "-IF:\Documents\Arduino\libraries\NTOOLS" "-IF:\Documents\Arduino\libraries\Midi-Utils" "C:\Users\steve\AppData\Local\Temp\arduino_build_785120\sketch\Rack_1.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega328 -DF_CPU=8000000L -DARDUINO=10805 -DARDUINO_AVR_ATmega328 -DARDUINO_ARCH_AVR "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\cores\MCUdude_corefiles" "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\variants\standard" "-IF:\Documents\Arduino\libraries\arduino_841278\src" "-IF:\Documents\Arduino\libraries\NTOOLS" "-IF:\Documents\Arduino\libraries\Midi-Utils" "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\libraries\SPI\src" "C:\Users\steve\AppData\Local\Temp\arduino_build_785120\sketch\Rack_1.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega328 -DF_CPU=8000000L -DARDUINO=10805 -DARDUINO_AVR_ATmega328 -DARDUINO_ARCH_AVR "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\cores\MCUdude_corefiles" "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\variants\standard" "-IF:\Documents\Arduino\libraries\arduino_841278\src" "-IF:\Documents\Arduino\libraries\NTOOLS" "-IF:\Documents\Arduino\libraries\Midi-Utils" "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\libraries\SPI\src" "-IC:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\libraries\Wire" "C:\Users\steve\AppData\Local\Temp\arduino_build_785120\sketch\Rack_1.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-

When installing (or updating) a library via Arduino IDE's Library Manager and a folder of that name already exists the Arduino IDE will instead install the library to the arduino_nnnn folder if the existing library has a different name value in library.properties or if it is unable to completely remove the existing folder.

I believe the reason why you can compile for Mega or Uno but not for the MiniCore board is that the Arduino AVR Boards hardware package sets the -fpermissive compiler flag, which downgrades these errors to warnings but MiniCore does not set this flag.

pert:
When installing (or updating) a library via Arduino IDE's Library Manager and a folder of that name already exists the Arduino IDE will instead install the library to the arduino_nnnn folder if the existing library has a different name value in library.properties or if it is unable to completely remove the existing folder.

I believe the reason why you can compile for Mega or Uno but not for the MiniCore board is that the Arduino AVR Boards hardware package sets the -fpermissive compiler flag, which downgrades these errors to warnings but MiniCore does not set this flag.

Thanks, can you tell me how I can set the compiler flag for minicore?

sorry - in the post above where I was getting avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xbb
this was because I forgot to SHIFT click on download so I was trying to put the code in my Arduino rather than the Atmega! Doing it properly gives the following error. Looks like the Breadboard board is expecting to see a 328p not my 328...:

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Users\steve\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/etc/avrdude.conf"

Using Port : COM4
Using Programmer : stk500v1
Overriding Baud Rate : 19200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : STK500
Description : Atmel STK500 Version 1.x firmware
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

An error occurred while uploading the sketch
Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9514 (probably m328)
avrdude: Expected signature for ATmega328P is 1E 95 0F
Double check chip, or use -F to override this check.

avrdude done. Thank you.

(deleted)

spycatcher2k:
Hi - GOOGLE "Expected signature for ATmega328P is 1E 95 0F" and you will find the quick fix (requires editing a file) :slight_smile:

Well I googled exactly that yesterday, got over 4000 pages and went through the first 10 or so. Nothing quick and easy I could see...

(deleted)

spycatcher2k:
find avrdude.conf in the hardware\tools\avr\etc folder in the Arduino IDE folder and edit it in notepad (or your fav. editor).

Search for 328, find the signature section and change the 14 to 0F, save and retry the upload. Remember to change it back.

Splendid I'll try that - thanks :slight_smile:

It's not necessary to modify avrdude.conf. MiniCore supports ATmega328. You only need to select Tools > Variant > ATmega328 / 328A.

stevehunt100:
Thanks, can you tell me how I can set the compiler flag for minicore?

Well... It's better to just fix the errors instead of telling the compiler to downgrade them. -fpermissive was intentionally left off by MiniCore's author:

If you do want to add it:

  • Tools > Board > select a MiniCore board
  • File > Examples > SPI (MiniCore) > BarometricPressureSensor
  • Sketch > Show Sketch Folder
  • Navigate up 4 folder levels to C:\Users\steve\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1
  • Use a text editor to create a file named platform.local.txt at this location that contains the line:
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
  • Save the file.
  • Close all Arduino IDE windows.
  • Restart the Arduino IDE and try compiling again.

Note that you will need to repeat that process everytime you update to a new version of MiniCore.

Isn't all that's needed here to fix the errors the right way an explicit cast in a few locations?

pert:
It’s not necessary to modify avrdude.conf. MiniCore supports ATmega328. You only need to select Tools > Variant > ATmega328 / 328A.

Thanks, yes I was doing that.

Agreed, best to fix the errors rather than ignore them. I have no doubt that my code is rather rustic. I haven’t posted it so far because it’s nearly 600 lines… I will post below the first section and a later part that is giving rise to an error. If I’m making a mistake with casting or something then please give me a push in the right direction. As I said, this all compiles perfectly for mega but the minicore seems a lot more fussy and seems to object to my coding?

#include <MIDI.h>
#include <button.h>
#include <midi-utils.h>
#include <ntools.h>
#define USE_OLED_64_ADAFRUIT
#include <XLCD.h>

const char Str00[16] PROGMEM = " ";
const char Str01[16] PROGMEM = "Numa ";
const char Str02[16] PROGMEM = "Kronos ";
const char Str03[16] PROGMEM = “Voyager”;
const char Str04[16] PROGMEM = “Blofeld”;
const char Str05[16] PROGMEM = "Peak ";
const char Str06[16] PROGMEM = "Mini D ";
const char Str07[16] PROGMEM = “Odyssey”;
const char Str08[16] PROGMEM = "unused ";
const char Str09[16] PROGMEM = "unused ";
const char Str10[16] PROGMEM = "unused ";
const char Str11[16] PROGMEM = "unused ";
const char Str12[16] PROGMEM = "unused ";
const char Str13[16] PROGMEM = "unused ";
const char Str14[16] PROGMEM = "unused ";
const char Str15[16] PROGMEM = "unused ";
const char Str16[16] PROGMEM = "unused ";

const char* const channels = {
Str00, Str01, Str02, Str03, Str04, Str05, Str06, Str07, Str08, Str09,
Str10, Str11, Str12, Str13, Str14, Str15, Str16
};

#define MODE_IDLE 0
#define MODE_SPLIT 3

#define UNISON (keySplit == 21)

byte _note = 0;
byte Data1T;
byte Data1Lo;
byte Data1Hi;
byte Data2;
boolean CC33 = false; //set if midi CC33 incoming - don’t send to Peak!
byte shrunkData1Lo;
byte shrunkData1Hi;
byte shrunkData1T;
byte shrunkData2;
String drawData1;
String drawData2 = "flabs ";
byte portT = 7;
float denominator = 4;
int fourteenBit;
byte MidiType;

byte Mode = MODE_IDLE;
byte lastMode = MODE_IDLE;

// reduce screen flickering

boolean needsUpdate = true;
boolean doSkip = false;
boolean dataToDisplay = false;

void noteSend() // ********** Note Send *********
{
if (UNISON)
{
if (portHi) // ie skip if we’ve selected midi channel 0
{
MIDI.send(MidiType,
Data1Hi,
Data2,
portHi);

if (portHi == 6 && toggleB) // toggleB echo’s everything on Ch6 to Ch7 as well
{
MIDI.send(MidiType,
Data1Hi + transposeLo,
Data2,
7);
}
}
if (portLo) // ie skip if we’ve selected midi channel 0
{
if (portLo != portHi) //so if both zones are same channel don’t send duplicate notes or CC
{

if (!((portLo == 6 || portLo == 7) && portHi == 6 && toggleB)) //don’t Tx on Ch7 if also echoing on other zone
{
MIDI.send(MidiType,
Data1Lo,
Data2,
portLo);
}

if (portLo == 6 && toggleB && !(portHi == 6 || portHi == 7)) // toggleB echo’s everything on Ch6 to Ch7 as well
{
MIDI.send(MidiType,
Data1Lo,
Data2,
7);
}

}
}

}

I found the FortySevenEffects MIDI library but it looks like there are one or two others required by your code.

Post a link to where you got the library from. Please use the chain links icon on the toolbar to make it clickable. Or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries) then say so and state the full name of the library.

several of these libraries were sent to me by an acquaintance who is not available to help for a while. I have no idea where he got them from :frowning:

ntools.h:

#ifndef NTOOLS_H
#define NTOOLS_H


/*
$Header: N:\cvs-repository/NTOOLS/ntools.h,v 1.3 2016/08/04 22:59:42 KBL Exp $

------------------------------------

$Log: ntools.h,v $
Revision 1.3  2016/08/04 22:59:42  KBL
no message

Revision 1.2  2016/08/03 09:34:29  KBL
cvs tags



*/


#include <include/memory.h>





//#define getbit(number,pos) (number >> pos) & 1
//#define setbit(number,pos,value) number ^= (-value ^ number) & (1 << pos)
#define setbit(number,pos,value) bitWrite(number,pos,value)
#define getbit(number,pos) bitRead(number,pos)

#define out Serial
#define endl "\n"
#define crlf "\n\r"

#define FSTR(a) reinterpret_cast<const __FlashStringHelper *>(a)

/*
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
*/
#define HEX2 32
#define HEX4 HEX
#define BIN2 33
#define BIN4 BIN
#define DEC2 34
#define DEC3 35
#define HEX2S 36


static char fmtbuffer [35];


#define INT_TO_BINARY(intA)  \
  (intA & 0x8000 ? '1' : '0'), \
  (intA & 0x4000 ? '1' : '0'), \
  (intA & 0x2000 ? '1' : '0'), \
  (intA & 0x1000 ? '1' : '0'), \
  (intA & 0x0800 ? '1' : '0'), \
  (intA & 0x0400 ? '1' : '0'), \
  (intA & 0x0200 ? '1' : '0'), \
  (intA & 0x0100 ? '1' : '0'), \
  (intA & 0x0080 ? '1' : '0'), \
  (intA & 0x0040 ? '1' : '0'), \
  (intA & 0x0020 ? '1' : '0'), \
  (intA & 0x0010 ? '1' : '0'), \
  (intA & 0x0008 ? '1' : '0'), \
  (intA & 0x0004 ? '1' : '0'), \
  (intA & 0x0002 ? '1' : '0'), \
  (intA & 0x0001 ? '1' : '0')

  #define BYTE_TO_BINARY(byteA)  \
  (byteA & 0x0080 ? '1' : '0'), \
  (byteA & 0x0040 ? '1' : '0'), \
  (byteA & 0x0020 ? '1' : '0'), \
  (byteA & 0x0010 ? '1' : '0'), \
  (byteA & 0x0008 ? '1' : '0'), \
  (byteA & 0x0004 ? '1' : '0'), \
  (byteA & 0x0002 ? '1' : '0'), \
  (byteA & 0x0001 ? '1' : '0')
  
  
  #define inRange(min , max , val)  \
	(val < min) ? (val = max) : (val) ; \
	(val > max) ? (val = min) : (val) ; 
	
	
inline char * fmt(unsigned int n, uint8_t base)
{

  switch (base)
  {
    case HEX:
      {
        sprintf (fmtbuffer, "0x%04x", n);
        break;
      }
	case HEX2:
      {
        sprintf (fmtbuffer, "0x%02x", n);
        break;
      }
	case HEX2S:
      {
        sprintf (fmtbuffer, "%02x\:", n);
        break;
      }

    case OCT:
      {
        sprintf (fmtbuffer, "0o%04o", n);
        break;

      }
    case BIN2:
      {
        sprintf (fmtbuffer, "0b%c%c%c%c%c%c%c%c", BYTE_TO_BINARY(n));
        break;

      }
	case BIN:
      {
        sprintf (fmtbuffer, "0B%c%c%c%c%c%c%c%c::%c%c%c%c%c%c%c%c", INT_TO_BINARY(n));
        break;

      }
	case DEC2:
      {
        sprintf (fmtbuffer, "%02d", n);
        break;

      }
	  case DEC3:
      {
        sprintf (fmtbuffer, "%03d", n);
        break;

      }
    case DEC:
    default:
      {
        sprintf (fmtbuffer, "%04d", n);
        break;

      }
  }
  return fmtbuffer;
}

inline char * fmt(const char *ch,char *s)
{
  
  sprintf (fmtbuffer, s, ch);
  return fmtbuffer;
}

template<class T> inline Stream &operator <<(Stream &obj, T arg) {
  obj.print(arg);
  return obj;
}

#ifdef ARDUINO_SAM_DUE
 inline void digitalWriteDirect(int pin, boolean val) {
      if (val) g_APinDescription[pin].pPort -> PIO_SODR = g_APinDescription[pin].ulPin;
      else    g_APinDescription[pin].pPort -> PIO_CODR = g_APinDescription[pin].ulPin;
    }

    inline int digitalReadDirect(int pin) {
      return !!(g_APinDescription[pin].pPort -> PIO_PDSR & g_APinDescription[pin].ulPin);
    }
#else
    inline void digitalWriteDirect(int pin, boolean val) {
        digitalWrite(pin,val);
    }

    inline int digitalReadDirect(int pin) {
      return digitalRead(pin);
    }
#endif

#endif

button.h:

#ifndef BUTTON_H
#define BUTTON_H
/*
$Header: Y:\CVSROOT/NControls/button.h,v 1.1.1.1 2018/04/06 08:40:51 Kris Exp $

-------------------------------------------

$Log: button.h,v $
Revision 1.1.1.1  2018/04/06 08:40:51  Kris
initial Release

*/


#define REPEAT 1000
#define DEBOUNCE 50

class Button
{
  public:
    Button()
    {}
	Button(int _pinP)
    {
		begin(_pinP);
	}
    void begin(int _pinP)
    {
		pin = _pinP; 
		pinMode(pin, INPUT_PULLUP);
		prev = false;
		
    }
	bool up(void)
	{	
		bool b = (digitalRead(pin) != LOW);
		if (b && prev) 
		{
			if (millis() - lastUp < DEBOUNCE){return false;};
			lastUp = millis();
			prev = b;			
			return true;
		}
		
		prev = b;
		return false;
	}	
	bool down(void)
	{	
		bool b = (digitalRead(pin) == LOW);
		if (b && (!prev)) lastPressed = millis();
		if (b && prev) 
		{		
			prev = b;
			return true;
		}
		prev = b;
		return false;
	}
	bool click()
	{
		bool b = (digitalRead(pin) == LOW);	
		if (b && (!prev)) 
		{
			if (millis() - lastClick < DEBOUNCE){return false;};
			lastPressed = millis();
			lastClick = millis();
			prev = b;			
			return true;
		}
		prev = b;
		return false;
	}
	bool repeat()
	{
		bool b = (digitalRead(pin) == LOW);
		if (b && (!prev)) lastPressed = millis();
		if (b && prev)
		{
			prev = b;	
			if (millis() - lastPressed > REPEAT) 	return true;
			return false;
		}
		prev = b;
		return false;
	}
	bool release()
	{
		bool b = (digitalRead(pin) != LOW);
		if (!b && (!prev)) lastPressed = millis();
		if (b && (!prev)) 
		{
			prev = b;			
			return true;
		}		
		prev = b;
		return false;
	}
    
	private:
   
		uint8_t pin;				
		bool prev;
		unsigned long lastPressed;  // for repeat
		unsigned long lastClick;	// for Debounce2
		unsigned long lastUp;	// for Debounce2
    
	
};
#endif

midi-ulils.h:

#pragma once
#ifndef midi_utils_h
#define midi_utils_h


// Some useful stuff


// Notenames
const char*  const notenames[]  = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
const char notefmtString[]  = "%2.2s%1d";
char notelogString[4];

const char* decodeNote (byte note)
{
  byte index = note % 12;
  return notenames[index];
}
byte decodeOct (byte note)
{
  return (note  / 12) - 1;

}
char* decodeNote2 (byte note)
{
  
  sprintf(notelogString,notefmtString,decodeNote(note),decodeOct(note));
  return notelogString;
}
#endif