I want to know that How I lock my firmware in atmega328

I want to know how I can lock my firmware on the ATmega328P. I have tried different lock bit values such as 0x3C, 0x0F, 0x2F, 0x00, etc. With 0x3C and 0x00, the firmware dump using avrdude stops, but I am still able to upload new firmware.

From my research, I found that 0x0F should fully lock the chip, meaning we should not be able to dump the firmware or upload new firmware. However, in my case, I am still able to both dump the firmware and upload new code.

I need help in understanding which lock byte setting ensures that nobody can dump or upload new firmware. I have done some research but could not find clear and correct information. If anyone has reliable references or guidance, it would be greatly appreciated.

I don’t want to lock it permanently. After erasing, I just want to be able to burn the bootloader and upload new code, that’s all.

I would also like to know: if we only partially lock the ATmega328P (using lock bits), is it possible that other tools besides avrdude can still dump or read the firmware?

No matter what lock bits you use it will always be possible to upload new firmware.
However, important for securing your code is only that no one can download your precious firmware for the purposes of installing it elsewhere. That is more or less guaranteed with the correct lock bit settings. However, attacks are still possible say by grinding the top off the chip and directly accessing the EEPROM. Some such services have been mentioned on this forum. Example link: Tiny at85 CHIP INFO NEEDED - #41 by dss67

You can make it very difficult for someone to reuse an ATmega328P in that they will need a high voltage programmer to "unbrick" it but I don't think that is the point here. Simple protection against intellectual property theft seems to be the goal.