Skip to content

Commit 3e4be17

Browse files
authored
Merge pull request #116 from SummerGGift/optimize_stack_prompt
【修改】micropython 是否开启文件同步时的栈检查
2 parents b51c31e + f310b1c commit 3e4be17

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

port/mpy_main.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
#include "mpgetcharport.h"
4747
#include "mpputsnport.h"
4848

49+
#define THREAD_STACK_NO_SYNC 4096
50+
#define THREAD_STACK_WITH_SYNC 8192
51+
4952
#if MICROPY_ENABLE_COMPILER
5053
void do_str(const char *src, mp_parse_input_kind_t input_kind) {
5154
nlr_buf_t nlr;
@@ -68,13 +71,21 @@ static char *heap = RT_NULL;
6871

6972
void mpy_main(const char *filename) {
7073
int stack_dummy;
74+
int stack_size_check;
7175
stack_top = (void *)&stack_dummy;
7276

7377
mp_getchar_init();
7478
mp_putsn_init();
7579

76-
if (rt_thread_self()->stack_size < 4096) {
77-
mp_printf(&mp_plat_print, "The stack (%.*s) size for executing MicroPython must be >=4096\n", RT_NAME_MAX, rt_thread_self()->name);
80+
#if defined(MICROPYTHON_USING_FILE_SYNC_VIA_IDE)
81+
stack_size_check = THREAD_STACK_WITH_SYNC;
82+
#else
83+
stack_size_check = THREAD_STACK_NO_SYNC;
84+
#endif
85+
86+
if (rt_thread_self()->stack_size < stack_size_check)
87+
{
88+
mp_printf(&mp_plat_print, "The stack (%.*s) size for executing MicroPython must be >= %d\n", RT_NAME_MAX, rt_thread_self()->name, stack_size_check);
7889
}
7990

8091
#if MICROPY_PY_THREAD

0 commit comments

Comments
 (0)