right now I'm using a Uno R3 to develop an enhanced lighting for my home office. It will consist of a control unit (which it is here about), and a power stage that will control the lighting itself.
The control unit will have its own PCB, to which a number of encoders and switches are attached, and a control command is send to power stage via I2C bus. Due to length of bus line, the physical layer is changed to CAN in between. Please refer to schematic below.
Of course, software is never perfect, and final integration may - oh, no, will(!) - require software modifications with ATmega328p installed on PCB.
--> So my question is what is - from your point of view - right solution to allow later software upload?
Some conditions / requirements
Installed Bootloader on final "product" is fine. Power-up time is not an issue because control unit will be always on.
It shall be possible to run the Arduino IDE, i.e. connect PC with "something" to the PCB. So, then I can run some tests for new software by serial monitor.
What I have understood so far is that SPI interface allows software upload without bootloader, however, it does not allow to run IDE, i.e. condition 2 is not fulfilled. Additonally - I'm not sure about - if SPI is used there shall be not other hardware attached to the pins. But since I need quite a lot of the GPIOs (in that sense the schematic isn't complete yet), I connected just normal open switches to MISO/MOSI pins.
With bootloader, communication would be done through USART (TxD, RxD). So, it looks to me that a device like this one Amazon: DSD TECH USB zu TTL Seriell Adapter should do the job. What I don't know if such a device allows to run the Arduino IDE ...
Here also a closer view to the adapter:
umpf, so many views on that capacitor... So I triple-checked it, and, well, I'll remove it.
What do you mean by floating? On schematics of Arduino Uno or Nano they are never pulled up ... they just have a 1k resistor between RX<->TX and TX -> RX. But still floating in that sense that there are no external resistors.
No fun, mistake on my side.
Yes, symbol in KiCad is a little misleading. And it is about the ATmega328 in DIP-housing, which has just two GND, one of them is hidden in the symbol (Pin 22). So it is there, and connected (together with Pin 8).
According to data sheet for 328P internal resistor is in the range of 20..50k with typical value of 36k. With 50k current at 5V is 0.1mA ... on my breadboard I haven't used pull-up resistors for none of the four switches, working fine - I just ran a measurement with a scope attached. Nothing to worry about ... but thanks. Now I know the internal pull-up resistor in detail ...
What to say? The 1M is on the schematic on the UNO, but not on the Nano. So far I added to have the capability to add, I guess, I will not install.
"spam" the Serial Monitor of Arduino IDE connected via SPI and configuration of IDE as you have written?
What I struggle with is how does "Serial.println()" knows that the SPI shall be used and not USART? Programming (software download) is a data flow from Arduino IDE downwards to the processor, so a configuration of Arduino IDE will do the right thing. But "Serial.println()" is upwards to IDE - so I assume Serial.println gives a sh*t what the configuration of the IDE is, isn't it?
I don't know enough about the 1MΩ over the crystal. I think the official Uno board has a resonator ?
The RX of the Uno is connected to the usb-serial chip. If it is open (floating) and nothing is connected to it, then it can receive noise. I looked at the schematic of the Arduino Mini, and the RX is open. It is a problem that I ran into with my own barebone board.
I also had some trouble with uploads to a self made board with a 328P on it.
If you want to use the Arduino IDE for editing and debugging (with Serial.print() on the Serial Monitor) then you have to use the UART (RX, TX) in the controller and the controller needs to have the bootloader installed.
To burn the bootloader in a new controller you have to use the ISP interface. For this very first upload you need a programmer. I tried this with a USBasp without success because it works with a higher clock rate than the required <250 kHz. With an Arduino board and the ArduinoISP sketch I could burn the bootloader. Probably other programmers than USBasp can do this too. Be aware that the very first upload can be critical. After the very first upload the 328P runs with its external crystal/resonator at its full speed, and further uploads now are possible also with USBasp.
With the bootloader installed you can use the serial interface (RX, TX) via a USB to serial converter. The DTR output of the USB to serial converter has to be connected to the 328P reset pin via a 100nF capacitor. Now you can upload and test your sketches within the IDE.
An important item to add:
Every upload via ISP destroys the bootloader.
With the bootloader installed you can perform any number of uploads within the IDE - until the maximally allowed programming cycles of the chip.
... it looks as you have already done what I like to do soon! What kind of programmer do you use? The one I shared above does not have the DTR signal (just RTS, which is a different one), the one shared by sterretje has it (so still looking quite attractive) ... Despite, which is the one you use?
And I will delete the SPI interface freeing I/Os. As said, I like to use the Serial Monitor when my application is running in its real environment.