Bootloader programming : Do not know how to make File target `ATmega328P'

I am new PlatformIO and getting acquainted with Arduino. I am trying to burn bootloader from PlatformIO but not able to succeed. I am getting error:

Do not know how to make File target `ATmega328P’

Below is the screenshot. platform.ini looks like this:

platform = atmelavr
board = ATmega328P
framework = arduino
lib_deps =
lib_compat_mode = off
test_build_src = yes

Please help.

Where did youread that you’re supposted to execute pio run --target ATmega328P? It’s supposted to be pio run -t bootloader.


I derived it from the same documentation where it is mentioned pio run --target.
I tried doing what you recommended but I am getting this error shown below.

I specified upload_port in platformio.ini but still getting same error.

Well how are you usually uploading your firmware onto the ATMega328P? Via some ISP programmer or via USB-to-UART and Optiboot?

As far as I understand those terms, I am using ISP programmer.
If I use arduino ide, first I have to burn bootloader and then upload code. I am trying to do it in platformio as I want to write test code and arduino ide doesn’t support much of testing libraries.
PS- Could you please recommend any online course/resources to learn the whole firmware programming - (not the coding part as I am SDE and can code in c/c++ but hardware part, microcontrollers, communication interfaces and development tools. Would be much grateful.