Finally got to make optiboot work on my custom board. The problem was in that I was incorrectly defining the board in boards.txt. This time I copied the UNO definition and changed f_cpu to 8000000L. Well, now I have enough room to add my calibration routine in the bootloader itself.
Thanks guys for your help!
Daniel.