Skip to content

Commit ec8b31c

Browse files
committed
Fixed frozen module loading
1 parent 0b46a00 commit ec8b31c

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

firmware/main/main.c

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -39,47 +39,47 @@ void app_main()
3939
size_t mp_task_heap_size = mp_preallocate_heap();
4040
ESP_LOGI(TAG, "Heap size: %d", mp_task_heap_size);
4141

42-
// logo();
43-
// bool is_first_boot = nvs_init();
42+
logo();
43+
bool is_first_boot = nvs_init();
4444

4545
fflush(stdout);
4646
platform_init();
4747

48-
// if (is_first_boot) {
49-
// #ifdef CONFIG_DRIVER_FRAMEBUFFER_ENABLE
50-
// driver_framebuffer_fill(NULL, COLOR_BLACK);
51-
// driver_framebuffer_print(NULL, "Extracting ZIP...\n", 0, 0, 1, 1, COLOR_WHITE, &roboto_12pt7b);
52-
// driver_framebuffer_flush(0);
53-
// #endif
54-
// printf("Attempting to unpack FAT initialization ZIP file...\b");
55-
// if (unpack_first_boot_zip() != ESP_OK) { //Error
56-
// #ifdef CONFIG_DRIVER_FRAMEBUFFER_ENABLE
57-
// driver_framebuffer_fill(NULL, COLOR_BLACK);
58-
// driver_framebuffer_print(NULL, "ZIP error!\n", 0, 0, 1, 1, COLOR_WHITE, &roboto_12pt7b);
59-
// driver_framebuffer_flush(0);
60-
// #endif
61-
// printf("An error occured while unpacking the ZIP file!");
62-
// nvs_write_zip_status(false);
63-
// } else {
64-
// nvs_write_zip_status(true);
65-
// }
66-
// esp_restart();
67-
// }
48+
if (is_first_boot) {
49+
#ifdef CONFIG_DRIVER_FRAMEBUFFER_ENABLE
50+
driver_framebuffer_fill(NULL, COLOR_BLACK);
51+
driver_framebuffer_print(NULL, "Extracting ZIP...\n", 0, 0, 1, 1, COLOR_WHITE, &roboto_12pt7b);
52+
driver_framebuffer_flush(0);
53+
#endif
54+
printf("Attempting to unpack FAT initialization ZIP file...\b");
55+
if (unpack_first_boot_zip() != ESP_OK) { //Error
56+
#ifdef CONFIG_DRIVER_FRAMEBUFFER_ENABLE
57+
driver_framebuffer_fill(NULL, COLOR_BLACK);
58+
driver_framebuffer_print(NULL, "ZIP error!\n", 0, 0, 1, 1, COLOR_WHITE, &roboto_12pt7b);
59+
driver_framebuffer_flush(0);
60+
#endif
61+
printf("An error occured while unpacking the ZIP file!");
62+
nvs_write_zip_status(false);
63+
} else {
64+
nvs_write_zip_status(true);
65+
}
66+
esp_restart();
67+
}
6868

69-
// int magic = get_magic();
69+
int magic = get_magic();
7070

71-
// switch(magic) {
72-
// case MAGIC_OTA:
73-
// // This triggers an Over-the-Air firmware update
74-
// badge_ota_update();
75-
// break;
76-
// case MAGIC_FACTORY_RESET:
77-
// // This clears any FAT data partitions
78-
// factory_reset();
79-
// break;
80-
// default:
81-
// // This starts the MicroPython FreeRTOS task
82-
start_mp();
83-
// while(1){}
84-
// }
71+
switch(magic) {
72+
case MAGIC_OTA:
73+
// This triggers an Over-the-Air firmware update
74+
badge_ota_update();
75+
break;
76+
case MAGIC_FACTORY_RESET:
77+
// This clears any FAT data partitions
78+
factory_reset();
79+
break;
80+
default:
81+
// This starts the MicroPython FreeRTOS task
82+
start_mp();
83+
while(1){}
84+
}
8585
}

firmware/python_modules/common/_boot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import uos, gc
1+
import uos, gc, sys
22

33
try:
44
uos.mkdir('/lib')
@@ -16,5 +16,5 @@
1616
uos.mkdir('/config')
1717
except:
1818
pass
19-
19+
sys.path.append(".frozen")
2020
gc.collect()

0 commit comments

Comments
 (0)