Skip to content

Commit 5ec7ced

Browse files
committed
Using jerryscript as a third-party dependency
1 parent e9c2b2b commit 5ec7ced

File tree

378 files changed

+94
-107563
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

378 files changed

+94
-107563
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.vscode
2+
deps/jerryscript
23
build
4+

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "deps/jerryscript"]
2+
path = deps/jerryscript
3+
url = git@github.com:jerryscript-project/jerryscript.git

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@
22
# CMakeLists in this exact order for cmake to work correctly
33
cmake_minimum_required(VERSION 3.5)
44

5+
set(JERRYSCRIPT_SOURCE "${CMAKE_SOURCE_DIR}/deps/jerryscript")
6+
7+
# Jerryscript setting here
8+
set(JERRY_GLOBAL_HEAP_SIZE "(128)")
9+
510
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
611
project(nodemcujs)

README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,16 @@ ESP-IDF(V3.2-RC): https://docs.espressif.com/projects/esp-idf/zh_CN/v3.2-rc/get-
7676
## 2. 获取 nodemcujs 源码
7777

7878
```bash
79-
$ git clone git@github.com:nodemcujs/nodemcujs-firmware.git
79+
$ git clone --recursive git@github.com:nodemcujs/nodemcujs-firmware.git
8080
```
8181

82-
项目已经内置了 JerryScript 并修改了一些 CMakeLists.txt 以使得它可以在 ESP-IDF 中构建。
82+
项目已经将 JerryScript 作为子模块,存放在 `/deps/jerryscript` 目录下。`clone` 的时候会一并将所有子模块 clone 下来。
83+
84+
如果你忘记了在 `clone` 时候加 `--recursive` 选项,那么你可以通过下面的命令单独 clone `子模块`
85+
86+
```bash
87+
$ git submodule update --init
88+
```
8389

8490
## 3. 编译固件
8591

@@ -97,10 +103,10 @@ $ cd build
97103
使用 Cmake 构建
98104

99105
```bash
100-
cmake ../
106+
$ cmake ../
101107
```
102108

103-
配置构建参数。大多数情况下使用默认参数就可以,这里一般只需要配置好串口和波特率。
109+
可选步骤。配置构建参数。大多数情况下使用默认参数就可以,这里一般只需要配置好串口和波特率。
104110

105111
```bash
106112
$ make menuconfig
@@ -111,7 +117,7 @@ $ make menuconfig
111117
最后进行编译固件。
112118

113119
```bash
114-
make
120+
$ make
115121
```
116122

117123
## 4. 烧录固件
@@ -125,7 +131,7 @@ make
125131
使用下面的命令进行固件的烧录。
126132

127133
```bash
128-
make flash
134+
$ make flash
129135
```
130136

131137
如果你看到控制台输出如下信息,并一直停留,那么你需要手动让 ESP32 芯片进入下载模式。
@@ -146,6 +152,8 @@ Connecting........___........___
146152

147153
我们推荐使用 [esptool.py][esptool] 工具进行烧录。可以从 [release][release-github] 页面下载已经构建好的固件。
148154

155+
Tips: ESP-IDF 内置了 `esptool.py` 工具,可以直接使用。路径在 `$IDF_PATH/components/esptool_py/esptool/esptool.py`
156+
149157
```bash
150158
$ python esptool.py --chip esp32 -p /dev/ttyUSB0 -b 460800 write_flash --flash_mode dio --flash_size detect --flash_freq 80m 0x1000 bootloader.bin 0x8000 partition-table.bin 0x10000 nodemcujs.bin
151159
```
@@ -177,6 +185,8 @@ $ mkspiffs -c spiffs -b 4096 -p 256 -s 0x2F0000 spiffs.bin
177185
这里有几点需要注意:
178186

179187
> -s 0x2F0000 是 nodemcujs 所使用的大小,至少在目前你不能大于此值。除非你自己定义分区表。
188+
>
189+
> 编译 mkspiffs 时需要传递参数: `CPPFLAGS="-DSPIFFS_OBJ_META_LEN=4"` 否则会出现 nodemcujs 文件系统无法工作。
180190
181191
## 7. 烧录文件到 flash 芯片
182192

@@ -185,7 +195,7 @@ nodemcujs 会在启动时检查分区,如果无法挂载 `storage` 分区,
185195
你可以将你的 JavaScript 应用或者任何文件烧录到 ESP32 上,nodemcujs 会在启动时自动加载 `/spiffs/index.js` 文件,所以这可能是自动启动应用的一个好主意。
186196

187197
```bash
188-
python esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 115200 write_flash -z 0x10000 spiffs.bin
198+
$ python esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 115200 write_flash -z 0x110000 spiffs.bin
189199
```
190200

191201
使用上面的命令将文件镜像烧录到 flash 中。
@@ -196,6 +206,16 @@ python esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 115200 write_flash -z
196206
>
197207
> -z 0x10000 是目前 nodemcujs 默认分区表参数,至少在目前你不能小于此值,否则 app 程序可能会被覆盖。
198208
209+
## 8. 更新 jerryscript
210+
211+
jerryscript 作为一个子模块放置在 `/deps/jerryscript` 目录下,所以更新 jerryscript 很方便,进入 `/deps/jerryscript` 目录,使用 `git` 拉取最新 `commit` 就行了。
212+
213+
或者手动下载最新 jerryscript 文件替换掉。
214+
215+
# FAQ | 常见错误一览
216+
217+
请前往官方网站查看。
218+
199219
# License
200220

201221
[MIT][MIT]

components/jerry-console/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ cmake_minimum_required (VERSION 2.8.12)
33
set(COMPONENT_ADD_INCLUDEDIRS include)
44
set(COMPONENT_SRCDIRS .)
55

6-
set(COMPONENT_REQUIRES "jerry-core" "jerry-ext")
6+
set(COMPONENT_PRIV_INCLUDEDIRS
7+
${JERRYSCRIPT_SOURCE}/jerry-core/include
8+
${JERRYSCRIPT_SOURCE}/jerry-ext/include
9+
${JERRYSCRIPT_SOURCE}/jerry-port/default/include)
710

811
register_component()

0 commit comments

Comments
 (0)