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.02k stars 448 forks source link

Some flags are not parsed from the boards.txt for SAMD #658

Closed JDuchniewicz closed 3 years ago

JDuchniewicz commented 3 years ago

I am trying to run Arduino Nano 33 IoT with this makefile and some variables are empty (mostly these related to PARSE_BOARD macro call).

I am sure that BOARDS_TXT does exist and that the macro is formed properly. I am not proficient enough in Makefiles to debug on my own where the issue originates from.

The exemplary logs are pasted below:

Sam.mk Configuration:
- [AUTODETECTED]       CURRENT_OS = LINUX
- [USER]               ARDUINO_DIR = /usr/share/arduino
- [USER]               ARDUINO_PACKAGE_DIR = /home/jduchniewicz/.arduino15/packages
- [AUTODETECTED]       CORE_VER = 1.8.11 (from ARDUINO_PACKAGE_DIR)
- [AUTODETECTED]       CMSIS_VER = 4.5.0 (from ARDUINO_PACKAGE_DIR)
- [AUTODETECTED]       CMSIS_ATMEL_VER = 1.2.0 (from ARDUINO_PACKAGE_DIR)
- [AUTODETECTED]       CMSIS_DIR = /home/jduchniewicz/.arduino15/packages/arduino/tools/CMSIS/4.5.0/CMSIS (from ARDUINO_PACKAGE_DIR)
- [AUTODETECTED]       CMSIS_ATMEL_DIR = /home/jduchniewicz/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS (from ARDUINO_PACKAGE_DIR)
- [COMPUTED]           ARM_TOOLS_DIR =  (from ARDUINO_PACKAGE_DIR)
- [COMPUTED]           ARDUINO_PLATFORM_LIB_PATH = /home/jduchniewicz/.arduino15/packages/arduino/hardware/samd/1.8.11/libraries (from ARDUINO_PACKAGE_DIR)
- [AUTODETECTED]       OPENOCD = /home/jduchniewicz/.arduino15/packages/arduino/tools/openocd/0.10.0-arduino7/bin/openocd -s /home/jduchniewicz/.arduino15/packages/arduino/tools/openocd/0.10.0-arduino7/share/openocd/scripts/ (from ARDUINO_PACKAGE_DIR)
- [AUTODETECTED]       BOSSA = /home/jduchniewicz/.arduino15/packages/arduino/tools/bossac/1.7.0-arduino3/bossac (from ARDUINO_PACKAGE_DIR)
-------------------------
Arduino.mk Configuration:
- [USER]               ARDMK_DIR = /mnt/games/Projects/Personal/BIBoP/Arduino-Makefile
- [AUTODETECTED]       ARDUINO_VERSION = 1813
- [USER]               ARCHITECTURE = samd
- [USER]               ARDMK_VENDOR = arduino
- [AUTODETECTED]       ARDUINO_PREFERENCES_PATH = /home/jduchniewicz/.arduino15/preferences.txt
- [AUTODETECTED]       ARDUINO_SKETCHBOOK = /home/jduchniewicz/Arduino (from arduino preferences file)
- [USER]               ALTERNATE_CORE_PATH = /home/jduchniewicz/.arduino15/packages/arduino/hardware/samd/1.8.11
- [COMPUTED]           ARDUINO_VAR_PATH = /home/jduchniewicz/.arduino15/packages/arduino/hardware/samd/1.8.11/variants (from ALTERNATE_CORE_PATH)
- [USER]               AVR_TOOLS_DIR = /home/jduchniewicz/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4
- [COMPUTED]           ARDUINO_LIB_PATH = /usr/share/arduino/libraries (from ARDUINO_DIR)
- [USER]               ARDUINO_PLATFORM_LIB_PATH = /home/jduchniewicz/.arduino15/packages/arduino/hardware/samd/1.8.11/libraries
- [USER]               USER_LIB_PATH = /mnt/games/Projects/Personal/BIBoP/lib
- [DEFAULT]            PRE_BUILD_HOOK = pre-build-hook.sh
- [USER]               BOARD_SUB = nano_33_iot
- [USER]               BOARD_TAG = nano
- [COMPUTED]           CORE =  (from build.core)
- [COMPUTED]           VARIANT =  (from build.variant)
- [USER]               OBJDIR = /mnt/games/Projects/Personal/BIBoP/build/FooProject/nano
- [USER]               ARDUINO_CORE_PATH = /home/jduchniewicz/.arduino15/packages/arduino/hardware/samd/1.8.11/cores/arduino
-                      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 = 115200
- [DEFAULT]            OPTIMIZATION_LEVEL = s
- [USER]               MCU_FLAG_NAME = mcpu
- [USER]               CFLAGS_STD = -std=gnu11 -std=gnu11
- [USER]               CXXFLAGS_STD = -std=gnu++17
- [COMPUTED]           DEVICE_PATH = /dev/ttyACM* (from MONITOR_PORT)
- [DEFAULT]            FORCE_MONITOR_PORT =
- [AUTODETECTED]       Size utility: ARM
-                      SKETCH_LIBS =
- [USER]                 FooLib
-                      SYSTEM_LIBS =
- [PLATFORM]             Wire
- [USER]               BOOTLOADER_PARENT = /home/jduchniewicz/.arduino15/packages/arduino/hardware/samd/1.8.11/bootloaders
- [COMPUTED]           ARDMK_VERSION = 1.6
- [COMPUTED]           CC_VERSION = 7.2.1 (arm-none-eabi-gcc)
-------------------------
mkdir -p /mnt/games/Projects/Personal/BIBoP/build/FooProject/nano
/home/jduchniewicz/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -MMD -c -D__PROG_TYPES_COMPAT__ -I/home/jduchniewicz/.arduino15/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include/ -I/home/jduchniewicz/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL -DMD -DUSBCON '-DUSB_PRODUCT=' '-DUSB_MANUFACTURER="Unknown"'  -DUSB_VID= -DUSB_PID= -mthumb -nostdlib --param max-inline-insns-single=500 -fno-exceptions -Wl,-Map=/mnt/games/Projects/Personal/BIBoP/build/FooProject/nano/FooProject_.map -mcpu= -DF_CPU= -DARDUINO=1813 -DARDUINO_ARCH_SAMD -I/home/jduchniewicz/.arduino15/packages/arduino/hardware/samd/1.8.11/cores/arduino -I/home/jduchniewicz/.arduino15/packages/arduino/hardware/samd/1.8.11/cores/arduino/api -I/home/jduchniewicz/.arduino15/packages/arduino/hardware/samd/1.8.11/variants/    -I/home/jduchniewicz/.arduino15/packages/arduino/hardware/samd/1.8.11/libraries/Wire -I/home/jduchniewicz/.arduino15/packages/arduino/hardware/samd/1.8.11/libraries/Wire -I/home/jduchniewicz/.arduino15/packages/arduino/hardware/samd/1.8.11/libraries/Wire/examples/   -I/mnt/games/Projects/Personal/BIBoP/lib/FooLib -I/mnt/games/Projects/Personal/BIBoP/lib/FooLib   -I/mnt/games/Projects/Personal/BIBoP/lib/FooLib -I/mnt/games/Projects/Personal/BIBoP/lib/FooLib -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-rtti -fno-threadsafe-statics -std=gnu++11 -fpermissive -fno-exceptions -std=gnu++17 -fno-threadsafe-statics -flto -fno-devirtualize -fdiagnostics-color=always main.cpp -o /mnt/games/Projects/Personal/BIBoP/build/FooProject/nano/main.cpp.o
arm-none-eabi-g++: error: missing argument to '-mcpu='
make: *** [/mnt/games/Projects/Personal/BIBoP/Arduino-Makefile/Arduino.mk:1432: /mnt/games/Projects/Personal/BIBoP/build/FooProject/nano/main.cpp.o] Error 1

For now I am hardcoding all of them, but this does not construe an extensible makefile 😄

Update: Despite hardcoding most of the paths, the definitions in samd board files cannot be found...

JDuchniewicz commented 3 years ago

Okay, the issue was with supplying only nano instead of nano_33_iot because that is how the Bare-Arduino-Makefile instructed. So it looked like this:

BOARD_TAG = nano
BOARD_SUB = nano_33_iot

instead of

BOARD_TAG = nano_33_iot
tuna-f1sh commented 3 years ago

Just for reference in case you come across this again, nano in that project will be referring to the original AVR Arduino Nano https://www.arduino.cc/en/pmwiki.php?n=Main/ArduinoBoardNano

The Nano IoT 33 is a much newer board so you can assume any documentation with nano is the AVR board.

JDuchniewicz commented 3 years ago

Thanks! I uploaded the PR to the other repo with clarification for the SAM boards.