1515import uos
1616import ujson
1717
18- '''
18+ """
1919Mark.Zhu - 2022/12/02
2020Added the littlefs2 mount function,it will be called after a failed attempt to mount littlefs1
21- '''
21+ """
2222# global datacall_flag
2323datacall_flag = 1
2424
2525def _repl_enable ():
2626 global datacall_flag
2727 if "system_config.json" in uos .listdir ("/" ):
28- with open ("/system_config.json" , "r" , encoding = ' utf-8' ) as fd :
28+ with open ("/system_config.json" , "r" , encoding = " utf-8" ) as fd :
2929 try :
3030 json_data = ujson .load (fd )
3131 datacall_flag = json_data .get ("datacallFlag" , 1 )
3232
3333 except ValueError :
34- with open ("/usr/system_config.json" , "w" , encoding = ' utf-8' ) as fdw :
34+ with open ("/usr/system_config.json" , "w" , encoding = " utf-8" ) as fdw :
3535 new_json_data = ujson .dumps ({"replFlag" : 0 , "datacallFlag" : datacall_flag })
3636 fdw .write (new_json_data )
3737 else :
38- with open ("/system_config.json" , "w+" , encoding = ' utf-8' ) as fd :
38+ with open ("/system_config.json" , "w+" , encoding = " utf-8" ) as fd :
3939 repl_data = ujson .dumps ({"replFlag" : 0 })
4040 fd .write (repl_data )
4141
@@ -46,20 +46,20 @@ def _repl_enable():
4646 except Exception :
4747 from uos import VfsLfs2 as VfsLfs
4848
49- udev = uos .FlashDevice (' customer_fs' , 4096 )
49+ udev = uos .FlashDevice (" customer_fs" , 4096 )
5050 try :
51- uos .mount (udev , '/' )
51+ uos .mount (udev , "/" )
5252 except Exception as e :
53- if ' ENODEV' in str (e ):
53+ if " ENODEV" in str (e ):
5454 VfsLfs .mkfs (udev )
55- uos .mount (udev , '/' )
56- if ' usr' not in uos .listdir ():
57- uos .mkdir (' usr' )
58- if ' bak' not in uos .listdir ():
59- uos .mkdir (' bak' )
55+ uos .mount (udev , "/" )
56+ if " usr" not in uos .listdir ():
57+ uos .mkdir (" usr" )
58+ if " bak" not in uos .listdir ():
59+ uos .mkdir (" bak" )
6060
6161except Exception :
62- print (' error occurs in boot step.' )
62+ print (" error occurs in boot step." )
6363
6464finally :
6565 _repl_enable ()
0 commit comments