Skip to content

Commit 17232ca

Browse files
committed
now it compiles!!!!
1 parent 16f113f commit 17232ca

File tree

2 files changed

+53
-4
lines changed

2 files changed

+53
-4
lines changed

builder/esp32.py

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,6 @@ def find_esp32_ports(chip):
826826
os.mkdir('micropy_updates/originals/esp32')
827827

828828

829-
830829
SDKCONFIG_PATH = f'build/sdkconfig.board'
831830

832831
MPTHREADPORT_PATH = 'lib/micropython/ports/esp32/mpthreadport.c'
@@ -844,6 +843,9 @@ def find_esp32_ports(chip):
844843
MAIN_PATH = 'lib/micropython/ports/esp32/main.c'
845844
MAIN_SAVE_PATH = 'micropy_updates/originals/esp32/main.c'
846845

846+
COMMON_CMAKE_PATH = 'lib/micropython/ports/esp32/esp32_common.cmake'
847+
COMMON_CMAKE_SAVE_PATH = 'micropy_updates/originals/esp32/esp32_common.cmake'
848+
847849

848850
def write_file(file, data):
849851
with open(file, 'wb') as f:
@@ -923,7 +925,7 @@ def update_mpconfigboard():
923925
global MPCONFIGBOARD_CMAKE_PATH
924926
global MPCONFIGBOARD_CMAKE_SAVE_PATH
925927

926-
board_save_path = f'micropy_updates/esp32/boards/{board}'
928+
board_save_path = f'micropy_updates/originals/esp32/boards/{board}'
927929

928930
if not os.path.exists(board_save_path):
929931
os.makedirs(board_save_path)
@@ -1188,7 +1190,53 @@ def compile(*args): # NOQA
11881190
update_mpconfigport()
11891191

11901192
if dual_core_threads:
1191-
compile_cmd.append('MICROPY_MULTICORE_THREAD=1')
1193+
cwd = os.getcwd()
1194+
1195+
ext_mod_path = os.path.abspath('ext_mod/threading')
1196+
os.chdir('lib/micropython/ports/esp32')
1197+
threading_includes = set()
1198+
1199+
threading_sources = []
1200+
for root, dirs, files in os.walk(ext_mod_path):
1201+
if root.endswith('inc'):
1202+
threading_includes.add(root)
1203+
1204+
for file in files:
1205+
if not file.endswith('.c'):
1206+
continue
1207+
1208+
threading_sources.append(
1209+
os.path.join(root, file)
1210+
)
1211+
1212+
os.chdir(cwd)
1213+
1214+
# compile_cmd.append('MICROPY_MULTICORE_THREAD=1')
1215+
1216+
1217+
data = read_file(COMMON_CMAKE_PATH, COMMON_CMAKE_SAVE_PATH)
1218+
1219+
if data.count('list(APPEND MICROPY_SOURCE_PORT') == 2:
1220+
threading_sources = '\n'.join(' ' + item for item in threading_sources)
1221+
1222+
code = [
1223+
'list(APPEND MICROPY_SOURCE_PORT',
1224+
threading_sources,
1225+
')',
1226+
'',
1227+
'list(APPEND MICROPY_SOURCE_QSTR'
1228+
]
1229+
data = data.replace('list(APPEND MICROPY_SOURCE_QSTR', '\n'.join(code))
1230+
1231+
threading_includes = '\n'.join(' ' + item for item in threading_includes)
1232+
1233+
code = [
1234+
'INCLUDE_DIRS',
1235+
threading_includes
1236+
]
1237+
data = data.replace('INCLUDE_DIRS', '\n'.join(code))
1238+
1239+
write_file(COMMON_CMAKE_PATH, data)
11921240

11931241
src_path = 'micropy_updates/esp32'
11941242
dst_path = 'lib/micropython/ports/esp32'

micropy_updates/esp32/mpthreadport.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "py/mphal.h"
3434
#include "mpthreadport.h"
3535

36+
#if MICROPY_PY_THREAD
3637
#include "esp_task.h"
3738
#include "../../../../ext_mod/threading/common/inc/thread_common.h"
3839

@@ -82,7 +83,7 @@ void mp_thread_init(void *stack, uint32_t stack_len) {
8283
// FREERTOS_TASK_DELETE_HOOK needs the thread ready after thread_mutex is ready
8384
thread = &thread_entry0;
8485

85-
void threading_init(stack, stack_len);
86+
threading_init(stack, stack_len);
8687
}
8788

8889
void mp_thread_gc_others(void) {

0 commit comments

Comments
 (0)