Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save takeru/eaf766b5c40c5c67773c45e9c8c7e0a2 to your computer and use it in GitHub Desktop.
Save takeru/eaf766b5c40c5c67773c45e9c8c7e0a2 to your computer and use it in GitHub Desktop.
Moddableの開発環境をDockerで作りたい
Moddableの開発環境をDockerで作りたい
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
####
RUN apt-get update -y && apt-get upgrade -y
# For esp-idf. https://docs.espressif.com/projects/esp-idf/en/v3.2.2/get-started/linux-setup.html
RUN apt-get install -y gcc git wget make libncurses-dev flex bison gperf python python-pip python-setuptools python-serial python-cryptography python-future
# For makefile. Used in makefile.
RUN apt-get install -y sudo
# For gtk-update-icon-cache.
RUN apt-get install -y gtk+3.0
RUN apt-get install -y libgtk-3-dev
####
ENV MODDABLE /moddable
RUN git clone https://github.com/Moddable-OpenSource/moddable $MODDABLE
RUN cd $MODDABLE/build/makefiles/lin && make && make install
ENV PATH $PATH:$MODDABLE/build/bin/lin/release
####
ENV ESP32_PATH /root/esp32
RUN mkdir $ESP32_PATH
COPY xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz $ESP32_PATH/
# TODO check file digest
RUN cd $ESP32_PATH && tar zxf xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
ENV PATH $PATH:$ESP32_PATH/xtensa-esp32-elf/bin
RUN cd $ESP32_PATH && git clone -b v3.2.2 --recursive https://github.com/espressif/esp-idf.git
ENV IDF_PATH $ESP32_PATH/esp-idf
RUN python -m pip install --user -r $IDF_PATH/docs/requirements.txt
# esptool@rfc2217esp https://github.com/takeru/esptool/pull/1
RUN cd $ESP32_PATH/esp-idf/components/esptool_py/esptool && git remote add takeru https://github.com/takeru/esptool.git && git fetch takeru && git checkout takeru/rfc2217esp
RUN mkdir /work
WORKDIR /work
RUN apt install lv nano tree
docker build . -t moddable
docker run -it moddable /bin/bash
docker run -it --rm -v `pwd`/work:/work moddable /bin/bash
root@41db9095cfee:/moddable/examples/drivers/m5stickc-imu# UPLOAD_PORT=rfc2217://192.168.0.119:9999 ESPBAUD=1500000 mcconfig -m -p esp32/m5stick_c
WARNING: esp-idf git submodule components/esptool_py/esptool may be out of date. Run 'git submodule update' in IDF_PATH dir to update.
Toolchain path: /root/esp32/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: crosstool-ng-1.22.0-80-g6c4433a
Compiler version: 5.2.0
CC /moddable/build/tmp/esp32/m5stick_c/release/idf/main/main.o
Python requirements from /root/esp32/esp-idf/requirements.txt are satisfied.
WARNING: esp-idf git submodule components/esptool_py/esptool may be out of date. Run 'git submodule update' in IDF_PATH dir to update.
AR /moddable/build/tmp/esp32/m5stick_c/release/idf/main/libmain.a
LD /moddable/build/tmp/esp32/m5stick_c/release/idf/xs_esp32.elf
esptool.py v2.6
Flashing binaries to serial port rfc2217://192.168.0.119:9999 (app at offset 0x10000)...
esptool.py v2.6
Serial port rfc2217://192.168.0.119:9999
Connecting....
Chip is ESP32-PICO-D4 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
MAC: d8:a0:1d:59:c3:d0
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 1500000
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 14560 bytes to 10112...
Wrote 14560 bytes (10112 compressed) at 0x00001000 in 0.4 seconds (effective 310.6 kbit/s)...
Hash of data verified.
Compressed 374896 bytes to 218114...
Wrote 374896 bytes (218114 compressed) at 0x00010000 in 5.8 seconds (effective 515.6 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 120...
Wrote 3072 bytes (120 compressed) at 0x00008000 in 0.2 seconds (effective 116.6 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
WARNING: esp-idf git submodule components/esptool_py/esptool may be out of date. Run 'git submodule update' in IDF_PATH dir to update.
Toolchain path: /root/esp32/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: crosstool-ng-1.22.0-80-g6c4433a
Compiler version: 5.2.0
Python requirements from /root/esp32/esp-idf/requirements.txt are satisfied.
MONITOR
--- idf_monitor on rfc2217://192.168.0.119:9999 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:736
ho 0 tail 12 room 4
load:0x40078000,len:7732
load:0x40080400,len:5996
entry 0x4008066c
Hash of data verified.になっているし、
M5StickCの起動時の何かが出てるので、書き込みは出来てるっぽい。
しかし、
- 画面に何も出ない
- Macでシリアルつないでもなにもでない
あとすこし!!
% docker cp 430b8a7a5a58:/moddable/build/tmp/esp32/m5stick_c/release/idf/bootloader/bootloader.bin .
% docker cp 430b8a7a5a58:/moddable/build/tmp/esp32/m5stick_c/release/idf/xs_esp32.bin .
% docker cp 430b8a7a5a58:/moddable/build/tmp/esp32/m5stick_c/release/idf/partitions.bin .
% scp "main02.local:/home/takeru/proj/moddable-docker/takeru/*.bin" ./
% time python ~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/tools/esptool.py -p /dev/cu.usbserial-9956C51FB4 -b 1500000 verify_flash --diff yes 0x00001000 bootloader.bin
esptool.py v2.8-dev
Serial port /dev/cu.usbserial-9956C51FB4
Connecting.....
Detecting chip type... ESP32
Chip is ESP32-PICO-D4 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: d8:a0:1d:59:c3:d0
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 1500000
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Verifying 0x38e0 (14560) bytes @ 0x00001000 in flash against bootloader.bin...
-- verify OK (digest matched)
Hard resetting via RTS pin...
python -p /dev/cu.usbserial-9956C51FB4 -b 1500000 verify_flash --diff yes 0.15s user 0.10s system 17% cpu 1.393 total
% time python ~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/tools/esptool.py -p /dev/cu.usbserial-9956C51FB4 -b 1500000 verify_flash --diff yes 0x00010000 xs_esp32.bin
esptool.py v2.8-dev
Serial port /dev/cu.usbserial-9956C51FB4
Connecting....
Detecting chip type... ESP32
Chip is ESP32-PICO-D4 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: d8:a0:1d:59:c3:d0
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 1500000
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Verifying 0x84230 (541232) bytes @ 0x00010000 in flash against xs_esp32.bin...
-- verify OK (digest matched)
Hard resetting via RTS pin...
python -p /dev/cu.usbserial-9956C51FB4 -b 1500000 verify_flash --diff yes 0.15s user 0.15s system 14% cpu 2.137 total
% time python ~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/tools/esptool.py -p /dev/cu.usbserial-9956C51FB4 -b 1500000 verify_flash --diff yes 0x00008000 partitions.bin
esptool.py v2.8-dev
Serial port /dev/cu.usbserial-9956C51FB4
Connecting....
Detecting chip type... ESP32
Chip is ESP32-PICO-D4 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: d8:a0:1d:59:c3:d0
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 1500000
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Verifying 0xc00 (3072) bytes @ 0x00008000 in flash against partitions.bin...
-- verify OK (digest matched)
Hard resetting via RTS pin...
python -p /dev/cu.usbserial-9956C51FB4 -b 1500000 verify_flash --diff yes 0.14s user 0.12s system 20% cpu 1.222 total
verifyもあってる。。
MacにDockerなしで開発環境をセットアップした。
Dockerで作ろうとして一度やったからだけど、ぜんぜんたいへんじゃない。みんなインストールすればいいのに。
pyenvでpythonとpipを分離さえすれば環境汚染はないのでDocker不要じゃね?とも思った。
で、build&実行してみたらデバッガで止まった。
https://twitter.com/urekat/status/1239093026829426689
ん?
##################
##################
################## ###############
################## #######################
########### ###########################
######### ###############################
######## ###################################
###### ################ #########
###### ############### #######
##### ############## ######
##### ############## #####
#### ############### #####
#### ############## ####
#### ############### ####
#### ############## ####
#### ############## ####
#### ############### ####
#### ############### ####
#### ############### ####
#### ############### ####
#### ############### ####
##### ############### ####
##### ############### #####
###### ################ #####
###### ################ ######
####### ################# ######
####### ################## ########
######## ################### #########
######### #################### ##########
########### ###################### #############
########################################### ##################
######################################### ##################
###################################### ##################
################################### ##################
###############################
###########################
######################
##############
#### ####
#### ####
#### ####
#### ####
###########################################################################################
###########################################################################################
###########################################################################################
###########################################################################################
###########################################################################################
###########################################################################################
###########################################################################################
###########################################################################################
###########################################################################################
#### #### ####
#### #### ####
#### #### ####
#### #### ####
####
####
####
####
####
####
####
####
####
####
####
####
#### #### ####
#### #### ####
#### #### ####
#### #### ####
###########################################################################################
###########################################################################################
###########################################################################################
###########################################################################################
###########################################################################################
###########################################################################################
###########################################################################################
###########################################################################################
###########################################################################################
#### ####
#### ####
#### ####
#### ####
###
#######
########## #
############# ##
################ ###
################## #####
##################### ######
####################### ######
############## ######## ######
############## ######## #####
############## ######## #####
############## ######## ####
############## ######## #####
############## ######### ####
############## ######### ####
############## ########## ####
############## ########## ####
############## ########### ####
############## ########### #####
############## ########### #####
############## ############ ######
############## ############# #######
############## ############# ########
############## ############### #########
############## ################ ###########
############## ################# ############
############## #################### ################
############## #################################################
############## ###############################################
############## #############################################
############## ##########################################
############### ######################################
############ ##################################
########## ##############################
###### #######################
### ###############
#
###############################
#############################################
#####################################################
###########################################################
#################################################################
#####################################################################
#########################################################################
#############################################################################
###############################################################################
############### ###############
########### ###########
######### #########
####### #######
###### ######
##### #####
##### #####
#### ####
#### ####
#### ####
#### ####
##### #####
##### #####
###### ######
####### #######
######### #########
########### ###########
############### ###############
###############################################################################
#############################################################################
#########################################################################
#####################################################################
#################################################################
###########################################################
#####################################################
#############################################
###############################
###############################
#############################################
#####################################################
###########################################################
#################################################################
#####################################################################
#########################################################################
#############################################################################
###############################################################################
############### ###############
########### ###########
######### #########
####### #######
###### ######
##### #####
##### #####
#### ####
#### ####
#### ####
#### ####
##### #####
##### #####
###### ######
####### #######
######### #########
########### ###########
############### ###############
###############################################################################
#############################################################################
#########################################################################
#####################################################################
#################################################################
###########################################################
#####################################################
#############################################
###############################
#########################
#####################################
#############################################
###################################################
#########################################################
#############################################################
#################################################################
#####################################################################
#########################################################################
##################### #####################
################## ##################
############## ##############
########### ###########
########## ##########
######## ########
###### ######
###### ######
##### #####
##### #####
##### #####
#### ## ####
#### #### ####
#### ##### ####
#### ###### ####
##### ######## #####
##### ########## #####
##### ########### #####
################## ######
################# ######
################ ########
############### ##########
############## ###########
################# ##############
####################### ##################
############################ #####################
##################################################################################
################################################################################
########### #################################################################
########## #############################################################
######## #########################################################
###### ###################################################
##### #############################################
#### #####################################
## #########################
diff --git a/build/devices/esp32/targets/m5stick_c/setup-target.js b/build/devices/esp32/targets/m5stick_c/setup-target.js
index df0ba09b..4ae40e3a 100644
--- a/build/devices/esp32/targets/m5stick_c/setup-target.js
+++ b/build/devices/esp32/targets/m5stick_c/setup-target.js
@@ -24,7 +24,7 @@ export default function (done) {
});
//@@ microphone
-
+/*
state.accelerometerGyro = new SH200Q;
//trace( 'The Temp:',state.accelerometerGyro.sampleTemp(),'\n');
@@ -78,7 +78,7 @@ export default function (done) {
Timer.clear(state.gyroTimerID);
delete state.gyroTimerID;
}
-
+*/
if (config.autorotate && global.Application){
state.handleRotation = function (reading) {
if (Math.abs(reading.y) > Math.abs(reading.x)) {
@@ -95,7 +95,7 @@ export default function (done) {
}
}
}
- accelerometer.start(300);
+ //accelerometer.start(300);
}
done();
diff --git a/examples/pins/blink/main.js b/examples/pins/blink/main.js
index 0b68cce0..b034f452 100644
--- a/examples/pins/blink/main.js
+++ b/examples/pins/blink/main.js
@@ -21,7 +21,8 @@ import Digital from "pins/digital";
let count = 0;
Timer.repeat(() => {
trace(`repeat ${++count} \n`);
- Digital.write(2, ~count & 1);
- Digital.write(16, count & 1);
-}, 200);
+ //Digital.write(2, ~count & 1);
+ //Digital.write(16, count & 1);
+ Digital.write(10, count & 1);
+}, 1000);
(docker) nano $MODDABLE/build/devices/esp32/targets/m5stick_c/setup-target.js # Comment out SH200Q code.
(docker) cd $MODDABLE/examples/pins/blink
(docker) nano main.js # Change PIN number to 10.
(mac) IPADDR=`ifconfig en0 inet | ruby -e 'puts STDIN.read[/inet (192\.168\.\d+\.\d+)/, 1]'` && echo $IPADDR
(mac) python rfc2217_server_esp.py -p 9999 `ls -1 /dev/cu.usbserial-*` -v -v -v
(docker) UPLOAD_PORT=rfc2217://192.168.0.xxx:9999 ESPBAUD=1500000 mcconfig -m -p esp32/m5stick_c
これでいけた。
でもMacにそのままインストールでも環境汚染はないってことがわかったし、そんなにインストールも大変じゃないのでMacでいいかなとおもいます。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment