Offline
Jr. Member
Karma: 0
Posts: 98
|
 |
« Reply #15 on: December 25, 2012, 07:10:02 pm » |
I edited the code to else if (subcommand == 'A') // use internal 8 MHz clock { Serial.println (F("Using Audioino 8 MHz loader.")); bootloader = chAudioBoot_ATMEGA168_IN_PD1_LED_PB5_hex; newlFuse = 0xE2; // internal 8 MHz oscillator newhFuse = 0xDA; // 1024 byte bootloader, SPI enabled newextFuse = 0xFF; addr = 0x3C00; len = sizeof chAudioBoot_ATMEGA168_IN_PD1_LED_PB5_hex; } // end of using the 8 MHz clock which should now account for a 1024 byte bootloader. I also realized that the quick flashing light from the Audioino is actually an error signal. In the chAudioBoot.c file you can see the portion of the code that states the error signal //*************** start command interpreter ************************************* LEDON; while(1) { if(!receiveFrame()) { //***** error: blink fast, press reset to restart ******************* while(1) { if(TIMER>100) // timerstop ==> frequency @16MHz= 16MHz/8/100=20kHz { TIMER=0; time--; if(time==0) { TOGGLELED; time=1000; } } } } else // succeed { TOGGLELED; switch(FrameData[COMMAND]) { case TESTCOMMAND: // not used yet { #ifdef ARDUINO_DEBUG Serial.println("testcommand"); #endif } break; case RUNCOMMAND: { //setExternalPort(2); #ifndef ARDUINO_DEBUG // leave bootloader and run program runProgramm(); #endif #ifdef ARDUINO_DEBUG Serial.println("runcommand"); #endif } break; case PROGCOMMAND: { #ifdef ATMEGA168_MICROCONTROLLER // Atmega168 Pagesize=64 Worte=128 Byte uint16_t k; k=(((uint16_t)FrameData[PAGEINDEXHIGH])<<8)+FrameData[PAGEINDEXLOW]; boot_program_page (SPM_PAGESIZE*k, FrameData+DATAPAGESTART); // erase and programm page #endif #ifdef ATMEGA8_MICROCONTROLLER // Atmega8 Pagesize=32 Worte=64 Byte uint16_t k; k=(((uint16_t)FrameData[PAGEINDEXHIGH])<<8)+FrameData[PAGEINDEXLOW]; boot_program_page (SPM_PAGESIZE*k*2, FrameData+DATAPAGESTART); // erase and programm page boot_program_page (SPM_PAGESIZE*(k*2+1), FrameData+SPM_PAGESIZE+DATAPAGESTART); // erase and programm page #ifdef PINGPONG_PLATTFORM setSpalte(k); // show frame number on ping pong game #endif
#endif #ifdef ARDUINO_DEBUG Serial.println("programming"); #endif } break; } FrameData[COMMAND]=NOCOMMAND; // delete command } } }
I still dont understand why it wont program correctly. I plugged the headphone jack into the Audioino with 2 10k resistors and a 10nF capactor (dont have a 100nF to test with currently)
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14106
Lua rocks!
|
 |
« Reply #16 on: December 25, 2012, 07:27:19 pm » |
Check out: http://www.engbedded.com/fusecalcI make extended fuse of 0xF8 being the 1024 byte word boot vector. Try 0xFA being the 512 word (1024 byte) boot vector.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 98
|
 |
« Reply #17 on: December 25, 2012, 07:36:12 pm » |
Im a bit confused now. I am currently using L: E2 H: DA E: FF
If I switch E to FA the only change I see is that that BOD is set to 4.3v. I was trying not to mess with the BOD right now so if I disable it and set the boot word to 512 like you mention I am getting fuses as: L: E2 H: DC E: FF
However that also changes the start address to 3E00 rather than 3C00 which is mentioned in the bootloader's README. When i try to flash the bootloader with the bolded fuses, it only works if I bootload at address 3C00, and even after that I have the same problem of although it boots, any attempt to upload code results in that error flash. Maybe the bootloader doesnt work with the atmega328p? BTW Thank you very much for helping me out!
|
|
|
|
« Last Edit: December 25, 2012, 07:46:35 pm by sdinnu »
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 98
|
 |
« Reply #18 on: December 26, 2012, 10:20:39 pm » |
Can anyone look at the bootloader and tell me what they think? I know on the chAudioBoot.c file it says atmega168 but it looks like it should work on the atmega328p also. Any help would be greatly appreciated since this is a really cool bootloader and I would love to get it to work.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14106
Lua rocks!
|
 |
« Reply #19 on: December 27, 2012, 02:04:00 am » |
OK, what chip do you have? You have made repeated references to the Atmega168, so I assumed you were using it. Or are you?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 98
|
 |
« Reply #20 on: December 27, 2012, 02:06:02 am » |
I am using the atmega328p. The bootloader looks like it was written only for the atmega8 and the atmega168 but it looks like it should port over just fine since the 168 and 328 are pretty much the same.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14106
Lua rocks!
|
 |
« Reply #21 on: December 27, 2012, 02:14:49 am » |
Apart from the program memory size.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 98
|
 |
« Reply #22 on: December 27, 2012, 02:16:45 am » |
were you able to flash the bootloader successfully? if so, can you upload code through audio?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 40
|
 |
« Reply #23 on: December 27, 2012, 05:00:31 am » |
The bootloader in the Flash is at the end of the Flash. Due to the size of the Atmega328 the address of the bootloader section differs from the Atmega168. After developing the first version of the bootloader I found a major bug. Some sound cards have an inverted output which would not work with the bootloader. I made a second java program which corrects this issue. Please use the program version which fits to your computer. http://www.hobby-roboter.de/forum/viewtopic.php?f=4&t=127
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 98
|
 |
« Reply #24 on: December 27, 2012, 05:09:06 am » |
I've been using the AudioBoot_v2_0.zip so I think that should solve the inverse audio problem correct? I am running java program on my mac and I guess i could try another machine.
Also do you know how to properly address the bootloader on the atmega328p so that it gets burnt in the right location?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14106
Lua rocks!
|
 |
« Reply #25 on: December 27, 2012, 03:35:31 pm » |
However that also changes the start address to 3E00 rather than 3C00 which is mentioned in the bootloader's README. When i try to flash the bootloader with the bolded fuses, it only works if I bootload at address 3C00, and even after that I have the same problem of although it boots, any attempt to upload code results in that error flash. Maybe the bootloader doesnt work with the atmega328p?
Wait, wait. You have an Atmega328P, right? So that has 32 Kb of Program Memory. Valid bootloader addresses are: - No bootloader: start at address 0x0000
- Small bootloader (512 bytes): start at address 0x7E00
- Larger bootloader (1024 bytes): start at address 0x7C00
- Even larger bootloader (2048 bytes): start at address 0x7800
- Largest bootloader (4096 bytes): start at address 0x7000
These are byte addresses not word addresses. The fuse calculator talks in word addresses. So if you have a 1024 byte bootloader it starts at byte 0x7C00 or word 0x3E00. So it should be compiled to start at (byte) 0x7C00, and the high fuse should be 0xDC (512 word, 1024 byte, bootloader).
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 98
|
 |
« Reply #26 on: December 27, 2012, 11:11:25 pm » |
I tried using Nick's Atmega programmer and changing the address on where the bootloader is placed and I cannot even get the chip to boot anymore. It only boots when I change the address to 0x3C00 Here is what I did: else if (subcommand == 'A') // use internal 8 MHz clock { Serial.println (F("Using Audioino 8 MHz loader.")); bootloader = chAudioBoot_ATMEGA168_IN_PD1_LED_PB5_hex; newlFuse = 0xE2; // internal 8 MHz oscillator newhFuse = 0xDC; // 1024 byte bootloader, SPI enabled newextFuse = 0xFF; addr = 0x7C00; len = sizeof chAudioBoot_ATMEGA168_IN_PD1_LED_PB5_hex; } // end of using the 8 MHz clock And here is the output of your program: Atmega chip programmer. Written by Nick Gammon. Entered programming mode OK. Signature = 0x1E 0x95 0x0F Processor = ATmega328P Flash memory size = 32768 bytes. LFuse = 0xE2 HFuse = 0xDC EFuse = 0xFF Lock byte = 0xEF Clock calibration = 0x8D Bootloader address = 0x7E00 Bootloader length = 512 bytes. Type 'L' to use Lilypad (8 MHz) loader, 'A' for Audioino (8 MHz), or 'U' for Uno (16 MHz) loader ... Using Audioino 8 MHz loader. Type 'V' to verify, or 'G' to program the chip with the bootloader ... Erasing chip ... Writing bootloader ... Committing page starting at 0x7C00 Committing page starting at 0x7C80 Committing page starting at 0x7D00 Committing page starting at 0x7D80 Committing page starting at 0x7E00 Committing page starting at 0x7E80 Committing page starting at 0x7F00 Committing page starting at 0x7F80 Written. Verifying ... No errors found. Writing fuses ... LFuse = 0xE2 HFuse = 0xDC EFuse = 0xFF Lock byte = 0xEF Clock calibration = 0x8D Done. Type 'C' when ready to continue with another chip ...
Since this doesnt even boot properly, does the bootloader need to be recompiled for the atmega328p? How would I go about doing that?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14106
Lua rocks!
|
 |
« Reply #27 on: December 28, 2012, 06:05:37 am » |
Since this doesnt even boot properly, does the bootloader need to be recompiled for the atmega328p?
Absolutely. The code is compiled to run at a certain address, and the bootloader has to be at certain limited addresses. You can't just stick them where you feel like it. How would I go about doing that?
I'm not sure exactly how to recompile bootloaders (depends on your platform a bit) but there should be a makefile there. I've recompiled Optiboot on the Mac by ignoring the makefile and doing my own thing.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 98
|
 |
« Reply #28 on: December 28, 2012, 01:51:26 pm » |
So this bootloader doenst come with any makefile so I installed AVR studio and tried to see if I can recompile the bootloader there but I am pretty lost. I have a mac and windows so environment should not be a problem. It seems like this bootloader would work if I just changed the address but I have no clue how to do that and recompile a hex.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14106
Lua rocks!
|
 |
« Reply #29 on: December 28, 2012, 04:12:58 pm » |
You can't recompile a hex. You need to find the source and recompile that. Where did you get this file? Perhaps there is a clue there.
|
|
|
|
|
Logged
|
|
|
|
|
|