c046b23ea2
Helps prevent the filesystem from getting formatted by mistake, among other things. For example, on a Pico board, entering Ctrl+D and Ctrl+C fast many times will eventually wipe the filesystem (without warning or notice). Further rationale: Ctrl+C is used a lot by automation scripts (eg mpremote) and UI's (eg Mu, Thonny) to get the board into a known state. If the board is not responding for a short time then it's not possible to know if it's just a slow start up (eg in _boot.py), or an infinite loop in the main application. The former should not be interrupted, but the latter should. The only way to distinguish these two cases would be to wait "long enough", and if there's nothing on the serial after "long enough" then assume it's running the application and Ctrl+C should break out of it. But defining "long enough" is impossible for all the different boards and their possible behaviour. The solution in this commit is to make it so that frozen start-up code cannot be interrupted by Ctrl+C. That code then effectively acts like normal C start-up code, which also cannot be interrupted. Note: on the stm32 port this was never seen as an issue because all start-up code is in C. But now other ports start to put more things in _boot.py and so this problem crops up. Signed-off-by: David Grayson <davidegrayson@gmail.com> |
||
---|---|---|
.. | ||
main.c | ||
Makefile | ||
mpconfigport.h | ||
mphalport.h | ||
qstrdefsport.h | ||
README.md | ||
stm32f405.ld | ||
uart_core.c |
The minimal port
This port is intended to be a minimal MicroPython port that actually runs. It can run under Linux (or similar) and on any STM32F4xx MCU (eg the pyboard).
Building and running Linux version
By default the port will be built for the host machine:
$ make
To run the executable and get a basic working REPL do:
$ make run
Building for an STM32 MCU
The Makefile has the ability to build for a Cortex-M CPU, and by default includes some start-up code for an STM32F4xx MCU and also enables a UART for communication. To build:
$ make CROSS=1
If you previously built the Linux version, you will need to first run
make clean
to get rid of incompatible object files.
Building will produce the build/firmware.dfu file which can be programmed to an MCU using:
$ make CROSS=1 deploy
This version of the build will work out-of-the-box on a pyboard (and anything similar), and will give you a MicroPython REPL on UART1 at 9600 baud. Pin PA13 will also be driven high, and this turns on the red LED on the pyboard.
Building without the built-in MicroPython compiler
This minimal port can be built with the built-in MicroPython compiler disabled. This will reduce the firmware by about 20k on a Thumb2 machine, and by about 40k on 32-bit x86. Without the compiler the REPL will be disabled, but pre-compiled scripts can still be executed.
To test out this feature, change the MICROPY_ENABLE_COMPILER
config
option to "0" in the mpconfigport.h file in this directory. Then
recompile and run the firmware and it will execute the frozentest.py
file.