README.md
1### About
2
3This folder contains files to run JerryScript beside Particle Device Firmware on Photon board.
4It runs a mini example, blinking an LED which is the "Hello World" example of the microcontroller universe.
5
6### How to build
7
8#### 1. Preface / Directory structure
9
10Assume `root` as the path to the projects to build.
11The folder tree related would look like this.
12
13```
14root
15 + jerryscript
16 | + targets
17 | + particle
18 + particle
19 | + firmware
20```
21
22
23#### 2, Update/Install the Particle Firmware
24
25For detailed descriptions please visit the official website of the firmware: https://www.particle.io/
26
27You can checkout the firmware with the following command:
28
29```
30# assume you are in root folder
31git clone https://github.com/spark/firmware.git particle/firmware
32````
33
34The Photon’s latest firmware release is hosted in the latest branch of the firmware repo.
35
36```
37# assume you are in root folder
38cd particle/firmware
39git checkout latest
40```
41
42Before you type any commands, put your Photon in DFU mode: hold down both the SETUP and RESET buttons. Then release RESET, but hold SETUP until you see the RGB blink yellow. That means the Photon is in DFU mode. To verify that the Photon is in DFU mode and dfu-util is installed properly, try the dfu-util -l command. You should see the device, and the important parts there are the hex values inside the braces – the USB VID and PID, which should be 2b04 and d006 for the Photon.
43
44To build and flash the firmware: switch to the modules directory then call make with a few parameters to build and upload the firmware:
45
46```
47cd modules
48make PLATFORM=photon clean all program-dfu
49```
50
51#### 3. Build JerryScript
52
53```
54# assume you are in root folder
55cd jerryscript
56make -f ./targets/particle/Makefile.particle
57```
58
59This will create a binary file in the `/build/particle/` folder:
60```
61jerry_main.bin
62```
63
64That’s the binary what we’ll be flashing with dfu-util.
65
66
67#### 4. Flashing
68
69Make sure you put your Photon in DFU mode.
70Alternatively, you can make your life a bit easier by using the make command to invoke dfu-util:
71
72```
73make -f targets/particle/Makefile.particle flash
74```
75
76You can also use this dfu-util command directly to upload your BIN file to the Photon’s application memory:
77
78```
79dfu-util -d 2b04:d006 -a 0 -i 0 -s 0x80A0000:leave -D build/particle/jerry_main.bin
80```
81
82#### 5. Cleaning
83
84To clean the build result:
85```
86make -f targets/particle/Makefile.particle clean
87```
88
89### Running the example
90
91The example program will blinks the D7 led periodically after the flash.