This week's assignment was to read a microcontroller data sheet
and program my board to do something.
I have to admit it, I have never been this confused with an assignment before. At one point, I was completely lost, but then I decided to set the steps I'm going to take in order to finish the assignment on time. First I was going to prepare the MakeFile in accordance to the data sheet of the ATtiny44, then the c code, and then link the FabISP to the echo hello board and program it on Linux Mint.
A data sheet is a very, very, very long manual of the microprocessor, it is very hard for on to read it entirely, and so I just searched whatever I needed in it. here you can check the data sheet I used with the ATtiny44 I used previously. From the data sheet, I learned about the fuses, which are There are 3 bytes of permanent storage in the chip called 'fuse low byte', 'fuse high byte' and 'fuse extended byte'. These bytes are called fuses and can be reprogrammed as many times as you want and determines the behaviour of the chip. To do that, their value is not erased when the chip is powered off or reprogrammed.
I used the data sheet to know what to change with the fuses on Neil's original Make file. This is how Neil's looked:
PROJECT=hello.ftdi.44.echo SOURCES=$(PROJECT).c MMCU=attiny44 F_CPU = 20000000 CFLAGS=-mmcu=$(MMCU) -Wall -Os -DF_CPU=$(F_CPU) $(PROJECT).hex: $(PROJECT).out avr-objcopy -O ihex $(PROJECT).out $(PROJECT).c.hex;\ avr-size --mcu=$(MMCU) --format=avr $(PROJECT).out $(PROJECT).out: $(SOURCES) avr-gcc $(CFLAGS) -I./ -o $(PROJECT).out $(SOURCES) program-bsd: $(PROJECT).hex avrdude -p t44 -c bsd -U flash:w:$(PROJECT).c.hex program-dasa: $(PROJECT).hex avrdude -p t44 -P /dev/ttyUSB0 -c dasa -U flash:w:$(PROJECT).c.hex program-avrisp2: $(PROJECT).hex avrdude -p t44 -P usb -c avrisp2 -U flash:w:$(PROJECT).c.hex program-avrisp2-fuses: $(PROJECT).hex avrdude -p t44 -P usb -c avrisp2 -U lfuse:w:0x5E:m program-usbtiny: $(PROJECT).hex avrdude -p t44 -P usb -c usbtiny -U flash:w:$(PROJECT).c.hex program-usbtiny-fuses: $(PROJECT).hex avrdude -p t44 -P usb -c usbtiny -U lfuse:w:0x5E:m program-dragon: $(PROJECT).hex avrdude -p t44 -P usb -c dragon_isp -U flash:w:$(PROJECT).c.hex program-ice: $(PROJECT).hex avrdude -p t44 -P usb -c atmelice_isp -U flash:w:$(PROJECT).c.hex
I changed the project definition, and I found an online Fuse calculator, which explained why I needed to burn the fuse number 0x5E. You can download the calculator from here, and then open it in brackets.
PROJECT=cCode SOURCES=$(PROJECT).c MMCU=attiny44 F_CPU = 20000000 CFLAGS=-mmcu=$(MMCU) -Wall -Os -DF_CPU=$(F_CPU) $(PROJECT).hex: $(PROJECT).out avr-objcopy -O ihex $(PROJECT).out $(PROJECT).c.hex;\ avr-size --mcu=$(MMCU) --format=avr $(PROJECT).out $(PROJECT).out: $(SOURCES) avr-gcc $(CFLAGS) -I./ -o $(PROJECT).out $(SOURCES) program-usbtiny: $(PROJECT).hex avrdude -p t44 -P usb -c usbtiny -U flash:w:$(PROJECT).c.hex program-usbtiny-fuses: $(PROJECT).hex avrdude -p t44 -P usb -c usbtiny -U lfuse:w:0x5E:m
Next step was to create the C code for the board. I was previously familiar with the c++ language and I found that to be helpful this week. Also, our instructor Nadine walked us through the basics of programing using c and assembly. I planned to code my program using both, but I didn't have enough time to do it, as well as that I found assembly confusing and super tricky.
So for the C code, this is my code, with the explanation of why I used each line:
#include <avr/io.h> // Library for Linux #include <util/delay.h> // the Library that contains the delay function #define F_CPU20000UL // define the speed from the crystal on the board #define LED PORTA // define the LED light #define BUTTON PA7 // define the Button int main (void){ DDRA = 0b00000100; //set PORTA 7 for input and 2 for output while (1){ if(BUTTON==1){ //if the button is pushed LED = 0b00000100; //set PORTA 2 high/on _delay_ms(1000); // wait for 1 sec LED = 0b00000000; //set PORTA 2 low/off _delay_ms(1000); // wait for 1 sec } } }
This part was fairly simple. After I finished it, I realized that this week wasn't as complicated as I thought. I proceeded by linking the FabISP with the Echo Hello board by linking all of the 6 pin heads on the ISP with its correspondent pin on the board.
In this part, I followed Nadine's steps in order to program my board. I added the following commands first:
sudo apt-get install flex byacc bison gcc libusb-dev avrdude
sudo apt-get install gcc-avr
sudo apt-get install avr-libc
sudo apt-get install libc6-dev
, then created a desktop file that had the make file saved from the text editor with no extension, and a code file with a .c extension.
I then started programming the board, and although I had trouble in the beginning with it as I kept getting an error whenever I gave the make command, it finally worked after editing the 0x0A (that was supposed to work from the data sheet) to 0x5E (the internal clock) in the code, starting the process again, and checking (and Fixing) the soldering between the board and some pin heads. and this is my log:
yazan@yazan-ThinkCentre-M710q:~$ sudo apt-get install flex byacc bison gcc libusb-dev avrdude [sudo] password for yazan: Reading package lists... Done Building dependency tree Reading state information... Done bison is already the newest version (2:3.0.4.dfsg-1build1). flex is already the newest version (2.6.4-6). libusb-dev is already the newest version (2:0.1.12-31). avrdude is already the newest version (6.3-4). byacc is already the newest version (20140715-1build1). gcc is already the newest version (4:7.3.0-3ubuntu2.1). 0 upgraded, 0 newly installed, 0 to remove and 164 not upgraded. yazan@yazan-ThinkCentre-M710q:~$ sudo apt-get install gcc-avr Reading package lists... Done Building dependency tree Reading state information... Done gcc-avr is already the newest version (1:5.4.0+Atmel3.6.0-1build1). 0 upgraded, 0 newly installed, 0 to remove and 164 not upgraded. yazan@yazan-ThinkCentre-M710q:~$ sudo apt-get install avr-libc Reading package lists... Done Building dependency tree Reading state information... Done avr-libc is already the newest version (1:2.0.0+Atmel3.6.0-1). 0 upgraded, 0 newly installed, 0 to remove and 164 not upgraded. yazan@yazan-ThinkCentre-M710q:~$ sudo apt-get install libc6-dev Reading package lists... Done Building dependency tree Reading state information... Done libc6-dev is already the newest version (2.27-3ubuntu1). 0 upgraded, 0 newly installed, 0 to remove and 164 not upgraded. yazan@yazan-ThinkCentre-M710q:~$ cd yazan@yazan-ThinkCentre-M710q:~$ ls Arduino fabISP_mac.0.8.2_firmware Music Templates yazan2 Desktop firmware.zip Pictures Videos Documents __MACOSX Public yazan Downloads MakeFile sketchbook 'yazan|'$'\n' yazan@yazan-ThinkCentre-M710q:~$ cd yazan yazan@yazan-ThinkCentre-M710q:~/yazan$ ls fabISP_mac.0.8.2_firmware firmware.zip __MACOSX yazan@yazan-ThinkCentre-M710q:~/yazan$ \ > yazan@yazan-ThinkCentre-M710q:~/yazan$ cd\ > yazan@yazan-ThinkCentre-M710q:~$ cd yazan@yazan-ThinkCentre-M710q:~$ ls Arduino fabISP_mac.0.8.2_firmware Music Templates yazan2 Desktop firmware.zip Pictures Videos Documents __MACOSX Public yazan Downloads MakeFile sketchbook 'yazan|'$'\n' yazan@yazan-ThinkCentre-M710q:~$ cd home bash: cd: home: No such file or directory yazan@yazan-ThinkCentre-M710q:~$ cd yazan yazan@yazan-ThinkCentre-M710q:~/yazan$ cd MakeFile bash: cd: MakeFile: No such file or directory yazan@yazan-ThinkCentre-M710q:~/yazan$ ls fabISP_mac.0.8.2_firmware firmware.zip __MACOSX yazan@yazan-ThinkCentre-M710q:~/yazan$ cd yazan@yazan-ThinkCentre-M710q:~$ ls Arduino fabISP_mac.0.8.2_firmware Music Templates yazan2 Desktop firmware.zip Pictures Videos Documents __MACOSX Public yazan Downloads MakeFile sketchbook 'yazan|'$'\n' yazan@yazan-ThinkCentre-M710q:~$ cd yazan yazan@yazan-ThinkCentre-M710q:~/yazan$ ls fabISP_mac.0.8.2_firmware firmware.zip __MACOSX yazan@yazan-ThinkCentre-M710q:~/yazan$ cd yazan@yazan-ThinkCentre-M710q:~$ ls Arduino fabISP_mac.0.8.2_firmware Pictures Videos Desktop firmware.zip Public yazan Documents __MACOSX sketchbook 'yazan|'$'\n' Downloads Music Templates yazan2 yazan@yazan-ThinkCentre-M710q:~$ cd desktop bash: cd: desktop: No such file or directory yazan@yazan-ThinkCentre-M710q:~$ cd Desktop yazan@yazan-ThinkCentre-M710q:~/Desktop$ cd MakeFile yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ ls cCode.c include.docx ls 'Original Make file.docx' yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make make: *** No targets specified and no makefile found. Stop. yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make avr-gcc -mmcu=attiny44 -Wall -Os -DF_CPU=20000000 -I./ -o cCode.out cCode.c avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make avr-gcc -mmcu=attiny44 -Wall -Os -DF_CPU=20000000 -I./ -o cCode.out cCode.c avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ program usbtiny program: command not found yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ program-usbtiny program-usbtiny: command not found yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make program-usbtiny avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) avrdude -p t44 -P usb -c usbtiny -U flash:w:cCode.c.hex avrdude: Error: Could not find USBtiny device (0x1781/0xc9f) avrdude done. Thank you. makefile:17: recipe for target 'program-usbtiny' failed make: *** [program-usbtiny] Error 1 yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make program-usbtiny avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) avrdude -p t44 -P usb -c usbtiny -U flash:w:cCode.c.hex avrdude: Error: Could not find USBtiny device (0x1781/0xc9f) avrdude done. Thank you. makefile:17: recipe for target 'program-usbtiny' failed make: *** [program-usbtiny] Error 1 yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make program-usbtiny avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) avrdude -p t44 -P usb -c usbtiny -U flash:w:cCode.c.hex avrdude: error: usbtiny_transmit: error sending control message: Protocol error avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check. avrdude: error: usbtiny_transmit: error sending control message: Protocol error avrdude done. Thank you. makefile:17: recipe for target 'program-usbtiny' failed make: *** [program-usbtiny] Error 1 yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 004: ID 17ef:608c Lenovo Bus 001 Device 003: ID 17ef:608d Lenovo Bus 001 Device 002: ID 8087:0a2a Intel Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 004: ID 17ef:608c Lenovo Bus 001 Device 003: ID 17ef:608d Lenovo Bus 001 Device 002: ID 8087:0a2a Intel Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 004: ID 17ef:608c Lenovo Bus 001 Device 003: ID 17ef:608d Lenovo Bus 001 Device 002: ID 8087:0a2a Intel Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 036: ID 1781:0c9f Multiple Vendors USBtiny Bus 001 Device 004: ID 17ef:608c Lenovo Bus 001 Device 003: ID 17ef:608d Lenovo Bus 001 Device 002: ID 8087:0a2a Intel Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 036: ID 1781:0c9f Multiple Vendors USBtiny Bus 001 Device 004: ID 17ef:608c Lenovo Bus 001 Device 003: ID 17ef:608d Lenovo Bus 001 Device 002: ID 8087:0a2a Intel Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make program-usbtiny avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) avrdude -p t44 -P usb -c usbtiny -U flash:w:cCode.c.hex avrdude: error: usbtiny_transmit: error sending control message: Protocol error avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check. avrdude: error: usbtiny_transmit: error sending control message: Protocol error avrdude done. Thank you. makefile:17: recipe for target 'program-usbtiny' failed make: *** [program-usbtiny] Error 1 yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make program-usbtiny avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) avrdude -p t44 -P usb -c usbtiny -U flash:w:cCode.c.hex avrdude: error: usbtiny_transmit: error sending control message: Protocol error avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check. avrdude: error: usbtiny_transmit: error sending control message: Protocol error avrdude done. Thank you. makefile:17: recipe for target 'program-usbtiny' failed make: *** [program-usbtiny] Error 1 yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make program-usbtiny -F make: invalid option -- 'F' Usage: make [options] [target] ... Options: -b, -m Ignored for compatibility. -B, --always-make Unconditionally make all targets. -C DIRECTORY, --directory=DIRECTORY Change to DIRECTORY before doing anything. -d Print lots of debugging information. --debug[=FLAGS] Print various types of debugging information. -e, --environment-overrides Environment variables override makefiles. --eval=STRING Evaluate STRING as a makefile statement. -f FILE, --file=FILE, --makefile=FILE Read FILE as a makefile. -h, --help Print this message and exit. -i, --ignore-errors Ignore errors from recipes. -I DIRECTORY, --include-dir=DIRECTORY Search DIRECTORY for included makefiles. -j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg. -k, --keep-going Keep going when some targets can't be made. -l [N], --load-average[=N], --max-load[=N] Don't start multiple jobs unless load is below N. -L, --check-symlink-times Use the latest mtime between symlinks and target. -n, --just-print, --dry-run, --recon Don't actually run any recipe; just print them. -o FILE, --old-file=FILE, --assume-old=FILE Consider FILE to be very old and don't remake it. -O[TYPE], --output-sync[=TYPE] Synchronize output of parallel jobs by TYPE. -p, --print-data-base Print make's internal database. -q, --question Run no recipe; exit status says if up to date. -r, --no-builtin-rules Disable the built-in implicit rules. -R, --no-builtin-variables Disable the built-in variable settings. -s, --silent, --quiet Don't echo recipes. -S, --no-keep-going, --stop Turns off -k. -t, --touch Touch targets instead of remaking them. --trace Print tracing information. -v, --version Print the version number of make and exit. -w, --print-directory Print the current directory. --no-print-directory Turn off -w, even if it was turned on implicitly. -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE Consider FILE to be infinitely new. --warn-undefined-variables Warn when an undefined variable is referenced. This program built for x86_64-pc-linux-gnu Report bugs to bug-make@gnu.org yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ -f -f: command not found yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make program-usbtiny avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) avrdude -p t44 -P usb -c usbtiny -U flash:w:cCode.c.hex avrdude: error: usbtiny_transmit: error sending control message: Protocol error avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check. avrdude: error: usbtiny_transmit: error sending control message: Protocol error avrdude done. Thank you. makefile:17: recipe for target 'program-usbtiny' failed make: *** [program-usbtiny] Error 1 yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 004: ID 17ef:608c Lenovo Bus 001 Device 003: ID 17ef:608d Lenovo Bus 001 Device 002: ID 8087:0a2a Intel Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 045: ID 1781:0c9f Multiple Vendors USBtiny Bus 001 Device 004: ID 17ef:608c Lenovo Bus 001 Device 003: ID 17ef:608d Lenovo Bus 001 Device 002: ID 8087:0a2a Intel Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make avr-gcc -mmcu=attiny44 -Wall -Os -DF_CPU=20000000 -I./ -o cCode.out cCode.c avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 047: ID 1781:0c9f Multiple Vendors USBtiny Bus 001 Device 004: ID 17ef:608c Lenovo Bus 001 Device 003: ID 17ef:608d Lenovo Bus 001 Device 002: ID 8087:0a2a Intel Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make program-usbtiny avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) avrdude -p t44 -P usb -c usbtiny -U flash:w:cCode.c.hex avrdude: error: usbtiny_transmit: error sending control message: Protocol error avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check. avrdude: error: usbtiny_transmit: error sending control message: Protocol error avrdude done. Thank you. makefile:17: recipe for target 'program-usbtiny' failed make: *** [program-usbtiny] Error 1 yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 055: ID 1781:0c9f Multiple Vendors USBtiny Bus 001 Device 004: ID 17ef:608c Lenovo Bus 001 Device 003: ID 17ef:608d Lenovo Bus 001 Device 002: ID 8087:0a2a Intel Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make program-usbtiny avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) avrdude -p t44 -P usb -c usbtiny -U flash:w:cCode.c.hex avrdude: error: usbtiny_transmit: error sending control message: Protocol error avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check. avrdude: error: usbtiny_transmit: error sending control message: Protocol error avrdude done. Thank you. makefile:17: recipe for target 'program-usbtiny' failed make: *** [program-usbtiny] Error 1 yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make avr-gcc -mmcu=attiny44 -Wall -Os -DF_CPU=20000000 -I./ -o cCode.out cCode.c avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make program-usbtiny avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) avrdude -p t44 -P usb -c usbtiny -U flash:w:cCode.c.hex avrdude: error: usbtiny_transmit: error sending control message: Protocol error avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check. avrdude: error: usbtiny_transmit: error sending control message: Protocol error avrdude done. Thank you. makefile:17: recipe for target 'program-usbtiny' failed make: *** [program-usbtiny] Error 1 yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make program-usbtiny avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) avrdude -p t44 -P usb -c usbtiny -U flash:w:cCode.c.hex avrdude: Error: Could not find USBtiny device (0x1781/0xc9f) avrdude done. Thank you. makefile:17: recipe for target 'program-usbtiny' failed make: *** [program-usbtiny] Error 1 yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$
The previous log was the one I first got, as I mentioned, I got an error in the beginning, I then checked the soldering again, then started again (making sure that the usb is well inserted), this is the second log:
yazan@yazan-ThinkCentre-M710q:~$ sudo apt-get install flex byacc bison gcc libusb-dev avrdude [sudo] password for yazan: Reading package lists... Done Building dependency tree Reading state information... Done bison is already the newest version (2:3.0.4.dfsg-1build1). flex is already the newest version (2.6.4-6). libusb-dev is already the newest version (2:0.1.12-31). avrdude is already the newest version (6.3-4). byacc is already the newest version (20140715-1build1). gcc is already the newest version (4:7.3.0-3ubuntu2.1). 0 upgraded, 0 newly installed, 0 to remove and 164 not upgraded. yazan@yazan-ThinkCentre-M710q:~$ sudo apt-get install gcc-avr Reading package lists... Done Building dependency tree Reading state information... Done gcc-avr is already the newest version (1:5.4.0+Atmel3.6.0-1build1). 0 upgraded, 0 newly installed, 0 to remove and 164 not upgraded. yazan@yazan-ThinkCentre-M710q:~$ sudo apt-get install avr-libc Reading package lists... Done Building dependency tree Reading state information... Done avr-libc is already the newest version (1:2.0.0+Atmel3.6.0-1). 0 upgraded, 0 newly installed, 0 to remove and 164 not upgraded. yazan@yazan-ThinkCentre-M710q:~$ sudo apt-get install libc6-dev Reading package lists... Done Building dependency tree Reading state information... Done libc6-dev is already the newest version (2.27-3ubuntu1). 0 upgraded, 0 newly installed, 0 to remove and 164 not upgraded. yazan@yazan-ThinkCentre-M710q:~$ cd yazan@yazan-ThinkCentre-M710q:~$ ls Arduino fabISP_mac.0.8.2_firmware Music Templates yazan2 Desktop firmware.zip Pictures Videos Documents __MACOSX Public yazan Downloads MakeFile sketchbook 'yazan|'$'\n' yazan@yazan-ThinkCentre-M710q:~$ cd yazan yazan@yazan-ThinkCentre-M710q:~/yazan$ ls fabISP_mac.0.8.2_firmware firmware.zip __MACOSX yazan@yazan-ThinkCentre-M710q:~/yazan$ \ > yazan@yazan-ThinkCentre-M710q:~/yazan$ cd\ > yazan@yazan-ThinkCentre-M710q:~$ cd yazan@yazan-ThinkCentre-M710q:~$ ls Arduino fabISP_mac.0.8.2_firmware Music Templates yazan2 Desktop firmware.zip Pictures Videos Documents __MACOSX Public yazan Downloads MakeFile sketchbook 'yazan|'$'\n' yazan@yazan-ThinkCentre-M710q:~$ cd home bash: cd: home: No such file or directory yazan@yazan-ThinkCentre-M710q:~$ cd yazan yazan@yazan-ThinkCentre-M710q:~/yazan$ cd MakeFile bash: cd: MakeFile: No such file or directory yazan@yazan-ThinkCentre-M710q:~/yazan$ ls fabISP_mac.0.8.2_firmware firmware.zip __MACOSX yazan@yazan-ThinkCentre-M710q:~/yazan$ cd yazan@yazan-ThinkCentre-M710q:~$ ls Arduino fabISP_mac.0.8.2_firmware Music Templates yazan2 Desktop firmware.zip Pictures Videos Documents __MACOSX Public yazan Downloads MakeFile sketchbook 'yazan|'$'\n' yazan@yazan-ThinkCentre-M710q:~$ cd yazan yazan@yazan-ThinkCentre-M710q:~/yazan$ ls fabISP_mac.0.8.2_firmware firmware.zip __MACOSX yazan@yazan-ThinkCentre-M710q:~/yazan$ cd yazan@yazan-ThinkCentre-M710q:~$ ls Arduino fabISP_mac.0.8.2_firmware Pictures Videos Desktop firmware.zip Public yazan Documents __MACOSX sketchbook 'yazan|'$'\n' Downloads Music Templates yazan2 yazan@yazan-ThinkCentre-M710q:~$ cd desktop bash: cd: desktop: No such file or directory yazan@yazan-ThinkCentre-M710q:~$ cd Desktop yazan@yazan-ThinkCentre-M710q:~/Desktop$ cd MakeFile yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ ls cCode.c include.docx ls 'Original Make file.docx' yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make make: *** No targets specified and no makefile found. Stop. yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make avr-gcc -mmcu=attiny44 -Wall -Os -DF_CPU=20000000 -I./ -o cCode.out cCode.c avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.5% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$ make avr-gcc -mmcu=attiny44 -Wall -Os -DF_CPU=20000000 -I./ -o cCode.out cCode.c avr-objcopy -O ihex cCode.out cCode.c.hex;\ avr-size --mcu=attiny44 --format=avr cCode.out AVR Memory Usage ---------------- Device: attiny44 Program: 62 bytes (1.6% Full) (.text + .data + .bootloader) Data: 0 bytes (0.0% Full) (.data + .bss + .noinit) avrdude -p t44 -P usb -c usbtiny -U flash:w: cCode.c.hex avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.00s avrdude: Device signature = 0x1e9207 (probably t44) avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed To disable this feature, specify the -D option. avrdude: erasing chip avrdude: reading input file "cCode.c.hex" avrdude: input file cCode.c.hex auto detected as Intel Hex avrdude: writing flash (62 bytes): Writing | ################################################## | 100% 0.46s avrdude: 62 bytes of flash written avrdude: verifying flash memory against cCode.c.hex: avrdude: load data flash data from input file cCode.c.hex: avrdude: input file cCode.c.hex auto detected as Intel Hex avrdude: input file cCode.c.hex contains 62 bytes avrdude: reading on-chip flash data: Reading | ################################################## | 100% 0.52s avrdude: verifying ... avrdude: 62 bytes of flash verified avrdude: safemode: Fuses OK (E:FF, H:DF, L:FE) avrdude done. Thank you. yazan@yazan-ThinkCentre-M710q:~/Desktop/MakeFile$
And here are the final results:
In addition to C language, I programmed the board using Arduino a couple of weeks ago, and you check it out using this link .
ADDITION: in the following weeks, I've worked on several newcodes, for example this code:
#include <Stepper.h> const int stepsPerRevolution = 48; int PushButton = 5; // initialize the stepper library on pins 8 through 11: Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11); void setup() { pinMode (PushButton, INPUT_PULLUP); myStepper.setSpeed(30); Serial.begin(9600); } void loop() { int readPushButton= digitalRead (PushButton); if (readPushButton == 0) { Serial.println("clockwise"); myStepper.step(stepsPerRevolution/6); delay(500); } }
Which is a code to control a stepper motor using a button on an ATmega 328p board. check out all the details related to this board and how to make it yourself from here . This is how the motor ended up working:
Also, another one I made is this code which you can download from here
/*Code designed by Sujay Alaspure in SA Lab */ const int sensor=A2; // Assigning analog pin A7 to variable 'sensor' const int LED=4; float tempc; //variable to store temperature in degree Celsius float vout; //temporary variable to hold sensor reading void setup() { pinMode(sensor,INPUT); // Configuring sensor pin as input pinMode(LED, OUTPUT); } void loop() { vout=analogRead(sensor); //Reading the value from sensor vout=(vout*500)/1023; tempc=vout; // Storing value in Degree Celsius if (tempc > 27) { digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) } else { digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW} } }
It measures the temperature using temp. sensor. Since I couldn’t use the FTDI, I decided to keep the LED, and have it lighting when the temperature received from the sensor is above 50 degrees Celsius. You can learn all about thecode and the board from here. Here is a video of the program working: