diff options
Diffstat (limited to 'stm/main.c')
-rw-r--r-- | stm/main.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/stm/main.c b/stm/main.c index 90fdab3d22..313a868c41 100644 --- a/stm/main.c +++ b/stm/main.c @@ -129,6 +129,7 @@ static const char *help_text = "Specific commands for the board:\n" " pyb.info() -- print some general information\n" " pyb.gc() -- run the garbage collector\n" +" pyb.repl_info(<val>) -- enable/disable printing of info after each command\n" " pyb.delay(<n>) -- wait for n milliseconds\n" " pyb.Led(<n>) -- create Led object for LED n (n=1,2)\n" " Led methods: on(), off()\n" @@ -174,15 +175,24 @@ static mp_obj_t pyb_info(void) { extern void *_ebss; extern void *_estack; extern void *_etext; + printf("_etext=%p\n", &_etext); printf("_sidata=%p\n", &_sidata); printf("_sdata=%p\n", &_sdata); printf("_edata=%p\n", &_edata); printf("_sbss=%p\n", &_sbss); printf("_ebss=%p\n", &_ebss); printf("_estack=%p\n", &_estack); - printf("_etext=%p\n", &_etext); printf("_ram_start=%p\n", &_ram_start); printf("_heap_start=%p\n", &_heap_start); + printf("_heap_end=%p\n", &_heap_end); + printf("_ram_end=%p\n", &_ram_end); + } + + // qstr info + { + uint n_pool, n_qstr, n_str_data_bytes, n_total_bytes; + qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes); + printf("qstr:\n n_pool=%u\n n_qstr=%u\n n_str_data_bytes=%u\n n_total_bytes=%u\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes); } // GC info @@ -206,12 +216,21 @@ static mp_obj_t pyb_info(void) { return mp_const_none; } +static bool repl_display_debugging_info = 0; + +static mp_obj_t pyb_set_repl_info(mp_obj_t o_value) { + repl_display_debugging_info = mp_obj_get_int(o_value); + return mp_const_none; +} + +#if MICROPY_HW_HAS_SDCARD // SD card test static mp_obj_t pyb_sd_test(void) { extern void sdio_init(void); sdio_init(); return mp_const_none; } +#endif static void SYSCLKConfig_STOP(void) { /* After wake-up from STOP reconfigure the system clock */ @@ -418,15 +437,18 @@ void do_repl(void) { if (nlr_push(&nlr) == 0) { rt_call_function_0(module_fun); nlr_pop(); - // optional timing - if (0) { - uint32_t ticks = sys_tick_counter - start; // TODO implement a function that does this properly - printf("(took %lu ms)\n", ticks); - } } else { // uncaught exception mp_obj_print_exception((mp_obj_t)nlr.ret_val); } + + // display debugging info if wanted + if (repl_display_debugging_info) { + uint32_t ticks = sys_tick_counter - start; // TODO implement a function that does this properly + printf("took %lu ms\n", ticks); + gc_collect(); + pyb_info(); + } } } } @@ -594,7 +616,7 @@ int main(void) { soft_reset: // GC init - gc_init(&_heap_start, (void*)HEAP_END); + gc_init(&_heap_start, &_heap_end); // Micro Python init qstr_init(); @@ -632,6 +654,8 @@ soft_reset: mp_obj_t m = mp_obj_new_module(MP_QSTR_pyb); rt_store_attr(m, MP_QSTR_info, rt_make_function_n(0, pyb_info)); + rt_store_attr(m, MP_QSTR_gc, (mp_obj_t)&pyb_gc_obj); + rt_store_attr(m, qstr_from_str("repl_info"), rt_make_function_n(1, pyb_set_repl_info)); #if MICROPY_HW_HAS_SDCARD rt_store_attr(m, MP_QSTR_sd_test, rt_make_function_n(0, pyb_sd_test)); #endif @@ -640,7 +664,6 @@ soft_reset: rt_store_attr(m, MP_QSTR_source_dir, rt_make_function_n(1, pyb_source_dir)); rt_store_attr(m, MP_QSTR_main, rt_make_function_n(1, pyb_main)); rt_store_attr(m, MP_QSTR_sync, rt_make_function_n(0, pyb_sync)); - rt_store_attr(m, MP_QSTR_gc, (mp_obj_t)&pyb_gc_obj); rt_store_attr(m, MP_QSTR_delay, rt_make_function_n(1, pyb_delay)); #if MICROPY_HW_HAS_SWITCH rt_store_attr(m, MP_QSTR_switch, (mp_obj_t)&pyb_switch_obj); @@ -655,7 +678,7 @@ soft_reset: rt_store_attr(m, MP_QSTR_mma_mode, (mp_obj_t)&pyb_mma_write_mode_obj); #endif rt_store_attr(m, MP_QSTR_hid, rt_make_function_n(1, pyb_hid_send_report)); -#if MICROPY_HW_HAS_RTC +#if MICROPY_HW_ENABLE_RTC rt_store_attr(m, MP_QSTR_time, rt_make_function_n(0, pyb_rtc_read)); #endif #if MICROPY_HW_ENABLE_RNG |