mirror of
https://github.com/Optiboot/optiboot.git
synced 2025-08-17 21:41:03 +03:00
Mega0 Makefile in good enough shape for initial commit.
"make optiboot_<mcuname>.hex <options>" should build a .hex file for any of the "xmgea3" chips (mega0, tiny0, tiny1)
This commit is contained in:
160
optiboot/bootloaders/optiboot/Makefile.mega0
Normal file
160
optiboot/bootloaders/optiboot/Makefile.mega0
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
# Makefile for AVR Mega-0 (4809), Tiny-0, and Tiny-1 version of Optiboot
|
||||||
|
# Bill Westfield, 2019
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
# Edit History
|
||||||
|
# Sep-2019 refactor from the normal AVR Makefile.
|
||||||
|
# * Copyright 2013-2019 by Bill Westfield. Part of Optiboot.
|
||||||
|
# * This software is licensed under version 2 of the Gnu Public Licence.
|
||||||
|
# * See optiboot.c for details.
|
||||||
|
|
||||||
|
HELPTEXT = "\n"
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# program name should not be changed...
|
||||||
|
PROGRAM = optiboot_x
|
||||||
|
MF:= $(MAKEFILE_LIST)
|
||||||
|
|
||||||
|
# export symbols to recursive makes (for ISP)
|
||||||
|
export
|
||||||
|
|
||||||
|
# defaults
|
||||||
|
MCU_TARGET = atmega4809
|
||||||
|
AVR_FREQ = 20000000
|
||||||
|
|
||||||
|
LDSECTIONS = -Wl,--section-start=.text=0 -Wl,--section-start=.postapp=0x200 \
|
||||||
|
-Wl,--section-start=.version=0x1fe
|
||||||
|
BAUD_RATE=115200
|
||||||
|
|
||||||
|
# If we have a PACKS directory specified, we should use it...
|
||||||
|
ifdef PACKS
|
||||||
|
PACK_OPT= -I $(PACKS)/include/ -B $(PACKS)/gcc/dev/$%
|
||||||
|
endif
|
||||||
|
GCCROOT =
|
||||||
|
AVRDUDE_CONF =
|
||||||
|
|
||||||
|
STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
|
||||||
|
STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
|
||||||
|
-lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
|
||||||
|
STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
|
||||||
|
#
|
||||||
|
# End of build environment code.
|
||||||
|
|
||||||
|
|
||||||
|
CC = $(GCCROOT)avr-gcc
|
||||||
|
OPTIMIZE = -Os -fno-split-wide-types -mrelax
|
||||||
|
|
||||||
|
# Override is only needed by avr-lib build system.
|
||||||
|
|
||||||
|
override CFLAGS = -g -Wall $(OPTIMIZE)
|
||||||
|
override LDFLAGS = $(LDSECTIONS) -Wl,--relax -nostartfiles -nostdlib
|
||||||
|
|
||||||
|
OBJCOPY = $(GCCROOT)avr-objcopy
|
||||||
|
OBJDUMP = $(GCCROOT)avr-objdump
|
||||||
|
SIZE = $(GCCROOT)avr-size
|
||||||
|
|
||||||
|
include parse_options.mk
|
||||||
|
.PRECIOUS: %.elf
|
||||||
|
|
||||||
|
ifndef PRODUCTION
|
||||||
|
LISTING= $(OBJDUMP) -S
|
||||||
|
else
|
||||||
|
LISTING= @true
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# "Chip-level Platform" targets.
|
||||||
|
# A "Chip-level Platform" compiles for a particular chip, but probably does
|
||||||
|
# not have "standard" values for things like clock speed, LED pin, etc.
|
||||||
|
# Makes for chip-level platforms should usually explicitly define their
|
||||||
|
# options like: "make atmega1285 AVR_FREQ=16000000L LED=D0"
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Mega0, tiny0, tiny1 don't really have any chip-specific requirements.
|
||||||
|
#
|
||||||
|
# Note about fuses:
|
||||||
|
# The fuses are defined in the source code. There are 9!
|
||||||
|
# Be sure to use a programmer that will program the fuses from the object file.
|
||||||
|
#
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
|
||||||
|
HELPTEXT += "\n-------------\n\n"
|
||||||
|
|
||||||
|
|
||||||
|
optiboot_%.hex: optiboot_%.elf
|
||||||
|
$(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex $< $@
|
||||||
|
|
||||||
|
optiboot_%.elf: optiboot_x.c FORCE
|
||||||
|
echo CPU_OPTIONS= $(CPU_OPTIONS)
|
||||||
|
echo LED_OPTIONS= $(LED_OPTIONS)
|
||||||
|
echo UART_OPTIONS=$(UART_OPTIONS)
|
||||||
|
$(CC) $(CFLAGS) $(CPU_OPTIONS) $(LED_OPTIONS) $(UART_OPTIONS) $(COMMON_OPTIONS) $(LDFLAGS) $(PACK_OPT) -mmcu=$* -o $@ $<
|
||||||
|
$(SIZE) $@
|
||||||
|
$(LISTING) $@ > optiboot_$*.lss
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# "Board-level Platform" targets.
|
||||||
|
# A "Board-level Platform" implies a manufactured platform with a particular
|
||||||
|
# AVR_FREQ, LED, and so on. Parameters are not particularly changable from
|
||||||
|
# the "make" command line.
|
||||||
|
# Most of the board-level platform builds should envoke make recursively
|
||||||
|
# appropriate specific options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
drazzy412:
|
||||||
|
$(MAKE) -f $(MF) optiboot_attiny412.hex UARTTX=A1 TIMEOUT=8 LED=A7
|
||||||
|
|
||||||
|
drazzy402:
|
||||||
|
$(MAKE) -f $(MF) optiboot_attiny402.hex UARTTX=A1 TIMEOUT=8 LED=A7
|
||||||
|
|
||||||
|
xplained416:
|
||||||
|
$(MAKE) -f $(MF) optiboot_attiny416.hex UARTTX=A1 TIMEOUT=8 LED=B5
|
||||||
|
|
||||||
|
xplained4809:
|
||||||
|
|
||||||
|
curiosity4809:
|
||||||
|
|
||||||
|
freeduino4809:
|
||||||
|
|
||||||
|
freeduino4809chip:
|
||||||
|
$(MAKE) -f $(MF) optiboot_atmega4809.hex UARTTX=F4 TIMEOUT=1 LED=A7 RESETPIN=1
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Generic build instructions
|
||||||
|
#
|
||||||
|
|
||||||
|
FORCE:
|
||||||
|
|
||||||
|
isp: $(TARGET) FORCE
|
||||||
|
"$(MAKE)" -f Makefile.isp isp TARGET=$(TARGET)
|
||||||
|
|
||||||
|
isp-stk500: $(PROGRAM)_$(TARGET).hex
|
||||||
|
$(STK500-1)
|
||||||
|
$(STK500-2)
|
||||||
|
|
||||||
|
#windows "rm" is dumb and objects to wildcards that don't exist
|
||||||
|
clean:
|
||||||
|
@touch __temp_.o __temp_.elf __temp_.lst __temp_.map
|
||||||
|
@touch __temp_.sym __temp_.lss __temp_.eep __temp_.srec
|
||||||
|
@touch __temp_.bin __temp_.hex __temp_.tmp.sh
|
||||||
|
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex *.tmp.sh
|
||||||
|
|
||||||
|
clean_asm:
|
||||||
|
rm -rf *.lst
|
||||||
|
|
||||||
|
%.lst: %.elf FORCE
|
||||||
|
$(OBJDUMP) -h -S $< > $@
|
||||||
|
|
||||||
|
%.srec: %.elf FORCE
|
||||||
|
$(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O srec $< $@
|
||||||
|
|
||||||
|
%.bin: %.elf FORCE
|
||||||
|
$(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O binary $< $@
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo -e $(HELPTEXT)
|
@@ -134,6 +134,11 @@ optiboot_version = 256*(OPTIBOOT_MAJVER + OPTIBOOT_CUSTOMVER) + OPTIBOOT_MINVER;
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
#if (!defined(__AVR_XMEGA__)) || (__AVR_ARCH__ != 103)
|
||||||
|
#error CPU not supported by this version of Optiboot.
|
||||||
|
#include <unsupported> // include a non-existent file to stop compilation
|
||||||
|
#endif
|
||||||
|
|
||||||
FUSES = {
|
FUSES = {
|
||||||
.WDTCFG = 0, /* Watchdog Configuration */
|
.WDTCFG = 0, /* Watchdog Configuration */
|
||||||
.BODCFG = FUSE_BODCFG_DEFAULT, /* BOD Configuration */
|
.BODCFG = FUSE_BODCFG_DEFAULT, /* BOD Configuration */
|
||||||
@@ -142,7 +147,7 @@ FUSES = {
|
|||||||
.TCD0CFG = FUSE_TCD0CFG_DEFAULT, /* TCD0 Configuration */
|
.TCD0CFG = FUSE_TCD0CFG_DEFAULT, /* TCD0 Configuration */
|
||||||
#endif
|
#endif
|
||||||
#ifdef RSTPIN
|
#ifdef RSTPIN
|
||||||
.SYSCFG0 = RSTPINCFG_RST_gc | CRCSRC_NOCRC_gc, /* RESET is enabled */
|
.SYSCFG0 = CRCSRC_NOCRC_gc | RSTPINCFG_RST_gc, /* RESET is enabled */
|
||||||
#else
|
#else
|
||||||
.SYSCFG0 = CRCSRC_NOCRC_gc | RSTPINCFG_UPDI_gc, /* RESET is not yet */
|
.SYSCFG0 = CRCSRC_NOCRC_gc | RSTPINCFG_UPDI_gc, /* RESET is not yet */
|
||||||
#endif
|
#endif
|
||||||
|
142
optiboot/bootloaders/optiboot/parse_options.mk
Normal file
142
optiboot/bootloaders/optiboot/parse_options.mk
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
# Make command-line Options for Optiboot, Optiboot-Mega0
|
||||||
|
# Permit commands like "make atmega4809 LED_START_FLASHES=10" to pass the
|
||||||
|
# appropriate parameters ("-DLED_START_FLASHES=10") to gcc
|
||||||
|
#
|
||||||
|
|
||||||
|
ifdef PRODUCTION
|
||||||
|
ifneq ($(PRODUCTION),0)
|
||||||
|
VERSION_CMD = -DPRODUCTION=1
|
||||||
|
endif
|
||||||
|
dummy = FORCE
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# Build Options
|
||||||
|
|
||||||
|
HELPTEXT += "Option CUSTOM_VERSION=nn - set a customer version number\n"
|
||||||
|
ifdef CUSTOM_VERSION
|
||||||
|
ifneq ($(CUSTOM_VERSION), 0)
|
||||||
|
VERSION_CMD = -DOPTIBOOT_CUSTOMVER=$(CUSTOM_VERSION)
|
||||||
|
else
|
||||||
|
VERSION_CMD = -DPRODUCTION=1
|
||||||
|
endif
|
||||||
|
dummy = FORCE
|
||||||
|
endif
|
||||||
|
|
||||||
|
HELPTEXT += "Option BIGBOOT=1 - enable extra features up to 1kbytes\n"
|
||||||
|
# BIGBOOT: Include extra features, up to 1K.
|
||||||
|
ifdef BIGBOOT
|
||||||
|
ifneq ($(BIGBOOT), 0)
|
||||||
|
BIGBOOT_CMD = -DBIGBOOT=1
|
||||||
|
dummy = FORCE
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
HELPTEXT += "Option SUPPORT_EEPROM=1 - Include code to read/write EEPROM\n"
|
||||||
|
ifdef SUPPORT_EEPROM
|
||||||
|
ifneq ($(SUPPORT_EEPROM), 0)
|
||||||
|
SUPPORT_EEPROM_CMD = -DSUPPORT_EEPROM
|
||||||
|
dummy = FORCE
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
HELPTEXT += "Option NO_APP_SPM=1 - disallow application call of do_spm\n"
|
||||||
|
ifdef NO_APP_SPM
|
||||||
|
ifneq ($(NO_APP_SPM),0)
|
||||||
|
APPSPM_CMD = -DAPP_NOSPM=1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# LED options
|
||||||
|
|
||||||
|
HELPTEXT += "Option LED=B3 - set LED pin to particular port/bit\n"
|
||||||
|
ifdef LED
|
||||||
|
LED_CMD = -DLED=$(LED)
|
||||||
|
dummy = FORCE
|
||||||
|
endif
|
||||||
|
|
||||||
|
HELPTEXT += "Option LED_START_FLASHES=n - set number of LED flashes when bootloader starts\n"
|
||||||
|
ifdef LED_START_FLASHES
|
||||||
|
LED_START_FLASHES_CMD = -DLED_START_FLASHES=$(LED_START_FLASHES)
|
||||||
|
dummy = FORCE
|
||||||
|
else
|
||||||
|
LED_START_FLASHES_CMD = -DLED_START_FLASHES=3
|
||||||
|
endif
|
||||||
|
|
||||||
|
HELPTEXT += "Option LED_DATA_FLASH=1 - flash the LED each time data is received.\n"
|
||||||
|
ifdef LED_DATA_FLASH
|
||||||
|
ifneq ($(LED_DATA_FLASH), 0)
|
||||||
|
LED_DATA_FLASH_CMD = -DLED_DATA_FLASH=1
|
||||||
|
dummy = FORCE
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
HELPTEXT += "Option LED_START_ON=1 - Turn the LED on at bootload start\n"
|
||||||
|
ifdef LED_START_ON
|
||||||
|
ifneq ($(LED_START_ON), 0)
|
||||||
|
LED_START_ON_CMD = -DLED_START_ON=1
|
||||||
|
endif
|
||||||
|
dummy = FORCE
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# UART options
|
||||||
|
|
||||||
|
HELPTEXT += "Option BAUD_RATE=nnnn - set the bit rate for communications\n"
|
||||||
|
ifdef BAUD_RATE
|
||||||
|
BAUD_RATE_CMD = -DBAUD_RATE=$(BAUD_RATE)
|
||||||
|
dummy = FORCE
|
||||||
|
else
|
||||||
|
BAUD_RATE_CMD = -DBAUD_RATE=115200
|
||||||
|
endif
|
||||||
|
|
||||||
|
HELPTEXT += "Option SOFT_UART=1 - use a software (bit-banged) UART\n"
|
||||||
|
ifdef SOFT_UART
|
||||||
|
ifneq ($(SOFT_UART), 0)
|
||||||
|
SOFT_UART_CMD = -DSOFT_UART=1
|
||||||
|
dummy = FORCE
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
HELPTEXT += "Option SINGLESPEED=1 - do not use U2X mode on UART\n"
|
||||||
|
ifdef SINGLESPEED
|
||||||
|
ifneq ($(SINGLESPEED), 0)
|
||||||
|
SS_CMD = -DSINGLESPEED=1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
#CPU Options
|
||||||
|
|
||||||
|
HELPTEXT += "Option TIMEOUT=n - set WDT to 1, 2, 4, or 8 seconds\n"
|
||||||
|
ifdef TIMEOUT
|
||||||
|
TIMEOUT_CMD = -DWDTTIME=$(TIMEOUT)
|
||||||
|
dummy = FORCE
|
||||||
|
endif
|
||||||
|
|
||||||
|
HELPTEXT += "RESETPIN=0/1 - change RESET pin behavior\n"
|
||||||
|
ifdef RESETPIN
|
||||||
|
RESETPIN_CMD = -DRSTPIN=$(RESETPIN)
|
||||||
|
dummy = FORCE
|
||||||
|
endif
|
||||||
|
|
||||||
|
HELPTEXT += "Option AVR_FREQ=<n> - Clock rate of AVR CPU\n"
|
||||||
|
|
||||||
|
|
||||||
|
LED_OPTIONS = $(LED_START_FLASHES_CMD) $(LED_DATA_FLASH_CMD) $(LED_CMD) $(LED_START_ON_CMD)
|
||||||
|
CPU_OPTIONS = -DF_CPU=$(AVR_FREQ) $(RESETPIN_CMD) $(TIMEOUT_CMD)
|
||||||
|
COMMON_OPTIONS = $(BIGBOOT_CMD) $(SUPPORT_EEPROM_CMD) $(APPSPM_CMD)
|
||||||
|
COMMON_OPTIONS += $(VERSION_CMD)
|
||||||
|
|
||||||
|
#UART is handled separately and only passed for devices with more than one.
|
||||||
|
HELPTEXT += "Option UART=n - use UARTn for communications\n"
|
||||||
|
HELPTEXT += "Option UARTTX=pin - describe UART for Mega0, Xtiny\n"
|
||||||
|
ifdef UART
|
||||||
|
UART_CMD = -DUART=$(UART)
|
||||||
|
endif
|
||||||
|
ifdef UARTTX
|
||||||
|
UART_CMD = -DUARTTX=$(UARTTX)
|
||||||
|
endif
|
||||||
|
|
||||||
|
UART_OPTIONS = $(UART_CMD) $(BAUD_RATE_CMD) $(SOFT_UART_CMD) $(SS_CMD)
|
Reference in New Issue
Block a user