Skip to content

Commit 83a80e4

Browse files
authored
Merge pull request #27 from yuuu/build_by_esp-idf_v5.0
Follow ESP-IDF 5.0
2 parents a5f9bf0 + 2153a36 commit 83a80e4

File tree

11 files changed

+931
-395
lines changed

11 files changed

+931
-395
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
build/
22
sdkconfig.old
3+
main/example_mrb.h
4+
components/mruby_component/esp32_build_config.rb.lock

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# For more information about build system see
2+
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
3+
# The following five lines of boilerplate have to be in your project's
4+
# CMakeLists in this exact order for cmake to work correctly
5+
cmake_minimum_required(VERSION 3.16)
6+
7+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
8+
project(mruby-esp32)

Makefile

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ the [esp-idf](https://github.com/espressif/esp-idf/tree/master/docs) project
55
for your specific operating system.
66

77
I have only tested this on macOS and using a certain version of
8-
[esp-idf](https://github.com/espressif/esp-idf/tree/abecab7525e7edb1fde16ab5d8cf7b368b1d332c).
8+
[esp-idf](https://github.com/espressif/esp-idf/tree/release/v5.0).
99
You should try to use [more recent version](https://github.com/espressif/esp-idf#setting-up-esp-idf) if you have failed.
1010

1111
You will need to recursively clone this project with the recursive flag
@@ -26,9 +26,8 @@ are at least somewhat familiar with the building steps. With that in mind you
2626
can do something like the following and see the example running:
2727

2828
```
29-
make menuconfig
30-
make MRUBY_EXAMPLE=simplest_mrb.rb
31-
make MRUBY_EXAMPLE=simplest_mrb.rb flash monitor
29+
idf.py build -D MRUBY_EXAMPLE=simplest_mrb.rb
30+
idf.py -p $(YOUR_SERIAL_PORT) flash monitor
3231
```
3332

3433
The flag `MRUBY_EXAMPLE` can be replaced with one of the following:
@@ -38,38 +37,10 @@ The flag `MRUBY_EXAMPLE` can be replaced with one of the following:
3837
modify this file to include your SSID and password
3938
* _system_mrb.rb_ - Examples of most of the system APIs
4039

41-
## wifi\_example\_mrb.rb stack overflow
42-
43-
If you experience a stack overflow during execution of the WiFi example, please
44-
adjust the stack size on file `main/mruby_main.c` from 8192 to 32768.
45-
46-
```
47-
void app_main()
48-
{
49-
nvs_flash_init();
50-
xTaskCreate(&mruby_task, "mruby_task", 32768, NULL, 5, NULL);
51-
}
52-
53-
```
54-
55-
Also adjust the configured stack size using `make menuconfig` from the default
56-
one (which may be either 2048 or 4096) to 32768.
57-
58-
```
59-
make menuconfig
60-
Component config ---> ESP32-specific ---> Event loop task stack size
61-
```
62-
63-
References: Issue [#11](https://github.com/mruby-esp32/mruby-esp32/issues/11)
64-
and
65-
[mruby-esp32\/mruby-socket](https://github.com/mruby-esp32/mruby-socket)
66-
67-
---
68-
6940
The clean command will clean both the ESP32 build and the mruby build:
7041

7142
```
72-
make clean
43+
idf.py fullclean
7344
```
7445

7546
There are multiple GEMS that can be turned on and off via the mruby
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
set(MRUBY_DIR "${COMPONENT_DIR}/mruby")
2+
set(LIBMRUBY_FILE "${COMPONENT_DIR}/mruby/build/esp32/lib/libmruby.a")
3+
set(MRUBY_CONFIG ${COMPONENT_DIR}/esp32_build_config.rb)
4+
5+
idf_component_register(
6+
INCLUDE_DIRS mruby/include
7+
REQUIRES esp_wifi esp_hw_support esp_rom
8+
)
9+
10+
add_custom_command(
11+
OUTPUT ${LIBMRUBY_FILE}
12+
COMMAND ${CMAKE_COMMAND} -E env "MRUBY_CONFIG=${MRUBY_CONFIG}" "CC=${CMAKE_C_COMPILER}" "LD=${CMAKE_LINKER}" "AR=${CMAKE_AR}" "COMPONENT_INCLUDES=$<TARGET_PROPERTY:${COMPONENT_TARGET},INTERFACE_INCLUDE_DIRECTORIES>" rake
13+
WORKING_DIRECTORY ${MRUBY_DIR}
14+
VERBATIM
15+
)
16+
17+
add_prebuilt_library(
18+
libmruby ${LIBMRUBY_FILE}
19+
PRIV_REQUIRES esp_wifi esp_hw_support esp_rom
20+
)
21+
target_link_libraries(${COMPONENT_LIB} INTERFACE libmruby)
22+
23+
add_custom_target(mruby DEPENDS ${LIBMRUBY_FILE})
24+
add_dependencies(${COMPONENT_LIB} mruby)

components/mruby_component/component.mk

Lines changed: 0 additions & 16 deletions
This file was deleted.

components/mruby_component/esp32_build_config.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
toolchain :gcc
3030

3131
conf.cc do |cc|
32-
cc.include_paths << ENV["COMPONENT_INCLUDES"].split(' ')
32+
cc.include_paths << ENV["COMPONENT_INCLUDES"].split(';')
3333

3434
cc.flags << '-Wno-maybe-uninitialized'
35+
cc.flags << '-mlongcalls'
36+
cc.flags << '-std=gnu17'
3537
cc.flags = cc.flags.flatten.collect { |x| x.gsub('-MP', '') }
3638

3739
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)

main/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
set(MRBC_COMMAND "${COMPONENT_DIR}/../components/mruby_component/mruby/bin/mrbc")
2+
3+
idf_component_register(
4+
SRCS mruby_main.c
5+
INCLUDE_DIRS .
6+
REQUIRES mruby_component
7+
PRIV_REQUIRES nvs_flash
8+
)
9+
10+
add_custom_command(
11+
OUTPUT example_mrb.h
12+
COMMAND ${MRBC_COMMAND} -B example_mrb -o example_mrb.h ${COMPONENT_DIR}/examples/${MRUBY_EXAMPLE}
13+
WORKING_DIRECTORY ${COMPONENT_DIR}
14+
VERBATIM
15+
)
16+
17+
add_custom_target(main DEPENDS example_mrb.h)
18+
add_dependencies(${COMPONENT_LIB} main)

main/component.mk

Lines changed: 0 additions & 10 deletions
This file was deleted.

main/mruby_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ void mruby_task(void *pvParameter)
4343
void app_main()
4444
{
4545
nvs_flash_init();
46-
xTaskCreate(&mruby_task, "mruby_task", 8192, NULL, 5, NULL);
46+
xTaskCreate(&mruby_task, "mruby_task", 16384, NULL, 5, NULL);
4747
}

0 commit comments

Comments
 (0)