Hello,
First of all thank you for your responses.
I completely forgot about optiboot. I remember setting up the IDE to get a broad overview and after installing MegaTinyCore just moving on and digging through the datasheet and working on designs already.
So my understanding thanks to you westfw and reading through optiboot's wiki is that I need two serial adapters. One to do the initial flash/burning of the bootloader using udpi, and one that interfaces with the bootloader using uart so that I can now send debug messages using the known Serial-library and can flash firmware over that as well.
I am a bit confused about what settings to use for both of these requirements, as I actually need to use the pins used for UART0 for my project and would like to move UART to UART1 in that case.
I saw on some other post that there is a Serial.swap() function that does this for me inside my program, but I'm wondering how to burn the bootloader so that it uses UART1 for flashing the firmware (and I assume that would also make a Serial.swap() call moot?).
In the boards manager I can select my MCU with the optiboot option and without.
I would assume that I would have to use the option without at first to burn the bootloader since then the menu also/still has the "burn bootloader" option listed. But in that case I don't see a "UART for bootloader" option listed, which means I would end up with UART0 for the bootloader.
I feel like the "burn bootloader" option when optiboot is not chosen in the boards manager is just a remnant the arduino ide has by default, and that I should immediately pick the "w optiboot" option, set the "UART for bootloader", set the programmer, and then use "burn bootloader", is that correct?
Furthermore, I am still confused about the reset pin. I understand that there is a fuse to control the setting of that pin, and that if you don't set it to anything with UPDI, then the 12V programming sets in.
What confuses me is that in the datasheet this pin is by default both the UPDI and reset pin. Can this be explained with settings I see in the arduino ide ("updi, optiboot for 8 sec. after power on & reset")? Does this mean the pin by default is updi in the beginning for a predefined amount of time (or when it is pulled to a specific level upon power up), then the bootloader takes over, and then it functions as a reset pin? I'm also confused about the 8 seconds, or rather, what they mean specifically, since it seems different from the "startup time" one can configure?
Given that my assumption is somewhat correct, and the pin is UPDI in the beginning, and then has reset functionality, what would a good hardware implementation look like? I see the Reset pin according to the datasheet wants a extra 100nf capacitor (unless that happens to be the one already used for the power up pin), and a 330Ohm debouncing(?) resistor. However I have seen a report of this wiring causing issues with UPDI functionality which I conveniently now cannot find in between my pile of bookmarks. The datasheet of the 1627 (I managed to screw up, and just now realized I kept writing 1624 even though I have the 1627) just shows the two capacitors for the power supply and shows to just wire up UPDI directly (for programming).
Oh, and in accordance to your mentioning of the pin count and alternate reset pin, I have the chip in the VQFN-24 package, so I should have an alternate reset pin.
Oh, and also, I'm a bit unsure about the correct modification of a UART adapter. The wiki lists multiple options, one using a diode, one a resistor. I don't have schottky diodes at hand, and it would influence where I place my order, should I have both resistors and diodes at hand because my mileage with a just resistor solution could vary and I might have to use a diode?
And another question. How does the flashing actually work in regards to powering on the device?
Does the serial adapter power cycle the device in the beginning of the flashing, or do I have to do that before and then hurry up in a predefined(?) amount of time and start the flashing process, or does it not matter at all (for example with optiboot and it always listens for a specific data sequence and then starts flashing)?
In regards to your expertise and solution 6v6gt:
I was under the (wrong) assumption that I could not use serial to flash the MCU due to my misinformation and insufficient knowledge about optiboot. Given that I apparently only need to flash the MCU using UPDI once and then can resort to a different UART adapter that serves as both my serial debugging output as well as my flashing device, for my workflow it seems somewhat moot to have a combined device now. But I'll keep that in mind if actually doing it this way seems to be a bit bothersome and I would end up preferring a solution of a 2in1 device.