Finally found the solution!
First I compiled and flashed optiboot+fuse&lock-bits using the makefile in $ARDUINO_HOME/hardware/arduino/bootloaders/optiboot (command 'make atmega328_isp') . When I still was having issues uploading sketches, I checked the ~/.arduino/preferences.txt-file, where I previously had changed the line 'upload.using=bootloader' to 'upload.using=stk500'. I thought I had changed it back to bootloader, but I hadn't.. So I changed it to use the bootloader and everything is now aok
So thanks for the help Coding Badly!
And if anyone else needs the commands and bits, this is how to upload the bootloader to the atmega328p using stk500, the right way:
- set fuses and lock bits:
avrdude -c stk500 -p atmega328p -P /dev/ttyS0 -b 115200 -e -u -U lock:w:0x3f:m -U efuse:w:0x05:m -U hfuse:w:0xDE:m -U lfuse:w:0xFF:m
- burn bootloader, and set lock bits to lock bootloader section:
avrdude -c stk500 -p atmega328p -P /dev/ttyS0 -b 115200 -U flash:w:optiboot_atmega328.hex -U lock:w:0x0f:m
And voila, you can use the Arduino IDE again!