@mocketech (Kiyotaka ATSUMI)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

Arduino IDE 1.8系でSeeedStudio XIAO nRF52840のSerialのコンパイルが通らない

解決したいこと

SeeedStudio XIAO nRF52840でArduino IDE 1.8系を使った時に素直にUSBのSerial使えるようにしたいのですが、原因は分かりますでしょうか?

発生している問題

以下のプログラムをArduino IDE 1.8.19でビルドするとエラーが発生します。

void setup() {
  Serial.begin(115200);
  while (!Serial);
}

void loop() {
  Serial.println("test");
  delay( 1000);
}

エラーの内容はこちら。

Arduino:1.8.19 (Linux), ボード:"Seeed XIAO nRF52840 Sense, S140 7.3.0, Level 0 (Release)"

警告:「Adafruit SPIFlash」ライブラリに誤ったフォルダ.codespellがあります
警告:ライブラリTracker T1000 E LoRaWAN Examplesのカテゴリ「IoT」は有効ではありません。「Uncategorized」に設定します。
/home/user/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: sketch/sketch_may25a.ino.cpp.o: in function `setup':
/home/user/Arduino/sketch_may25a/sketch_may25a.ino:4: undefined reference to `Adafruit_USBD_CDC::begin(unsigned long)'
/home/user/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /home/user/Arduino/sketch_may25a/sketch_may25a.ino:5: undefined reference to `Adafruit_USBD_CDC::operator bool()'
/home/user/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /home/user/Arduino/sketch_may25a/sketch_may25a.ino:6: undefined reference to `Serial'
/home/user/.arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: sketch/sketch_may25a.ino.cpp.o: in function `loop':
/home/user/Arduino/sketch_may25a/sketch_may25a.ino:10: undefined reference to `Serial'
collect2: error: ld returned 1 exit status
exit status 1
ボードSeeed XIAO nRF52840 Senseに対するコンパイル時にエラーが発生しました。


「ファイル」メニューの「環境設定」から
「より詳細な情報を表示する:コンパイル」を有効にすると
より詳しい情報が表示されます。

一方、以下のこのIssueの内容によると、#include "Adafruit_TinyUSB.h"を追加すると正常にコンパイルできます。また、手元で調べた限りですが、#include <Wire.h>を追加しても正常にコンパイルできます。

いずれにしても、オリジナルコードに無関係な行を追加するのは、メンテナンス上の不都合になる可能性があります。できれば、そのような行を追加せずに正常にコンパイルできるようにしたいのですが、何か良い方法はありますでしょうか?

0 likes

mbed-enabled でないボードでは include 文を追加するように、と公式 wiki に書いてあります。

  1. If you use the onboard package of Seeed nRF52 Boards, the Serial function may not compile. The solution is to add the line "#include <Adafruit_TinyUSB.h>" in your code. You can download this package from: https://github.com/adafruit/Adafruit_TinyUSB_Arduino
  2. If you prefer a simpler approach, you can choose Seeed nRF52 mbed-enabled Boards from the beginning. It supports the compilation of the Serial function without the need for additional modifications.

1Like

Your answer might help someone💌