1425bb815Sopenharmony_ci### About 2425bb815Sopenharmony_ci 3425bb815Sopenharmony_ciFiles in this folder (targets/esp8266) are copied from 4425bb815Sopenharmony_ci`examples/project_template` of `esp_iot_rtos_sdk` and modified for JerryScript. 5425bb815Sopenharmony_ciYou can view online from 6425bb815Sopenharmony_ci[this](https://github.com/espressif/esp_iot_rtos_sdk/tree/master/examples/project_template) page. 7425bb815Sopenharmony_ci 8425bb815Sopenharmony_ci 9425bb815Sopenharmony_ci### How to build JerryScript for ESP8266 10425bb815Sopenharmony_ci 11425bb815Sopenharmony_ci#### 1. SDK 12425bb815Sopenharmony_ci 13425bb815Sopenharmony_ciFollow [this](./docs/ESP-PREREQUISITES.md) page to setup build environment 14425bb815Sopenharmony_ci 15425bb815Sopenharmony_ci 16425bb815Sopenharmony_ci#### 2. Building JerryScript 17425bb815Sopenharmony_ci 18425bb815Sopenharmony_ci``` 19425bb815Sopenharmony_ci# assume you are in jerryscript folder 20425bb815Sopenharmony_cimake -f ./targets/esp8266/Makefile.esp8266 21425bb815Sopenharmony_ci``` 22425bb815Sopenharmony_ci 23425bb815Sopenharmony_ciOutput files should be placed at $BIN_PATH 24425bb815Sopenharmony_ci 25425bb815Sopenharmony_ci#### 3. Flashing for ESP8266 12E 26425bb815Sopenharmony_ciFollow 27425bb815Sopenharmony_ci[this](http://www.kloppenborg.net/images/blog/esp8266/esp8266-esp12e-specs.pdf) page to get details about this board. 28425bb815Sopenharmony_ci 29425bb815Sopenharmony_ci``` 30425bb815Sopenharmony_cimake -f ./targets/esp8266/Makefile.esp8266 flash 31425bb815Sopenharmony_ci``` 32425bb815Sopenharmony_ci 33425bb815Sopenharmony_ciDefault USB device is `/dev/ttyUSB0`. If you have different one, give with `USBDEVICE`, like; 34425bb815Sopenharmony_ci 35425bb815Sopenharmony_ci``` 36425bb815Sopenharmony_ciUSBDEVICE=/dev/ttyUSB1 make -f ./targets/esp8266/Makefile.esp8266 flash 37425bb815Sopenharmony_ci``` 38425bb815Sopenharmony_ci 39425bb815Sopenharmony_ci### 4. Running 40425bb815Sopenharmony_ci 41425bb815Sopenharmony_ci* power off 42425bb815Sopenharmony_ci* connect GPIO2 with serial of 470 Ohm + LED and to GND 43425bb815Sopenharmony_ci* power On 44425bb815Sopenharmony_ci 45425bb815Sopenharmony_ciLED should blink on and off every second 46425bb815Sopenharmony_ci 47425bb815Sopenharmony_ci#### 5. Cleaning 48425bb815Sopenharmony_ci 49425bb815Sopenharmony_ciTo clean the build result: 50425bb815Sopenharmony_ci 51425bb815Sopenharmony_ci``` 52425bb815Sopenharmony_cimake -f ./targets/esp8266/Makefile.esp8266 clean 53425bb815Sopenharmony_ci``` 54425bb815Sopenharmony_ci 55425bb815Sopenharmony_ciTo clean the board's flash memory: 56425bb815Sopenharmony_ci``` 57425bb815Sopenharmony_cimake -f ./targets/esp8266/Makefile.esp8266 erase_flash 58425bb815Sopenharmony_ci``` 59425bb815Sopenharmony_ci 60425bb815Sopenharmony_ci 61425bb815Sopenharmony_ci### 6. Optimizing initial RAM usage (ESP8266 specific) 62425bb815Sopenharmony_ciThe existing open source gcc compiler with Xtensa support stores const(ants) in 63425bb815Sopenharmony_cithe same limited RAM where our code needs to run. 64425bb815Sopenharmony_ci 65425bb815Sopenharmony_ciIt is possible to force the compiler to store a constant into ROM and also read it from there thus saving RAM. 66425bb815Sopenharmony_ciThe only requirement is to add `JERRY_ATTR_CONST_DATA` attribute to your constant. 67425bb815Sopenharmony_ci 68425bb815Sopenharmony_ciFor example: 69425bb815Sopenharmony_ci 70425bb815Sopenharmony_ci```C 71425bb815Sopenharmony_cistatic const lit_magic_size_t lit_magic_string_sizes[] = 72425bb815Sopenharmony_ci``` 73425bb815Sopenharmony_ci 74425bb815Sopenharmony_cican be modified to 75425bb815Sopenharmony_ci 76425bb815Sopenharmony_ci```C 77425bb815Sopenharmony_cistatic const lit_magic_size_t lit_magic_string_sizes[] JERRY_ATTR_CONST_DATA = 78425bb815Sopenharmony_ci``` 79425bb815Sopenharmony_ci 80425bb815Sopenharmony_ciThat is already done to some constants in jerry-core. E.g.: 81425bb815Sopenharmony_ci 82425bb815Sopenharmony_ci- vm_decode_table 83425bb815Sopenharmony_ci- ecma_property_hashmap_steps 84425bb815Sopenharmony_ci- lit_magic_string_sizes 85425bb815Sopenharmony_ci- unicode_letter_interv_sps 86425bb815Sopenharmony_ci- unicode_letter_interv_len 87425bb815Sopenharmony_ci- unicode_non_letter_ident_ 88425bb815Sopenharmony_ci- unicode_letter_chars 89