how arduino bootloader work ?

I don't know the answer to your questions, but I think this is a good starting point: