user67594: Currently I am using avrdude and I'm programming my atmega328p chip via the spi pins by pulling the RESET pin low (spidev programmer).
In my project I'm using predominantly i2c and this the only place where spi is used. I was wondering whether it is possible to program the chip via the i2c protocol and remove the spi connections altogether?
My searches were unsuccessful.

user313: From section 27.2(*) of the Atmega328xx data sheet (emphasis mine):

In ATmega88A/88PA/168A/168PA/328/328P the Boot Loader Support provides
a real Read-While-Write Self- Programming mechanism for downloading
and uploading program code by the MCU itself. This feature allows
flexible application software updates controlled by the MCU using a
Flash-resident Boot Loader program. The Boot Loader program can use
any available data interface and associated protocol to read code and
write (program) that code into the Flash memory, or read the code from
the program memory. The program code within the Boot Loader section
has the capability to write into the entire Flash, including the Boot
Loader memory. The Boot Loader can thus even modify itself, and it can
also erase itself from the code if the feature is not needed anymore.
The size of the Boot Loader memory is configurable with fuses and the
Boot Loader has two separate sets of Boot Lock bits which can be set
independently. This gives the user a unique flexibility to select
different levels of protection.

You may need to re-write the input section of the bootloader, but it sure sounds like Atmel intended it to be doable.
[*] My data-sheet is dated 2018; the relevant section, Section 27, is titled "Boot Loader Support – Read-While-Write Self-Programming", in case a later revision has different section numbers.

user87849: Yes, as JRobert pointed out, I have no doubt - it is possible!
You need just 3 things:

a Bootloader that supports uploading the firmware via I2C
an Upload-Software that supports uploading the firmware to the bootloader mentioned in 1.)
an physical connection from the system the upload software is running on to the actual I2C bus of your device

Actually the physical interface is not the problem - there are USB<>I2C interfaces available widely, you can also re-use an arduino itself to be such.
Let's look at the bootloader.
Actually I found a german site that claims having a working I2C bootloader for Atmega8 including an upload tool (use Deepl.com to translate it). It may or may not work for other Atmegas as is.
There is also another project at github.
There will be more if you google for it. Actually I have not investigated any of them.
But chances are good than any of those might work for you.

67594: <p>Currently I am using <code>avrdude</code> and I'm programming my <code>atmega328p</code> chip via the <code>spi</code> pins by pulling the RESET pin low (spidev programmer).</p>
<p>In my project I'm using predominantly <code>i2c</code> and this the only place where <code>spi</code> is used. I was wondering whether it is possible to program the chip via the <code>i2c</code> protocol and remove the <code>spi</code> connections altogether?</p>
<p>My searches were unsuccessful.</p>
 313: <p>From section 27.2(*) of the Atmega328xx data sheet (emphasis mine):</p>
<blockquote>
<p>In ATmega88A/88PA/168A/168PA/328/328P the Boot Loader Support provides
a real Read-While-Write Self- Programming mechanism for downloading
and uploading program code by the MCU itself. This feature allows
flexible application software updates controlled by the MCU using a
Flash-resident Boot Loader program. <strong>The Boot Loader program can use
any available data interface and associated protocol to read code and
write (program) that code into the Flash memory,</strong> or read the code from
the program memory. The program code within the Boot Loader section
has the capability to write into the entire Flash, including the Boot
Loader memory. The Boot Loader can thus even modify itself, and it can
also erase itself from the code if the feature is not needed anymore.
The size of the Boot Loader memory is configurable with fuses and the
Boot Loader has two separate sets of Boot Lock bits which can be set
independently. This gives the user a unique flexibility to select
different levels of protection.</p>
</blockquote>
<p>You may need to re-write the input section of the bootloader, but it sure sounds like Atmel intended it to be doable.</p>
<p>[*] My data-sheet is dated 2018; the relevant section, Section 27, is titled &quot;Boot Loader Support – Read-While-Write Self-Programming&quot;, in case a later revision has different section numbers.</p>
 87849: <p>Yes, as JRobert pointed out, I have no doubt - it is possible!</p>
<p>You need just 3 things:</p>
<ol>
<li>a Bootloader that supports uploading the firmware via I2C</li>
<li>an Upload-Software that supports uploading the firmware to the bootloader mentioned in 1.)</li>
<li>an physical connection from the system the upload software is running on to the actual I2C bus of your device</li>
</ol>
<p>Actually the physical interface is not the problem - there are USB&lt;&gt;I2C interfaces available widely, you can also re-use an arduino itself to be such.</p>
<p>Let's look at the bootloader.</p>
<p>Actually I found a german site that claims having a working <a href="https://old.ethersex.de/index.php/I2C_Bootloader" rel="nofollow noreferrer">I2C bootloader for Atmega8</a> including an upload tool (use Deepl.com to translate it). It may or may not work for other Atmegas as is.</p>
<p>There is also <a href="https://github.com/tspspi/ATMega328PBootloaderI2C" rel="nofollow noreferrer">another project at github</a>.</p>
<p>There will be more if you google for it. Actually I have not investigated any of them.</p>
<p>But chances are good than any of those might work for you.</p>
