OLD | NEW |
1 --- | 1 --- |
2 title: Fletch project | 2 title: Fletch project |
3 layout: page | 3 layout: page |
4 --- | 4 --- |
5 | 5 |
6 # The Fletch project | 6 # The Fletch project |
7 | 7 |
8 More details coming soon. | 8 Fletch is an **experimental** project to enable highly productive development |
| 9 for embedded devices. It is powered by the [Dart |
| 10 language](https://www.dartlang.org/docs/dart-up-and-running/ch02.html) and a |
| 11 fast, lean runtime. |
| 12 |
| 13 This page will take you through getting the Fletch platform installed on your |
| 14 local developer PC so that you can run and write Fletch programs that target |
| 15 embedded devices. Note that the current early version of Fletch only supports a |
| 16 single embedded device -- the Raspberry Pi 2 -- and the only supported |
| 17 client operating systems supported for development are MacOS and Linux (sorry, |
| 18 no Windows support). |
| 19 |
| 20 If you just want to get a look at what Fletch programs look like, take a peek at |
| 21 our [samples page](samples.html). |
| 22 |
| 23 * [Installing the SDK](#installing-the-sdk) |
| 24 * [Running your first program](#running-your-first-program) |
| 25 * [Preparing your Raspberry Pi 2](#preparing-your-raspberry-pi-2) |
| 26 * [Running on the Raspberry Pi 2](#running-on-the-raspberry-pi) |
| 27 * [Next steps](#next-steps) |
| 28 |
| 29 ## Installing the SDK |
| 30 |
| 31 First download the SDK. This is available as a '.zip' archive; pick the one that |
| 32 matches the OS of the PC you will be using for development: |
| 33 |
| 34 * [MacOS, 32-bit](https://storage.googleapis.com/fletch-archive/channels/dev/rel
ease/latest/sdk/fletch-sdk-macos-ia32-release.zip) |
| 35 * [MacOS, 64-bit](https://storage.googleapis.com/fletch-archive/channels/dev/rel
ease/latest/sdk/fletch-sdk-macos-x64-release.zip) |
| 36 * [Linux, 32-bit](https://storage.googleapis.com/fletch-archive/channels/dev/rel
ease/latest/sdk/fletch-sdk-linux-ia32-release.zip) |
| 37 * [Linux, 64-bit](https://storage.googleapis.com/fletch-archive/channels/dev/rel
ease/latest/sdk/fletch-sdk-linux-x64-release.zip) |
| 38 |
| 39 Unzip this, and make sure that the Fletch command is in the path by typing the |
| 40 below in a terminal window: |
| 41 |
| 42 ~~~ |
| 43 cd $HOME |
| 44 unzip ./Downloads/fletch-sdk-macos-x64-release.zip |
| 45 export "PATH=$PATH:$HOME/fletch-sdk/bin" |
| 46 ~~~ |
| 47 |
| 48 Test if the Fletch program works; it should print a version number to the |
| 49 console: |
| 50 |
| 51 ~~~ |
| 52 fletch --version |
| 53 ~~~ |
| 54 |
| 55 ## Running your first program |
| 56 |
| 57 Let’s go ahead and run our first Fletch program. This is a simple program that |
| 58 prints Hello. In your command line type: |
| 59 |
| 60 ~~~ |
| 61 cd $HOME/fletch-sdk/samples/general/ |
| 62 fletch run hello.dart |
| 63 ~~~ |
| 64 |
| 65 You should see output that looks like this on your screen: |
| 66 |
| 67 ~~~ |
| 68 Hello from Darwin running on ‘michael-pc2’ |
| 69 ~~~ |
| 70 |
| 71 Try to open `hello.dart` in your favorite editor. We recommend the [Atom |
| 72 editor](https://atom.io/) by Github with the [Dart |
| 73 plugin](https://github.com/dart-atom/dartlang/). Pretty easy to read, right? |
| 74 (Note: you will get some Analyzer warnings in Atom as we don't fully support it |
| 75 yet. You can ignore those.) |
| 76 |
| 77 But what actually happened when we asked the ```fletch``` command to run |
| 78 `hello.dart`? By default ```fletch``` is connected to a local session, |
| 79 which is connected to a local VM (Virtual Machine) running on your developer PC. |
| 80 When you ask ```fletch``` to run the program, it compiles the program to byte |
| 81 code, and then passes it to the local Fletch VM for execution. The VM passes |
| 82 back the result, and fletch prints it to your command line. |
| 83 |
| 84  |
| 85 |
| 86 Now let’s get things running on your Raspberry! |
| 87 |
| 88 ## Preparing your Raspberry Pi 2 |
| 89 |
| 90 *Note*: If you already have a working Raspberry Pi 2 with a recent Raspbian |
| 91 image, then you can skip to step 2. |
| 92 |
| 93 ### Step 1: Raspbian operating system |
| 94 |
| 95 In this first step we will get a copy of the Raspbian operating system, and get |
| 96 it written to your SD card. You can skip this step if you already have Raspbian |
| 97 running. Otherwise follow these steps to get the image installed: |
| 98 |
| 99 * Download the zip file containing 'Raspbian Jessie' from the [Raspbian download |
| 100 page](https://www.raspberrypi.org/downloads/raspbian/). |
| 101 * Unzip the file by typing this in a termnal window: |
| 102 * On Mac: ```ditto -x -k 2015-09-24-raspbian-jessie.zip .``` |
| 103 * On Linux: ```unzip 2015-09-24-raspbian-jessie.zip``` |
| 104 * Follow the steps to [get the .img file onto your SD |
| 105 Card](https://www.raspberrypi.org/documentation/installation/installing-images/
README.md). |
| 106 |
| 107 ### Step 2: Configure the IP address for the Raspberry Pi 2 |
| 108 |
| 109 We need to enable IP communication between your developer PC and your Raspberry |
| 110 Pi. You can either connect your Raspberry to your router (via a cable or WiFi), |
| 111 or you can add a second Ethernet adapter to your developer PC and connect to the |
| 112 Raspberry Pi directly via an Ethernet cable. |
| 113 |
| 114 There are several ways you can configure the IP number of the Raspberry: |
| 115 |
| 116 * *Option 1*: If you have your Raspberry connected to a monitor, then you can us
e this approach: |
| 117 * Boot the Raspberry |
| 118 * After boot enter ```sudo ip show addr``` in a terminal prompt on the Raspber
ry.Note down the IP as we will be using it below. |
| 119 * If it does not have an IP, configure a static IP. |
| 120 |
| 121 * *Option 2*: If you are on a Linux developer PC, you can also configure the ima
ge directly from your developer PC. |
| 122 * Mount the SD card |
| 123 * Enter the following in a console: ```$HOME/fletch-sdk/platforms/raspberry-pi
2/setup-ip.sh <path to SD card's boot partition>``` |
| 124 |
| 125 * *Option 3*: If you are on a Mac developer PC, you can connect directly to the
Raspberry Pi via an USB Network adapter connected to the Raspberry Pi via a netw
orking cable, and the following configuration steps: |
| 126 * Turn off your Raspberry Pi |
| 127 * Open System Preferences and pick the Network icon |
| 128 * Plug the USB Ethernet adapter into your Mac |
| 129 * Change the IPv4 option to ```Manually``` |
| 130 * Enter the IP Address ```192.168.2.1``` |
| 131 * Go back to System Preferences and pick the Sharing icon. Enable sharing of I
nternet for the USB Ethernet Adapter |
| 132 * Turn your Raspberry Pi back on |
| 133 * After a little while you should be able to ping the Raspberry Pi at ```192.1
68.2.2``` |
| 134 |
| 135 ### Step 3: Install Fletch binaries |
| 136 |
| 137 **Note**: In the steps below, replace ```192.168..``` with whatever IP address y
ou configured above. |
| 138 |
| 139 The last step is to install the Fletch runtime on the Raspberry Pi (see the |
| 140 right-hand side of the architecture diagram above). Use the following commands. |
| 141 |
| 142 A. Copy the fletch-agent package to the Raspberry Pi 2 (the default password for |
| 143 user 'pi' on Raspbian is 'raspberry'): |
| 144 |
| 145 ~~~ |
| 146 cd $HOME/fletch-sdk |
| 147 scp ./platforms/raspberry-pi2/fletch-agent*.deb pi@192.168..:/home/pi/ |
| 148 ~~~ |
| 149 |
| 150 B. Install the package: |
| 151 |
| 152 ~~~ |
| 153 ssh pi@192.168.. sudo dpkg --install /home/pi/fletch-agent*.deb |
| 154 ~~~ |
| 155 |
| 156 You should see something like ```Unpacking fletch-agent...``` on your screen. |
| 157 |
| 158 ## Running on the Raspberry Pi 2 |
| 159 |
| 160 The Fletch platform is now available on the Raspberry Pi 2. Let’s make our Hello |
| 161 program run again, this time on the Raspberry Pi 2. Type the following command |
| 162 on your local developer PC: |
| 163 |
| 164 ~~~ |
| 165 cd $HOME/fletch-sdk/ |
| 166 fletch run ./samples/general/hello.dart in session remote |
| 167 ~~~ |
| 168 |
| 169 The first time you run in the remote session you will be asked to enter the IP |
| 170 address. Enter the IP you picked in the previous step, e.g. ```192.168.2.2```. |
| 171 |
| 172 You should then see the following output on your screen: |
| 173 |
| 174 ~~~ |
| 175 Hello from Linux running on raspberrypi. |
| 176 ~~~ |
| 177 |
| 178 Did you notice the difference? As before Fletch compiled the hello.dart program |
| 179 to byte code, but this time rather than passing it to the local VM via the local |
| 180 session it passed it to the Raspberry Pi via the remote session. On the |
| 181 Raspberry Pi, the Fletch VM Agent made sure that a VM (Virtual Machine) was spun |
| 182 up, and the program was executed on it. The result of the program (the printing |
| 183 to the console) was passed back by the VM to the Fletch command on the developer |
| 184 PC, and it was printed to the local console. |
| 185 |
| 186 ## Next steps |
| 187 |
| 188 Ready for some more fun? Take a look at our [samples](samples.html), and read |
| 189 more about the [Fletch tool]()tool.html. |
| 190 |
| 191 And don’t forget to send us some [feedback](feedback.html), and ask some |
| 192 [questions](faq.html). |
OLD | NEW |