alt function pins, small packages with fewer pins, pins.csv

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
jgriessen
Posts: 191
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

Re: alt function pins, small packages with fewer pins, pins.csv

Post by jgriessen » Tue Apr 10, 2018 8:29 pm

Thanks, I'll try that. I see I need to use git latest also. I'll do this in a branch called stm32_frozen in case its wanted to merge.
Last edited by jgriessen on Tue Apr 10, 2018 8:41 pm, edited 1 time in total.
John Griessen blog.kitmatic.com

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: alt function pins, small packages with fewer pins, pins.csv

Post by dhylands » Tue Apr 10, 2018 8:35 pm

Something like this:

Code: Select all

diff --git a/ports/stm32/main.c b/ports/stm32/main.c
index fb3e843..fae0319 100644
--- a/ports/stm32/main.c
+++ b/ports/stm32/main.c
@@ -593,6 +593,10 @@ soft_reset:
     // 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";
+#define USE_FROZEN_BOOT_AND_MAIN 1
+#if USE_FROZEN_BOOT_AND_MAIN
+        pyexec_frozen_module(boot_py);
+#else
         mp_import_stat_t stat = mp_import_stat(boot_py);
         if (stat == MP_IMPORT_STAT_FILE) {
             int ret = pyexec_file(boot_py);
@@ -603,6 +607,7 @@ soft_reset:
                 flash_error(4);
             }
         }
+#endif
     }
 
     // turn boot-up LEDs off
@@ -656,6 +661,9 @@ soft_reset:
         } else {
             main_py = mp_obj_str_get_str(MP_STATE_PORT(pyb_config_main));
         }
+#if USE_FROZEN_BOOT_AND_MAIN
+        pyexec_frozen_module(main_py);
+#else
         mp_import_stat_t stat = mp_import_stat(main_py);
         if (stat == MP_IMPORT_STAT_FILE) {
             int ret = pyexec_file(main_py);
@@ -666,6 +674,7 @@ soft_reset:
                 flash_error(3);
             }
         }
+#endif
     }
 
     // Main script is finished, so now go into REPL mode.

User avatar
jgriessen
Posts: 191
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

Re: alt function pins, small packages with fewer pins, pins.csv

Post by jgriessen » Tue Apr 10, 2018 8:57 pm

I did that change and compiled and compiler shows that then there is no way to get to the goto soft_reset_exit.

Seems like adding a section like below would do it:

Code: Select all

    int ret = pyexec_file(main_py);
            if (ret & PYEXEC_FORCED_EXIT) {
                goto soft_reset_exit;
            }
===============================================

#if USE_FROZEN_BOOT_AND_MAIN
        pyexec_frozen_module(main_py);
            if (ret & PYEXEC_FORCED_EXIT) {
                goto soft_reset_exit;
            }
Yes, that compiles. Will test now.
John Griessen blog.kitmatic.com

Post Reply