@@ -69,6 +69,19 @@ static void make_empty_file(FATFS *fatfs, const char *path) {
69
69
f_close (& fp );
70
70
}
71
71
72
+
73
+ static void make_sample_code_file (FATFS * fatfs ) {
74
+ #if CIRCUITPY_FULL_BUILD
75
+ FIL fs ;
76
+ UINT char_written = 0 ;
77
+ const byte buffer [] = "print('Hello World!')\n" ;
78
+ //Create or modify existing code.py file
79
+ f_open (fatfs , & fs , "/code.py" , FA_WRITE | FA_CREATE_ALWAYS );
80
+ f_write (& fs , buffer , sizeof (buffer ) - 1 , & char_written );
81
+ f_close (& fs );
82
+ #endif
83
+ }
84
+
72
85
// we don't make this function static because it needs a lot of stack and we
73
86
// want it to be executed without using stack within main() function
74
87
void filesystem_init (bool create_allowed , bool force_create ) {
@@ -98,6 +111,8 @@ void filesystem_init(bool create_allowed, bool force_create) {
98
111
make_empty_file (& vfs_fat -> fatfs , "/.metadata_never_index" );
99
112
make_empty_file (& vfs_fat -> fatfs , "/.Trashes" );
100
113
make_empty_file (& vfs_fat -> fatfs , "/.fseventsd/no_log" );
114
+ // make a sample code.py file
115
+ make_sample_code_file (& vfs_fat -> fatfs );
101
116
102
117
// create empty lib directory
103
118
f_mkdir (& vfs_fat -> fatfs , "/lib" );
0 commit comments