From ee475fae2036c84bf4f3175076b2e7cc1f5676ab Mon Sep 17 00:00:00 2001 From: Manfred Steiner Date: Sun, 18 Aug 2024 11:47:59 +0200 Subject: [PATCH] v1a abgeschlossen (merge mit branch v1a --- kicad/dist/v1a/README.md | 9 +- software/bootloader-arduino/Makefile | 128 ++++++++++++++++++------- software/bootloader-arduino/src/main.c | 5 +- 3 files changed, 102 insertions(+), 40 deletions(-) diff --git a/kicad/dist/v1a/README.md b/kicad/dist/v1a/README.md index 26e7952..f606265 100644 --- a/kicad/dist/v1a/README.md +++ b/kicad/dist/v1a/README.md @@ -58,12 +58,19 @@ Q1 bewusst nahe am Rand platziert, damit keine Kollision mit Lötstelle J1-15 au ---------------------------------------------------- -## Fehler / Verbesserungen +## Fehler Datum | Reference | Beschreibung | --------- | -------------- | ---------------------------------------------------------- | 16.6.2024 | J3, U3, U1 | JLCPCB plugin, Rotation um 90° | + 8.8.2024 | C14 | RTC Oscilator Trim C mit 100nF viel zu groß -> kein Takt -> C14 entfernen oder Wert laut Datenblatt (100nF -> 10..15pF) | +## Verbesserungen + + Datum | Reference | Beschreibung |https://jlcpcb.com/partdetail/DiodesIncorporated-AP7332_3333W67/C155362 +--------- | -------------- | ---------------------------------------------------------- | +29.7.2024 | R17 | RxD1 erreicht nur 2.4V, R17: 470K -> 47K (2.4V -> 3.2V). Abhilfe via SW: internen Pullup PD2 aktivieren | +10.8.2024 | U2, U3, ... | Modem U3 bei fehlerhaft konfiguriertem ISP-Programmer vermutlich defekt, Spannung wird nur auf 4.6V begrenzt. Weiters führt ein eingschaltetes Modem eventuell zu Störungen der ISP Schnittstelle (MISO nicht tristate). Abhilfe: Statt Schaltregler Linerarregler mit 2x3.3V Output (zB https://jlcpcb.com/partdetail/DiodesIncorporated-AP7332_3333W67/C155362). Ein Enable EIngang kann über PC6 gesteuert werden und Schaltet Modem Versorgung ein/aus. Zusätzliche 120Ohm Widerstäde + Diode bei CS, SCK, MOSI. ### Konzept diff --git a/software/bootloader-arduino/Makefile b/software/bootloader-arduino/Makefile index cfd5700..67d4eb0 100644 --- a/software/bootloader-arduino/Makefile +++ b/software/bootloader-arduino/Makefile @@ -1,34 +1,74 @@ +#.PHONY: all info flash picocom clean +#$(shell mkdir -p dist >/dev/null) +#$(shell mkdir -p build >/dev/null) +#$(shell mkdir -p sim >/dev/null) + +#NAME="bootloader-arduino_nano-644" +#DEVICE="atmega644p" +#SRC= $(wildcard src/*.c) +#OBJ = $(SRC:src/%.c=build/%.o) +#OBJ_SIM = $(SRC:src/%.c=sim/%.o) + +#CC= avr-gcc +#CFLAGS_DEFINES= -DF_CPU=12000000 -DBAUD_RATE=115200 -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4' +#LFLAGS_DEFINES= -DF_CPU=12000000 +#CFLAGS= -Wall -mmcu=$(DEVICE) -Os $(CFLAGS_DEFINES) -c +#LFLAGS= -Wall -mmcu=$(DEVICE) -Os $(LFLAGS_DEFINES) -Wl,--section-start=.text=0xe000 + +#CFLAGS_SIM= -Wall -mmcu=$(DEVICE) -O1 $(CFLAGS_DEFINES) -g -c +#LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -O1 $(LFLAGS_DEFINES) -g -Wl,--section-start=.text=0xe000 + .PHONY: all info flash picocom clean $(shell mkdir -p dist >/dev/null) $(shell mkdir -p build >/dev/null) $(shell mkdir -p sim >/dev/null) +$(shell mkdir -p sim/build >/dev/null) NAME="bootloader-arduino_nano-644" -DEVICE="atmega644p" -SRC= $(wildcard src/*.c) -OBJ = $(SRC:src/%.c=build/%.o) -OBJ_SIM = $(SRC:src/%.c=sim/%.o) - -CC= avr-gcc -CFLAGS_DEFINES= -DF_CPU=12000000 -DBAUD_RATE=115200 -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4' -LFLAGS_DEFINES= -DF_CPU=12000000 -CFLAGS= -Wall -mmcu=$(DEVICE) -Os $(CFLAGS_DEFINES) -c -LFLAGS= -Wall -mmcu=$(DEVICE) -Os $(LFLAGS_DEFINES) -Wl,--section-start=.text=0xe000 - -CFLAGS_SIM= -Wall -mmcu=$(DEVICE) -O1 $(CFLAGS_DEFINES) -g -c -LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -O1 $(LFLAGS_DEFINES) -g -Wl,--section-start=.text=0xe000 +SRC= $(wildcard src/*.c src/*.cpp src/*/*.c src/*/*.cpp) +HDR= $(wildcard src/*.h src/*.hpp src/*/*.h src/*/*.hpp) +OBJ_CPP = $(SRC:src/%.cpp=build/%.o) +OBJ = $(OBJ_CPP:src/%.c=build/%.o) +OBJ_SIM_CPP = $(SRC:src/%.cpp=sim/build/%.o) +OBJ_SIM = $(OBJ_SIM_CPP:src/%.c=sim/build/%.o) + +DEVICE=atmega644p + +CC= avr-g++ +CFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=12000000 -DBAUD_RATE=115200 -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4' -c +#LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=12000000 -Wl,-u,vfprintf -lprintf_flt -lm +LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=12000000 -Wl,--section-start=.text=0xe000 + +CFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=12000000 -g -DBAUD_RATE=115200 -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4' -c +#LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=12000000 -g -Wl,-u,vfprintf -lprintf_flt -lm +LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=12000000 -g -Wl,--section-start=.text=0xe000 + + +all: dist/$(NAME).elf dist/$(NAME).s dist/$(NAME).hex sim/$(NAME).elf sim/$(NAME).s info + +dbg: + @echo --HDR--------------------------------- + @echo $(HDR) + @echo --SRC--------------------------------- + @echo $(SRC) + @echo --OBJ--------------------------------- + @echo $(OBJ) + @echo --OBJ_CPP----------------------------- + @echo $(OBJ_CPP) + @echo --OBJ--------------------------------- + @echo $(OBJ) + @echo =================================== + @echo - -all: dist/$(NAME).elf dist/$(NAME).s dist/$(NAME).hex sim/$(NAME).elf sim/$(NAME).s info - info: - @echo @avr-size --mcu=$(DEVICE) --format=avr dist/$(NAME).elf -.depend: $(SRC) - $(CC) -mmcu=$(DEVICE) -MM $(SRC) > .depend +.depend: $(SRC) $(HDR) + $(CC) --mcu=$(DEVICE) -MM $(SRC) | sed --regexp-extended 's/^(.*\.o)\: src\/(.*)(\.cpp|\.c) (.*)/build\/\2\.o\: src\/\2\3 \4/g' > .depend + +-include .depend --include $(DEPENDFILE) +# .depend solte auch auf Header Files achten! dist/$(NAME).elf: .depend $(OBJ) $(CC) $(LFLAGS) -o $@ $(OBJ) @@ -37,15 +77,27 @@ dist/%.s: dist/%.elf avr-objdump -d $< > $@ dist/%.hex: dist/%.elf - avr-objcopy -j .text -j .data -O ihex $< $@ + #avr-objcopy -j .text -j .data -O ihex $< $@ + avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@ sim/$(NAME).elf: .depend $(OBJ_SIM) $(CC) $(LFLAGS_SIM) -o $@ $(OBJ_SIM) + build/%.o: src/%.c + @mkdir -p $(dir $@) + $(CC) $(CFLAGS) -o $@ $< + +build/%.o: src/%.cpp + @mkdir -p $(dir $@) $(CC) $(CFLAGS) -o $@ $< -sim/%.o: src/%.c +sim/build/%.o: src/%.c + @mkdir -p $(dir $@) + $(CC) $(CFLAGS_SIM) -o $@ $< + +sim/build/%.o: src/%.cpp + @mkdir -p $(dir $@) $(CC) $(CFLAGS_SIM) -o $@ $< sim/%.s: sim/%.elf @@ -57,28 +109,30 @@ simuc: sim/$(NAME).elf gdb: sim/$(NAME).elf avr-gdb $< -picocom: - # picocom sends CR for ENTER -> convert cr (\r) to lf (\n) - picocom -b 115200 --omap crlf /dev/ttyUSB0 +isp-644p: + avrdude -c usbasp -p m644p -flash: dist/$(NAME).elf all - avrdude -c arduino -P /dev/ttyUSB0 -p m644p -e -U flash:w:$< +isp-flash-644p: dist/$(NAME).elf all + avrdude -c usbasp -p m644p -e -U flash:w:$< -isp: - avrdude -c usbasp -p m644p -U lock:r:-:h +flash-644p: dist/$(NAME).elf all + avrdude -c arduino -p m644p -P /dev/ttyUSB0 -b 115200 -e -U flash:w:$< -isp-flash: dist/$(NAME).elf all - avrdude -c usbasp -p m644p -e -U flash:w:$< -isp-read: - avrdude -c usbasp -p m644p -U flash:r:/tmp/flash.bin +picocom: + # picocom sends CR for ENTER -> convert cr (\r) to lf (\n) + picocom -b 115200 --omap crlf /dev/ttyUSB0 -isp-erase: +isp-erase-644p: avrdude -c usbasp -p m644p -e - -isp-fuse: + +isp-fuse-644p: #avrdude -c usbasp -p m644p -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m -U lock:w:0xFF:m - avrdude -c usbasp -p m644p -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFE:m -U lock:w:0xEF:m + #avrdude -c usbasp -p m644p -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFE:m -U lock:w:0xEF:m + # LFUSE=0xEE -> startuptime 1K CLOCKS + 0ms -> 83us + #avrdude -c usbasp -p m644p -U lfuse:w:0xEE:m -U hfuse:w:0xD8:m -U efuse:w:0xFE:m -U lock:w:0xEF:m + # LFUSE=0xE7 -> startuptime 16K CLOCKS + 4.1ms -> 5.4ms + avrdude -c usbasp -p m644p -U lfuse:w:0xE7:m -U hfuse:w:0xD8:m -U efuse:w:0xFE:m -U lock:w:0xEF:m clean: @rm -r dist diff --git a/software/bootloader-arduino/src/main.c b/software/bootloader-arduino/src/main.c index 32ccfbd..7f9c87c 100644 --- a/software/bootloader-arduino/src/main.c +++ b/software/bootloader-arduino/src/main.c @@ -113,9 +113,10 @@ int main () { asm volatile("nop\n\t"); #endif - // LED ports output and off - DDRC = (1 << PC4) | (1 << PC3) |(1 << PC2); + // LED ports output and off, ensure that Q1 (battery power) on (PC7) PORTC = 0; + DDRC = (1 << PC7) | (1 << PC4) | (1 << PC3) |(1 << PC2); + #ifdef DOUBLE_SPEED UCSR0A = (1 << U2X0); // Double speed mode USART0 -- 2.39.5