Some HELP with programming an Atmega32U4 with ISP
- Helder
- Trailblazer
- Posts: 2985
- Joined: Thu May 05, 2016 8:33 am
- Location: Rogers, AR
- Has thanked: 1459 times
- Been thanked: 3114 times
Some HELP with programming an Atmega32U4 with ISP
Sooooo I'm at my wits end right now trying to program my test board with the bootloader and eve skipping that and using a compiled hex of the controller code and no matter wtf I do it always give me a verify error at the end about data mismatch.
I had to use my leonardo as an ISP Programmer to reprogram my USB programmer as a USBasp which it did and both the Leonardo and USBasp give me the same error. Then I also have no idea on the fuses and have tried many many combinations using the fuse calculators and default setting and even the bootloader fuse setting in a tutorial :
http://electronut.in/bootloader-atmega32u4/
Still same error and when I plug it in the USB into my PC nothing is recognized like nothing is plugged in, I checked the fuse and the chip itself which is getting the 5v and the chip is recognized in the programmers with the ISP header.
Any help on this? I'm about to solder up another board and throw this thing out the window and see if the new one will have better results.
I had to use my leonardo as an ISP Programmer to reprogram my USB programmer as a USBasp which it did and both the Leonardo and USBasp give me the same error. Then I also have no idea on the fuses and have tried many many combinations using the fuse calculators and default setting and even the bootloader fuse setting in a tutorial :
http://electronut.in/bootloader-atmega32u4/
Still same error and when I plug it in the USB into my PC nothing is recognized like nothing is plugged in, I checked the fuse and the chip itself which is getting the 5v and the chip is recognized in the programmers with the ISP header.
Any help on this? I'm about to solder up another board and throw this thing out the window and see if the new one will have better results.
Chat with me and other members On Discord
Don't contact me about obtaining my board files (as you will not get them). If my Boards or PCB Kits are sold out, they will be restocked as soon as I can get them and there is demand for them. You can join the mailing list on my Website to be notified when they are available.
Helder's Game Tech Website
We will not support any cloned work so don't come to us with technical issues to resolve, go talk to the cloner for help.
Don't contact me about obtaining my board files (as you will not get them). If my Boards or PCB Kits are sold out, they will be restocked as soon as I can get them and there is demand for them. You can join the mailing list on my Website to be notified when they are available.
Helder's Game Tech Website
We will not support any cloned work so don't come to us with technical issues to resolve, go talk to the cloner for help.
- tronicgr
- Posts: 143
- Joined: Tue Jun 07, 2016 4:26 pm
- Has thanked: 95 times
- Been thanked: 67 times
- Contact:
Re: Some HELP with programming an Atmega32U4 with ISP
I was going to work in a simple solution that you can use the raspberry zero to program the atmega chip but not until Monday.
You can get an idea for what I'm talking about here:
https://learn.adafruit.com/program-an-a ... -gpio-pins
Be careful with the fuses... if you set wrong fuses it might not be able to use the ISP to program it with ANY programmer!
Thanks
Thanos
You can get an idea for what I'm talking about here:
https://learn.adafruit.com/program-an-a ... -gpio-pins
Be careful with the fuses... if you set wrong fuses it might not be able to use the ISP to program it with ANY programmer!
Thanks
Thanos
- Helder
- Trailblazer
- Posts: 2985
- Joined: Thu May 05, 2016 8:33 am
- Location: Rogers, AR
- Has thanked: 1459 times
- Been thanked: 3114 times
Re: Some HELP with programming an Atmega32U4 with ISP
That would be good for people who get the boards blank but I need to test mine to be sure it's all good (your testing will be helpful too).
Here is the link to the code for the controller:
https://github.com/oxodao/GBZGamePad
Also has the link to the one I linked in the first post.
Could you give me the settings especially the fuses and the bootloader hex files to properly program the 32u4? I don't want to use the Pi since I have 2 programmers that I'd rather use anyways.
Maybe provide me the hex with bootloader and controller programmed into it already, I'm also using AVRDudess for the programming which is just a AVRDude Gui.
Here is the link to the code for the controller:
https://github.com/oxodao/GBZGamePad
Also has the link to the one I linked in the first post.
Could you give me the settings especially the fuses and the bootloader hex files to properly program the 32u4? I don't want to use the Pi since I have 2 programmers that I'd rather use anyways.
Maybe provide me the hex with bootloader and controller programmed into it already, I'm also using AVRDudess for the programming which is just a AVRDude Gui.
Chat with me and other members On Discord
Don't contact me about obtaining my board files (as you will not get them). If my Boards or PCB Kits are sold out, they will be restocked as soon as I can get them and there is demand for them. You can join the mailing list on my Website to be notified when they are available.
Helder's Game Tech Website
We will not support any cloned work so don't come to us with technical issues to resolve, go talk to the cloner for help.
Don't contact me about obtaining my board files (as you will not get them). If my Boards or PCB Kits are sold out, they will be restocked as soon as I can get them and there is demand for them. You can join the mailing list on my Website to be notified when they are available.
Helder's Game Tech Website
We will not support any cloned work so don't come to us with technical issues to resolve, go talk to the cloner for help.
- tronicgr
- Posts: 143
- Joined: Tue Jun 07, 2016 4:26 pm
- Has thanked: 95 times
- Been thanked: 67 times
- Contact:
Re: Some HELP with programming an Atmega32U4 with ISP
Do you have any programmer compatible with AVRStudio4 ? That is the best way to ensure you flash the correct fuses.
Also make sure the crystal has correct orientation.
BTW, what is the model of crystal you used? The ones I use are two pin and much smaller.
I haven't got to the bootloader yet as I don't have an ATmega32u4 mounted on a board yet, I was waiting your board. But I also ordered a dev board for it in case there is a design error on your board preventing the ISP from working correctly. Can you pm me a schematic of the board to ensure all is connected correctly?
Thanks
Thanos
Also make sure the crystal has correct orientation.
BTW, what is the model of crystal you used? The ones I use are two pin and much smaller.
I haven't got to the bootloader yet as I don't have an ATmega32u4 mounted on a board yet, I was waiting your board. But I also ordered a dev board for it in case there is a design error on your board preventing the ISP from working correctly. Can you pm me a schematic of the board to ensure all is connected correctly?
Thanks
Thanos
- Helder
- Trailblazer
- Posts: 2985
- Joined: Thu May 05, 2016 8:33 am
- Location: Rogers, AR
- Has thanked: 1459 times
- Been thanked: 3114 times
Re: Some HELP with programming an Atmega32U4 with ISP
Yea I'll get you the info you need when I get home.
Chat with me and other members On Discord
Don't contact me about obtaining my board files (as you will not get them). If my Boards or PCB Kits are sold out, they will be restocked as soon as I can get them and there is demand for them. You can join the mailing list on my Website to be notified when they are available.
Helder's Game Tech Website
We will not support any cloned work so don't come to us with technical issues to resolve, go talk to the cloner for help.
Don't contact me about obtaining my board files (as you will not get them). If my Boards or PCB Kits are sold out, they will be restocked as soon as I can get them and there is demand for them. You can join the mailing list on my Website to be notified when they are available.
Helder's Game Tech Website
We will not support any cloned work so don't come to us with technical issues to resolve, go talk to the cloner for help.
- tronicgr
- Posts: 143
- Joined: Tue Jun 07, 2016 4:26 pm
- Has thanked: 95 times
- Been thanked: 67 times
- Contact:
Re: Some HELP with programming an Atmega32U4 with ISP
Just to let everybody, I got it working.
Tomorrow, I'll backup the bootloader+program to a hex file, along instructions to flash it using AVRDUDE on Raspberry command line, as its the easiest way right now for people that do not have hardware programmer (AVRMKII).
Thanks
Thanos
Tomorrow, I'll backup the bootloader+program to a hex file, along instructions to flash it using AVRDUDE on Raspberry command line, as its the easiest way right now for people that do not have hardware programmer (AVRMKII).
Thanks
Thanos
- tronicgr
- Posts: 143
- Joined: Tue Jun 07, 2016 4:26 pm
- Has thanked: 95 times
- Been thanked: 67 times
- Contact:
Re: Some HELP with programming an Atmega32U4 with ISP
Hey Helder,
Here are few photos for now of the board with the new crystal:
Thanks
Thanos
Here are few photos for now of the board with the new crystal:
Thanks
Thanos
- tronicgr
- Posts: 143
- Joined: Tue Jun 07, 2016 4:26 pm
- Has thanked: 95 times
- Been thanked: 67 times
- Contact:
Re: Some HELP with programming an Atmega32U4 with ISP
Hi Helder,
The Crystal I used is a Ceramic one:
http://www.digikey.com/product-detail/e ... -ND/584635
I placed a 1Mohm resistor in parallel with the crystal to filter any noise. No extra capacitors required.
I also didn't use the Fuse you have on the parts list, I just shorted it out with a piece of wire.
I soldered a 6-pin connector so I can use the ribbon from my Mattair Zeptoprog II programmer.
https://www.mattairtech.com/index.php/zeptoprog-ii.html
I used the Atmel Studio 4 to program the Atmega32U4.
Fuse should be as:
Extended fuse: 0xCB
High fuse: 0xD8
Low fuse: 0xFF
I used the Bootloader file from here:
https://github.com/sparkfun/Arduino_Boa ... icro16.hex
The equivalent command IF using AVRDUDE would be:
Now you Should see the COM port appear when you connect the USB to the computer. Mine shows as Teensy board as it using their driver, but in Arduino Ide you still select the Sparkfun Pro Micro 5v /16Mhz.
Before you be able to load the code you should make sure you have Arduino Ide 1.6.6 and Arduino AVR Boards 1.6.9 loaded.
Then add the Repository for the Description of Sparkfun AVR boards found in this link (instructions included):
https://github.com/sparkfun/Arduino_Boards
Select the correct board from Arduino Ide: Load the GameBoy code:
https://github.com/oxodao/GBZGamePad
and FIX the Missing PULLUP part (it has to be "<14"):
Upload the arduino code to the board and Enjoy!
Thanks
Thanos
The Crystal I used is a Ceramic one:
http://www.digikey.com/product-detail/e ... -ND/584635
I placed a 1Mohm resistor in parallel with the crystal to filter any noise. No extra capacitors required.
I also didn't use the Fuse you have on the parts list, I just shorted it out with a piece of wire.
I soldered a 6-pin connector so I can use the ribbon from my Mattair Zeptoprog II programmer.
https://www.mattairtech.com/index.php/zeptoprog-ii.html
I used the Atmel Studio 4 to program the Atmega32U4.
Fuse should be as:
Extended fuse: 0xCB
High fuse: 0xD8
Low fuse: 0xFF
I used the Bootloader file from here:
https://github.com/sparkfun/Arduino_Boa ... icro16.hex
The equivalent command IF using AVRDUDE would be:
Code: Select all
avrdude -p m32u4 -P usb -c avrispmkii -U flash:w:Caterina-promicro16.hex -U efuse:w:0xcb:m -U hfuse:w:0xd8:m -U lfuse:w:0xff:m
Now you Should see the COM port appear when you connect the USB to the computer. Mine shows as Teensy board as it using their driver, but in Arduino Ide you still select the Sparkfun Pro Micro 5v /16Mhz.
Before you be able to load the code you should make sure you have Arduino Ide 1.6.6 and Arduino AVR Boards 1.6.9 loaded.
Then add the Repository for the Description of Sparkfun AVR boards found in this link (instructions included):
https://github.com/sparkfun/Arduino_Boards
Select the correct board from Arduino Ide: Load the GameBoy code:
https://github.com/oxodao/GBZGamePad
and FIX the Missing PULLUP part (it has to be "<14"):
Upload the arduino code to the board and Enjoy!
Thanks
Thanos
- tronicgr
- Posts: 143
- Joined: Tue Jun 07, 2016 4:26 pm
- Has thanked: 95 times
- Been thanked: 67 times
- Contact:
Re: Some HELP with programming an Atmega32U4 with ISP
I just realized the Up - Down buttons are also inversed.
See below correct code:
See below correct code:
Code: Select all
#include <Gamepad.h>
Gamepad gb;
#define BTN_DOWN 1
#define BTN_UP 0
#define BTN_LEFT 2
#define BTN_RIGHT 3
#define BTN_A 4
#define BTN_START 5
#define BTN_Y 6
#define BTN_L1 7
#define BTN_X 8
#define BTN_R1 9
#define BTN_R2 10
#define BTN_L2 11
#define BTN_B 12
#define BTN_SELECT 13
void setup() {
for (int x = 0; x<14; x++){
pinMode(x, INPUT_PULLUP);
}
}
void loop() {
bool downSet = digitalRead(BTN_DOWN);
bool upSet = digitalRead(BTN_UP); // No pun intended
bool leftSet = digitalRead(BTN_LEFT);
bool rightSet = digitalRead(BTN_RIGHT);
gb.setLeftXaxis(!leftSet ? -127 : !rightSet ? 127 : 0);
gb.setLeftYaxis(!downSet ? 127 : !upSet ? -127 : 0);
gb.setButtonState(1, !digitalRead(BTN_A));
gb.setButtonState(2, !digitalRead(BTN_B));
gb.setButtonState(3, !digitalRead(BTN_X));
gb.setButtonState(4, !digitalRead(BTN_Y));
gb.setButtonState(5, !digitalRead(BTN_SELECT));
gb.setButtonState(6, !digitalRead(BTN_START));
gb.setButtonState(7, !digitalRead(BTN_L1));
gb.setButtonState(8, !digitalRead(BTN_R1));
gb.setButtonState(9, !digitalRead(BTN_L2));
gb.setButtonState(10, !digitalRead(BTN_R2));
gb.sendUpdate();
}
- tronicgr
- Posts: 143
- Joined: Tue Jun 07, 2016 4:26 pm
- Has thanked: 95 times
- Been thanked: 67 times
- Contact:
Re: Some HELP with programming an Atmega32U4 with ISP
Now, if you want to do all the above much easier, you can use the Raspberry as programmer!!
Here are some basic instructions:
SSH to the Raspberry and install avrdude
Verify installation by running the command
Copy the configuration file to the home directory
Edit the configuration file to add new programmer info and assign the GPIO we want to use
ADD These lines
To program an AVR from the Pi you'll need to have 4 GPIO pins free on the Raspberry Pi. These pins will connect to the AVR's ISP/ICSP MOSI, MISO, SCK, and RESET pins.
In addition you'll connect the Pi's 5 volt power and ground to the AVR to power it during programming.
From the GPIO we used in the configuration above you need to connect the following:
Gameboy board <--> Pi Zero GPIO
Vcc = 5v
Gnd = GND
reset = 26
sck = 16
mosi = 20
miso = 21
Download and copy the following hex file in home directory of raspberry pi zero (Unzip first).
To program the bootloader and the program into the new (empty Atmega32U4 chip), execute the following command:
That's it, now the Atmega32U4 is ready to be used as gamepad, and also contains a bootloader that can be used to be reprogrammed via Arduino IDE if any changes in the code are needed.
Thanks
Thanos
Here are some basic instructions:
SSH to the Raspberry and install avrdude
Code: Select all
sudo apt-get install avrdude
Code: Select all
avrdude -v
Code: Select all
cp /etc/avrdude.conf ~/avrdude_gpio.conf
Code: Select all
nano ~/avrdude_gpio.conf
Code: Select all
# Linux GPIO configuration for avrdude.
# Change the lines below to the GPIO pins connected to the AVR.
programmer
id = "pi_0";
desc = "Use the Linux sysfs interface to bitbang GPIO lines";
type = "linuxgpio";
reset = 26;
sck = 16;
mosi = 20;
miso = 21;
;
To program an AVR from the Pi you'll need to have 4 GPIO pins free on the Raspberry Pi. These pins will connect to the AVR's ISP/ICSP MOSI, MISO, SCK, and RESET pins.
In addition you'll connect the Pi's 5 volt power and ground to the AVR to power it during programming.
From the GPIO we used in the configuration above you need to connect the following:
Gameboy board <--> Pi Zero GPIO
Vcc = 5v
Gnd = GND
reset = 26
sck = 16
mosi = 20
miso = 21
Download and copy the following hex file in home directory of raspberry pi zero (Unzip first).
To program the bootloader and the program into the new (empty Atmega32U4 chip), execute the following command:
Code: Select all
sudo avrdude -p m32u4 -C ~/avrdude_gpio.conf -c pi_0 -v -U flash:w:/home/pi/Bootflash_program_gameboy.hex:i -U efuse:w:0xcb:m -U hfuse:w:0xd8:m -U lfuse:w:0xff:m
That's it, now the Atmega32U4 is ready to be used as gamepad, and also contains a bootloader that can be used to be reprogrammed via Arduino IDE if any changes in the code are needed.
Thanks
Thanos
Who is online
Users browsing this forum: No registered users and 1 guest