To flash bootloader to ATmega328P install avrdude and run 
sudo ./flash.sh