-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuickstart.txt
194 lines (133 loc) · 5.79 KB
/
Quickstart.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
AVR_Stick_Apps Quick Start Guide
================================
0. Required Hardware
--------------------
This guide assumes you have a Sparkfun AVR Stick[1] or a compatible
device.
See HOWTO.txt for more information on the Hardware options.
In addition to the AVR Stick hardware itself you will need a
programmer to initially flash the micronucleus[2] bootloader.
1. Required Software
--------------------
To compile the examples avr-gcc[3] and avr-libc are required.
If you want to use an Arduino as a programmer, you will also
need the Arduino IDE. See [4] for detailed instruction on
how to do that.
For flashing the firmware we will use avrdude[5] which is
included with the Arduino IDE or can be installed separately
if you wish.
For the host tools libusb1[6] is required and since the
micronucleus commandline tool still uses libusb-0.1 the
compatibility package libusb-compat-0.1[7] might be needed, too.
1.1 Installation on Linux
-------------------------
The Arduino IDE (if required) can be downloaded from:
https://www.arduino.cc/en/Main/Software
All the other required software should be available as
packages from your Linux distribution.
On Ubuntu the following command will install the
necessary packages:
$ sudo apt-get install gcc-avr avr-libc avrdude binutils-avr libusb-1.0-0-dev
1.2 Installation on Windows
---------------------------
The Arduino IDE (if required) can be downloaded from:
https://www.arduino.cc/en/Main/Software
Please see [8] for instructions on how to install the AVR
GCC toolchain on Windows 10 and [4] on how to install libusb.
2. Getting the sources
----------------------
$ git clone --recurse-submodules https://github.com/tickelton/AVR_Stick_Apps.git
Since the AVR_Stick_Apps repository contains references to all the
third party software we will use in the form of submodules, this
command gives us access to all the code we will need.
3. Building the micronucleus bootloader
---------------------------------------
$ cd AVR_Stick_Apps
$ make bootloader
Building Micronucleus configuration: AVR_Stick
Size of sections:
text data bss dec hex filename
1588 0 44 1632 660 main.bin
Size of binary hexfile. Use the data size to calculate the bootloader address:
text data bss dec hex filename
0 1588 0 1588 634 main.hex
This command should leave you with the compiled bootloader in the
file 'AVR_Stick_Apps/submodules/micronucleus/firmware/main.hex'.
4. Installing the micronucleus bootloader
-----------------------------------------
First we need to set the fuses of the ATtiny85 correctly.
The following command assumes that an Arduino with the ArduinoISP
sketch is used as a programmer. Otherwise you need to adapt the
programmer parameters according to your setup.
$ avrdude -p attiny85 -b 19200 -c arduino -P /dev/ttyUSB0 -U lfuse:w:0xe1:m -U hfuse:w:0xdd:m -U efuse:w:0xfe:m
After that we can flash the actual bootloader:
$ cd AVR_Stick_Apps/submodules/micronucleus/firmware/
$ avrdude -p attiny85 -b 19200 -c arduino -P /dev/ttyUSB0 -U flash:w:main.hex
5. Building the USBSlacker app
------------------------------
$ cd AVR_Stick_Apps
$ make USBSlacker
...
AVR Memory Usage
----------------
Device: attiny85
Program: 2040 bytes (24.9% Full)
(.text + .data + .bootloader)
Data: 67 bytes (13.1% Full)
(.data + .bss + .noinit)
...
Now you should have the compiled binary for the app in
AVR_Stick_Apps/apps/USBSlacker/src/USBSlacker.hex
6. Building the micronucleus command line tool
----------------------------------------------
On Windows you can skip this step as micronucleus comes
with a pre-compiled binary for Windows in:
AVR_Stick_Apps/submodules/micronucleus/commandline/builds/Windows/micronucleus.exe
On Linux you can build the tool with the following command:
$ cd AVR_Stick_Apps
$ make micronucleus
This results in the following file:
AVR_Stick_Apps/submodules/micronucleus/commandline/micronucleus
7. Flashing the app using micronucleus
--------------------------------------
Now you have all the necessary components to flash the newly built
app to your AVR Stick.
With the AVR Stick _NOT_ plugged in run the following commands:
$ cd AVR_Stick_Apps
$ sudo ./submodules/micronucleus/commandline/micronucleus --run apps/USBSlacker/src/USBSlacker.hex
> Please plug in the device ...
> Press CTRL+C to terminate the program.
The plug in the AVR Stick and the app will get flashed to the device:
> Device is found!
connecting: 33% complete
> Device has firmware version 2.4
> Device signature: 0x1e930b
> Available space for user applications: 6522 bytes
> Suggested sleep time between sending pages: 7ms
> Whole page count: 102 page size: 64
> Erase function sleep duration: 714ms
parsing: 50% complete
> Erasing the memory ...
erasing: 66% complete
> Starting to upload ...
writing: 83% complete
> Starting the user app ...
running: 100% complete
>> Micronucleus done. Thank you!
After 5 seconds the AVR Stick will automatically reboot into the newly
flashed app.
8. Enjoy
--------
At this point you have successfully turned your AVR Stick into an
USB mouse emulator that will wiggle the cursor every couple of minutes.
You can now try to also build and flash the other demo apps or
dive into HOWTO.txt to find out how to create your own ones.
---------------------------------------------------------------------
[1]: https://www.sparkfun.com/products/retired/9147
[2]: https://github.com/micronucleus/micronucleus
[3]: https://gcc.gnu.org/wiki/avr-gcc
[4]: https://www.arduino.cc/en/Tutorial/ArduinoISP
[5]: https://www.nongnu.org/avrdude/
[6]: https://libusb.info/
[7]: https://github.com/hjelmn/libusb-compat-0.1
[8]: http://fab.cba.mit.edu/classes/863.16/doc/projects/ftsmin/windows_avr.html