@@ -69,6 +69,19 @@ static void make_empty_file(FATFS *fatfs, const char *path) {
6969 f_close (& fp );
7070}
7171
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+
7285// we don't make this function static because it needs a lot of stack and we
7386// want it to be executed without using stack within main() function
7487void filesystem_init (bool create_allowed , bool force_create ) {
@@ -98,6 +111,8 @@ void filesystem_init(bool create_allowed, bool force_create) {
98111 make_empty_file (& vfs_fat -> fatfs , "/.metadata_never_index" );
99112 make_empty_file (& vfs_fat -> fatfs , "/.Trashes" );
100113 make_empty_file (& vfs_fat -> fatfs , "/.fseventsd/no_log" );
114+ // make a sample code.py file
115+ make_sample_code_file (& vfs_fat -> fatfs );
101116
102117 // create empty lib directory
103118 f_mkdir (& vfs_fat -> fatfs , "/lib" );
0 commit comments