REPL prompt on expansion board UART

General discussion about topics related to OpenMV.
Capstan
Posts: 11
Joined: Tue Nov 12, 2019 11:04 am

REPL prompt on expansion board UART

Postby Capstan » Wed Dec 04, 2019 12:13 pm

I've got an H7 with the WiFi shield. I am able to run scripts from the IDE (over USB) and now would like to be able to access the H7 via REPL using a serial connection to a UART port on the device. I routinely do this with ESP32/Micropython devices and in principle should be able to do the same thing with H7. I soldered 3 header pins into the TXD/RXD/GND pins on the WiFi board and have a FTDI cable attached to them that works with ESP32.

I'm looking at the documentation https://docs.openmv.io/wipy/tutorial/re ... light=repl;

To enable REPL duplication on UART0 (the one accessible via the expansion board) do:

from machine import UART
import os
uart = UART(0, 115200)
os.dupterm(uart)

So I tried running that code from the IDE and get an error;
ValueError: UART(0) doesn't exist

I also tried tools->configure Cam settings file and tried checking the 'duplicate REPL on the UART on startup' box, then resetting the board, still not seeing anything.
User avatar
kwagyeman
Posts: 3503
Joined: Sun May 24, 2015 2:10 pm

Re: REPL prompt on expansion board UART

Postby kwagyeman » Wed Dec 04, 2019 4:45 pm

How did you get access to that page? Hmm, that shouldn't be there.

Anyway, this is easier than you think. Go into the IDE, select the config openmv cam option under tools, and then clock the enable repl on uart button and click save, then restart the board and repl will be there.

Otherwise, change the uart to 3 in your code. We do not have uart zero.
Nyamekye,
Capstan
Posts: 11
Joined: Tue Nov 12, 2019 11:04 am

Re: REPL prompt on expansion board UART

Postby Capstan » Wed Dec 04, 2019 6:41 pm

Hi thanks, I had tried clicking the 'duplicate REPL on the UART on startup' box, then resetting the board as I said in my previous post. Still not seeing anything.

I also changed the UART number to 3 in my code in the IDE and clicked the green arrow. The code appears to execute without failure now but still nothing coming from the UART port on the WiFi shield. Can you please verify that this works on your end with the current firmware and the WiFi shield?

I am establishing a REPL session with a FTDI cable on a known good ESP32 board, and then plugging the cable into the pins on the WiFi shield. This works with ESP32 boards, I get all the boot text and then a Python prompt upon powerup or reset. Not seeing anything coming from the WiFi shield yet.
User avatar
kwagyeman
Posts: 3503
Joined: Sun May 24, 2015 2:10 pm

Re: REPL prompt on expansion board UART

Postby kwagyeman » Wed Dec 04, 2019 7:24 pm

Hi, you can't put the UART over the WiFi shield. Just connect the ftdi cable directly to the UART pins on the OpenMV Cam to see the REPL UART.

The UART on the WiFi shield is just for debugging the onboard firmware on the device. It's not a functional interface.

We don't actually have a wifi debug solution right now. We did try to make one however. There's code in then IDE and camera to do the OpenMV debug protocol over WiFi. However, performance was found to... be lacking... because we stream video which is much harder for cheap mcus to transfer than just text data. This is what the config wifi stuff in the IDE is for. We don't advertise the feature because it's pretty bad. That said, we fixed a lot of wifi bugs recently so maybe I'll try to see how well it works again.
Nyamekye,
Capstan
Posts: 11
Joined: Tue Nov 12, 2019 11:04 am

Re: REPL prompt on expansion board UART

Postby Capstan » Wed Dec 04, 2019 7:36 pm

Thanks for the reply. I am looking at the H7 board diagram here;
https://docs.openmv.io/_images/pinout1.png

It looks like there are a couple of sets of UART TX/RX pins but they double as SPI and IC2? Which pins should I use for TX and RX for UART(3)? Pins 4 and 5? Which pins are enabled when you select the 'duplicate REPL on the UART on startup' box in the IDE?
User avatar
kwagyeman
Posts: 3503
Joined: Sun May 24, 2015 2:10 pm

Re: REPL prompt on expansion board UART

Postby kwagyeman » Wed Dec 04, 2019 7:40 pm

Yeah, pins 4/5 become a REPL UART. If you connect those to an ESP32 that's doing UART over WiFi you can control the camera from that. Our WiFi shield has nothing to do with those pins however.
Nyamekye,
Capstan
Posts: 11
Joined: Tue Nov 12, 2019 11:04 am

Re: REPL prompt on expansion board UART

Postby Capstan » Wed Dec 04, 2019 8:46 pm

Got it, thanks. I'll solder up a header to plug in to the H7 that collects those pins plus ground for my FTDI cable tomorrow.
User avatar
iabdalkader
Posts: 1026
Joined: Sun May 24, 2015 3:53 pm

Re: REPL prompt on expansion board UART

Postby iabdalkader » Thu Dec 05, 2019 5:50 am

Hi, the 3 pins header (TXD/RXD/GND) on the WiFi shield is the WINC1500 debugging header, it's not the H7/F7 UART you shouldn't use that (I use this to update the WINC1500 firmware with Microchip's software for testing). Second, when you enable the "duplicate REPL on the UART on startup" the IDE writes a config file to the camera's Flash/SD card. Sometimes this file is not flushed, so please make sure to umount/eject/safe-remove the storage after enabling it and then reset the camera.
It's easy to confirm that the config file was written successfully, just look for the openmv.config file after reset, it should have the following:

Code: Select all

[BoardConfig]
REPLUart=true
WiFiDebug=false

[WiFiConfig]
AccessPointChannel=2
AccessPointKey=
AccessPointSSID=
AccessPointSecurity=1
BoardName=OpenMV Cam
ClientChannel=2
ClientKey=
ClientSSID=Please enter or select your WiFi
ClientSecurity=1
Mode=0
Capstan
Posts: 11
Joined: Tue Nov 12, 2019 11:04 am

Re: REPL prompt on expansion board UART

Postby Capstan » Thu Dec 05, 2019 2:21 pm

I was able to wire up a header that adapts from the H7 board to my FTDI cable (a little awkward because ground is on the opposite side of the board from pins 4 and 5) and can get a python prompt now. But I am puzzled about some things now, will start another thread to ask questions.
User avatar
kwagyeman
Posts: 3503
Joined: Sun May 24, 2015 2:10 pm

Re: REPL prompt on expansion board UART

Postby kwagyeman » Thu Dec 05, 2019 2:43 pm

Use the Open Terminal feature under tools in the IDE to talk to the camera over that. You can run scripts over that UART using the IDE.
Nyamekye,

Return to “General Topics”

Who is online

Users browsing this forum: MSN [Bot] and 5 guests