micropython/ports/powerpc
David Grayson c046b23ea2 shared/runtime/pyexec: Don't allow Ctrl+C to interrupt frozen boot code.
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>
2023-04-05 10:38:50 +10:00
..
Makefile all: Use += rather than = everywhere for CFLAGS/LDFLAGS/LIBS. 2022-10-11 23:17:41 +11:00
README.md powerpc/uart: Choose which UART to use at build time, not runtime. 2020-05-29 22:54:55 +10:00
head.S
main.c shared/runtime/pyexec: Don't allow Ctrl+C to interrupt frozen boot code. 2023-04-05 10:38:50 +10:00
mpconfigport.h shared/readline: Use MP_REGISTER_ROOT_POINTER(). 2022-07-18 13:48:49 +10:00
mphalport.h all: Reformat C and Python source code with tools/codeformat.py. 2020-02-28 10:33:03 +11:00
powerpc.lds
qstrdefsport.h all: Add *FORMAT-OFF* in various places. 2020-02-28 10:31:07 +11:00
uart_lpc_serial.c powerpc/uart: Choose which UART to use at build time, not runtime. 2020-05-29 22:54:55 +10:00
uart_lpc_serial.h
uart_potato.c powerpc/uart: Choose which UART to use at build time, not runtime. 2020-05-29 22:54:55 +10:00
uart_potato.h
unistd.h

README.md

The PowerPC port that runs on microwatt and qemu

This port is intended to be a minimal MicroPython port that runs in QEMU, microwatt simulator with ghdl or microwatt on Xilinx FPGA with potato UART.

Building

By default the port will be built with the potato uart for microwatt:

$ make

To instead build for a machine with LPC serial, such as QEMU powernv:

$ make UART=lpc_serial

Cross compilation for POWERPC

If you need to cross compilers you'll want to grab a powerpc64le compiler (not powerpc or powerpc64).

On Ubuntu (18.04) you'll want:

$ apt install gcc-powerpc64le-linux-gnu

(Use CROSS_COMPILE=powerpc64le-linux-gnu-)

If your distro doesn't have cross compilers, you can get cross compilers here:

(Avoid musl libc as it defines __assert_fail() differently to glibc which breaks the micropython powerpc code)

Then do:

$ make CROSS_COMPILE=<compiler prefix>

Building will produce the build/firmware.bin file which can be used QEMU or microwatt.

To run in QEMU use:

$ ./qemu-system-ppc64 -M powernv -cpu POWER9 -nographic -bios build/firmware.bin