SlideShare una empresa de Scribd logo
1 de 34
Running JavaScript
on microcontrollers
Volodymyr Shymanskyy
What systems are we talking about?
System architecture
Engines overview
Benefits
Used on production?
Demo!
V8
SpiderMonkey
JavaScriptCore
Chakra
JavaScriptCoreV8 ???
Raspberry Pi Zero W
VoCore v2
Intel Joule
Library
Processor(s) Memory Devices
Kernel
Drivers
Supervisor
Application
Hardware
Library Lib
Library L
Program
Program
Program
ProgramNode.js
SYSTEM OVERVIEW
ARDUINO UNO
CPU 16 MHz [8-bit]
Flash 32 Kb
RAM 2 Kb
Bare metal (no OS)
ESP8266 ~ $1.8
CPU 160 MHz
Flash 4 Mb
RAM 128 Kb
+ WiFi
ESP32 ~ $4.5
CPU 2x 240 MHz
Flash 4 Mb+
RAM 520 Kb
+ WiFi
+ Bluetooth 4.2
+ crypto engine, etc.
nRF52832 ~ $8.5
CPU 64MHz
Flash 512 Kb
RAM 64 Kb
+ Bluetooth 5
+ 6LoWPAN
+ NFC
+ Low Power
HOW MUCH IS ENOUGH?
Engine License Binary RAM
Google V8 BSD 3-clause >8M >24M
JavaScriptCore LGPL 2.0 >4M >8M
Duktape MIT 100k 30k
V7 GPL v2.0 70k 1k
mJS GPL v2.0 50k 1k
JerryScript Apache 2 200k 64k
Espruino MPL v2.0 128k 8k
JS Library
Processor(s) Memory Devices
RTOS Drivers
Application
Hardware
JS Lib JS
JS Library
JS App
JS engine
Supervisor
SYSTEM OVERVIEW
JS Library
Processor(s) Memory Devices
JS engine
Drivers
Supervisor
Application
Hardware
JS Lib JS
JS Library
JS App
SYSTEM OVERVIEW
Bluetooth Key Tag ~ $12
DISASSEMBLING
SOC: nRF51822
● Single chip 2.4 GHz multi-protocol device
● 32-bit ARM Cortex M0 CPU core
● 256k Flash
● 32k RAM
● Bluetooth Low Energy 4.0
● Thread safe and run-time protected
● Event driven API
+3.3v IO CLK GND
● Feature-rich JS engine
● Declares nRF51822 support
(as well as many other MCUs)
● Supports Bluetooth
● Has an IDE
● Auto-minifies JS
● Provides REPL via bluetooth
● & I had some prev. experience ;)
BUILD IT
1. Get Espruino release from github
2. Install gcc-arm-none-eabi-5_4-2016q3 toolchain
3. Build:
BOARD=NUT2 RELEASE=1 make
-> hex file is produced
4. Flash it to the board
.:[ complete instructions ]:.
ST-Link V2 ~ $2
LET’S CODE
LED1.write(1); /* Turn led ON */
LED1.write(0); /* Turn led OFF */
function toggle() {
state = !state;
LED1.write(state);
}
/* Start timer */
setInterval(toggle, 500)
/* Output frequency: 1000 hz square wave */
analogWrite(D30, 0.5, { freq: 1000 } )
function buzz(f, duration) {
analogWrite(D30, 0.5, { freq: f } );
setTimeout(function() {
pinMode(D30, 'input');
}, duration);
}
let mario_freq = new Uint16Array([330,330,0,330,0,262,330,0,392,0,0,196,0,0, ...]);
let mario_temp = new Uint8Array([80 ,80,80,80,80,80,80,80,80,80,40,80,80,40, ...]);
let pos = 0, tmr = -1;
function step() {
let freq = mario_freq[pos];
if (freq === undefined)
return stop();
let temp = 10000/mario_temp[pos];
changeInterval(tmr, temp);
buzz(freq, temp);
pos++;
}
function stop() {
if (tmr >= 0) {
buzz(0);
clearInterval(tmr);
tmr = -1;
}
}
function play_mario() {
stop();
pos = 0;
tmr = setInterval(step, 0);
}
Not too much simplified ;)
DEMO
(plays Mario theme)
● Platform abstraction
● Interactive, dynamic execution
● Event-Driven model
● Semi-automatic Power Management
● Perfect for prototyping
● Security
BENEFITS
IN PRODUCTION
Python, actually
Puck.js
.:[nRF52]:.
M5stack
.:[ESP32]:.
OUT OF THE BOX
.:[ Q & A ]:.
Volodymyr Shymanskyy
Entrepreneur, Software & Hardware Developer, Trainer
Co-Founder of Blynk, Hackerspace Coordinator
● Lots of projects
● 10+ years in IT, 8 in outsourcing and embedded
● Master’s degree in Cybernetics
@ National Taras Shevchenko University of Kyiv
> facebook > LinkedIn > vshymanskyi@gmail.com
Disclaimer: these brands are not affiliated with current presentation or it’s topic
.:[ additional materials ]:.
TI CC2650 ~ $8.5
CPU 48MHz
Flash 128 Kb
RAM 28 Kb
+ Bluetooth 4.2
+ 6LoWPAN
EZ-BLE™ PSoC® ~ $10
CPU 48MHz
Flash 128 Kb
RAM 16 Kb
+ Bluetooth 4.1
TI CC3220 ~ $15.6
CPU 80 MHz
Flash 1 Mb
RAM 256 Kb
+ WiFi
+ secure + low power
OpenOCD: Backup
source [find interface/cmsis-dap.cfg]
set WORKAREASIZE 0
source [find target/nrf51.cfg]
openocd_ble_nano.cfg:
OpenOCD: Backup
$ openocd -f openocd_ble_nano.cfg
Open On-Chip Debugger 0.9.0 (2015-09-02-10:42)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
cortex_m reset_config sysresetreq
adapter speed: 1000 kHz
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 1.0
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD IDCODE 0x0bb11477
Info : nrf51.cpu: hardware has 4 breakpoints, 2 watchpoints
OpenOCD: Backup
$ telnet localhost 4444
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> flash list
{name nrf51 base 0 size 0 bus_width 1 chip_width 1} {name nrf51 base 268439552 size 0
bus_width 1 chip_width 1}
> flash banks
#0 : nrf51.flash (nrf51) at 0x00000000, size 0x00040000, buswidth 1, chipwidth 1
#1 : nrf51.uicr (nrf51) at 0x10001000, size 0x00000100, buswidth 1, chipwidth 1
> flash info 0
nRF51822-QFAA(build code: H0) 256kB Flash
…
> dump_image backup.bin 0x00000000 0x00040000
dumped 262144 bytes in 16.601297s (15.420 KiB/s)
http://openocd.org/doc/html/Flash-Commands.html
OpenOCD: Restore
$ telnet localhost 4444
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> reset halt
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x000006d0 msp: 0x000007c0
> program backup.bin verify reset exit 0x00000000
...

Más contenido relacionado

La actualidad más candente

Aditech innodisk-flash disk technology
Aditech innodisk-flash disk technologyAditech innodisk-flash disk technology
Aditech innodisk-flash disk technology
Vilas Fulsundar
 
Highload осень 2012 лекция 5
Highload осень 2012 лекция 5Highload осень 2012 лекция 5
Highload осень 2012 лекция 5
Technopark
 
G1-component computer(processor)
G1-component computer(processor)G1-component computer(processor)
G1-component computer(processor)
nurazrinmalik
 
Killing any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureKilling any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented feature
Cyber Security Alliance
 
Inside ASUS ZENBOOK
Inside ASUS ZENBOOKInside ASUS ZENBOOK
Inside ASUS ZENBOOK
JJ Wu
 

La actualidad más candente (20)

Industrial Touch Screen Panel PC with RFID / Wireless / Fanless
Industrial Touch Screen Panel PC with RFID / Wireless / FanlessIndustrial Touch Screen Panel PC with RFID / Wireless / Fanless
Industrial Touch Screen Panel PC with RFID / Wireless / Fanless
 
Multipath
MultipathMultipath
Multipath
 
IoT and IIOT at QuBit Prague 2018
IoT and IIOT at QuBit Prague 2018 IoT and IIOT at QuBit Prague 2018
IoT and IIOT at QuBit Prague 2018
 
Aditech innodisk-flash disk technology
Aditech innodisk-flash disk technologyAditech innodisk-flash disk technology
Aditech innodisk-flash disk technology
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218
 
Ganeti - build your own cloud
Ganeti - build your own cloudGaneti - build your own cloud
Ganeti - build your own cloud
 
Staging driver sins
Staging driver sinsStaging driver sins
Staging driver sins
 
Oscar compiler for power reduction
Oscar compiler for power reduction Oscar compiler for power reduction
Oscar compiler for power reduction
 
Highload осень 2012 лекция 5
Highload осень 2012 лекция 5Highload осень 2012 лекция 5
Highload осень 2012 лекция 5
 
G1-component computer(processor)
G1-component computer(processor)G1-component computer(processor)
G1-component computer(processor)
 
Amd epyc update_gdep_xilinx_ai_web_seminar_20201028
Amd epyc update_gdep_xilinx_ai_web_seminar_20201028Amd epyc update_gdep_xilinx_ai_web_seminar_20201028
Amd epyc update_gdep_xilinx_ai_web_seminar_20201028
 
Killing any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureKilling any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented feature
 
Fail2ban - the system security for green hand -on linux os
Fail2ban  - the system security  for green hand -on linux osFail2ban  - the system security  for green hand -on linux os
Fail2ban - the system security for green hand -on linux os
 
OpenCR
OpenCROpenCR
OpenCR
 
C&C Botnet Factory
C&C Botnet FactoryC&C Botnet Factory
C&C Botnet Factory
 
Inside ASUS ZENBOOK
Inside ASUS ZENBOOKInside ASUS ZENBOOK
Inside ASUS ZENBOOK
 
Ha opensuse
Ha opensuseHa opensuse
Ha opensuse
 
O Meu Computador
O Meu ComputadorO Meu Computador
O Meu Computador
 
Quanta ze7 r1b_schematics
Quanta ze7 r1b_schematicsQuanta ze7 r1b_schematics
Quanta ze7 r1b_schematics
 
St5801 gb specification-www.ttbvs.com
St5801 gb specification-www.ttbvs.comSt5801 gb specification-www.ttbvs.com
St5801 gb specification-www.ttbvs.com
 

Similar a JS Fest 2018. Володимир Шиманський. Запуск двіжка JS на мікроконтролері

05 module managing your network enviornment
05  module managing your network enviornment05  module managing your network enviornment
05 module managing your network enviornment
Asif
 
SBC6020 SAM9G20 based Single Board Computer
SBC6020 SAM9G20 based Single Board ComputerSBC6020 SAM9G20 based Single Board Computer
SBC6020 SAM9G20 based Single Board Computer
yclinda666
 

Similar a JS Fest 2018. Володимир Шиманський. Запуск двіжка JS на мікроконтролері (20)

Embedded Recipes 2019 - Introduction to JTAG debugging
Embedded Recipes 2019 - Introduction to JTAG debuggingEmbedded Recipes 2019 - Introduction to JTAG debugging
Embedded Recipes 2019 - Introduction to JTAG debugging
 
Android 4.2 Internals - Bluetooth and Network
Android 4.2 Internals - Bluetooth and NetworkAndroid 4.2 Internals - Bluetooth and Network
Android 4.2 Internals - Bluetooth and Network
 
Stm32 f4 first touch
Stm32 f4 first touchStm32 f4 first touch
Stm32 f4 first touch
 
Dx diag
Dx diagDx diag
Dx diag
 
wifi_sw_birdview_v0.4
wifi_sw_birdview_v0.4wifi_sw_birdview_v0.4
wifi_sw_birdview_v0.4
 
Jetson AGX Xavier and the New Era of Autonomous Machines
Jetson AGX Xavier and the New Era of Autonomous MachinesJetson AGX Xavier and the New Era of Autonomous Machines
Jetson AGX Xavier and the New Era of Autonomous Machines
 
Tft touch screen manufacturers
Tft touch screen manufacturersTft touch screen manufacturers
Tft touch screen manufacturers
 
Android Things in action
Android Things in actionAndroid Things in action
Android Things in action
 
05 module managing your network enviornment
05  module managing your network enviornment05  module managing your network enviornment
05 module managing your network enviornment
 
Network Docs
Network DocsNetwork Docs
Network Docs
 
Ghosterr
GhosterrGhosterr
Ghosterr
 
Kamery, światło, akcja!
Kamery, światło, akcja!Kamery, światło, akcja!
Kamery, światło, akcja!
 
Presentation for IoT workshop at Sinhagad University (Feb 4, 2016) - 2/2
Presentation for IoT workshop at Sinhagad University (Feb 4, 2016) - 2/2Presentation for IoT workshop at Sinhagad University (Feb 4, 2016) - 2/2
Presentation for IoT workshop at Sinhagad University (Feb 4, 2016) - 2/2
 
iWave Systems Techologies Pvt Ltd: Products- Software BSPs
iWave Systems Techologies Pvt Ltd: Products- Software BSPsiWave Systems Techologies Pvt Ltd: Products- Software BSPs
iWave Systems Techologies Pvt Ltd: Products- Software BSPs
 
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterDUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
 
Intel DPDK Step by Step instructions
Intel DPDK Step by Step instructionsIntel DPDK Step by Step instructions
Intel DPDK Step by Step instructions
 
SBC6020 SAM9G20 based Single Board Computer
SBC6020 SAM9G20 based Single Board ComputerSBC6020 SAM9G20 based Single Board Computer
SBC6020 SAM9G20 based Single Board Computer
 
managing your network environment
managing your network environmentmanaging your network environment
managing your network environment
 
How to Speak Intel DPDK KNI for Web Services.
How to Speak Intel DPDK KNI for Web Services.How to Speak Intel DPDK KNI for Web Services.
How to Speak Intel DPDK KNI for Web Services.
 
JavaScript Robotics #NodeWeek
JavaScript Robotics #NodeWeekJavaScript Robotics #NodeWeek
JavaScript Robotics #NodeWeek
 

Más de JSFestUA

Más de JSFestUA (20)

JS Fest 2019/Autumn. Роман Савіцький. Webcomponents & lit-element in production
JS Fest 2019/Autumn. Роман Савіцький. Webcomponents & lit-element in productionJS Fest 2019/Autumn. Роман Савіцький. Webcomponents & lit-element in production
JS Fest 2019/Autumn. Роман Савіцький. Webcomponents & lit-element in production
 
JS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript Performance
JS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript PerformanceJS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript Performance
JS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript Performance
 
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
 
JS Fest 2019/Autumn. Anton Cherednikov. Choreographic or orchestral architect...
JS Fest 2019/Autumn. Anton Cherednikov. Choreographic or orchestral architect...JS Fest 2019/Autumn. Anton Cherednikov. Choreographic or orchestral architect...
JS Fest 2019/Autumn. Anton Cherednikov. Choreographic or orchestral architect...
 
JS Fest 2019/Autumn. Adam Leos. So why do you need to know Algorithms and Dat...
JS Fest 2019/Autumn. Adam Leos. So why do you need to know Algorithms and Dat...JS Fest 2019/Autumn. Adam Leos. So why do you need to know Algorithms and Dat...
JS Fest 2019/Autumn. Adam Leos. So why do you need to know Algorithms and Dat...
 
JS Fest 2019/Autumn. Marko Letic. Saving the world with JavaScript: A Data Vi...
JS Fest 2019/Autumn. Marko Letic. Saving the world with JavaScript: A Data Vi...JS Fest 2019/Autumn. Marko Letic. Saving the world with JavaScript: A Data Vi...
JS Fest 2019/Autumn. Marko Letic. Saving the world with JavaScript: A Data Vi...
 
JS Fest 2019/Autumn. Александр Товмач. JAMstack
JS Fest 2019/Autumn. Александр Товмач. JAMstackJS Fest 2019/Autumn. Александр Товмач. JAMstack
JS Fest 2019/Autumn. Александр Товмач. JAMstack
 
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
 
JS Fest 2019/Autumn. Дмитрий Жарков. Blockchainize your SPA or Integrate Java...
JS Fest 2019/Autumn. Дмитрий Жарков. Blockchainize your SPA or Integrate Java...JS Fest 2019/Autumn. Дмитрий Жарков. Blockchainize your SPA or Integrate Java...
JS Fest 2019/Autumn. Дмитрий Жарков. Blockchainize your SPA or Integrate Java...
 
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developersJS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
 
JS Fest 2019/Autumn. Kyle Boss. A Tinder Love Story: Create a Wordpress Blog ...
JS Fest 2019/Autumn. Kyle Boss. A Tinder Love Story: Create a Wordpress Blog ...JS Fest 2019/Autumn. Kyle Boss. A Tinder Love Story: Create a Wordpress Blog ...
JS Fest 2019/Autumn. Kyle Boss. A Tinder Love Story: Create a Wordpress Blog ...
 
JS Fest 2019/Autumn. Андрей Старовойт. Зачем нужен тип "true" в TypeScript?
JS Fest 2019/Autumn. Андрей Старовойт. Зачем нужен тип "true" в TypeScript?JS Fest 2019/Autumn. Андрей Старовойт. Зачем нужен тип "true" в TypeScript?
JS Fest 2019/Autumn. Андрей Старовойт. Зачем нужен тип "true" в TypeScript?
 
JS Fest 2019/Autumn. Eyal Eizenberg. Tipping the Scale
JS Fest 2019/Autumn. Eyal Eizenberg. Tipping the ScaleJS Fest 2019/Autumn. Eyal Eizenberg. Tipping the Scale
JS Fest 2019/Autumn. Eyal Eizenberg. Tipping the Scale
 
JS Fest 2019/Autumn. Sota Ohara. Сreate own server less CMS from scratch
JS Fest 2019/Autumn. Sota Ohara. Сreate own server less CMS from scratchJS Fest 2019/Autumn. Sota Ohara. Сreate own server less CMS from scratch
JS Fest 2019/Autumn. Sota Ohara. Сreate own server less CMS from scratch
 
JS Fest 2019/Autumn. Джордж Евтушенко. Как стать программистом, которого хотят
JS Fest 2019/Autumn. Джордж Евтушенко. Как стать программистом, которого хотятJS Fest 2019/Autumn. Джордж Евтушенко. Как стать программистом, которого хотят
JS Fest 2019/Autumn. Джордж Евтушенко. Как стать программистом, которого хотят
 
JS Fest 2019/Autumn. Алексей Орленко. Node.js N-API for Rust
JS Fest 2019/Autumn. Алексей Орленко. Node.js N-API for RustJS Fest 2019/Autumn. Алексей Орленко. Node.js N-API for Rust
JS Fest 2019/Autumn. Алексей Орленко. Node.js N-API for Rust
 
JS Fest 2019/Autumn. Daniel Ostrovsky. Falling in love with decorators ES6/Ty...
JS Fest 2019/Autumn. Daniel Ostrovsky. Falling in love with decorators ES6/Ty...JS Fest 2019/Autumn. Daniel Ostrovsky. Falling in love with decorators ES6/Ty...
JS Fest 2019/Autumn. Daniel Ostrovsky. Falling in love with decorators ES6/Ty...
 
JS Fest 2019/Autumn. Андрей Андрийко. Гексагональна архітектура в Nodejs проекті
JS Fest 2019/Autumn. Андрей Андрийко. Гексагональна архітектура в Nodejs проектіJS Fest 2019/Autumn. Андрей Андрийко. Гексагональна архітектура в Nodejs проекті
JS Fest 2019/Autumn. Андрей Андрийко. Гексагональна архітектура в Nodejs проекті
 
JS Fest 2019/Autumn. Борис Могила. Svelte. Почему нам не нужно run-time ядро
JS Fest 2019/Autumn. Борис Могила. Svelte. Почему нам не нужно run-time ядроJS Fest 2019/Autumn. Борис Могила. Svelte. Почему нам не нужно run-time ядро
JS Fest 2019/Autumn. Борис Могила. Svelte. Почему нам не нужно run-time ядро
 
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
 

Último

Último (20)

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 

JS Fest 2018. Володимир Шиманський. Запуск двіжка JS на мікроконтролері

  • 2. What systems are we talking about? System architecture Engines overview Benefits Used on production? Demo!
  • 4. Raspberry Pi Zero W VoCore v2 Intel Joule
  • 5. Library Processor(s) Memory Devices Kernel Drivers Supervisor Application Hardware Library Lib Library L Program Program Program ProgramNode.js SYSTEM OVERVIEW
  • 6.
  • 7. ARDUINO UNO CPU 16 MHz [8-bit] Flash 32 Kb RAM 2 Kb Bare metal (no OS)
  • 8. ESP8266 ~ $1.8 CPU 160 MHz Flash 4 Mb RAM 128 Kb + WiFi ESP32 ~ $4.5 CPU 2x 240 MHz Flash 4 Mb+ RAM 520 Kb + WiFi + Bluetooth 4.2 + crypto engine, etc. nRF52832 ~ $8.5 CPU 64MHz Flash 512 Kb RAM 64 Kb + Bluetooth 5 + 6LoWPAN + NFC + Low Power
  • 9. HOW MUCH IS ENOUGH? Engine License Binary RAM Google V8 BSD 3-clause >8M >24M JavaScriptCore LGPL 2.0 >4M >8M Duktape MIT 100k 30k V7 GPL v2.0 70k 1k mJS GPL v2.0 50k 1k JerryScript Apache 2 200k 64k Espruino MPL v2.0 128k 8k
  • 10. JS Library Processor(s) Memory Devices RTOS Drivers Application Hardware JS Lib JS JS Library JS App JS engine Supervisor SYSTEM OVERVIEW
  • 11. JS Library Processor(s) Memory Devices JS engine Drivers Supervisor Application Hardware JS Lib JS JS Library JS App SYSTEM OVERVIEW
  • 14.
  • 15. SOC: nRF51822 ● Single chip 2.4 GHz multi-protocol device ● 32-bit ARM Cortex M0 CPU core ● 256k Flash ● 32k RAM ● Bluetooth Low Energy 4.0 ● Thread safe and run-time protected ● Event driven API
  • 16.
  • 18.
  • 19. ● Feature-rich JS engine ● Declares nRF51822 support (as well as many other MCUs) ● Supports Bluetooth ● Has an IDE ● Auto-minifies JS ● Provides REPL via bluetooth ● & I had some prev. experience ;)
  • 20. BUILD IT 1. Get Espruino release from github 2. Install gcc-arm-none-eabi-5_4-2016q3 toolchain 3. Build: BOARD=NUT2 RELEASE=1 make -> hex file is produced 4. Flash it to the board .:[ complete instructions ]:. ST-Link V2 ~ $2
  • 21. LET’S CODE LED1.write(1); /* Turn led ON */ LED1.write(0); /* Turn led OFF */ function toggle() { state = !state; LED1.write(state); } /* Start timer */ setInterval(toggle, 500) /* Output frequency: 1000 hz square wave */ analogWrite(D30, 0.5, { freq: 1000 } )
  • 22. function buzz(f, duration) { analogWrite(D30, 0.5, { freq: f } ); setTimeout(function() { pinMode(D30, 'input'); }, duration); } let mario_freq = new Uint16Array([330,330,0,330,0,262,330,0,392,0,0,196,0,0, ...]); let mario_temp = new Uint8Array([80 ,80,80,80,80,80,80,80,80,80,40,80,80,40, ...]); let pos = 0, tmr = -1; function step() { let freq = mario_freq[pos]; if (freq === undefined) return stop(); let temp = 10000/mario_temp[pos]; changeInterval(tmr, temp); buzz(freq, temp); pos++; } function stop() { if (tmr >= 0) { buzz(0); clearInterval(tmr); tmr = -1; } } function play_mario() { stop(); pos = 0; tmr = setInterval(step, 0); } Not too much simplified ;)
  • 24. ● Platform abstraction ● Interactive, dynamic execution ● Event-Driven model ● Semi-automatic Power Management ● Perfect for prototyping ● Security BENEFITS
  • 27. .:[ Q & A ]:.
  • 28. Volodymyr Shymanskyy Entrepreneur, Software & Hardware Developer, Trainer Co-Founder of Blynk, Hackerspace Coordinator ● Lots of projects ● 10+ years in IT, 8 in outsourcing and embedded ● Master’s degree in Cybernetics @ National Taras Shevchenko University of Kyiv > facebook > LinkedIn > vshymanskyi@gmail.com Disclaimer: these brands are not affiliated with current presentation or it’s topic
  • 30. TI CC2650 ~ $8.5 CPU 48MHz Flash 128 Kb RAM 28 Kb + Bluetooth 4.2 + 6LoWPAN EZ-BLE™ PSoC® ~ $10 CPU 48MHz Flash 128 Kb RAM 16 Kb + Bluetooth 4.1 TI CC3220 ~ $15.6 CPU 80 MHz Flash 1 Mb RAM 256 Kb + WiFi + secure + low power
  • 31. OpenOCD: Backup source [find interface/cmsis-dap.cfg] set WORKAREASIZE 0 source [find target/nrf51.cfg] openocd_ble_nano.cfg:
  • 32. OpenOCD: Backup $ openocd -f openocd_ble_nano.cfg Open On-Chip Debugger 0.9.0 (2015-09-02-10:42) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : only one transport option; autoselect 'swd' cortex_m reset_config sysresetreq adapter speed: 1000 kHz Info : CMSIS-DAP: SWD Supported Info : CMSIS-DAP: Interface Initialised (SWD) Info : CMSIS-DAP: FW Version = 1.0 Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1 Info : CMSIS-DAP: Interface ready Info : clock speed 1000 kHz Info : SWD IDCODE 0x0bb11477 Info : nrf51.cpu: hardware has 4 breakpoints, 2 watchpoints
  • 33. OpenOCD: Backup $ telnet localhost 4444 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Open On-Chip Debugger > flash list {name nrf51 base 0 size 0 bus_width 1 chip_width 1} {name nrf51 base 268439552 size 0 bus_width 1 chip_width 1} > flash banks #0 : nrf51.flash (nrf51) at 0x00000000, size 0x00040000, buswidth 1, chipwidth 1 #1 : nrf51.uicr (nrf51) at 0x10001000, size 0x00000100, buswidth 1, chipwidth 1 > flash info 0 nRF51822-QFAA(build code: H0) 256kB Flash … > dump_image backup.bin 0x00000000 0x00040000 dumped 262144 bytes in 16.601297s (15.420 KiB/s) http://openocd.org/doc/html/Flash-Commands.html
  • 34. OpenOCD: Restore $ telnet localhost 4444 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Open On-Chip Debugger > reset halt target state: halted target halted due to debug-request, current mode: Thread xPSR: 0xc1000000 pc: 0x000006d0 msp: 0x000007c0 > program backup.bin verify reset exit 0x00000000 ...