Skip to content

Commit fb44606

Browse files
author
Federico Fissore
committed
TargetBoardResolver was handling 4th fqbn value too late and setting 'core'
to a wrong value. Fixes #46 Signed-off-by: Federico Fissore <[email protected]>
1 parent a28be5f commit fb44606

File tree

6 files changed

+311
-9
lines changed

6 files changed

+311
-9
lines changed

Diff for: src/arduino.cc/builder/target_board_resolver.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ func (s *TargetBoardResolver) Run(context map[string]interface{}) error {
6868
context[constants.CTX_TARGET_PLATFORM] = targetPlatform
6969
context[constants.CTX_TARGET_BOARD] = targetBoard
7070

71+
if len(fqbnParts) > 3 {
72+
addAdditionalPropertiesToTargetBoard(targetBoard, fqbnParts[3])
73+
}
74+
7175
core := targetBoard.Properties[constants.BUILD_PROPERTIES_BUILD_CORE]
7276
if core == constants.EMPTY_STRING {
7377
core = DEFAULT_BUILD_CORE
7478
}
7579

76-
if len(fqbnParts) > 3 {
77-
addAdditionalPropertiesToTargetBoard(targetBoard, fqbnParts[3])
78-
}
79-
8080
var corePlatform *types.Platform
8181
coreParts := strings.Split(core, ":")
8282
if len(coreParts) > 1 {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# VID 0x6666 is a prototype product Vendor ID
2+
# http://www.linux-usb.org/usb.ids
3+
4+
menu.speed=Speed
5+
menu.core=Core
6+
menu.info=Info
7+
8+
9+
# ATmega32u4 @ 16 MHz
10+
atmega32u4.name=ATmega32u4
11+
atmega32u4.menu.speed.16mhz=16 MHz
12+
atmega32u4.menu.speed.16mhz.build.f_cpu=16000000L
13+
atmega32u4.menu.speed.16mhz.bootloader.file=caterina_16mhz.hex
14+
atmega32u4.menu.speed.8mhz=8 MHz
15+
atmega32u4.menu.speed.8mhz.build.f_cpu=8000000L
16+
atmega32u4.menu.speed.8mhz.bootloader.file=caterina_8mhz.hex
17+
atmega32u4.vid.0=0x1D50
18+
atmega32u4.pid.0=0x60B0
19+
atmega32u4.vid.1=0x6666
20+
atmega32u4.pid.1=0x60B0
21+
atmega32u4.vid.2=0x2341
22+
atmega32u4.pid.2=0x0036
23+
atmega32u4.vid.3=0x2341
24+
atmega32u4.pid.3=0x8036
25+
atmega32u4.vid.4=0x2A03
26+
atmega32u4.pid.4=0x0036
27+
atmega32u4.vid.5=0x2A03
28+
atmega32u4.pid.5=0x8036
29+
atmega32u4.bootloader.tool=avrdude
30+
atmega32u4.bootloader.low_fuses=0xff
31+
atmega32u4.bootloader.high_fuses=0xd8
32+
atmega32u4.bootloader.extended_fuses=0xcb
33+
#atmega32u4.bootloader.file=caterina_16mhz.hex
34+
atmega32u4.bootloader.unlock_bits=0x3F
35+
atmega32u4.bootloader.lock_bits=0x2F
36+
atmega32u4.upload.tool=avrdude
37+
atmega32u4.upload.protocol=avr109
38+
atmega32u4.upload.maximum_size=28672
39+
atmega32u4.upload.maximum_data_size=2560
40+
atmega32u4.upload.speed=57600
41+
atmega32u4.upload.disable_flushing=true
42+
atmega32u4.upload.use_1200bps_touch=true
43+
atmega32u4.upload.wait_for_upload_port=true
44+
atmega32u4.build.mcu=atmega32u4
45+
#atmega32u4.build.f_cpu=16000000L
46+
atmega32u4.build.vid=0x6666
47+
atmega32u4.build.pid=0x60B0
48+
atmega32u4.build.usb_product="USB IO Board"
49+
atmega32u4.build.usb_manufacturer="ATmega32u4"
50+
atmega32u4.build.board=AVR_LEONARDO
51+
atmega32u4.build.core=arduino:arduino
52+
atmega32u4.build.variant=leonardo
53+
atmega32u4.build.extra_flags={build.usb_flags} -DMOUSE_ABS_ENABLED
54+
55+
56+
# ATtiny841 @ internal 8 MHz
57+
attiny841.name=ATtiny841 (8 MHz)
58+
# use Standard Arduino Core
59+
attiny841.menu.core.arduino=Standard Arduino
60+
attiny841.menu.core.arduino.build.core=arduino:arduino
61+
attiny841.menu.core.arduino.build.variant=tiny14
62+
# use Spence Konde Core: https://github.com/SpenceKonde/arduino-tiny-841/
63+
attiny841.menu.core.spencekonde=ATtiny841 (by Spence Konde)
64+
#attiny841.menu.core.spencekonde.build.core=arduino-tiny-841:tiny
65+
attiny841.menu.core.spencekonde.build.core=tiny841
66+
attiny841.menu.core.spencekonde.build.variant=tiny14
67+
# info menu item
68+
attiny841.menu.info.info=Press Reset, when Uploading is shown.
69+
attiny841.vid.0=0x16D0
70+
attiny841.pid.0=0x0753
71+
attiny841.bootloader.tool=avrdude
72+
attiny841.bootloader.low_fuses=0xE2
73+
attiny841.bootloader.high_fuses=0xDD
74+
attiny841.bootloader.extended_fuses=0xFE
75+
attiny841.bootloader.unlock_bits=0xFF
76+
attiny841.bootloader.lock_bits=0xFF
77+
attiny841.bootloader.file=micronucleus-t841.hex
78+
attiny841.upload.tool=micronucleus
79+
attiny841.upload.protocol=usb
80+
attiny841.upload.wait_for_upload_port=false
81+
attiny841.upload.use_1200bps_touch=false
82+
attiny841.upload.disable_flushing=false
83+
attiny841.upload.maximum_size=6500
84+
attiny841.build.mcu=attiny841
85+
attiny841.build.f_cpu=8000000L
86+
attiny841.build.board=AVR_ATTINY841
87+
#attiny841.build.core=arduino:arduino
88+
#attiny841.build.variant=tiny14
89+
90+
91+
# ATtiny85 @ internal 16.5 MHz
92+
attiny85.name=ATtiny85 (16.5 MHz)
93+
# use Standard Arduino Core
94+
attiny85.menu.core.arduino=Standard Arduino
95+
attiny85.menu.core.arduino.build.board=AVR_ATTINY85
96+
attiny85.menu.core.arduino.build.core=arduino:arduino
97+
attiny85.menu.core.arduino.build.variant=tiny8
98+
# use Spence Konde Core: https://github.com/SpenceKonde/ATTinyCore
99+
attiny85.menu.core.spencekonde=ATtiny85 (by Spence Konde)
100+
attiny85.menu.core.spencekonde.build.board=AVR_ATTINY85
101+
#attiny85.menu.core.spencekonde.build.core=ATTinyCore:tiny
102+
attiny85.menu.core.spencekonde.build.core=tiny85
103+
attiny85.menu.core.spencekonde.build.variant=tiny8
104+
# use Digistump Core: https://github.com/digistump/DigistumpArduino
105+
attiny85.menu.core.digistump=Digistump/Digispark
106+
attiny85.menu.core.digistump.build.board=AVR_DIGISPARK
107+
attiny85.menu.core.digistump.build.core=digistump:tiny
108+
attiny85.menu.core.digistump.build.variant=digispark
109+
# info menu item
110+
attiny85.menu.info.info=Press Reset, when Uploading is shown.
111+
attiny85.vid.0=0x16D0
112+
attiny85.pid.0=0x0753
113+
attiny85.bootloader.tool=avrdude
114+
attiny85.bootloader.low_fuses=0xE1
115+
attiny85.bootloader.high_fuses=0xDD
116+
attiny85.bootloader.extended_fuses=0xFE
117+
attiny85.bootloader.unlock_bits=0xFF
118+
attiny85.bootloader.lock_bits=0xFF
119+
attiny85.bootloader.file=micronucleus-t85.hex
120+
attiny85.upload.tool=micronucleus
121+
attiny85.upload.protocol=usb
122+
attiny85.upload.wait_for_upload_port=false
123+
attiny85.upload.use_1200bps_touch=false
124+
attiny85.upload.disable_flushing=false
125+
attiny85.upload.maximum_size=6300
126+
attiny85.build.mcu=attiny85
127+
attiny85.build.f_cpu=16500000L
128+
attiny85.build.board=AVR_ATTINY85
129+
#attiny85.build.core=arduino:arduino
130+
#attiny85.build.variant=tiny8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
2+
# Watterott AVR Core and platform.
3+
# ------------------------------
4+
#
5+
# For more info:
6+
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification
7+
8+
name=Watterott AVR Boards
9+
version=1.0.0
10+
11+
# AVR compile variables
12+
# ---------------------
13+
14+
compiler.warning_flags=-w
15+
compiler.warning_flags.none=-w
16+
compiler.warning_flags.default=
17+
compiler.warning_flags.more=-Wall
18+
compiler.warning_flags.all=-Wall -Wextra
19+
20+
# Default "compiler.path" is correct, change only if you want to overidde the initial value
21+
#compiler.path={runtime.ide.path}/hardware/tools/avr/bin/
22+
compiler.path={runtime.tools.avr-gcc.path}/bin/
23+
compiler.c.cmd=avr-gcc
24+
compiler.c.flags=-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -MMD
25+
# -w flag added to avoid printing a wrong warning http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396
26+
# This is fixed in gcc 4.8.3 and will be removed as soon as we update the toolchain
27+
compiler.c.elf.flags=-Os {compiler.warning_flags} -Wl,--gc-sections
28+
compiler.c.elf.cmd=avr-gcc
29+
compiler.S.flags=-c -g -x assembler-with-cpp
30+
compiler.cpp.cmd=avr-g++
31+
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
32+
compiler.ar.cmd=avr-ar
33+
compiler.ar.flags=rcs
34+
compiler.objcopy.cmd=avr-objcopy
35+
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
36+
compiler.elf2hex.flags=-O ihex -R .eeprom
37+
compiler.elf2hex.cmd=avr-objcopy
38+
compiler.ldflags=
39+
compiler.size.cmd=avr-size
40+
41+
# This can be overriden in boards.txt
42+
build.extra_flags=
43+
44+
# These can be overridden in platform.local.txt
45+
compiler.c.extra_flags=
46+
compiler.c.elf.extra_flags=
47+
compiler.S.extra_flags=
48+
compiler.cpp.extra_flags=
49+
compiler.ar.extra_flags=
50+
compiler.objcopy.eep.extra_flags=
51+
compiler.elf2hex.extra_flags=
52+
53+
# AVR compile patterns
54+
# --------------------
55+
56+
## Compile c files
57+
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
58+
59+
## Compile c++ files
60+
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
61+
62+
## Compile S files
63+
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
64+
65+
## Create archives
66+
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}"
67+
68+
## Combine gc-sections, archives, and objects
69+
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm
70+
71+
## Create output files (.eep and .hex)
72+
recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep"
73+
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
74+
75+
## Save hex
76+
recipe.output.tmp_file={build.project_name}.hex
77+
recipe.output.save_file={build.project_name}.{build.variant}.hex
78+
79+
## Compute size
80+
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
81+
recipe.size.regex=^(?:\.text|\.data|\.bootloader)\s+([0-9]+).*
82+
recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*
83+
recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
84+
85+
## Preprocessor
86+
preproc.includes.flags=-w -x c++ -M -MG -MP
87+
recipe.preproc.includes="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.includes.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}"
88+
preproc.macros.flags=-w -x c++ -E -CC
89+
recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}"
90+
91+
92+
# AVR Uploader/Programmers tools
93+
# ------------------------------
94+
95+
## AVRdude
96+
#tools.avrdude.path={runtime.ide.path}/hardware/tools/avr/
97+
tools.avrdude.path={runtime.tools.avrdude.path}
98+
tools.avrdude.cmd.path={path}/bin/avrdude
99+
#tools.avrdude.config.path={path}/etc/avrdude.conf
100+
tools.avrdude.config.path={runtime.platform.path}/tools/avrdude.conf
101+
102+
tools.avrdude.upload.params.verbose=-v
103+
tools.avrdude.upload.params.quiet=-q -q
104+
tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"
105+
106+
tools.avrdude.program.params.verbose=-v
107+
tools.avrdude.program.params.quiet=-q -q
108+
tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} -P{serial.port} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"
109+
110+
tools.avrdude.erase.params.verbose=-v
111+
tools.avrdude.erase.params.quiet=-q -q
112+
tools.avrdude.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} -P{serial.port} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m
113+
114+
tools.avrdude.bootloader.params.verbose=-v
115+
tools.avrdude.bootloader.params.quiet=-q -q
116+
tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} -P{serial.port} {program.extra_params} "-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m
117+
118+
## Micronucleus
119+
tools.micronucleus.path={runtime.tools.micronucleus.path}
120+
tools.micronucleus.cmd=micronucleus
121+
tools.micronucleus.cmd.windows=micronucleus.exe
122+
123+
tools.micronucleus.upload.params.verbose=
124+
tools.micronucleus.upload.params.quiet=
125+
tools.micronucleus.upload.pattern="{path}/{cmd}" --run --timeout 60 "{build.path}/{build.project_name}.hex"
126+
127+
tools.micronucleus.program.params.verbose=
128+
tools.micronucleus.program.params.quiet=
129+
tools.micronucleus.program.pattern="{path}/{cmd}" --run --timeout 60 "{build.path}/{build.project_name}.hex"
130+
131+
tools.micronucleus.erase.params.verbose=
132+
tools.micronucleus.erase.params.quiet=
133+
tools.micronucleus.erase.pattern=
134+
#tools.micronucleus.erase.pattern="{path}/{cmd}" --erase-only --timeout 60
135+
136+
tools.micronucleus.bootloader.params.verbose=
137+
tools.micronucleus.bootloader.params.quiet=
138+
tools.micronucleus.bootloader.pattern="{path}/{cmd}" --run --timeout 60 "{runtime.platform.path}/bootloaders/{bootloader.file}"
139+
140+
141+
# USB Default Flags
142+
# Default blank usb manufacturer will be filled it at compile time
143+
# - from numeric vendor ID, set to Unknown otherwise
144+
build.usb_manufacturer="Unknown"
145+
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
146+

Diff for: src/arduino.cc/builder/test/hardware/watterott/avr/programmers.txt

Whitespace-only changes.

Diff for: src/arduino.cc/builder/test/hardware_loader_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestLoadHardware(t *testing.T) {
5555
}
5656

5757
packages := context[constants.CTX_HARDWARE].(*types.Packages)
58-
require.Equal(t, 1, len(packages.Packages))
58+
require.Equal(t, 2, len(packages.Packages))
5959
require.NotNil(t, packages.Packages["arduino"])
6060
require.Equal(t, 2, len(packages.Packages["arduino"].Platforms))
6161

@@ -105,9 +105,9 @@ func TestLoadHardwareMixingUserHardwareFolder(t *testing.T) {
105105

106106
if runtime.GOOS == "windows" {
107107
//a package is a symlink, and windows does not support them
108-
require.Equal(t, 2, len(packages.Packages))
109-
} else {
110108
require.Equal(t, 3, len(packages.Packages))
109+
} else {
110+
require.Equal(t, 4, len(packages.Packages))
111111
}
112112

113113
require.NotNil(t, packages.Packages["arduino"])
@@ -222,9 +222,9 @@ func TestLoadLotsOfHardware(t *testing.T) {
222222

223223
if runtime.GOOS == "windows" {
224224
//a package is a symlink, and windows does not support them
225-
require.Equal(t, 4, len(packages.Packages))
226-
} else {
227225
require.Equal(t, 5, len(packages.Packages))
226+
} else {
227+
require.Equal(t, 6, len(packages.Packages))
228228
}
229229

230230
require.NotNil(t, packages.Packages["arduino"])

Diff for: src/arduino.cc/builder/test/target_board_resolver_test.go

+26
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,29 @@ func TestTargetBoardResolverCustomYun(t *testing.T) {
165165
require.Equal(t, "atmega32u4", targetBoard.Properties[constants.BUILD_PROPERTIES_BUILD_MCU])
166166
require.Equal(t, "AVR_YUN", targetBoard.Properties[constants.BUILD_PROPERTIES_BUILD_BOARD])
167167
}
168+
169+
func TestTargetBoardResolverCustomCore(t *testing.T) {
170+
context := make(map[string]interface{})
171+
context[constants.CTX_HARDWARE_FOLDERS] = []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware", "user_hardware"}
172+
context[constants.CTX_FQBN] = "watterott:avr:attiny841:core=spencekonde,info=info"
173+
174+
commands := []types.Command{
175+
&builder.SetupHumanLoggerIfMissing{},
176+
&builder.HardwareLoader{},
177+
&builder.TargetBoardResolver{},
178+
}
179+
180+
for _, command := range commands {
181+
err := command.Run(context)
182+
NoError(t, err)
183+
}
184+
185+
targetPackage := context[constants.CTX_TARGET_PACKAGE].(*types.Package)
186+
require.Equal(t, "watterott", targetPackage.PackageId)
187+
targetPlatform := context[constants.CTX_TARGET_PLATFORM].(*types.Platform)
188+
require.Equal(t, "avr", targetPlatform.PlatformId)
189+
targetBoard := context[constants.CTX_TARGET_BOARD].(*types.Board)
190+
require.Equal(t, "attiny841", targetBoard.BoardId)
191+
require.Equal(t, "tiny841", context[constants.CTX_BUILD_CORE].(string))
192+
require.Equal(t, "tiny14", targetBoard.Properties[constants.BUILD_PROPERTIES_BUILD_VARIANT])
193+
}

0 commit comments

Comments
 (0)