Loading bootloader onto custom nano pcb

I have a project that i have tested and works great on a Arduino Nano and Arduino Nano Every. I would like to create a custom PCB for my project but am confused with loading the bootloader. I have read it is very different for the Nano and the Nano Every, so i can use whichever is easier to work with.
When using either of the devices on actual Arduino boards, i program from the IDE through USB. If i have a new 328P IC, i believe i need to load the bootloader on it so i can then use the USB for programming. Is this correct? To load the bootloader, it looks like i need to use the ICSP port. Is this correct? If so, can i still use those pins in my program as I/O? Currently i use those pins without issue, but i have not tried to use the ICSP port for anything since i program through USB. I would assume that anything also connected to those pins could cause problems with the serial comm while programming. How does this work on the Nano board?
Finally, is there a difference in how to attack this if using the 4809 Every chip versus the 328P nano IC? Why would one be easier than the other?
Thank you

If you want to upload via serial, that is indeed correct.

Yes. Note that you can also upload a sketch directly using ICSP instead of USB.

If you take precautions in your design, you can disconnect whatever is connected to those pins. Use e.g. jumpers or dip switches.

Yes.

I do not know much about the 4809 but uploading is done via UPDI which is significantly different from the approach used for the 328P and you need a special programmer for that; consult the schematic of the Nano Every for some details. Further I think that the 4809 actually does not have a bootloader but I'm not 100% sure.

Because the 4809 is programmed via UPDI it does not need a bootloader, but it needs a UPDI Programmer. The Nano Every has such a programmer on board. The SAMD chip which serves as the serial to USB converter also serves as the UPDI programmer for the 4809 chip.

1 Like

Thank you. This is pretty much what ive read, but i am lost on how i would get the SAMD to be recognized by the Arduino IDE. The info i have found about programming the SAMD is sparce compared to info for the 328P Nano. I assume it would be easier to just use the 328P so i don't have to deal with the SAMD? This is for a new design and i probably won't benefit from the EVERY version of the nano.
With the 328P, i can just use an Arduino as ISP to load the bootloader then it will appear as a standard nano in the IDE, correct?
To be clear, i would like my board to look and act just like an official arduino Nano from the standpoint of the IDE.

You can put together a one time UPDI programmer with an Uno or Nano classic, a 4.7K resistor and a 10uF capacitor.

Use that to load a bootloader from MegaCoreX onto the 4809 (using the serial port of your choice) and after that you can program it serially just like any other Arduino. No SAMD chip required; just the usual serial to USB stuff. Here's a DIP 4809 with an FT232RL USB interface I was tinkering with a while back. You could also use a CH340G or even a 16u2 if you wanted to.

Thank you. With this method, the bootloader resides on the 4809 as opposed to the SAMD?
Is there a reason i should go this way instead of just using the 328P version? I don't need much space for code, so memory should not be an issue.
I would like for this device to show up in the IDE as an arduino Nano or Nano Every. I probably should have just made a socket and put a Nano on the PCB, but i wanted to improve the regulators and add some LEDs. I've only used the IDE with "official" arduinos and did not consider the additional steps to program the arduino if it does not come with the bootloader.

Reason for Nano vs Every - more serial on the Every - up to 4, depending.

Also, ATMEGA328P now 'sunset' - not recommended for new designs - means exactly that. Now, if this is a one-off, probably doesn't matter, but I'd be thinking about at least an ATMEGA328PB, the replacement version, which has, yep, two serial, two I2C, and lots of other nice features. But, no DIP package, if that matters to you.