8000 stm32/main: Search for frozen or fs boot.py and main.py. by higstar · Pull Request #4248 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

stm32/main: Search for frozen or fs boot.py and main.py. #4248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

10000
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ports/stm32/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@

void SystemClock_Config(void);

// TODO Find an appropriate header file to place this prototype in. Needed in this file in order to load boot.py and main.py from either frozen or fs
extern mp_import_stat_t mp_import_stat_any(const char *path);

pyb_thread_t pyb_thread_main;
fs_user_mount_t fs_user_mount_flash;

Expand Down Expand Up @@ -652,7 +655,7 @@ void stm32_main(uint32_t reset_mode) {
// TODO perhaps have pyb.reboot([bootpy]) function to soft-reboot and execute custom boot.py
if (reset_mode == 1 || reset_mode == 3) {
const char *boot_py = "boot.py";
mp_import_stat_t stat = mp_import_stat(boot_py);
mp_import_stat_t stat = mp_import_stat_any(boot_py);
if (stat == MP_IMPORT_STAT_FILE) {
int ret = pyexec_file(boot_py);
if (ret & PYEXEC_FORCED_EXIT) {
Expand Down Expand Up @@ -713,7 +716,7 @@ void stm32_main(uint32_t reset_mode) {
} else {
main_py = mp_obj_str_get_str(MP_STATE_PORT(pyb_config_main));
}
mp_import_stat_t stat = mp_import_stat(main_py);
mp_import_stat_t stat = mp_import_stat_any(main_py);
if (stat == MP_IMPORT_STAT_FILE) {
int ret = pyexec_file(main_py);
if (ret & PYEXEC_FORCED_EXIT) {
Expand Down
2 changes: 1 addition & 1 deletion py/builtinimport.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool mp_obj_is_package(mp_obj_t module) {

// Stat either frozen or normal module by a given path
// (whatever is available, if at all).
STATIC mp_import_stat_t mp_import_stat_any(const char *path) {
mp_import_stat_t mp_import_stat_any(const char *path) {
#if MICROPY_MODULE_FROZEN
mp_import_stat_t st = mp_frozen_stat(path);
if (st != MP_IMPORT_STAT_NO_EXIST) {
Expand Down
0