Start work in TMC initialization MCU firmware

This commit is contained in:
Kelvin Ly 2021-02-15 08:10:58 -05:00
parent 178d3e997a
commit b9c1bc3d94
5 changed files with 4929 additions and 0 deletions

8
init-fw/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
*.hex
*.srec
*_eeprom.*
*.bin
*.elf
*.lst
*.map
*.o

151
init-fw/Makefile Normal file
View File

@ -0,0 +1,151 @@
PRG = init
OBJ = main.o
#MCU_TARGET = at90s2313
#MCU_TARGET = at90s2333
#MCU_TARGET = at90s4414
#MCU_TARGET = at90s4433
#MCU_TARGET = at90s4434
#MCU_TARGET = at90s8515
#MCU_TARGET = at90s8535
#MCU_TARGET = atmega128
#MCU_TARGET = atmega1280
#MCU_TARGET = atmega1281
#MCU_TARGET = atmega1284p
#MCU_TARGET = atmega16
#MCU_TARGET = atmega163
#MCU_TARGET = atmega164p
#MCU_TARGET = atmega165
#MCU_TARGET = atmega165p
#MCU_TARGET = atmega168
#MCU_TARGET = atmega169
#MCU_TARGET = atmega169p
#MCU_TARGET = atmega2560
#MCU_TARGET = atmega2561
#MCU_TARGET = atmega32
#MCU_TARGET = atmega324p
#MCU_TARGET = atmega325
#MCU_TARGET = atmega3250
#MCU_TARGET = atmega329
#MCU_TARGET = atmega3290
#MCU_TARGET = atmega32u4
#MCU_TARGET = atmega48
#MCU_TARGET = atmega64
#MCU_TARGET = atmega640
#MCU_TARGET = atmega644
#MCU_TARGET = atmega644p
#MCU_TARGET = atmega645
#MCU_TARGET = atmega6450
#MCU_TARGET = atmega649
#MCU_TARGET = atmega6490
#MCU_TARGET = atmega8
#MCU_TARGET = atmega8515
#MCU_TARGET = atmega8535
#MCU_TARGET = atmega88
#MCU_TARGET = attiny2313
#MCU_TARGET = attiny24
#MCU_TARGET = attiny25
#MCU_TARGET = attiny26
#MCU_TARGET = attiny261
#MCU_TARGET = attiny44
#MCU_TARGET = attiny45
#MCU_TARGET = attiny461
#MCU_TARGET = attiny84
#MCU_TARGET = attiny85
#MCU_TARGET = attiny861
MCU_TARGET = attiny404
OPTIMIZE = -O2
DEFS =
LIBS =
# You should not have to change anything below here.
#CC = ~/repos/avr-toolchain-atmel/avr-toolchain-bin/avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc
CC = avr-gcc
# Override is only needed by avr-lib build system.
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -nodevicelib $(DEFS) -nostdlib
override LDFLAGS = -Wl,-Map,$(PRG).map
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
all: $(PRG).elf lst text eeprom
$(PRG).elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
# dependency:
main.o: main.c
clean:
rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak
rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
lst: $(PRG).lst
%.lst: %.elf
$(OBJDUMP) -h -S $< > $@
# Rules for building the .text rom images
text: hex bin srec
hex: $(PRG).hex
bin: $(PRG).bin
srec: $(PRG).srec
flash: hex
avrdude -C ~/repos/jtag2updi/avrdude.conf -c jtag2updi -b 19200 -P /dev/ttyUSB0 -p t412 -U flash:w:$(PRG).hex
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
%.srec: %.elf
$(OBJCOPY) -j .text -j .data -O srec $< $@
%.bin: %.elf
$(OBJCOPY) -j .text -j .data -O binary $< $@
# Rules for building the .eeprom rom images
eeprom: ehex ebin esrec
ehex: $(PRG)_eeprom.hex
ebin: $(PRG)_eeprom.bin
esrec: $(PRG)_eeprom.srec
%_eeprom.hex: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ \
|| { echo empty $@ not generated; exit 0; }
%_eeprom.srec: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ \
|| { echo empty $@ not generated; exit 0; }
%_eeprom.bin: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ \
|| { echo empty $@ not generated; exit 0; }
# Every thing below here is used by avr-libc's build system and can be ignored
# by the casual user.
FIG2DEV = fig2dev
EXTRA_CLEAN_FILES = *.hex *.bin *.srec
dox: eps png pdf
eps: $(PRG).eps
png: $(PRG).png
pdf: $(PRG).pdf
%.eps: %.fig
$(FIG2DEV) -L eps $< $@
%.pdf: %.fig
$(FIG2DEV) -L pdf $< $@
%.png: %.fig
$(FIG2DEV) -L png $< $@

4643
init-fw/iotn404.h Normal file

File diff suppressed because it is too large Load Diff

20
init-fw/main.c Normal file
View File

@ -0,0 +1,20 @@
#include <avr/interrupt.h>
#include "iotn404.h"
#define SEI() asm volatile ("sei")
#define CLI() asm volatile ("cli")
//#define F_CPU (3333333UL)
#define F_CPU (20000000UL)
int main() {
SEI();
VPORTA_DIR |= (1 << 6) | (1 << 3);
VPORTA_OUT |= (1 << 6);
VPORTA_OUT &= ~(1 << 3);
while (1);
return 0;
}

107
init-fw/specs-attiny404 Normal file
View File

@ -0,0 +1,107 @@
#
# Auto-generated specs for AVR device attiny404 (core avrxmega3, 16-bit SP, short-calls)
#
# Generated by : ./gcc/config/avr/gen-avr-mmcu-specs.c
# Generated from : ./gcc/config/gcc.c
# ./gcc/config/avr/specs.h
# ./gcc/config/avr/avrlibc.h
# Used by : avr-gcc compiler driver
# Used for : building command options for sub-processes
#
# See <https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html>
# for a documentation of spec files.
# If you intend to use an existing device specs file as a starting point
# for a new device spec file, make sure you are copying from a specs
# file for a device from the same core architecture and SP width.
# See <https://gcc.gnu.org/gcc-5/changes.html> for a description
# of how to use such own spec files.
*avrlibc_startfile:
crtattiny404.o%s
*avrlibc_devicelib:
%{!nodevicelib:-lattiny404}
*cc1_n_flash:
%{!mn-flash=*:-mn-flash=1}
*cc1_rmw:
%{mrmw}
*cc1_errata_skip:
%{!mskip-bug: -mno-skip-bug}
*cc1_absdata:
%{mabsdata}
*asm_arch:
-mmcu=avrxmega3
*asm_relax:
%{mrelax:--mlink-relax}
*asm_rmw:
%{mrmw}
*asm_gccisr:
%{!mno-gas-isr-prologues: -mgcc-isr}
*asm_errata_skip:
%{!mskip-bug: -mno-skip-bug}
*link_pmem_wrap:
*link_relax:
%{mrelax:--relax}
*link_arch:
%{mmcu=*:-m%*}
*link_data_start:
-Tdata 0x803F00
*link_text_start:
*self_spec:
%<mmcu=* -mmcu=avrxmega3 -mshort-calls %<msp8
# AVR-LibC's avr/io.h uses the device specifying macro to determine
# the name of the device header. For example, -mmcu=atmega8a triggers
# the definition of __AVR_ATmega8A__ and avr/io.h includes the device
# header 'iom8a.h' by means of:
#
# ...
# #elif defined (__AVR_ATmega8A__)
# # include <avr/iom8a.h>
# #elif ...
#
# If no device macro is defined, AVR-LibC uses __AVR_DEV_LIB_NAME__
# as fallback to determine the name of the device header as
#
# "avr/io" + __AVR_DEV_LIB_NAME__ + ".h"
#
# If you provide your own specs file for a device not yet known to
# AVR-LibC, you can now define the hook macro __AVR_DEV_LIB_NAME__
# as needed so that
#
# #include <avr/io.h>
#
# will include the desired device header. For ATmega8A the supplement
# to *cpp would read
#
# -D__AVR_DEV_LIB_NAME__=m8a
*cpp:
-D__AVR_ATtiny404__ -D__AVR_DEVICE_NAME__=attiny404 -D__AVR_DEV_LIB_NAME__=tn404
%rename link old_link
*link:
%(old_link)--defsym=__RODATA_PM_OFFSET__=0x8000
# End of file