forked from sudar/Arduino-Makefile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATtiny.mk
More file actions
113 lines (99 loc) · 3.59 KB
/
Copy pathATtiny.mk
File metadata and controls
113 lines (99 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#
# Support for ATTiny boards
#
# You must install an ATTiny core package (default: ATTinyCore) to use this,
# then define ALTERNATE_CORE_PATH as the path to the root of the core package
# if it is not autodetected.
#
# To use Micronucleus, install the 'micronucleus' package
# and define MICRONUCLEUS as the path to the 'micronucleus' command
# if it is not autodetected.
#
# Use 'make ispload' to upload with an ISP
# and 'make microload' to upload with Micronucleus.
#
# Copyright (C) 2026 stygian-violet
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# License, or (at your option) any later version.
#
ifndef ARDMK_DIR
ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
endif
arduino_output =
ifndef ARDUINO_QUIET
ARDUINO_QUIET = 0
endif
ifeq ($(ARDUINO_QUIET),0)
ifeq ($(MAKE_RESTARTS),)
ifeq ($(MAKELEVEL),0)
arduino_output = $(info $(1))
endif
endif
endif
include $(ARDMK_DIR)/Common.mk
ALTERNATE_CORE ?= ATTinyCore
TIMER_CLOCK_SOURCE ?= default
ISP_PROG ?= usbasp
MICRONUCLEUS_OPTS ?= --no-ansi --run --timeout 60
$(call show_config_variable,HOME,[AUTODETECTED])
ifndef ALTERNATE_CORE_PATH
ALTERNATE_CORE_PATH := $(firstword \
$(wildcard $(HOME)/.arduino*/packages/$(ALTERNATE_CORE)/hardware/avr/*)\
$(wildcard $(HOME)/Library/Arduino*/packages/$(ALTERNATE_CORE)/hardware/avr/*))
$(call show_config_variable,ALTERNATE_CORE_PATH,$(if $(ALTERNATE_CORE_PATH),[AUTODETECTED],[NOT FOUND]))
ifndef ALTERNATE_CORE_PATH
echo $(error ALTERNATE_CORE_PATH is not defined)
endif
else
$(call show_config_variable,ALTERNATE_CORE_PATH,[USER])
endif
ifndef BOARDS_TXT
BOARDS_TXT := $(ALTERNATE_CORE_PATH)/boards.txt
$(call show_config_variable,BOARDS_TXT,[COMPUTED])
else
$(call show_config_variable,BOARDS_TXT,[USER])
endif
ifndef CLOCK_SOURCE
ifdef BOARD_CLOCK
CLOCK_SOURCE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(speed|clock|sketchclock).$(BOARD_CLOCK).build.clocksource)
endif
ifndef CLOCK_SOURCE
CLOCK_SOURCE := $(call PARSE_BOARD,$(BOARD_TAG),build.clocksource)
endif
$(call show_config_variable,CLOCK_SOURCE,$(if $(CLOCK_SOURCE),[COMPUTED],[NOT FOUND]))
ifndef CLOCK_SOURCE
echo $(error CLOCK_SOURCE is not defined)
endif
else
$(call show_config_variable,CLOCK_SOURCE,[USER])
endif
ifndef PLL_SETTINGS
ifdef TIMER_CLOCK_SOURCE
PLL_SETTINGS := $(call PARSE_BOARD,$(BOARD_TAG),menu.TimerClockSource.$(TIMER_CLOCK_SOURCE).build.pllsettings)
endif
ifndef PLL_SETTINGS
PLL_SETTINGS := $(call PARSE_BOARD,$(BOARD_TAG),build.pllsettings)
endif
$(call show_config_variable,PLL_SETTINGS,[COMPUTED])
else
$(call show_config_variable,PLL_SETTINGS,[USER])
endif
CPPFLAGS += -DCLOCK_SOURCE=$(CLOCK_SOURCE) $(PLL_SETTINGS)
ifndef MICRONUCLEUS
MICRONUCLEUS := $(firstword $(shell which micronucleus 2> /dev/null) \
$(wildcard $(HOME)/.arduino*/packages/$(ALTERNATE_CORE)/tools/micronucleus/*/micronucleus) \
$(wildcard $(HOME)/Library/Arduino*/packages/$(ALTERNATE_CORE)/tools/micronucleus/*/micronucleus))
$(call show_config_variable,MICRONUCLEUS,$(if $(MICRONUCLEUS),[AUTODETECTED],[NOT FOUND]))
else
$(call show_config_variable,MICRONUCLEUS,[USER])
endif
include $(ARDMK_DIR)/Arduino.mk
microload: $(TARGET_HEX) verify_size
ifndef MICRONUCLEUS
@$(ECHO) $(error MICRONUCLEUS is not defined)
endif
$(MICRONUCLEUS) $(MICRONUCLEUS_OPTS) $(TARGET_HEX)
.PHONY: microload