-1

I ordered ATMEGA328P AU from China recent but I got "ATMEGA328P U-TH". which seem super problematic. I try to use USBasp to burn bootloader but it fail and show error message as shown.

avrdude: error: program enable: target doesn't answer. 1 
avrdude: initialization failed, rc=-1
     Double check connections and try again, or use -F to override
     this check.

which I believed many people face same situation as mine. Then I accidentally found the solution by using Arduino as ISP which successfully birn bootloader. After that I can use USBasp to upload sketch or burn bootloader. I don't understand what happen here. Note: I solder ATMEGA328P U-TH in SMD package to Arduino UNO clone.

-1

If you want to upload a sketch via any other interface than ISP, the atmega needs a bootloader.

The bootloader basically is a piece of software which is stored in a dedicated flash section, the "bootloader section". Code stored in this bootloader section has the special ability to write to parts of flash memory where the actual program is stored (this is called the "application section"). In general, a program can not overwrite its own flash section, so the bootloader and the application need to be stored in different sections/partitions.

In principle, a bootloader can do whatever a normal sketch could do: toggle pins, access eeprom, read UART/I2C/etc... and as it can also write to the "application section", you can make it read data from any interface and transfer it to the application section. This is what happens if you upload code via USBasp (Arduinos have a USB-to-UART converter on board). But of course, this requires that a bootloader is installed.

avrdude: error: program enable: target doesn't answer. 1 - this might sound misleading, what it actually means is, that the bootloader doesn't answer. That makes sense, as the device doesn't have a bootloader.

When there is no bootloader, the only way to upload code is to use ISP, which doesn't need any software to function. It's a hardware functionality that Atmel implements in silicon. A code upload via ISP works in (almost) any case.

2
  • Both usb-asp and Arduino as ISP is the programmer which be able to upload sketch either bootloader. In my question it do the same job to uploader but the chip not answer to usbasp but it work fine with arduino as isp. my inspectation is is about factory setting clock speed of the chip the corelate to programmer clock speed. but still no clue.
    – M lab
    May 3 '21 at 7:20
  • I think bootloader only use with stk500 Serial UART protocol upload.
    – M lab
    May 3 '21 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.