I have started an automated indoor nursery project and have encountered a bootloader problem. I have designed a PCB that allows for multiple components to function on (pumps, sensors, relays, wifi module). I've been told by my peers and professors that it is very likely to be a bootloader problem. I'm new to troubleshooting bootloader issues so this has been fairly difficult obstacle to figure out. I am using an Arduino Uno R3 as my programmer. I will attach the links I've used to attempt and overcome this issue as well as the .json files for my schematic and PCB design. Also this is being programmed via Arduino IDE.
Thank you for your help!
When I connect my Uno R3 it automatically detects which port it is connected to. When I connect my designed PCB with an ATmega2560 mcu the port selection is greyed out.
I use a USBasp version 2 programmer with a cable and a 10-pin to 6-pin adapter. It is harder with a Arduino Uno as programmer. It is also harder for Arduino Mega board (but I forgot why).
Have you changed fuses ? The ATmega chips need a clock to work with a programmer. If you set an external clock and that clock is missing, then you can not burn firmware/bootloader into it.
There are not enough decoupling capacitors near the ATmega2560.
Have you compared your schematic with the official Arduino Mega ? You don't have a diode at the /RESET pin. Without that diode, the ATmega chip could turn into HV (High Voltage programming) mode and change the bootloader.
Do you have another Arduino Uno ? I suggest to first try to put a sketch in a Arduino Uno with a programmer (overwriting the bootloader) and then burn the bootloader back into it.
How are you connecting your ArduinoAsISP? I don’t see an ICSP header for either the ATmega2560 or the ATmega32u4.
I see you have a socket for an ESP8266 but it has a ground plane near the antenna so the wireless range may be limited. It is preferable to have the antenna extend past the edge of the circuit board or at least have the part of the board under the antenna not have any copper.
-->I will attempt the guide and let you know how it goes. Currently trying to get my components to work on just the Arduino Mega 2560 build because I'm short on time for my project.
-->That diode is not present in my design but all other components near those ICSP pins are. How exactly without that diode could the ATmega chip turn in HV mode and change the bootloader? Which ATmega chip will turn HV mode and which bootloader gets changed. Excuse me for my confusion.
-->Yes so we are going to attempt to flash our program to a preexisting Arduino Mega 2560 and ignore the schematic at this point. Mainly dealing with getting the ESP8266-01 to connect via the Arduino Mega 2560. But that last part, you mean after the Arduino Mega 2560 is flashed with my finished program. To then burn the bootloader onto the my PCB design?
-->So I've been following this set up. I am using an Arduino Uno R3 as Arduino as ISP (with my pc connected to the USB-B port in order to flash and power). My Target Arduino is my designed PCB with a ATmega2560 mcu. Pins MOSI, MISO, SCK, +5V, and GND are found either at the legs of the mcu or at the contact holes where the camera module is inserted. Since those pins are directly connected to the mcu thanks to vias I use those contact holes. For the RST pin I had to solder it on directly onto the mcu leg.
If you want a bootloader on the ATmega2560, then I assume that you want to upload a sketch via the RX/TX lines. To do that, you probably need a 100nF capacitor from the DTR signal to the /RESET pin.
Because of that 100nF capacitor, it can lift the /RESET to almost 10V for a short pulse when the DTR is going from 0V to 5V. That is enough to turn on High Voltage programming to corrupt the bootloader.