Go Down

Topic: Audioino? (Read 5 times) previous topic - next topic

Nick Gammon


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).

sdinnu


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: [Select]
    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?

Nick Gammon


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.

sdinnu

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.

Nick Gammon

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.

Go Up