summaryrefslogtreecommitdiff
path: root/supervisor
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2019-11-29 11:27:09 -0600
committerJeff Epler <jepler@gmail.com>2019-11-29 11:27:09 -0600
commit95d9c49e439cc4ba440ea737b57d03544bc952dc (patch)
treecd3f4d0f38f509036f4b141eb4b9222be460c045 /supervisor
parentbfdfe0e68191554b70103f249ae1fe08f7fc85f0 (diff)
parent83ecb1b65e24d970833d17d8322230ba05c5d527 (diff)
Merge remote-tracking branch 'origin/master' into tick-refactor
Diffstat (limited to 'supervisor')
-rw-r--r--supervisor/shared/filesystem.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c
index c50d7f4ee..92727f6fb 100644
--- a/supervisor/shared/filesystem.c
+++ b/supervisor/shared/filesystem.c
@@ -69,6 +69,19 @@ static void make_empty_file(FATFS *fatfs, const char *path) {
f_close(&fp);
}
+
+static void make_sample_code_file(FATFS *fatfs) {
+ #if CIRCUITPY_FULL_BUILD
+ FIL fs;
+ UINT char_written = 0;
+ const byte buffer[] = "print('Hello World!')\n";
+ //Create or modify existing code.py file
+ f_open(fatfs, &fs, "/code.py", FA_WRITE | FA_CREATE_ALWAYS);
+ f_write(&fs, buffer, sizeof(buffer) - 1, &char_written);
+ f_close(&fs);
+ #endif
+}
+
// we don't make this function static because it needs a lot of stack and we
// want it to be executed without using stack within main() function
void filesystem_init(bool create_allowed, bool force_create) {
@@ -98,6 +111,8 @@ void filesystem_init(bool create_allowed, bool force_create) {
make_empty_file(&vfs_fat->fatfs, "/.metadata_never_index");
make_empty_file(&vfs_fat->fatfs, "/.Trashes");
make_empty_file(&vfs_fat->fatfs, "/.fseventsd/no_log");
+ // make a sample code.py file
+ make_sample_code_file(&vfs_fat->fatfs);
// create empty lib directory
f_mkdir(&vfs_fat->fatfs, "/lib");