STM32: Write to UART after disabling REPL?

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
User avatar
kevingislason
Posts: 1
Joined: Tue Jan 05, 2021 4:32 am

STM32: Write to UART after disabling REPL?

Post by kevingislason » Wed Jan 06, 2021 5:20 am

Hello all,

I'm trying to make a bitcoin hardware wallet on an stm32f469-disco. I want to disable the REPL for security, to reduce the device's attack surface. On the other hand, the wallet needs to talk to my laptop, so I need a UART to read and write. Reduced example of what I've tried:

Code: Select all

# kill REPL
uos.dupterm(None, 1)
uart = pyb.UART(BUS_NUMBER, 115200)
uart.write("ping \n")
while not uart.read():
        pass
led.toggle()
 
I see three UART busses (2, 3, and 6) for my board in its mpconfigboard.h. For reasons beyond my understanding, the above example doesn't do anything for busses #3 and #6; I can't read the ping on my laptop, and the read loop never terminates.

Bus #2 is more interesting. The REPL is using it, so I know that it works in principle. But the dupterm still prevents me from using bus #2 even if I kill off the dupterm from python code. When I try to init pyb.UART, I get "UART(2) doesn't exist".

So--what is the easiest way to do what I am trying to do? Can I, in fact, use bus #3 or #6? Is there some straightforward way to disable dupterm from C code to free up bus #2? Would that even solve my problem?

Can't tell you how much I would appreciate some help. Cheers! :mrgreen:

Post Reply