Wow, thank you so much for this work, I appreciate it. I understand it might take a few back-and-forths since you don't have a 164p on hand, but I'll try my best... I haven't done this stuff before, so if we could go a little bit step-by-step that'd be great.
Here's what I've done so far.
-
I copied the hardware/sanguino folder as hardware/sanguino164p, and changed the board name in the new boards.txt to match.
-
I noticed there was no optiboot in the sanguino bootloaders, so I copied the folder from hardware/arduino/bootloaders/optiboot to my new hardware/sanguino164p/bootloaders/optiboot
-
I copy/pasted your patch code, and created a file with it, patch.txt, and placed it in hardware/sanguino164p/bootloaders/optiboot
-
I ran patch -p1 < patch.txt and it couldn't find the files to patch because the addresses were /optiboot/bootloaders/optiboot/Makefile etc. so I made a patch2.txt adjusting the addresses all to ie. --- a/Makefile etc.
-
I then get 'Hunk #1 FAILED' errors, eg.
patching file Makefile
Hunk #1 FAILED at 265.
1 out of 1 hunk FAILED
If you could let me know where I've gone wrong, that'd be great.
------- EDIT -------
I realized that though the Sanguino distribution didn't come with optiboot, you must have been using the one directly from Google-code. So I cloned that, tried the patch there, and got :
patch -p1 < patch.txtpatching file optiboot/bootloaders/optiboot/Makefile
patching file optiboot/bootloaders/optiboot/makeall
patching file optiboot/bootloaders/optiboot/optiboot.c
patching file optiboot/bootloaders/optiboot/pin_defs.h
Hunk #1 FAILED at 44.
Reading up on the patch file syntax, still not sure why the last hunk failed, so I replaced the ifdef manually and tried to compile with make atmega164. I got this output :
optiboot$ make atmega164
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega164p -DF_CPU=16000000L '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' -c -o optiboot.o optiboot.c
optiboot.c: In function ‘main’:
optiboot.c:420:3: error: ‘LED_DDR’ undeclared (first use in this function)
optiboot.c:420:3: note: each undeclared identifier is reported only once for each function it appears in
optiboot.c:420:14: error: ‘LED’ undeclared (first use in this function)
optiboot.c: In function ‘flash_led’:
optiboot.c:746:5: error: ‘LED_PIN’ undeclared (first use in this function)
optiboot.c:746:16: error: ‘LED’ undeclared (first use in this function)
make: *** [optiboot.o] Error 1