Skip to content

Commit 6f27c1f

Browse files
committed
gen-device: only generate device files for supported devices
This changes the make gen-device command such that it only converts relevant device files. This saves a lot of build time. The process of determining which files to convert is now handled by make. Incremental builds are now supported. Appropriate parallel building is now done for all device generation (previously it was only handled properly for AVR). The generated file names were updated to match their source name formatting. I could probbably lowercase everything when converting them, but this would complicate the makefile. I don't really think this is worth it.
1 parent f166976 commit 6f27c1f

26 files changed

Lines changed: 193 additions & 205 deletions

GNUmakefile

Lines changed: 91 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -215,58 +215,112 @@ fmt-check: ## Warn if any source needs reformatting
215215

216216
gen-device: gen-device-avr gen-device-esp gen-device-nrf gen-device-sam gen-device-sifive gen-device-kendryte gen-device-nxp gen-device-rp ## Generate microcontroller-specific sources
217217
ifneq ($(RENESAS), 0)
218-
gen-device: gen-device-renesas
218+
# Renesas is currently unused
219+
#gen-device: gen-device-renesas
219220
endif
220221
ifneq ($(STM32), 0)
221222
gen-device: gen-device-stm32
222223
endif
223224

224-
gen-device-avr:
225-
@if [ ! -e lib/avr/README.md ]; then echo "Submodules have not been downloaded. Please download them using:\n git submodule update --init"; exit 1; fi
226-
$(GO) build -o ./build/gen-device-avr ./tools/gen-device-avr/
227-
./build/gen-device-avr lib/avr/packs/atmega src/device/avr/
228-
./build/gen-device-avr lib/avr/packs/tiny src/device/avr/
229-
@GO111MODULE=off $(GO) fmt ./src/device/avr
225+
build/gen-device-%: ./tools/gen-device-%/*.go
226+
$(GO) build -o $@ ./tools/gen-device-$*/
230227

231-
build/gen-device-svd: ./tools/gen-device-svd/*.go
232-
$(GO) build -o $@ ./tools/gen-device-svd/
228+
gen-device-avr: gen-device-atmega gen-device-attiny
233229

234-
gen-device-esp: build/gen-device-svd
235-
./build/gen-device-svd -source=https://github.com/posborne/cmsis-svd/tree/master/data/Espressif-Community -interrupts=software lib/cmsis-svd/data/Espressif-Community/ src/device/esp/
236-
./build/gen-device-svd -source=https://github.com/posborne/cmsis-svd/tree/master/data/Espressif -interrupts=software lib/cmsis-svd/data/Espressif/ src/device/esp/
237-
GO111MODULE=off $(GO) fmt ./src/device/esp
230+
# ATmega
238231

239-
gen-device-nrf: build/gen-device-svd
240-
./build/gen-device-svd -source=https://github.com/NordicSemiconductor/nrfx/tree/master/mdk lib/nrfx/mdk/ src/device/nrf/
241-
GO111MODULE=off $(GO) fmt ./src/device/nrf
232+
DEVICES_AVR_MEGA = 1280 1284P 2560 328PB 328P 32U4
242233

243-
gen-device-nxp: build/gen-device-svd
244-
./build/gen-device-svd -source=https://github.com/posborne/cmsis-svd/tree/master/data/NXP lib/cmsis-svd/data/NXP/ src/device/nxp/
245-
GO111MODULE=off $(GO) fmt ./src/device/nxp
234+
gen-device-atmega: $(foreach m,$(DEVICES_AVR_MEGA),src/device/avr/ATmega$(m).go src/device/avr/ATmega$(m).s src/device/avr/ATmega$(m).ld)
246235

247-
gen-device-sam: build/gen-device-svd
248-
./build/gen-device-svd -source=https://github.com/posborne/cmsis-svd/tree/master/data/Atmel lib/cmsis-svd/data/Atmel/ src/device/sam/
249-
GO111MODULE=off $(GO) fmt ./src/device/sam
236+
src/device/avr/ATmega%.go src/device/avr/ATmega%.s src/device/avr/ATmega%.ld: lib/avr/packs/atmega/ATmega%.atdf build/gen-device-avr
237+
build/gen-device-avr $< src/device/avr/ATmega$*.go src/device/avr/ATmega$*.s src/device/avr/ATmega$*.ld
250238

251-
gen-device-sifive: build/gen-device-svd
252-
./build/gen-device-svd -source=https://github.com/posborne/cmsis-svd/tree/master/data/SiFive-Community -interrupts=software lib/cmsis-svd/data/SiFive-Community/ src/device/sifive/
253-
GO111MODULE=off $(GO) fmt ./src/device/sifive
239+
# ATtiny
254240

255-
gen-device-kendryte: build/gen-device-svd
256-
./build/gen-device-svd -source=https://github.com/posborne/cmsis-svd/tree/master/data/Kendryte-Community -interrupts=software lib/cmsis-svd/data/Kendryte-Community/ src/device/kendryte/
257-
GO111MODULE=off $(GO) fmt ./src/device/kendryte
241+
DEVICES_AVR_TINY = 1616 85
258242

259-
gen-device-stm32: build/gen-device-svd
260-
./build/gen-device-svd -source=https://github.com/tinygo-org/stm32-svd lib/stm32-svd/svd src/device/stm32/
261-
GO111MODULE=off $(GO) fmt ./src/device/stm32
243+
gen-device-attiny: $(foreach m,$(DEVICES_AVR_TINY),src/device/avr/ATtiny$(m).go src/device/avr/ATtiny$(m).s src/device/avr/ATtiny$(m).ld)
262244

263-
gen-device-rp: build/gen-device-svd
264-
./build/gen-device-svd -source=https://github.com/posborne/cmsis-svd/tree/master/data/RaspberryPi lib/cmsis-svd/data/RaspberryPi/ src/device/rp/
265-
GO111MODULE=off $(GO) fmt ./src/device/rp
245+
src/device/avr/ATtiny%.go src/device/avr/ATtiny%.s src/device/avr/ATtiny%.ld: lib/avr/packs/tiny/ATtiny%.atdf build/gen-device-avr
246+
build/gen-device-avr $< src/device/avr/ATtiny$*.go src/device/avr/ATtiny$*.s src/device/avr/ATtiny$*.ld
247+
248+
# Espressif
249+
250+
# Both Espressif and Espressif-Community define esp32.
251+
# The Espressif directory takes priority.
252+
253+
gen-device-esp: src/device/esp/esp32c3.go src/device/esp/esp32s3.go src/device/esp/esp32.go src/device/esp/esp8266.go
254+
255+
src/device/esp/%.go: lib/cmsis-svd/data/Espressif/%.svd build/gen-device-svd
256+
build/gen-device-svd -url=https://github.com/posborne/cmsis-svd/tree/master/data/Espressif -interrupts=software $< $@
257+
258+
src/device/esp/%.go: lib/cmsis-svd/data/Espressif-Community/%.svd build/gen-device-svd
259+
build/gen-device-svd -url=https://github.com/posborne/cmsis-svd/tree/master/data/Espressif-Community -interrupts=software $< $@
260+
261+
# NRF
262+
263+
DEVICES_NRF = 51 52833 52840 52
264+
265+
gen-device-nrf: $(foreach m,$(DEVICES_NRF),src/device/nrf/nrf$(m).go src/device/nrf/nrf$(m).s)
266+
267+
src/device/nrf/nrf%.go src/device/nrf/nrf%.s: lib/nrfx/mdk/nrf%.svd build/gen-device-svd
268+
build/gen-device-svd -url=https://github.com/NordicSemiconductor/nrfx/tree/master/mdk -asm=src/device/nrf/nrf$*.s $< src/device/nrf/nrf$*.go
269+
270+
# NXP
271+
272+
DEVICES_NXP = MIMXRT1062 MK66F18
273+
274+
gen-device-nxp: $(foreach m,$(DEVICES_NXP),src/device/nxp/$(m).go src/device/nxp/$(m).s)
275+
276+
src/device/nxp/%.go src/device/nxp/%.s: lib/cmsis-svd/data/NXP/%.svd build/gen-device-svd
277+
build/gen-device-svd -url=https://github.com/posborne/cmsis-svd/tree/master/data/NXP -asm=src/device/nxp/$*.s $< src/device/nxp/$*.go
278+
279+
# SAM
280+
281+
DEVICES_SAM = D21E18A D21G18A D51G19A D51J19A D51J20A D51P19A D51P20A D51J19A E51J19A E54P20A
282+
283+
gen-device-sam: $(foreach m,$(DEVICES_SAM),src/device/sam/ATSAM$(m).go src/device/sam/ATSAM$(m).s)
284+
285+
src/device/sam/ATSAM%.go src/device/sam/ATSAM%.s: lib/cmsis-svd/data/Atmel/ATSAM%.svd build/gen-device-svd
286+
build/gen-device-svd -url=https://github.com/posborne/cmsis-svd/tree/master/data/Atmel -asm=src/device/sam/ATSAM$*.s $< src/device/sam/ATSAM$*.go
287+
288+
# SiFive
289+
290+
DEVICES_SIFIVE = e310x
291+
292+
gen-device-sifive: $(foreach m,$(DEVICES_SIFIVE),src/device/sifive/$(m).go)
293+
294+
src/device/sifive/%.go: lib/cmsis-svd/data/SiFive-Community/%.svd build/gen-device-svd
295+
build/gen-device-svd -url=https://github.com/posborne/cmsis-svd/tree/master/data/SiFive-Community -interrupts=software $< $@
296+
297+
# Kendryte
298+
299+
DEVICES_KENDRYTE = 210
300+
301+
gen-device-kendryte: $(foreach m,$(DEVICES_KENDRYTE),src/device/kendryte/k$(m).go)
302+
303+
src/device/kendryte/k%.go: lib/cmsis-svd/data/Kendryte-Community/k%.svd build/gen-device-svd
304+
build/gen-device-svd -url=https://github.com/posborne/cmsis-svd/tree/master/data/Kendryte-Community -interrupts=software $< $@
305+
306+
# STM32
307+
308+
DEVICES_STM32 = f103 f405 f407 f469 f722 g0b1 l4r5 l0x1 l0x2 l4x2 l4x5 l4x6 l552 u585 wl5x_cm4 wle5
309+
310+
gen-device-stm32: $(foreach m,$(DEVICES_STM32),src/device/stm32/stm32$(m).go src/device/stm32/stm32$(m).s)
311+
312+
src/device/stm32/stm32%.go src/device/stm32/stm32%.s: lib/stm32-svd/svd/stm32%.svd build/gen-device-svd
313+
build/gen-device-svd -url=https://github.com/tinygo-org/stm32-svd -asm=src/device/stm32/stm32$*.s $< src/device/stm32/stm32$*.go
314+
315+
# Raspberry Pi
316+
317+
DEVICES_RP = 2040 2350
318+
319+
gen-device-rp: $(foreach m,$(DEVICES_RP),src/device/rp/rp$(m).go src/device/rp/rp$(m).s)
320+
321+
src/device/rp/rp%.go src/device/rp/rp%.s: lib/cmsis-svd/data/RaspberryPi/rp%.svd build/gen-device-svd
322+
build/gen-device-svd -url=https://github.com/posborne/cmsis-svd/tree/master/data/RaspberryPi -asm=src/device/rp/rp$*.s $< src/device/rp/rp$*.go
266323

267-
gen-device-renesas: build/gen-device-svd
268-
./build/gen-device-svd -source=https://github.com/cmsis-svd/cmsis-svd-data/tree/master/data/Renesas lib/cmsis-svd/data/Renesas/ src/device/renesas/
269-
GO111MODULE=off $(GO) fmt ./src/device/renesas
270324

271325
$(LLVM_PROJECTDIR)/llvm:
272326
git clone -b tinygo_20.x --depth=1 https://github.com/tinygo-org/llvm-project $(LLVM_PROJECTDIR)

src/device/kendryte/.gitignore

Whitespace-only changes.

src/device/sifive/.gitignore

Whitespace-only changes.

src/device/stm32/.gitignore

Whitespace-only changes.

targets/atmega1280.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"ldflags": [
77
"--defsym=_stack_size=512"
88
],
9-
"linkerscript": "src/device/avr/atmega1280.ld",
9+
"linkerscript": "src/device/avr/ATmega1280.ld",
1010
"extra-files": [
1111
"targets/avr.S",
12-
"src/device/avr/atmega1280.s"
12+
"src/device/avr/ATmega1280.s"
1313
]
1414
}

targets/atmega1284p.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"--defsym=_bootloader_size=0",
88
"--defsym=_stack_size=512"
99
],
10-
"linkerscript": "src/device/avr/atmega1284p.ld",
10+
"linkerscript": "src/device/avr/ATmega1284P.ld",
1111
"extra-files": [
1212
"targets/avr.S",
13-
"src/device/avr/atmega1284p.s"
13+
"src/device/avr/ATmega1284P.s"
1414
],
1515
"emulator": "simavr -m atmega1284p -f 20000000 {}"
1616
}

targets/atmega2560.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"ldflags": [
77
"--defsym=_stack_size=512"
88
],
9-
"linkerscript": "src/device/avr/atmega2560.ld",
9+
"linkerscript": "src/device/avr/ATmega2560.ld",
1010
"extra-files": [
1111
"targets/avr.S",
12-
"src/device/avr/atmega2560.s"
12+
"src/device/avr/ATmega2560.s"
1313
]
1414
}

targets/atmega328p.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"cpu": "atmega328p",
44
"build-tags": ["atmega328p", "atmega", "avr5"],
55
"serial": "uart",
6-
"linkerscript": "src/device/avr/atmega328p.ld",
6+
"linkerscript": "src/device/avr/ATmega328P.ld",
77
"extra-files": [
88
"targets/avr.S",
9-
"src/device/avr/atmega328p.s"
9+
"src/device/avr/ATmega328P.s"
1010
]
1111
}

targets/atmega328pb.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"--defsym=_stack_size=512"
88
],
99
"serial": "uart",
10-
"linkerscript": "src/device/avr/atmega328pb.ld",
10+
"linkerscript": "src/device/avr/ATmega328PB.ld",
1111
"extra-files": [
1212
"targets/avr.S",
13-
"src/device/avr/atmega328pb.s"
13+
"src/device/avr/ATmega328PB.s"
1414
]
1515
}

targets/atmega32u4.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"cpu": "atmega32u4",
44
"build-tags": ["atmega32u4", "avr5"],
55
"serial": "none",
6-
"linkerscript": "src/device/avr/atmega32u4.ld",
6+
"linkerscript": "src/device/avr/ATmega32U4.ld",
77
"extra-files": [
88
"targets/avr.S",
9-
"src/device/avr/atmega32u4.s"
9+
"src/device/avr/ATmega32U4.s"
1010
]
1111
}

0 commit comments

Comments
 (0)