Page 1 of 1
USB bootloaderhid with Atmega128
Posted: Wed Oct 30, 2013 10:43 am
by trkien
Hi all,
I am using bootloadHID.2012-12-08 for my Atmega128A. I modify the bootloaderconfig.h for suitable with my hardware:
#define USB_CFG_IOPORTNAME D
#define USB_CFG_DMINUS_BIT 4 //PD4: D-
#define USB_CFG_DPLUS_BIT 0 //PD0: D+ (INT0)
and modify in the makefile:
DEVICE = atmega128
BOOTLOADER_ADDRESS = 1E000
F_CPU = 16000000
FUSEH = 0xd0
FUSEL = 0xbf
My hardware is same with the original including zenner diodes 3V6. I donot know why I always fail when connecting circuit to PC with error:"USB device not recognized". I did successfully with atmega8, atmega16 and atmega32 with this code so I am sure my configuration is true. Maybe atmega128 has some parts different. Did anyone successful implement usb bootloader hid with atmega128? Can you help me to solve this problem or send me your successfully running code? Thank you very much.
Re: USB bootloaderhid with Atmega128
Posted: Sat Nov 02, 2013 1:08 pm
by matrixstorm
Perhaps you might want to try USBaspLoader (
https://github.com/baerwolf/USBaspLoader) insead of bootloaderhid.
With USBaspLoader you have many more features and you also will be able to access the EEPROM, too.
BR matrixstorm
Re: USB bootloaderhid with Atmega128
Posted: Mon Nov 04, 2013 6:38 pm
by ulao
atmega 8 and 128 are indeed a bit different. the bootloader start address for the 128 is 0x3800 (this is counted in "words") or in "bytes" (2x) its 0x7000.
so when you set the bootloader start address it's 0x7000.
Re: USB bootloaderhid with Atmega128
Posted: Wed Nov 06, 2013 3:11 am
by trkien
@matrixstorm: I used USBaspLoader original with some modifications to suit with my hardware but i also got the same problem: "usb device not recognized". Did you try with atmega128 successfully before?
@ulao: The boot start address value depends on the size of bootloader you use. I used 4kB bootloader size with boot start = 0x1E000 for atmega128 using avrnet bootloader and it works well. So I think that problem is not related to the boot start address.
I modified USB_READ_FLASH function to pgm_read_bye_far following this
viewtopic.php?f=8&t=2433&p=21472&hilit=atmega128#p21472 but also it is not working.
Anyone successfully implemented with atmega128 please let me how to solve this problem.
trkien.
Re: USB bootloaderhid with Atmega128
Posted: Thu Nov 07, 2013 1:26 pm
by matrixstorm
Hi
trkien wrote:I used USBaspLoader original with some modifications to suit with my hardware
Did you use the revised version of USBaspLoader (
https://github.com/baerwolf/USBaspLoader/tree/testing)?
Compared to the version from VUSB-Webside this Loader has gone through much improvement and bug-fixing.
Also all necessary devicesettings (FUSE, Adresses etc...) are now mostly automatically selected by Makefile.
trkien wrote:Anyone successfully implemented with atmega128 please let me how to solve this problem.
I haven't testes ATmega128, yet. (I have one somewhere here around, so I could test if it is important)
I have successfully tested ATmega2560 and ATmega1284p - both with more than 64k Flash.
(Actually this was when I fixed some Bug regarding 64k memory borders)
Btw. the new USBaspLoader also has a feature where you can update the Loader without the need of ISP again.
(There is also an API to gain Flash writeaccess in your own firmwares)
BR matrixstorm
Re: USB bootloaderhid with Atmega128
Posted: Thu Nov 07, 2013 6:06 pm
by matrixstorm
Hi, it's again me:
If you want to try the new, revised USBaspLoader please use the testing-branch (
https://github.com/baerwolf/USBaspLoader/tree/testing).
From the previous message motivated I tried to compile and experienced an build-issue for ATmega128.
I fixed the Bug and commited it to testing-branch.
BR matrixstorm
Re: USB bootloaderhid with Atmega128
Posted: Fri Nov 08, 2013 5:19 pm
by trkien
Hi matrixstorm,
Happy to hear response from you.
As your comments, I used testing-branch with some modifications:
- bootloaderconfig.h:
#ifndef USB_CFG_IOPORTNAME
#define USB_CFG_IOPORTNAME D
#endif
#ifndef USB_CFG_DMINUS_BIT
#define USB_CFG_DMINUS_BIT 6
#endif
#ifndef USB_CFG_DPLUS_BIT
#define USB_CFG_DPLUS_BIT 0
#endif
#ifndef JUMPER_PORT
#define JUMPER_PORT A
#endif
#ifndef JUMPER_BIT
#define JUMPER_BIT 4
#endif
- Makefile.inc
F_CPU = 16000000
DEVICE = atmega128
- FUSES:
FUSEH = 0xd0
FUSEL = 0xbf
Result: USB Boot still not working. I am sure to connect PA4 to GND ( bootloader condition).
Can you send me your compile project with atmega128 including hex file?
I am looking for your reply.
Thank you very much.
trkien.
Re: USB bootloaderhid with Atmega128
Posted: Sat Nov 09, 2013 1:44 pm
by matrixstorm
Hi trkien.
First of all, I recompiled your USBaspLoader configuration:
http://matrixstorm.com/baerwolf/files/t ... rieken.ziphttp://matrixstorm.com/baerwolf/files/t ... en.zip.ascWithin the ZIP there is also a patch-file (against current testing-head), which indicates to you my changes for your configuration.
(Please clone a fresh copy before applying patch, since:
https://github.com/baerwolf/USBaspLoade ... a3e18df5ed)
However I do not recommend your fuse configuration (YOURS: HF:0xd0, LF:0xbf), since you forgot the efuse and USBaspLoader suggests:
FUSEOPT_128 = -U lfuse:w:0x1f:m -U hfuse:w:0xc0:m -U efuse:w:0xfd:m
BR matrixstorm
Re: USB bootloaderhid with Atmega128
Posted: Fri Nov 15, 2013 6:31 am
by trkien
Thank you Matrixstorm,
I can compile and the code works well with Atmega128 now.
However, it cannot work with USBasploader suggestion fuses. It works with my previous fuses: HF:0xd0, LF:0xbf, EX: 0xff.
Anyway, thank you very much.
trkien.
Re: USB bootloaderhid with Atmega128
Posted: Fri Nov 15, 2013 7:50 am
by matrixstorm
Hi trkien.
What is the vlatge you are using the ATmega128 on?
Because ATmega128 for 16MHz only runs stable at 4.5 .. 5.5V, the fuses were configured to activate brown out detector.
Without brownout detection, the bootloader section may destroy its contents by itself (brownout during write) and the bootloader will be bricked!!
Also the Value 11 for START-UP TIME is marked as reserved and makes no sense:
Activating the BrownOut with BODLEVEL 4.5V and given the ATmega128 maximum time to start-up: Adjusts your low-fuse (0xbf) into 0x1f.
To your high-fuse:
You are using the value 0xd0, which is pretty much the same than 0xc0: Except CKOPT which is one in your case.
But using a crystal (as it is recommended for VUSB) this Option needs to be zero: HFuse = 0xc0
Please also note, that leaving the lock-bits unchanged at their value 0x3f is important to have all functions of USBasp work properly.
The old way of protecting the bootloader section by programming the proper LOCKBITs is deprecheated now and done in software.
Waiting for your response,
BR matrixstorm
Re: USB bootloaderhid with Atmega128
Posted: Fri Nov 15, 2013 4:18 pm
by trkien
Hi Maxtrixstorm,
It is my mistake at somewhere in hardware connections. You are totally right with the suggestion fuses.
I checked again and everything works well.
By the way, using INT3 instead of INT0 also works well.
Thank you very much.
trkien.
Re: USB bootloaderhid with Atmega128
Posted: Fri Nov 15, 2013 11:11 pm
by matrixstorm
Hi trkien.
I am glad I could help.
Since you sucessfully tested USBaspLoader with ATmega128-16AU, may I mark ATmega128 as tested (16MHz) in the next commit to github?
Btw.: If you like USBaspLoader, please give it a star on github
BR matrixstorm
Re: USB bootloaderhid with Atmega128
Posted: Sat Nov 16, 2013 3:28 am
by trkien
Hi Matrixstorm,
Sure, you can mark ATmega128 as tested (16MHz) in the next commit to github.
I also give USBasp loader star on github now. You did a wonderful work.
Nice to talk to you, too.
trkien.
Re: USB bootloaderhid with Atmega128
Posted: Tue Aug 12, 2014 1:03 pm
by medavr
I am able to burn the bootloader into the atmega128. (I read the flash memory contents with eXtreme burner AVR, and it shows some values beginning from 1E000)
However, I am unable to burn my project hex file through usb.
I wrote in the command line "avrdude -P com10 -b 19200 -c usbasp -p atmega128 -U flash:w:myfilename.hex"
I used 'usbasp" after -c because this is supposed to be a usbasp emulator, isn't it?
It says programmer not found.
can you help?
I have followed all other protocols mentioned, only that I use Port E as my communication port, and I have an FT232 connected between the USB and the Microcontroller. Would that make a difference?
I have physically connected INT0 to my D+ pin, so I guess that should do?
Re: USB bootloaderhid with Atmega128
Posted: Thu Aug 14, 2014 4:42 am
by xiangrui
You are using bootloaderHID, right? In that case you don't need other hardware, but only the USB connection with the microcontroller. The command should be
avrdude -c usbasp -p atmega128 -U flash:w:myfilename.hex
Good luck.
-Xiangrui
medavr wrote:I am able to burn the bootloader into the atmega128. (I read the flash memory contents with eXtreme burner AVR, and it shows some values beginning from 1E000)
However, I am unable to burn my project hex file through usb.
I wrote in the command line "avrdude -P com10 -b 19200 -c usbasp -p atmega128 -U flash:w:myfilename.hex"
I used 'usbasp" after -c because this is supposed to be a usbasp emulator, isn't it?
It says programmer not found.
can you help?
I have followed all other protocols mentioned, only that I use Port E as my communication port, and I have an FT232 connected between the USB and the Microcontroller. Would that make a difference?
I have physically connected INT0 to my D+ pin, so I guess that should do?