Browse Source

Install arduino IDE

master
Jeckel 6 months ago
parent
commit
074a547621

+ 6
- 1
roles/arduino/defaults/main.yml View File

@@ -1,4 +1,9 @@
1 1
 ---
2
-arduino_version: "1.8.18"
2
+arduino_version: "1.8.13"
3
+
4
+#https://www.arduino.cc/download_handler.php?f=/arduino-1.8.13-linuxarm.tar.xz
5
+#arduino_ide_url: "https://downloads.arduino.cc/arduino-1.8.13-linuxaarch64.tar.xz"
3 6
 arduino_ide_url: "https://downloads.arduino.cc/arduino-{{ arduino_version }}-linuxarm.tar.xz"
4 7
 arduino_download_directory: /opt/arduino
8
+
9
+arduino_port: "/dev/ttyACM0"

+ 43
- 0
roles/arduino/tasks/main.yml View File

@@ -9,3 +9,46 @@
9 9
 - name: "install inotool with pip"
10 10
   pip:
11 11
     name: ino
12
+
13
+- name: Create Arduino download directory.
14
+  become: yes
15
+  file:
16
+    state: directory
17
+    path: "{{ arduino_download_directory }}"
18
+    mode: "0755"
19
+    owner: root
20
+    group: root
21
+
22
+- name: Download Arduino IDE and checksum files.
23
+  become: yes
24
+  get_url:
25
+    url: "{{ arduino_ide_url }}"
26
+    dest: "{{ arduino_download_directory }}/{{ arduino_ide_url|basename }}"
27
+
28
+- name: Extract Arduino archive.
29
+  become: yes
30
+  unarchive:
31
+    src: "{{ arduino_download_directory }}/{{ arduino_ide_url|basename }}"
32
+    dest: "{{ arduino_download_directory }}/"
33
+    remote_src: yes
34
+    creates: "{{ arduino_download_directory }}/arduino-{{ arduino_version }}"
35
+
36
+- name: Install Arduino IDE.
37
+  become: yes
38
+  command: "{{ arduino_download_directory }}/arduino-{{ arduino_version }}/install.sh"
39
+  # Cheating a bit and chaining the install.sh logic with directory extraction,
40
+  # to maintain idempotence.
41
+  args:
42
+    creates: "{{ arduino_download_directory }}/arduino-{{ arduino_version }}"
43
+
44
+- name: Installs Arduino helper scripts.
45
+  become: yes
46
+  template:
47
+    src: "{{ item }}"
48
+    dest: "/usr/local/bin/{{ item.rstrip('.j2') }}"
49
+    mode: "0755"
50
+    owner: root
51
+    group: root
52
+  with_items:
53
+    - arduino-push.j2
54
+    - arduino-verify.j2

+ 18
- 0
roles/arduino/templates/arduino-push.j2 View File

@@ -0,0 +1,18 @@
1
+ 
2
+#!/bin/bash
3
+# {{ ansible_managed }}
4
+set -e
5
+
6
+
7
+# Ensure sketchfile is provided as an argument. This is the code file
8
+# that will be compiled and pushed to the Arduino board.
9
+if [[ -z "$1" ]]; then
10
+    echo "Usage: $0 <sketchfile>"
11
+    exit 1
12
+fi
13
+
14
+# Declare path to Arduino binary. Will change according to Arduino version use.
15
+ARDUINO_BINARY="/opt/arduino/arduino-{{ arduino_version }}/arduino"
16
+
17
+# Push code file to Arduino board
18
+$ARDUINO_BINARY --port "{{ arduino_port }}" --upload "$1"

+ 17
- 0
roles/arduino/templates/arduino-verify.j2 View File

@@ -0,0 +1,17 @@
1
+#!/bin/bash
2
+# {{ ansible_managed }}
3
+set -e
4
+
5
+
6
+# Ensure sketchfile is provided as an argument. This is the code file
7
+# that will be compiled and its results reported.
8
+if [[ -z "$1" ]]; then
9
+    echo "Usage: $0 <sketchfile>"
10
+    exit 1
11
+fi
12
+
13
+# Declare path to Arduino binary. Will change according to Arduino version use.
14
+ARDUINO_BINARY="/opt/arduino/arduino-{{ arduino_version }}/arduino"
15
+
16
+# Build and verify code file without pushing to board.
17
+$ARDUINO_BINARY --verify "$1"

Loading…
Cancel
Save