1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[Teensy 4.1@Ubuntu20.04] Arduino IDEを使って遊ぶ

Posted at

Teensy 4.1は高機能・低価格なマイコンボードである.
ボードも小さいのも組み込み系には嬉しい.

  • スペック[1]
    • ARM Cortex-M7 at 600 MHz
    • Float point math unit, 64 & 32 bits
    • 7936K Flash, 1024K RAM (512K tightly coupled), 4K EEPROM (emulated)
    • QSPI memory expansion, locations for 2 extra RAM or Flash chips
    • USB device 480 Mbit/sec & USB host 480 Mbit/sec
    • 55 digital input/output pins, 35 PWM output pins
    • 18 analog input pins
    • 8 serial, 3 SPI, 3 I2C ports
    • 2 I2S/TDM and 1 S/PDIF digital audio port
    • 3 CAN Bus (1 with CAN FD)
    • 1 SDIO (4 bit) native SD Card port
    • Ethernet 10/100 Mbit with DP83825 PHY
    • 32 general purpose DMA channels
    • Cryptographic Acceleration & Random Number Generator
    • RTC for date/time
    • Programmable FlexIO
    • Pixel Processing Pipeline
    • Peripheral cross triggering
    • Power On/Off management

存在自体は知っていたものの、今まで手に入れる機会がなかったが、今回巡り合わせたので、早速Arduino IDEで遊んでいく.

1. IDEにTeensyduinoをインストールする

基本的なインストール方法は、以下のURL[2]を参考にする.
https://www.pjrc.com/teensy/td_download.html

Arduino IDE 1.8.19以上であれば、ボードマネージャーからインストールできる.
以下のURLを設定の追加のボードマネージャURLに追加する.

https://www.pjrc.com/teensy/package_teensy_index.json

次に、ボードマネージャを開き、「teensy」と入力して、ダウンロードする.
インストールが完了したら、これでArduino IDEで行うことは終わり.

2. Teensyのudevルールを書き込む

以下のように、udevルールファイルを作成し、Teensyを認識させる.

sudo nano /etc/udev/rules.d/00-teensy.rules
00-teensy.rules
# UDEV Rules for Teensy boards, http://www.pjrc.com/teensy/
#
# The latest version of this file may be found at:
#   http://www.pjrc.com/teensy/00-teensy.rules
#
# This file must be placed at:
#
# /etc/udev/rules.d/00-teensy.rules    (preferred location)
#   or
# /lib/udev/rules.d/00-teensy.rules    (req'd on some broken systems)
#
# To install, type this command in a terminal:
#   sudo cp 00-teensy.rules /etc/udev/rules.d/00-teensy.rules
#
# After this file is installed, physically unplug and reconnect Teensy.
#
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04*", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{ID_MM_PORT_IGNORE}="1"
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789a]*", ENV{MTP_NO_PROBE}="1"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04*", MODE:="0666", RUN:="/bin/stty -F /dev/%k raw -echo"
KERNEL=="hidraw*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04*", MODE:="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04*", MODE:="0666"
KERNEL=="hidraw*", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="013*", MODE:="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="013*", MODE:="0666"

#
# If you share your linux system with other users, or just don't like the
# idea of write permission for everybody, you can replace MODE:="0666" with
# OWNER:="yourusername" to create the device owned by you, or with
# GROUP:="somegroupname" and mange access using standard unix groups.
#
# ModemManager tends to interfere with USB Serial devices like Teensy.
# Problems manifest as the Arduino Serial Monitor missing some incoming
# data, and "Unable to open /dev/ttyACM0 for reboot request" when
# uploading.  If you experience these problems, disable or remove
# ModemManager from your system.  If you must use a modem, perhaps
# try disabling the "MM_FILTER_RULE_TTY_ACM_INTERFACE" ModemManager
# rule.  Changing ModemManager's filter policy from "strict" to "default"
# may also help.  But if you don't use a modem, completely removing
# the troublesome ModemManager is the most effective solution.

最後に、ルールを読み込む.

sudo udevadm control --reload-rules

うまく行けば、/dev/ttyACM*として、認識される.

/dev/ttyACM*でないんだが?

  1. USBの抜き差しをする
  2. とりあえず、次の工程に進む.Arduino IDEでコンパイルすると認識されることもあるかも.
  3. それでも認識されないならrebootしてみよう

3. Arduino IDEでサンプルプログラムを動かそう

いつもの通り、Lチカを行う.
以下のプログラムを書き込む.

#define LED_BUILTIN (13)  // LEDのピン

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

ボードをTeensy 4.1に設定し、書き込むボタンを押すと、Teensyと書かれたwindowが自動的に立ち上がり、Reboot OKと表示されたら成功だ.

参考

[1] https://www.pjrc.com/store/teensy41.html
[2] https://www.pjrc.com/teensy/td_download.html

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?