diff --git a/src/Kconfig b/src/Kconfig index 16ce3531..6add97a3 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -13,9 +13,9 @@ choice prompt "Micro-controller Architecture" config MACH_AVR bool "Atmega AVR" - config MACH_SAM3 + config MACH_ATSAM bool "SAM3/SAM4 (Due and Duet)" - config MACH_SAMD21 + config MACH_ATSAMD bool "SAMD21 (Arduino Zero)" config MACH_LPC176X bool "LPC176x (Smoothieboard)" @@ -30,8 +30,8 @@ choice endchoice source "src/avr/Kconfig" -source "src/sam3/Kconfig" -source "src/samd21/Kconfig" +source "src/atsam/Kconfig" +source "src/atsamd/Kconfig" source "src/lpc176x/Kconfig" source "src/stm32f1/Kconfig" source "src/pru/Kconfig" diff --git a/src/sam3/Kconfig b/src/atsam/Kconfig similarity index 91% rename from src/sam3/Kconfig rename to src/atsam/Kconfig index c2ebb200..0ea82241 100644 --- a/src/sam3/Kconfig +++ b/src/atsam/Kconfig @@ -1,8 +1,8 @@ -# Kconfig settings for SAM3/SAM4 processors +# Kconfig settings for Atmel SAM processors -if MACH_SAM3 +if MACH_ATSAM -config SAM3_SELECT +config ATSAM_SELECT bool default y select HAVE_GPIO @@ -13,7 +13,7 @@ config SAM3_SELECT config BOARD_DIRECTORY string - default "sam3" + default "atsam" choice prompt "Processor model" diff --git a/src/sam3/Makefile b/src/atsam/Makefile similarity index 82% rename from src/sam3/Makefile rename to src/atsam/Makefile index a9510717..4aece952 100644 --- a/src/sam3/Makefile +++ b/src/atsam/Makefile @@ -1,9 +1,9 @@ -# Additional SAM3/SAM4 build rules +# Additional ATSAM build rules # Setup the toolchain CROSS_PREFIX=arm-none-eabi- -dirs-y += src/sam3 src/generic +dirs-y += src/atsam src/generic dirs-$(CONFIG_MACH_SAM3X8E) += lib/sam3x/gcc/gcc dirs-$(CONFIG_MACH_SAM4S8C) += lib/sam4s/gcc/gcc dirs-$(CONFIG_MACH_SAM4E8E) += lib/sam4e/gcc/gcc @@ -25,17 +25,17 @@ eflags-$(CONFIG_MACH_SAM4E8E) += -T lib/sam4e/gcc/gcc/sam4e8e_flash.ld CFLAGS_klipper.elf += $(eflags-y) --specs=nano.specs --specs=nosys.specs # Add source files -src-y += sam3/main.c sam3/gpio.c sam3/i2c.c sam3/spi.c +src-y += atsam/main.c atsam/gpio.c atsam/i2c.c atsam/spi.c src-y += generic/crc16_ccitt.c generic/alloc.c src-y += generic/armcm_irq.c generic/timer_irq.c -src-$(CONFIG_USBSERIAL) += sam3/sam4_usb.c generic/usb_cdc.c -src-$(CONFIG_SERIAL) += sam3/serial.c generic/serial_irq.c -src-$(CONFIG_MACH_SAM3X8E) += sam3/adc.c sam3/timer.c +src-$(CONFIG_USBSERIAL) += atsam/sam4_usb.c generic/usb_cdc.c +src-$(CONFIG_SERIAL) += atsam/serial.c generic/serial_irq.c +src-$(CONFIG_MACH_SAM3X8E) += atsam/adc.c atsam/timer.c src-$(CONFIG_MACH_SAM3X8E) += ../lib/sam3x/gcc/system_sam3xa.c src-$(CONFIG_MACH_SAM3X8E) += ../lib/sam3x/gcc/gcc/startup_sam3xa.c -src-$(CONFIG_MACH_SAM4S8C) += sam3/adc.c sam3/sam4s_timer.c sam3/sam4s_sysinit.c +src-$(CONFIG_MACH_SAM4S8C) += atsam/adc.c atsam/sam4s_timer.c atsam/sam4s_sysinit.c src-$(CONFIG_MACH_SAM4S8C) += ../lib/sam4s/gcc/gcc/startup_sam4s.c -src-$(CONFIG_MACH_SAM4E8E) += sam3/sam4e_afec.c sam3/timer.c sam3/sam4_cache.c +src-$(CONFIG_MACH_SAM4E8E) += atsam/sam4e_afec.c atsam/timer.c atsam/sam4_cache.c src-$(CONFIG_MACH_SAM4E8E) += ../lib/sam4e/gcc/system_sam4e.c src-$(CONFIG_MACH_SAM4E8E) += ../lib/sam4e/gcc/gcc/startup_sam4e.c diff --git a/src/sam3/adc.c b/src/atsam/adc.c similarity index 100% rename from src/sam3/adc.c rename to src/atsam/adc.c diff --git a/src/sam3/gpio.c b/src/atsam/gpio.c similarity index 100% rename from src/sam3/gpio.c rename to src/atsam/gpio.c diff --git a/src/sam3/gpio.h b/src/atsam/gpio.h similarity index 100% rename from src/sam3/gpio.h rename to src/atsam/gpio.h diff --git a/src/sam3/i2c.c b/src/atsam/i2c.c similarity index 100% rename from src/sam3/i2c.c rename to src/atsam/i2c.c diff --git a/src/sam3/internal.h b/src/atsam/internal.h similarity index 100% rename from src/sam3/internal.h rename to src/atsam/internal.h diff --git a/src/sam3/main.c b/src/atsam/main.c similarity index 100% rename from src/sam3/main.c rename to src/atsam/main.c diff --git a/src/sam3/sam4_cache.c b/src/atsam/sam4_cache.c similarity index 100% rename from src/sam3/sam4_cache.c rename to src/atsam/sam4_cache.c diff --git a/src/sam3/sam4_usb.c b/src/atsam/sam4_usb.c similarity index 100% rename from src/sam3/sam4_usb.c rename to src/atsam/sam4_usb.c diff --git a/src/sam3/sam4e_afec.c b/src/atsam/sam4e_afec.c similarity index 100% rename from src/sam3/sam4e_afec.c rename to src/atsam/sam4e_afec.c diff --git a/src/sam3/sam4s_sysinit.c b/src/atsam/sam4s_sysinit.c similarity index 100% rename from src/sam3/sam4s_sysinit.c rename to src/atsam/sam4s_sysinit.c diff --git a/src/sam3/sam4s_timer.c b/src/atsam/sam4s_timer.c similarity index 100% rename from src/sam3/sam4s_timer.c rename to src/atsam/sam4s_timer.c diff --git a/src/sam3/serial.c b/src/atsam/serial.c similarity index 100% rename from src/sam3/serial.c rename to src/atsam/serial.c diff --git a/src/sam3/spi.c b/src/atsam/spi.c similarity index 100% rename from src/sam3/spi.c rename to src/atsam/spi.c diff --git a/src/sam3/timer.c b/src/atsam/timer.c similarity index 100% rename from src/sam3/timer.c rename to src/atsam/timer.c diff --git a/src/sam3/usb_cdc_ep.h b/src/atsam/usb_cdc_ep.h similarity index 100% rename from src/sam3/usb_cdc_ep.h rename to src/atsam/usb_cdc_ep.h diff --git a/src/samd21/Kconfig b/src/atsamd/Kconfig similarity index 80% rename from src/samd21/Kconfig rename to src/atsamd/Kconfig index 18bd7d81..02e21b7b 100644 --- a/src/samd21/Kconfig +++ b/src/atsamd/Kconfig @@ -1,8 +1,8 @@ -# Kconfig settings for SAMD21 processors +# Kconfig settings for Atmel SAMD processors -if MACH_SAMD21 +if MACH_ATSAMD -config SAMD_SELECT +config ATSAMD_SELECT bool default y select HAVE_GPIO @@ -14,7 +14,13 @@ config SAMD_SELECT config BOARD_DIRECTORY string - default "samd21" + default "atsamd" + +choice + prompt "Processor model" + config MACH_SAMD21A + bool "SAMD21G18A (Arduino Zero)" +endchoice config CLOCK_FREQ int diff --git a/src/atsamd/Makefile b/src/atsamd/Makefile new file mode 100644 index 00000000..ca8b2e99 --- /dev/null +++ b/src/atsamd/Makefile @@ -0,0 +1,54 @@ +# Additional atsamd build rules + +# Setup the toolchain +CROSS_PREFIX=arm-none-eabi- + +dirs-y += src/atsamd src/generic +dirs-$(CONFIG_MACH_SAMD21A) += lib/samd21/samd21a/gcc/gcc/ + +CFLAGS-$(CONFIG_MACH_SAMD21A) += -mcpu=cortex-m0plus +CFLAGS-$(CONFIG_MACH_SAMD21A) += -Ilib/samd21/samd21a/include -D__SAMD21G18A__ +CFLAGS += $(CFLAGS-y) -mthumb -Ilib/cmsis-core + +eflags-$(CONFIG_MACH_SAMD21A) += -T $(OUT)samd21a.ld +CFLAGS_klipper.elf += $(eflags-y) --specs=nano.specs --specs=nosys.specs + +# Add source files +src-y += atsamd/main.c atsamd/timer.c atsamd/clock.c atsamd/gpio.c +src-y += generic/crc16_ccitt.c generic/alloc.c +src-y += generic/armcm_irq.c generic/timer_irq.c +src-$(CONFIG_USBSERIAL) += atsamd/usbserial.c generic/usb_cdc.c +src-$(CONFIG_SERIAL) += atsamd/serial.c generic/serial_irq.c +src-$(CONFIG_HAVE_GPIO_ADC) += atsamd/adc.c +src-$(CONFIG_HAVE_GPIO_I2C) += atsamd/i2c.c +src-$(CONFIG_HAVE_GPIO_SPI) += atsamd/spi.c +src-$(CONFIG_HAVE_GPIO_HARD_PWM) += atsamd/hard_pwm.c +src-$(CONFIG_MACH_SAMD21A) += ../lib/samd21/samd21a/gcc/gcc/startup_samd21.c + +# Support bootloader offset address +target-$(CONFIG_MACH_SAMD21A) := $(OUT)samd21a.ld $(target-y) + +$(OUT)samd21a.ld: lib/samd21/samd21a/gcc/gcc/samd21g18a_flash.ld $(OUT)board-link + @echo " Preprocessing $@" + $(Q)$(CPP) -P -MD -MT $@ -DFLASH_START=$(CONFIG_FLASH_START) $< -o $@ + +# Build the additional hex and bin output files +target-y += $(OUT)klipper.bin $(OUT)klipper.elf.hex + +$(OUT)klipper.bin: $(OUT)klipper.elf + @echo " Creating hex file $@" + $(Q)$(OBJCOPY) -O binary $< $@ + +$(OUT)klipper.elf.hex: $(OUT)klipper.elf + @echo " Creating hex file $@" + $(Q)$(OBJCOPY) -j .text -j .relocate -O ihex $< $@ + +# Flash rules +lib/bossac/bin/bossac: + @echo " Building bossac" + $(Q)make -C lib/bossac bin/bossac + +flash: $(OUT)klipper.bin lib/bossac/bin/bossac + @echo " Flashing $^ to $(FLASH_DEVICE) via bossac" + $(Q)if [ -z $(FLASH_DEVICE) ]; then echo "Please specify FLASH_DEVICE"; exit 1; fi + $(Q)lib/bossac/bin/bossac -U -p "$(FLASH_DEVICE)" -a --offset=0x2000 -w $(OUT)klipper.bin -v -b -R diff --git a/src/samd21/adc.c b/src/atsamd/adc.c similarity index 100% rename from src/samd21/adc.c rename to src/atsamd/adc.c diff --git a/src/samd21/clock.c b/src/atsamd/clock.c similarity index 100% rename from src/samd21/clock.c rename to src/atsamd/clock.c diff --git a/src/samd21/gpio.c b/src/atsamd/gpio.c similarity index 100% rename from src/samd21/gpio.c rename to src/atsamd/gpio.c diff --git a/src/samd21/gpio.h b/src/atsamd/gpio.h similarity index 100% rename from src/samd21/gpio.h rename to src/atsamd/gpio.h diff --git a/src/samd21/hard_pwm.c b/src/atsamd/hard_pwm.c similarity index 100% rename from src/samd21/hard_pwm.c rename to src/atsamd/hard_pwm.c diff --git a/src/samd21/i2c.c b/src/atsamd/i2c.c similarity index 100% rename from src/samd21/i2c.c rename to src/atsamd/i2c.c diff --git a/src/samd21/internal.h b/src/atsamd/internal.h similarity index 100% rename from src/samd21/internal.h rename to src/atsamd/internal.h diff --git a/src/samd21/main.c b/src/atsamd/main.c similarity index 100% rename from src/samd21/main.c rename to src/atsamd/main.c diff --git a/src/samd21/serial.c b/src/atsamd/serial.c similarity index 100% rename from src/samd21/serial.c rename to src/atsamd/serial.c diff --git a/src/samd21/spi.c b/src/atsamd/spi.c similarity index 100% rename from src/samd21/spi.c rename to src/atsamd/spi.c diff --git a/src/samd21/timer.c b/src/atsamd/timer.c similarity index 100% rename from src/samd21/timer.c rename to src/atsamd/timer.c diff --git a/src/samd21/usbserial.c b/src/atsamd/usbserial.c similarity index 100% rename from src/samd21/usbserial.c rename to src/atsamd/usbserial.c diff --git a/src/samd21/Makefile b/src/samd21/Makefile deleted file mode 100644 index 24ef1e49..00000000 --- a/src/samd21/Makefile +++ /dev/null @@ -1,54 +0,0 @@ -# Additional samd21 build rules - -# Setup the toolchain -CROSS_PREFIX=arm-none-eabi- - -dirs-y += src/samd21 src/generic -dirs-y += lib/samd21/samd21a/gcc/gcc/ - -CFLAGS += -mthumb -mcpu=cortex-m0plus -CFLAGS += -Ilib/cmsis-core -Ilib/samd21/samd21a/include -CFLAGS += -D__SAMD21G18A__ - -CFLAGS_klipper.elf += -T $(OUT)samd21.ld -CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs - -# Add source files -src-y += samd21/main.c samd21/timer.c samd21/clock.c samd21/gpio.c -src-y += generic/crc16_ccitt.c generic/alloc.c -src-y += generic/armcm_irq.c generic/timer_irq.c -src-y += ../lib/samd21/samd21a/gcc/gcc/startup_samd21.c -src-$(CONFIG_USBSERIAL) += samd21/usbserial.c generic/usb_cdc.c -src-$(CONFIG_SERIAL) += samd21/serial.c generic/serial_irq.c -src-$(CONFIG_HAVE_GPIO_ADC) += samd21/adc.c -src-$(CONFIG_HAVE_GPIO_I2C) += samd21/i2c.c -src-$(CONFIG_HAVE_GPIO_SPI) += samd21/spi.c -src-$(CONFIG_HAVE_GPIO_HARD_PWM) += samd21/hard_pwm.c - -# Support bootloader offset address -target-y := $(OUT)samd21.ld $(target-y) - -$(OUT)samd21.ld: lib/samd21/samd21a/gcc/gcc/samd21g18a_flash.ld $(OUT)board-link - @echo " Preprocessing $@" - $(Q)$(CPP) -P -MD -MT $@ -DFLASH_START=$(CONFIG_FLASH_START) $< -o $@ - -# Build the additional hex and bin output files -target-y += $(OUT)klipper.bin $(OUT)klipper.elf.hex - -$(OUT)klipper.bin: $(OUT)klipper.elf - @echo " Creating hex file $@" - $(Q)$(OBJCOPY) -O binary $< $@ - -$(OUT)klipper.elf.hex: $(OUT)klipper.elf - @echo " Creating hex file $@" - $(Q)$(OBJCOPY) -j .text -j .relocate -O ihex $< $@ - -# Flash rules -lib/bossac/bin/bossac: - @echo " Building bossac" - $(Q)make -C lib/bossac bin/bossac - -flash: $(OUT)klipper.bin lib/bossac/bin/bossac - @echo " Flashing $^ to $(FLASH_DEVICE) via bossac" - $(Q)if [ -z $(FLASH_DEVICE) ]; then echo "Please specify FLASH_DEVICE"; exit 1; fi - $(Q)lib/bossac/bin/bossac -U -p "$(FLASH_DEVICE)" -a --offset=0x2000 -w $(OUT)klipper.bin -v -b -R diff --git a/test/configs/sam3x8e.config b/test/configs/sam3x8e.config index 9bf772a8..e7da6460 100644 --- a/test/configs/sam3x8e.config +++ b/test/configs/sam3x8e.config @@ -1,3 +1,3 @@ # Base config file for Atmel SAM3x8e ARM processor -CONFIG_MACH_SAM3=y +CONFIG_MACH_ATSAM=y CONFIG_MACH_SAM3X8E=y diff --git a/test/configs/sam4e8e.config b/test/configs/sam4e8e.config index d55a5bfe..6be54c34 100644 --- a/test/configs/sam4e8e.config +++ b/test/configs/sam4e8e.config @@ -1,3 +1,3 @@ # Base config file for Atmel SAM4E8E ARM processor -CONFIG_MACH_SAM3=y +CONFIG_MACH_ATSAM=y CONFIG_MACH_SAM4E8E=y diff --git a/test/configs/sam4s8c.config b/test/configs/sam4s8c.config index 3b032bea..20c539fc 100644 --- a/test/configs/sam4s8c.config +++ b/test/configs/sam4s8c.config @@ -1,3 +1,3 @@ # Base config file for Atmel SAM4S8C ARM processor -CONFIG_MACH_SAM3=y +CONFIG_MACH_ATSAM=y CONFIG_MACH_SAM4S8C=y diff --git a/test/configs/samd21.config b/test/configs/samd21.config index f40da125..8dd361d1 100644 --- a/test/configs/samd21.config +++ b/test/configs/samd21.config @@ -1,2 +1,3 @@ # Base config file for SAMD21 boards +CONFIG_MACH_ATSAMD=y CONFIG_MACH_SAMD21=y