[NUCLEO-L476RG] main.py start only after soft-reboot

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
vinz-uts
Posts: 22
Joined: Fri Sep 10, 2021 9:22 am

[NUCLEO-L476RG] main.py start only after soft-reboot

Post by vinz-uts » Wed Sep 29, 2021 3:49 pm

Hi everyone, I've a issue with autostart my script. I've write and load my `main.py` script that toggle a led every second and put him in the flash. Using ampy I've verified the script is correctly loaded. When I power-on my board the 'main.py` doesn't run, it start only after a soft reboot (ctrl+D). The same issue there is if I put my code in the 'boot.py' file. Any suggestion? Thanks for your support!

@edit: I test the same code on a ESP32 and all works fine, every power on/off cycle the code start without problem.

vinz-uts
Posts: 22
Joined: Fri Sep 10, 2021 9:22 am

Re: [NUCLEO-L476RG] main.py start only after soft-reboot

Post by vinz-uts » Thu Sep 30, 2021 9:07 am

I've done some tests. I'm using a custom board mounting a STM32-L476RG microcontroller, and I can't fix this problem. Using an official NUCLEO-L476RG instead, the main.py start autonomously when the board is powered and works normally. It's possible that the problem have to be found in hardware connection? Thanks to evreyone can help me to investigate where is the problem.

vinz-uts
Posts: 22
Joined: Fri Sep 10, 2021 9:22 am

Re: [NUCLEO-L476RG] main.py start only after soft-reboot

Post by vinz-uts » Fri Oct 01, 2021 7:41 am

I found the problem, then the solution. The problem was in the hardware and configuration of my custom board, it have not a user switch like pyBoard or NUCLEO-L476RG, but in `mpconfigboard.h` was present:

Code: Select all

#define MICROPY_HW_USRSW_PIN                 (pin_C12)
#define MICROPY_HW_USRSW_PULL              (GPIO_NOPULL)
#define MICROPY_HW_USRSW_EXTI_MODE  (GPIO_MODE_IT_FALLING)
#define MICROPY_HW_USRSW_PRESSED      (0)
On this pin my board forces the 0, so the system was starting in Safe Mode (https://micropython-docs-esp32.readthed ... reset.html), so `boot.py` and `main.py` was skipped. Changing the user button pin, all normally works.

Post Reply