Pages: 1 [2] 3 4 5   Go Down
Author Topic: Audioino?  (Read 4002 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I edited the code to

Code:
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

Code:
  //*************** 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
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Check out: http://www.engbedded.com/fusecalc

I make extended fuse of 0xF8 being the 1024 byte word boot vector.

Try 0xFA being the 512 word (1024 byte) boot vector.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Apart from the program memory size.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

were you able to flash the bootloader successfully? if so, can you upload code through audio?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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:

Code:
    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:
Quote
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
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Quote
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 Offline
Jr. Member
**
Karma: 0
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: 1 [2] 3 4 5   Go Up
Jump to: