0

Attinyisp Makefile header question.
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Attinyisp Makefile header question.

by Naliya on Wed Aug 07, 2019 1:45 pm

Dear AdaFruit,

I love your products. Remember the MiniPov3? My question is, how can I use the ISP programmer to load a makefie?

Example: here is the first few lines from the MiniPov3 makefile. I have used the serial programmer command before. Is it possible to change the input lines to the ISP and program a 2313? So far I have not been successful. See lines below. The first block of code is the original COM3 code. What should I tell AVR so it does the same thing but from my ISP device?

MCU = attiny2313
F_CPU = 8000000 # 8 MHz
#AVRDUDE_PORT = lpt1 # programmer connected to windows parallel
AVRDUDE_PORT = com3 # programmer connected to serial
AVRDUDE_PROGRAMMER = dasa

# Default target.
all: begin gccversion \
minipov.hex all_leds.hex alt_leds.hex mypov.hex test_leds.hex \
largeimage.hex makefair.hex makezine.hex eyebeam.hex digg.hex make.hex \
finished end





MCU = attiny2313
F_CPU = 8000000 # 8 MHz
#AVRDUDE_PORT = lpt1 # programmer connected to windows parallel
AVRDUDE_PORT = isp # programmer connected to usb
AVRDUDE_PROGRAMMER = dasa

# Default target.
all: begin gccversion \
minipov.hex all_leds.hex alt_leds.hex mypov.hex test_leds.hex \
largeimage.hex makefair.hex makezine.hex eyebeam.hex digg.hex make.hex \
finished end




c:\minipov3>make program-mypov
avrdude -p attiny2313 -P isp -c dasa -U flash:w:mypov.hex
avrdude: ser_open(): can't open device "isp": The system cannot find the file sp
ecified.

avrdude: serbb_setpin(): SetCommState() failed: The handle is invalid.

make: *** [program-mypov] Error 1

c:\minipov3>avrdude -c usbtiny -p ATtiny2313

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e910a

avrdude: safemode: Fuses OK

avrdude done. Thank you.


c:\minipov3>

Any help would be much appreciated.
Thank you.
Attachments
dev.jpg
dev.jpg (448.81 KiB) Viewed 154 times

Naliya
 
Posts: 6
Joined: Sat Jan 27, 2018 6:29 pm

Re: Attinyisp Makefile header question.

by Naliya on Fri Aug 09, 2019 5:28 pm

What I mean is, can I use the attinyisp for programming individual chips using my dev board. If so, how does the makefile find the isp programmer?

Can someone fix this minipov3 makefile for me? I would use it for years! That's the best answer to my question. Or, can you point out a good tutorial for the attinyisp and makefiles. Maybe this is just a dream, I'm new to the isp and would like to learn how it's used. I just have the minipov3 kit and serial uses.

There's got to be a way to do more than flash chips with this thing!

Thanks a bunch,
Naliya

P.S both filed below are same.
Attachments
Makefile-original.zip
(2.25 KiB) Downloaded 6 times
Makefile-original.zip
(2.25 KiB) Downloaded 6 times

Naliya
 
Posts: 6
Joined: Sat Jan 27, 2018 6:29 pm

Re: Attinyisp Makefile header question.

by adafruit_support_mike on Sat Aug 10, 2019 4:50 am

A makefile is just a set of instructions for the program `make`.

`make` is a program that mostly runs other programs, using instructions arranged in what's called 'topologically-sorted order'.. if you tell `make` to do C, but requires output from A and B, `make` will automatically do A and B before it does C.

A makefile contains a list of 'targets', which follow the general form:

Code: Select all | TOGGLE FULL SIZE
name: requirements-list
    command-list
The command is something you could enter from the command line to turn the list of requirements into the target.

If you had a program with a couple of source files and a header, and wanted to write a makefile to delete the last version you compiled, then build a new one, it would look something like this:

Code: Select all | TOGGLE FULL SIZE
all: clean program

clean:
    rm -f myProgram source-1.o source-2.o

program: source-1.c source-2.c header.h
    gcc -o myProgram source-1.c source-2.c -I   
which gives you three build options:

- `make clean` will just delete the compiled program and any object files (name.o)
- `make program` will compile a new version of the program without deleting anything
- `make all` will delete the existing program and object files, then compile new ones

To upload firmware to a microcontroller, you'd use a program like `avrdude` with options to tell it the kind of programmer it's talking to, the kind of chip being programmed, and the file you want to upload. That's a command (`avrdude`) with a requirement (the file to upload) which can be written in the form of a target.

The process of compiling a project, linking it, and creating an executable in a form that can be uploaded has several steps. If you don't already know the sequence, it will be easier to start from a makefile that's already been written and tested, like this one:

https://github.com/hexagon5un/AVR-Programming

adafruit_support_mike
 
Posts: 58911
Joined: Thu Feb 11, 2010 2:51 pm

Re: Attinyisp Makefile header question.

by Naliya on Sun Aug 11, 2019 8:18 pm

Thank you for that info. That book will become my favorite textbook in the near future. I am interested in programming. Yes. The A.M. radio truely fascinates me... But, for now, I just want to play with my best toy. Question? Can the TinyISP programmer- an 2313 from the Evil DEV board? Why doesn't this config work?


Computer:

Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.


c:\minipov3>make program-mypov
avrdude -p attiny2313 -P -c -U flash:w:mypov.hex

avrdude: no programmer has been specified on the command line or the config file

Specify a programmer using the -c option and try again

make: *** [program-mypov] Error 1

c:\minipov3>

Me: __________________________...

Here is the Minipov3 makefile with my new adjustments... in order that the ATTinyISP might program a 2313 IC through an EVIL Scientist DEV board.


Me:___________________How come not works? Anyone?

Computer:_________________________


MCU = attiny2313
F_CPU = 1000000
BAUD = 9600

# Default target.
all: begin gccversion \
minipov.hex all_leds.hex alt_leds.hex mypov.hex test_leds.hex \
largeimage.hex makefair.hex makezine.hex eyebeam.hex digg.hex make.hex \
finished end

# Program the device w/various programs
program-minipov: minipov.hex
program-all_leds: all_leds.hex
program-test_leds: test_leds.hex
program-alt_leds: alt_leds.hex
program-mypov: mypov.hex
program-test_sensor: test_sensor.hex
program-largeimage: largeimage.hex
program-makefair: makefair.hex
program-makezine: makezine.hex
program-eyebeam: eyebeam.hex
program-make: make.hex
program-digg: digg.hex

# this is necessary if you're burning the AVR for the first time...
# sets the proper fuse for 8MHz internal oscillator with no clk div
burn-fuse:
$(AVRDUDE) $(AVRDUDE_FLAGS) -u -U lfuse:w:0xe4:m

# this programs the dependant hex file using our default avrdude flags
program-%:
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)$<


FORMAT = ihex # create a .hex file

OPT = s # assembly-level optimization

# Optional compiler flags.
# -g: generate debugging information (for GDB, or for COFF conversion)
# -O*: optimization level
# -f...: tuning, see gcc manual and avr-libc documentation
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create assembler listing
CFLAGS = -g -O$(OPT) \
-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
-Wall -Wstrict-prototypes \
-DF_CPU=$(F_CPU) \
-Wa,-adhlns=$(<:.c=.lst) \
$(patsubst %,-I%,$(EXTRAINCDIRS)) \
-mmcu=$(MCU)


# Set a "language standard" compiler flag.
CFLAGS += -std=gnu99


# Optional assembler flags.
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create listing
# -gstabs: have the assembler create line number information; note that
# for use in COFF files, additional information about filenames
# and function names needs to be present in the assembler source
# files -- see avr-libc docs [FIXME: not yet described there]
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs


# Optional linker flags.
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref


# ---------------------------------------------------------------------------
# Programming support using avrdude.
AVRDUDE = avrdude



AVRDUDE_WRITE_FLASH = -U flash:w:

AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)

# ---------------------------------------------------------------------------

# Define directories, if needed.
DIRAVR = c:/winavr
DIRAVRBIN = $(DIRAVR)/bin
DIRAVRUTILS = $(DIRAVR)/utils/bin
DIRINC = .
DIRLIB = $(DIRAVR)/avr/lib


# Define programs and commands.
SHELL = sh

CC = avr-gcc

OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size

REMOVE = rm -f
COPY = cp

# Define Messages
# English
MSG_ERRORS_NONE = Errors: none
MSG_BEGIN = -------- begin --------
MSG_END = -------- end --------
MSG_SIZE_BEFORE = Size before:
MSG_SIZE_AFTER = Size after:
MSG_FLASH = Creating load file for Flash:
MSG_EXTENDED_LISTING = Creating Extended Listing:
MSG_SYMBOL_TABLE = Creating Symbol Table:
MSG_LINKING = Linking:
MSG_COMPILING = Compiling:
MSG_ASSEMBLING = Assembling:
MSG_CLEANING = Cleaning project:


# Define all object files.
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)

# Define all listing files.
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)

# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -I. $(CFLAGS)
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)




# Eye candy.
# AVR Studio 3.x does not check make's exit code but relies on
# the following magic strings to be generated by the compile job.
begin:
@echo
@echo $(MSG_BEGIN)

finished:
@echo $(MSG_ERRORS_NONE)

end:
@echo $(MSG_END)
@echo



# Display compiler version information.
gccversion :
@$(CC) --version


# Create final output files (.hex) from ELF output file.
%.hex: %.elf
@echo
@echo $(MSG_FLASH) $@
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@

# Link: create ELF output file from object files.
.SECONDARY : $(TARGET).elf
.PRECIOUS : $(OBJ)
%.elf: %.o
@echo
@echo $(MSG_LINKING) $@
$(CC) $(ALL_CFLAGS) $< --output $@ $(LDFLAGS)


# Compile: create object files from C source files.
%.o : %.c
@echo
@echo $(MSG_COMPILING) $<
$(CC) -c $(ALL_CFLAGS) $< -o $@


# Compile: create assembler files from C source files.
%.s : %.c
$(CC) -S $(ALL_CFLAGS) $< -o $@


# Assemble: create object files from assembler source files.
%.o : %.S
@echo
@echo $(MSG_ASSEMBLING) $<
$(CC) -c $(ALL_ASFLAGS) $< -o $@





# Target: clean project.
clean: begin clean_list finished end

clean_list :
@echo
@echo $(MSG_CLEANING)
$(REMOVE) *.hex
$(REMOVE) *.lst
$(REMOVE) *.obj
$(REMOVE) *.elf
$(REMOVE) *.o

# Listing of phony targets.
.PHONY : all begin finish end \
clean clean_list program

Me:________________

...Thank you for any HELPs!!!

Naliya
 
Posts: 6
Joined: Sat Jan 27, 2018 6:29 pm

Re: Attinyisp Makefile header question.

by adafruit_support_mike on Tue Aug 13, 2019 10:38 pm

The USBtinyISP can program any microcontroller from the AVR family, but we don't have any information about programming the ATtiny2313 specifically.

adafruit_support_mike
 
Posts: 58911
Joined: Thu Feb 11, 2010 2:51 pm

Re: Attinyisp Makefile header question.

by Naliya on Wed Aug 14, 2019 11:31 am

Thank you. I had the coolest dream about you guys. You do good work. Keep the best toys coming!

Naliya
 
Posts: 6
Joined: Sat Jan 27, 2018 6:29 pm

Please be positive and constructive with your questions and comments.