2022年4月7日 星期四

Setup Arduino IDE for Digispark Attiny85 on Linux

Digispark Attiny85 Linux driver
Digispark and compatible boards


Arduino IDE Digispark Linux Mint Setup Tutorial Steps

The following steps show how to set up a Digispark board for programming with the Arduino IDE in Linux Mint.

1. Install the Arduino IDE

Go to the Arduino website and download and install the Arduino IDE.

Download the Linux 64 bits file for 64-bit Linux Intel systems or the Linux 32 bits file for Linux 32-bit Intel systems. There are also equivalent files for 32-bit and 64-bit ARM systems. Unzip the downloaded file, and extract the folder found in the zipped file to a convenient location, such as the Desktop. To run the Arduino IDE application, open the extracted folder and double-click the Arduino executable file.

The image below shows the contents of the folder extracted from the downloaded zipped file, with the Arduino application selected. Simply double-click this file to start the Arduino IDE application.

Unzipped Arduino IDE folder with Arduino application highlighted

After double-clicking the Arduino executable file, a dialog box pops up, as shown below. Click the Run button in the dialog box to start the Arduino IDE application.

Arduino run dialog box in Linux Mint

2. Install the Digispark Board Support Package

Start the Arduino IDE application that you downloaded in the previous step.

Open Preferences Dialog box

From the top menu of the Arduino IDE application, select File → Preferences to open the Preferences dialog box.

Paste the following in the Additional Boards Manager URLs: box of the Preferences dialog box.

http://digistump.com/package_digistump_index.json

The image below shows the Additional Boards Manager URLs field of the Preferences dialog box.

Additional Boards Manager URLs field of the Arduino IDE Preferences dialog box

Click the OK button to close the dialog box.

Open Boards Manager Dialog Box

In the Arduino IDE, use the top menu to navigate to Tools → Board → Boards Manager... to open the Boards Manager dialog box.

Type Digispark into the search field at the top of the Boards Manager dialog box that contains the text "Filter your search..." to easily find the Digispark package.

After filtering the packages, Digistump AVR Boards is displayed in the Boards Manager dialog box. Click the Install button at the bottom right of the Digistump item in the dialog box, as shown in the image below.

Digispark board support package in the Arduino IDE Boards Manager dialog box

After clicking the Install button, the package will start installing. This may take a while, depending on the internet speed.

When installation completes, click the Close button at the bottom right of the dialog box.

3. Add Linux User Name to the Dialout Group(I didn't do this on ubuntu)

In order to be able to program any board from the Arduino IDE, the Linux user must be added to the dialout group.

Open a terminal window in Linux and enter the following command:

sudo adduser $USER dialout

Enter your Linux password when prompted.

You will need to log out and then log back in, or reboot, for the changes to take effect.

4. Add udev Rules to the System

To be able to program the Digispark board from the Arduino IDE in Linux, udev rules must be added to the system. This is done by creating a file in /etc/udev/rules.d/ that contains the rules.

Create a text file called 49-micronucleus.rules in /etc/udev/rules.d/ and add the following rules to it.

# UDEV Rules for Micronucleus boards including the Digispark.
# This file must be placed at:
#
# /etc/udev/rules.d/49-micronucleus.rules    (preferred location)
#   or
# /lib/udev/rules.d/49-micronucleus.rules    (req'd on some broken systems)
#
# After this file is copied, physically unplug and reconnect the board.
#
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
#
# 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.

In order to be able to create this file in the file system, you will need root permission. This can be done by opening a terminal window and entering:

sudo nano /etc/udev/rules.d/49-micronucleus.rules

The above line opens a new file called 49-micronucleus.rules with root permission from /etc/udev/rules.d/ in the nano command line text editor.

After running the above line to start the nano editor, copy all of the udev rules code from the listing above and paste them into the nano editor using the keyboard combination Ctrl + Shift + V.

In the nano editor, press Ctrl + O and then press the Enter key save the file and then Ctrl + X to exit the application.

Finally enter the following in the terminal window to reload the udev rules.

sudo udevadm control --reload-rules

5. Testing the Digispark Linux Mint Installation

Uploading a sketch to a Digispark board works differently from other Arduino boards. The board must not be plugged into a USB port, but must first be selected in the Arduino IDE. No port is selected. The sketch is uploaded, and when a prompt appears in the Arduino IDE, the board is plugged into a USB port. The following tutorial steps show how to load a sketch to a Digispark board.

Digispark Blink Sketch

The following sketch works on both Model A and Model B Digispark boards. The difference is that Model A boards have the on-board LED connected to pin 1, while the Model B boards have the on-board LED connected to pin 0.

Copy the following sketch and paste it into the Arduino IDE window. Save it as digispark_blink or a name of your choice.

void setup() {                
  pinMode(0, OUTPUT);      // LED on Model B
  pinMode(1, OUTPUT);      // LED on Model A   
}

void loop() {
  digitalWrite(0, HIGH);   // Turn the LED on
  digitalWrite(1, HIGH);
  delay(1000);             // Wait for a second
  digitalWrite(0, LOW);    // Turn the LED off
  digitalWrite(1, LOW); 
  delay(1000);             // Wait for a second
}

Select the Digispark Board in the Arduino IDE

From the top menu in the Arduino IDE, select Tools → Board → Digistump AVR Boards → Digispark (Default - 16.5MHz) to select the Digispark board.

Load the Blink Sketch to the Digispark Board

Click the Arduino Upload button on the top toolbar before plugging the Digispark board into a USB port.

Wait for the prompt at the bottom of the Arduino IDE window, as shown in the following image.

Arduino IDE with Digispark uploader prompting for device to be plugged in

When the prompt Plug in device now... (will timeout in 60 seconds) appears, plug the Digispark board into a USB port of the computer.

After the sketch finishes uploading, a success message running: 100% complete and >> Micronucleus done. Thank you! appears at the bottom of the Arduino IDE window, as can be seen in the following image.

Arduino IDE displaying Digispark upload success message

資料來源:https://startingelectronics.org/tutorials/arduino/digispark/digispark-linux-setup/


儘管以 root 身份運行 arduino IDE 並創建這些文件,但我仍然收到此錯誤:



/etc/udev/rules.d/49-micronucleus.rules AND /lib/udev/rules.d/49-micronucleus.rules:

代碼:[選擇]

SUBSYSTEMS=="usb", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666", GROUP="dialout"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666", ENV{ID_MM_DEVICE_IGNORE}="1"


/etc/udev/rules.d/90-digispark.rules 和 /lib/udev/rules.d/90-digispark.rules:
代碼:[選擇]

SUBSYSTEMS=="usb", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666", ENV{ID_MM_DEVICE_IGNORE}="1"


(我還嘗試了 sudo cp 90-digispark.rules /etc/udev/rules.d/90-digispark.rules,正如預編譯二進制壓縮包中的 README.udev 所建議的那樣。)


我正在嘗試上傳示例/Digispark/開始草圖,但是,當我插入我的 Digispark kickstarter 版本 rev2(當請求時)時,它在上傳時達到 79%,然後失敗:


代碼:[選擇]

Running Digispark Uploader...
Plug in device now...
> Please plug in the device ...
> Press CTRL+C to terminate the program.
> Device is found!
connecting: 40% complete
> Device looks like ATtiny85!
> Available space for user application: 6010 bytes
> Suggested sleep time between sending pages: 8ms
> Whole page count: 94
> Erase function sleep duration: 752ms
parsing: 60% complete
> Erasing the memory ...
erasing: 79% complete
>> Abort mission! -1 error has occured ...
>> Please unplug the device and restart the program.

 

資料來源:https://digistump.com/board/index.php?topic=106.0

沒有留言: