Arduino UNO R4 WiFiを買ってArduino ISP(Arduino as ISP)にしてATTiny85の開発をしようとしていたんですが、変なバグ踏んだのでメモ代わりに書き残しておきます。
元リンク:Can I use the R4 minima as an icsp? - UNO R4 Minima - Arduino Forum
(↑のArduino ForumスレッドのPost#4とその先のプルリクに全部書いてありますが)
Arduino IDE公式スケッチ例の"ArduinoISP"のソースコードはPIN_{MOSI,MISO,SCK}という名前のマクロを含んでいて、これがArduino UNO R4 Minima/WiFiのボード側のコードと名前衝突してしまっていて、まともに動かないようです。
対策としては↑のリンクに修正版のArduino ISPのソースコードが置いてあるので、公式スケッチ例を使わずにそっちをコピペしてUNOに焼けばいいようです。
また、書き込み装置も"Arduino ISP"じゃなくて"Arduino as ISP (ATmega32U4)"(手元だと"Arduino Leo/Micro as ISP (ATMega32U4)")を使えとのことです。
私の手元ではまだArduino IDE 1.8.19を使っていてこの問題を踏んでいたので、ATTiny85を接続して書き込もうとすると以下のようなエラーが出て、Arduino ISPへの接続自体が失敗していました。
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
また、書き込み時のコマンドラインのプログラマがstk500v1になってたのも気になっていたので、コマンドラインからavrdude -c arduinoで接続を試みても以下のような感じでDevice Signatureが空になってしまいました。やっぱりちゃんと接続できてないようですね。
avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.
何度接続ピン見直しても繋がらないのでATTiny85壊れたかと思ってFUSEリセットをやってみたら、FUSEリセット用のプログラムでは全然問題なく接続できたので、もしやArduino ISPがバグってるんじゃ…?と疑ってググったらこんな話でした、というオチです。
その他注意点としては、Arduino UNO R4はArduino AVR BoardsじゃなくてArduino Renesas UNO R4 Boardsという別のパッケージが必要になるくらいですかね。
追記:
Arduino IDEを2.3.2にアップグレードしたところ、Arduino ISPのソースコードの名前衝突問題は修正されていて、公式のスケッチ例がそのまま使えるようになってました。
書き込み装置の方はやっぱり"Arduino as ISP"はstk500v1になっててダメなので、相変わらず"Arduino Leo/Micro as ISP (ATMega32U4)"を使わないといけないようです。