Skip to content

Commit

Permalink
Initalsetup fuer die IO-Controller ueberarbeitet
Browse files Browse the repository at this point in the history
  • Loading branch information
ingo authored and ingo committed Jan 3, 2018
1 parent c8abf86 commit 57fe0a4
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 184 deletions.
10 changes: 1 addition & 9 deletions doc/atmega32-initial-setup
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,9 @@ Fuse Lo Byte:
uisp -dlpt=/dev/parport0 -dprog=dapa --wr_fuse_l=0x0f
uisp -dlpt=/dev/parport0 -dprog=dapa --wr_lock=0x2f

ACHTUNG: Fuer das HCAN-HI-v02 (USB Variante):
- hier gibt es KEINEN ext. Quarz, somit fuer 4MHz intern
- auch gibt es hier KEINEN Bootloader!

uisp -dlpt=/dev/parport0 -dprog=dapa --wr_fuse_h=0xc0
uisp -dlpt=/dev/parport0 -dprog=dapa --wr_fuse_l=0x03
uisp -dlpt=/dev/parport0 -dprog=dapa --wr_lock=0x2f

"modprobe ppdev" ist fuer uisp Betrieb noetig.


Oder mit avrdude und dem ATMEL-ISP-Programmer mkII:
sudo 'avrdude -c avrispmkII -p m32 -P usb -e -U flash:w:"./hcanbl/hcanBL_atmega32/main.hex" -U hfuse:w:0xc0:m -U lfuse:w:0x0f:m' -U lock:w:0x2f:m'
avrdude -c avrispmkII -p m32 -P usb -e -U flash:w:"./hcanbl/hcanBL_atmega32/main.hex" -U hfuse:w:0xc0:m -U lfuse:w:0x0f:m' -U lock:w:0x2f:m

55 changes: 55 additions & 0 deletions doc/atmega328p-initial-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

Wie wird ein Atmega328p initialisiert ?
---------------------------------------

- externen Osz einschalten
- Bootloader auf 4k
- Jump-to-Bootloader on reset
- Bootload Speicher schuetzen
- WD Enabled
- Brownout Detection enabled

__________________________________________________________________
dazu Fuse Hi Byte wie folgt programmieren (von Bit 7 zu bit 0):
- RSTDISBL: 1 - External Reset Disable
- DWEN: 1 - debugWIRE Enable
- SPIEN: 0 (progr) - Enable Serial Program and Data Downloading
- WDTON: 0 (progr) - Watchdog Timer Always On
- EESAVE: 1 - EEPROM memory is preserved through the Chip Erase
- BOOTSZ1: 0 (progr) - Select Boot Size
- BOOTSZ0: 0 (progr)
- BOOTRST: 0 (progr) - Select Reset Vector

-> fuse hi byte = 0xC8
__________________________________________________________________
Fuse Lo Byte:
- CKDIV8: 1 - Divide clock by 8
- CKOUT: 1 - Clock output
- SUT1: 1 - Select start-up time: Crystal Oscillator 14CK+65ms -> SUT[1:0] = 11
- SUT0: 1 slowly rising power
- CKSEL3: 1 - Select Clock source: 16MHz -> CKSEL[3:1] = 111
- CKSEL2: 1
- CKSEL1: 1
- CKSEL0: 1

-> fuse lo byte = 0xFF

__________________________________________________________________
Fuse Extended Byte:
- -/-
- -/-
- -/-
- -/-
- -/-
- BODLEVEL2: 1
- BODLEVEL1: 0 (progr)- Brown-out Detector trigger level: 101 = 2.7 V
- BODLEVEL0: 1 1

-> efuse = 0xFD

Fuses auslesen:
avrdude -c avrispmkII -p atmega328p -P usb
--> E:FD, H:DA, L:FF

avrdude und dem ATMEL-ISP-Programmer mkII:
avrdude -c avrispmkII -p atmega328p -P usb -U flash:w:"/hcanbl/hcanBL_atmega328p/main.hex" -U hfuse:w:0xC8:m -U lfuse:w:0xFF:m -U efuse:w:0xFD:m
5 changes: 1 addition & 4 deletions doc/atmega644-initial-setup → doc/atmega644p-initial-setup
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@ Fuse Lo Byte:
-> fuse lo byte = 0xe6


sudo 'avrdude -c avrispmkII -p m644p -P usb -e -U flash:w:"./hcanbl/hcanBL_atmega644/main.hex" -U hfuse:w:0xd0:m -U lfuse:w:0xe6:m'

sudo, da "su" für die Nutzung von avrdude erfrderlich ist.

avrdude -c avrispmkII -p m644p -P usb -e -U flash:w:"./hcanbl/hcanBL_atmega644/main.hex" -U hfuse:w:0xd0:m -U lfuse:w:0xe6:m
162 changes: 0 additions & 162 deletions doc/testconf-controller1612.cf

This file was deleted.

25 changes: 16 additions & 9 deletions hcanbl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,30 @@ ifeq ($(MCU),atmega644p)
# atmega644 (64kbytes flash = 0 bis FFFF)
# 0xF000 for firmware, 2048 words boot size
MT_BOOTLOADER_ADDRESS = F000
#JTAG-Enable: AVRDUDE_FLASH = avrdude -c avrispmkII -p m644p -P usb -e -U flash:w:"hcanBL_$(MCU)/$(TARGET).hex" -U hfuse:w:0x90:m -U lfuse:w:0xc7:m -U efuse:w:0xfc:m
AVRDUDE_FLASH = avrdude -c avrispmkII -p m644p -P usb -U flash:w:"hcanBL_$(MCU)/$(TARGET).hex" -U hfuse:w:0xD0:m -U lfuse:w:0xc7:m -U efuse:w:0xfc:m
# JTAG-Enable: hfuse:w:0x90:m
AVRDUDE_FLASH = avrdude -c avrispmkII -p m644p -P usb -U flash:w:"hcanBL_$(MCU)/$(TARGET).hex" -U efuse:w:0xFC:m -U hfuse:w:0xD0:m -U lfuse:w:0xC7:m
AVRDUDE_READ_FLASH = avrdude -c avrispmkII -p m644p -P usb -U flash:r:flash.hex:r
AVRDUDE_ERASE_EEPROM = avrdude -c avrispmkII -p m644p -P usb -e
else ifeq ($(MCU),atmega328p)
# atmega328p (32kbytes flash = 0 bis 7FFF)
# 0x7000 for firmware (bytes boot size), 2048 words boot size
MT_BOOTLOADER_ADDRESS = 7000
AVRDUDE_READ_FUSES = avrdude -c avrispmkII -p $(MCU) -P usb
# JTAG-Enable (debugWIRE Enable): hfuse:w:0x88:m
AVRDUDE_FLASH = avrdude -c avrispmkII -p $(MCU) -P usb -U flash:w:"hcanBL_$(MCU)/$(TARGET).hex" -U efuse:w:0xFD:m -U hfuse:w:0xC8:m -U lfuse:w:0xFF:m
AVRDUDE_READ_FLASH = avrdude -c avrispmkII -p $(MCU) -P usb -U flash:r:flash.hex:r
AVRDUDE_ERASE_EEPROM = avrdude -c avrispmkII -p $(MCU) -P usb -e
else
# atmega32 oder atmega328p (32kbytes flash = 0 bis 7FFF)
# atmega32 (32kbytes flash = 0 bis 7FFF)
# 0x7000 for firmware, 2048 words boot size
MT_BOOTLOADER_ADDRESS = 7000
#JTAG-Enable: AVRDUDE_FLASH = avrdude -c avrispmkII -p m32 -P usb -e -U flash:w:"hcanBL_$(MCU)/$(TARGET).hex" -U hfuse:w:0x80:m -U lfuse:w:0x0f:m
# JTAG-Enable: hfuse:w:0x80:m -U
AVRDUDE_FLASH = avrdude -c avrispmkII -p m32 -P usb -U flash:w:"hcanBL_$(MCU)/$(TARGET).hex" -U hfuse:w:0xC0:m -U lfuse:w:0x0f:m
AVRDUDE_READ_FLASH = avrdude -c avrispmkII -p m32 -P usb -U flash:r:flash.hex:r
AVRDUDE_ERASE_EEPROM = avrdude -c avrispmkII -p m32 -P usb -e
endif


CFLAGS= -mmcu=$(MCU) -Wall -Wstrict-prototypes -Os -mcall-prologues \
-std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct \
-fshort-enums -DF_CPU=$(F_CPU) -DF_CAN=$(F_CAN) -DCAN_SPEED=$(CAN_SPEED)
Expand All @@ -61,17 +71,14 @@ $(TARGET).out : $(OBJ)
$(CXX) $(CFLAGS) -o $(TARGET).out $(SRC) $(LDFLAGS)

flash:
sudo $(AVRDUDE_FLASH)
#uisp -dlpt=/dev/parport0 --erase -dprog=dapa
#uisp -dlpt=/dev/parport0 --upload if="hcanBL_$(MCU)/$(TARGET).hex" -dprog=dapa -v=3 --hash=32
$(AVRDUDE_FLASH)

erase_eeprom:
sudo $(AVRDUDE_ERASE_EEPROM)
#uisp -dlpt=/dev/parport0 --erase --segment=eeprom -dprog=dapa

# BL und FW lesen (alles was im flash-Speicher enthalten ist)
read_flash:
sudo $(AVRDUDE_READ_FLASH)
$(AVRDUDE_READ_FLASH)

clean_part:
sudo rm -f *.map *.out
Expand Down

0 comments on commit 57fe0a4

Please sign in to comment.