1425bb815Sopenharmony_ci### About 2425bb815Sopenharmony_ci 3425bb815Sopenharmony_ciThis folder contains files to run JerryScript beside Particle Device Firmware on Photon board. 4425bb815Sopenharmony_ciIt runs a mini example, blinking an LED which is the "Hello World" example of the microcontroller universe. 5425bb815Sopenharmony_ci 6425bb815Sopenharmony_ci### How to build 7425bb815Sopenharmony_ci 8425bb815Sopenharmony_ci#### 1. Preface / Directory structure 9425bb815Sopenharmony_ci 10425bb815Sopenharmony_ciAssume `root` as the path to the projects to build. 11425bb815Sopenharmony_ciThe folder tree related would look like this. 12425bb815Sopenharmony_ci 13425bb815Sopenharmony_ci``` 14425bb815Sopenharmony_ciroot 15425bb815Sopenharmony_ci + jerryscript 16425bb815Sopenharmony_ci | + targets 17425bb815Sopenharmony_ci | + particle 18425bb815Sopenharmony_ci + particle 19425bb815Sopenharmony_ci | + firmware 20425bb815Sopenharmony_ci``` 21425bb815Sopenharmony_ci 22425bb815Sopenharmony_ci 23425bb815Sopenharmony_ci#### 2, Update/Install the Particle Firmware 24425bb815Sopenharmony_ci 25425bb815Sopenharmony_ciFor detailed descriptions please visit the official website of the firmware: https://www.particle.io/ 26425bb815Sopenharmony_ci 27425bb815Sopenharmony_ciYou can checkout the firmware with the following command: 28425bb815Sopenharmony_ci 29425bb815Sopenharmony_ci``` 30425bb815Sopenharmony_ci# assume you are in root folder 31425bb815Sopenharmony_cigit clone https://github.com/spark/firmware.git particle/firmware 32425bb815Sopenharmony_ci```` 33425bb815Sopenharmony_ci 34425bb815Sopenharmony_ciThe Photon’s latest firmware release is hosted in the latest branch of the firmware repo. 35425bb815Sopenharmony_ci 36425bb815Sopenharmony_ci``` 37425bb815Sopenharmony_ci# assume you are in root folder 38425bb815Sopenharmony_cicd particle/firmware 39425bb815Sopenharmony_cigit checkout latest 40425bb815Sopenharmony_ci``` 41425bb815Sopenharmony_ci 42425bb815Sopenharmony_ciBefore 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. 43425bb815Sopenharmony_ci 44425bb815Sopenharmony_ciTo build and flash the firmware: switch to the modules directory then call make with a few parameters to build and upload the firmware: 45425bb815Sopenharmony_ci 46425bb815Sopenharmony_ci``` 47425bb815Sopenharmony_cicd modules 48425bb815Sopenharmony_cimake PLATFORM=photon clean all program-dfu 49425bb815Sopenharmony_ci``` 50425bb815Sopenharmony_ci 51425bb815Sopenharmony_ci#### 3. Build JerryScript 52425bb815Sopenharmony_ci 53425bb815Sopenharmony_ci``` 54425bb815Sopenharmony_ci# assume you are in root folder 55425bb815Sopenharmony_cicd jerryscript 56425bb815Sopenharmony_cimake -f ./targets/particle/Makefile.particle 57425bb815Sopenharmony_ci``` 58425bb815Sopenharmony_ci 59425bb815Sopenharmony_ciThis will create a binary file in the `/build/particle/` folder: 60425bb815Sopenharmony_ci``` 61425bb815Sopenharmony_cijerry_main.bin 62425bb815Sopenharmony_ci``` 63425bb815Sopenharmony_ci 64425bb815Sopenharmony_ciThat’s the binary what we’ll be flashing with dfu-util. 65425bb815Sopenharmony_ci 66425bb815Sopenharmony_ci 67425bb815Sopenharmony_ci#### 4. Flashing 68425bb815Sopenharmony_ci 69425bb815Sopenharmony_ciMake sure you put your Photon in DFU mode. 70425bb815Sopenharmony_ciAlternatively, you can make your life a bit easier by using the make command to invoke dfu-util: 71425bb815Sopenharmony_ci 72425bb815Sopenharmony_ci``` 73425bb815Sopenharmony_cimake -f targets/particle/Makefile.particle flash 74425bb815Sopenharmony_ci``` 75425bb815Sopenharmony_ci 76425bb815Sopenharmony_ciYou can also use this dfu-util command directly to upload your BIN file to the Photon’s application memory: 77425bb815Sopenharmony_ci 78425bb815Sopenharmony_ci``` 79425bb815Sopenharmony_cidfu-util -d 2b04:d006 -a 0 -i 0 -s 0x80A0000:leave -D build/particle/jerry_main.bin 80425bb815Sopenharmony_ci``` 81425bb815Sopenharmony_ci 82425bb815Sopenharmony_ci#### 5. Cleaning 83425bb815Sopenharmony_ci 84425bb815Sopenharmony_ciTo clean the build result: 85425bb815Sopenharmony_ci``` 86425bb815Sopenharmony_cimake -f targets/particle/Makefile.particle clean 87425bb815Sopenharmony_ci``` 88425bb815Sopenharmony_ci 89425bb815Sopenharmony_ci### Running the example 90425bb815Sopenharmony_ci 91425bb815Sopenharmony_ciThe example program will blinks the D7 led periodically after the flash.