Port to STM32F407-DISCO

289 views
Skip to first unread message

nick lewty

unread,
Feb 3, 2015, 10:29:30 PM2/3/15
to open...@googlegroups.com
Hi Ibrahim and Michael,

I recently became a backer of your kickstarter, which looks like it has almost made it target, great stuff. I was wondering as the boards are not due to ship until August if it would be possible to port openmv to the STM32F407-DISCO, as I have this board and a OV2640 on a breakout board. I naively tried to flash the openmv binary to the board but it did not should up as a USB device like micropython does. I assume this is because the two boards are laid out differently. Therefore a port would be a case of just changing the pin definitions or is it much more complicated. Any help with this matter would be much appreciated.

Cheers,

Nick

Ibrahim Abdelkader

unread,
Feb 4, 2015, 10:06:21 PM2/4/15
to open...@googlegroups.com
Thank you :)

Flashing the binaries to DSICO won't work, as you've guessed, different pins, a port right now is basically changing the pins, the crystal frequency and maybe other stuff in src/micropython I can't be sure, might be forgetting something, later it won't work because we're upgrading the MCU (will need to change more stuff)

nick lewty

unread,
Feb 6, 2015, 7:07:01 AM2/6/15
to open...@googlegroups.com
I did check the clock frequencies they seem to be the same. After compiling the binary and flashing the board LD8 lights up on the DISC indicating VBUS over current. I did try to apply this VBUS configuration option added to micropython a month ago, https://github.com/micropython/micropython/issues/1048  but it did not seem to fix the issue. I think the port to the DISC is beyond my skill sets so I will leave it and just wait for the board to arrive in Aug. 

Thanks for you help.

Cheers,

Nick  

nick lewty

unread,
Feb 26, 2015, 8:52:24 AM2/26/15
to open...@googlegroups.com
I managed to get openmv1 to work on the STM32F407-DISCO it was actually quite simple only two minor changes to the code.  The pincfg for LED's needed changing then the USB would be detected but not enumerate and changing the clock speed to 8MHz in system_stm32fxx meant the USB would enumerate and you could the micropython REPL up through the COM port.

After getting this part working I build a daughter board to connect the OV2640 and uSD card. I then came to two issues, the first was connecting to the IDE. Using linux if first got this error "Failed to set custom baud rate: 12000000"  I changed the baud rate to 2000000 and I then got this error:

"Traceback (most recent call last):
  File "openmv-ide.py", line 424, in update_terminal
    buf_len = openmv.tx_buf_len()
  File "/home/nick/Documents/Projects/openmv/usr/openmv.py", line 128, in tx_buf_len
    __serial.write(struct.pack("<BBI", __USBDBG_CMD, __USBDBG_TX_BUF_LEN, 4))
  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 466, in write
    if not self._isOpen: raise portNotOpenError
ValueError: Attempting to use a port that is not open"

Which I dont understand as I can communicate with the COM port using minicom, therefore the port must be open. Not to be deterred I tried it on a windows machine and after fixing the baud rate issue it connect no problem. Then came the second issue the sensor was just giving me garbage images. I kind of expected this because I assumed I would make a mistake with the wiring I double check and triple checked everything and it all seemed fine so I was stuck for a while. I then took a closer look at the schematic and realized that the D7, D6 and D5 are not connected to the pins that are defined in pincfg. In pincfg D7>PB6, D6>PE6 and D5>PE5, also hsync and vsync are swapped around compared with the schematic. In the schematic D7>PE6, D6>PE5 and D5>PB5. I fixed the wiring and the code to be the same as the schematic then everything worked in windows. I assume it is a mistake in the code if the schematic and the code dont agree.

I then tried going back to an older commit of openmv that used the pyusb interface this did work on my 64bit Ubuntu machine after trying to connect 3-4 times I always got Error 16 can not connect a few times then it would work. On  a 32bit Ubuntu machine I could not get it connect at all by this method.

Should I submit a bug report to github for the pyserial connection issue on linux systems?

I attached a couple of images of the board.

Cheers,

Nick
IMG_20150226_214737.jpg
IMG_20150226_214745.jpg

Ibrahim Abdelkader

unread,
Feb 26, 2015, 9:47:54 AM2/26/15
to open...@googlegroups.com
Hi Nick, about the pins/code maybe you were looking at an older HW rev ? I know the repo can very confusing, I am going to clean it up really soon, anyway, yes please submit a bug report include details on which Ubuntu/pyserial you tried, the baudrate is set to a certain high value to switch the CDC into "debug mode" I tested this baud rate on Linux (arch 64-bit) and Windows 7 seemed to work fine, maybe you're using an older pyserial ?

Ibrahim Abdelkader

unread,
Feb 26, 2015, 9:54:54 AM2/26/15
to open...@googlegroups.com
Let me just add if you want to try a different baudrate for debugging you have to change it in:
micropython/stmhal/usbd_cdc_interface.c you'll find something like;

            if (baudrate == 12000000) {
                debug_mode = 1;
Set it to whatever baud you use in the IDE, but lower baudrates might be slower.

nick lewty

unread,
Feb 27, 2015, 1:03:46 AM2/27/15
to open...@googlegroups.com
Hi Ibrahim,

I looked at both openmv.pdf and openmv3.pdf the both have the same pin configuration using stm32f407 chip. But they do not agree pincfg.h. This is the code from the latest git commit. The schematics agree with the pin configuration for the chip where DCMI7 is PE6, etc. I would say your code is wrong but as this has been working fine for so long without an issues I can not explain where the problem is. All I know is changing the code and wiring the board correctly to the schematics given in openmv.pdf or openmv3.pdf got the sensor working correctly for me.

The second issue of connecting in Ubuntu is now fixed if I set the baud rate in usbd_cdc_interface.c to the same as the IDE. I also found that the fastest baud rate that could be set is 4000000 without bringing up the error of "Failed to set custom baud rate:". Therefore I guess this is the really problem setting the baud rate. I will file a bug report for this error.

Ibrahim Abdelkader

unread,
Feb 27, 2015, 8:37:21 AM2/27/15
to open...@googlegroups.com
openmv3 is the new cam we're using for the KS, the config for this HW is still not in the repo, I've been testing this locally so far, using the same code just with different pin config.. I thought you said openmv1 ? if so, you should be looking at eagle/openmv1/openmv.sch

The schematic says 407, just because it's pin-compatible but it should actually say 429 will fix this.

nick lewty

unread,
Feb 27, 2015, 10:05:57 PM2/27/15
to open...@googlegroups.com

Yes I mean eagle/openmv1/openmv.pdf. But I still conclude that pincfg.h D7 D6 and D5 need changing to agree with the schematic.

--
You received this message because you are subscribed to a topic in the Google Groups "Openmvcam" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openmvcam/FlB0hM490jw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openmvcam+...@googlegroups.com.
To post to this group, send email to open...@googlegroups.com.
Visit this group at http://groups.google.com/group/openmvcam.
To view this discussion on the web visit https://groups.google.com/d/msgid/openmvcam/1942bcc5-e91b-49c6-bb39-9f133be824ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ibrahim Abdelkader

unread,
Feb 28, 2015, 9:16:26 AM2/28/15
to open...@googlegroups.com
You were right,  the pincfg is wrong! but note that all pins are DCMI pins, so it doesn't really matter what you call them in pincfg, they're all configured to their alternative functions and the DCMI knows which one is which, except for the clock pin because it's not controlled by the DCMI, I hope this makes sense.

Will fix those anyway, sorry for the confusion and thanks for pointing that out :)
To unsubscribe from this group and all its topics, send an email to openmvcam+unsubscribe@googlegroups.com.

Alison Williams

unread,
Mar 18, 2015, 7:26:05 AM3/18/15
to open...@googlegroups.com

Nick,

If I can't get my board to work I am planning to go down the Discovery Route. I already have the camera breakout board. My question for you is where is the schematic showing the connections between the discovery board and camera board.

Also is there an image capture program available in C.

Saleem

nick lewty

unread,
Mar 18, 2015, 10:58:36 PM3/18/15
to open...@googlegroups.com
Hi Saleem,

You just use the schematics given in eagle/openmv1/openmv.sch or openmv.pdf. There is no specific schematic for the discovery board. The pin labelling between openmv board and the discovery board are consistent.

Cheers,

Nick

--
You received this message because you are subscribed to a topic in the Google Groups "Openmvcam" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openmvcam/FlB0hM490jw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openmvcam+...@googlegroups.com.

To post to this group, send email to open...@googlegroups.com.
Visit this group at http://groups.google.com/group/openmvcam.
Reply all
Reply to author
Forward
0 new messages