@@ -826,7 +826,6 @@ def find_esp32_ports(chip):
826826os .mkdir ('micropy_updates/originals/esp32' )
827827
828828
829-
830829SDKCONFIG_PATH = f'build/sdkconfig.board'
831830
832831MPTHREADPORT_PATH = 'lib/micropython/ports/esp32/mpthreadport.c'
@@ -844,6 +843,9 @@ def find_esp32_ports(chip):
844843MAIN_PATH = 'lib/micropython/ports/esp32/main.c'
845844MAIN_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
848850def write_file (file ,data ):
849851with open (file ,'wb' )as f :
@@ -923,7 +925,7 @@ def update_mpconfigboard():
923925global MPCONFIGBOARD_CMAKE_PATH
924926global 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
928930if not os .path .exists (board_save_path ):
929931os .makedirs (board_save_path )
@@ -1188,7 +1190,53 @@ def compile(*args): # NOQA
11881190update_mpconfigport ()
11891191
11901192if 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
11931241src_path = 'micropy_updates/esp32'
11941242dst_path = 'lib/micropython/ports/esp32'