h7 CAN not available

Discussion related to "under the hood" OpenMV topics.
inno
Posts: 5
Joined: Thu May 09, 2019 9:18 am

h7 CAN not available

Postby inno » Thu May 09, 2019 9:38 am

Hello everyone,

I am currently in the process of switching from the M7 to the H7. However it seems there
is no CAN module builtin to the H7 firmware. CAN however is crucial for my current project.

from pyb import CAN
-> ImportError: cannot import name CAN

Note that this works flawlessly on the M7

Also help(pyb) shows no can module whatsoever.
I tested the same with both v3.41 as well as v3.2 but no difference.
Looking at the firmware revealed, that there is no stm32h7xx_hal_can.h available in the sthal.

So I wondered if CAN is available for the H7 as described on the product page?
If yes, how can I get a firmware which supports CAN?
Since it's important to me, minor changes and compiling the firmware myself if necessary is an option.

Thanks,
Stefan
User avatar
iabdalkader
Posts: 840
Joined: Sun May 24, 2015 3:53 pm

Re: h7 CAN not available

Postby iabdalkader » Thu May 09, 2019 10:30 am

Unfortunately CAN has changed significantly from F7 to H7 and there's No driver in MicroPython. I started the support for H7 in upstream MicroPython but no one else has contributed a CAN driver yet. I could look into implementing a CAN driver for H7 soon.
User avatar
kwagyeman
Posts: 3048
Joined: Sun May 24, 2015 2:10 pm

Re: h7 CAN not available

Postby kwagyeman » Thu May 09, 2019 1:54 pm

We will have a CAN shield on sale soon so we can get this fixed. Please create a bug report on the github for this. The peripheral hasn't changed much so it's just some clock stuff that has to be dealt with.
Nyamekye,
inno
Posts: 5
Joined: Thu May 09, 2019 9:18 am

Re: h7 CAN not available

Postby inno » Fri May 10, 2019 6:18 am

Since we require CAN functionality as soon as possible (think next week) depending on what you mean by "soon" we would be willing to contribute.
iabdalkader - can you maybe pinpoint me to the location of the work you have already done?

Thanks for the quick replies
User avatar
iabdalkader
Posts: 840
Joined: Sun May 24, 2015 3:53 pm

Re: h7 CAN not available

Postby iabdalkader » Fri May 10, 2019 8:37 am

inno wrote:
Fri May 10, 2019 6:18 am
Since we require CAN functionality as soon as possible (think next week) depending on what you mean by "soon" we would be willing to contribute.
iabdalkader - can you maybe pinpoint me to the location of the work you have already done?

Thanks for the quick replies
That would be great! Note no work has been done on the new CAN driver at all, anyway, here's the STHAL FDCAN driver (it's called FDCAN on H7):

https://github.com/openmv/openmv/blob/m ... al_fdcan.h
https://github.com/openmv/openmv/blob/m ... al_fdcan.c

This is our fork of MicroPython (all work is done in the openmv branch):

https://github.com/openmv/micropython

This is the old CAN driver you can base your work on this:

https://github.com/openmv/micropython/b ... tm32/can.h
https://github.com/openmv/micropython/b ... tm32/can.c


You can either fork our MicroPython and send a PR or send it upstream. If you send it to us it will get merged a lot faster, and I'll send it upstream.
User avatar
travist
Posts: 2
Joined: Fri May 10, 2019 5:49 pm

Re: h7 CAN not available

Postby travist » Fri May 10, 2019 5:57 pm

Hello,

I am also very interested in CAN/CANFD on the H7. I have spoken with Damien at Micropython several times about this, and his time and focus has been on short supply to work on the new peripheral. As it has been pointed out the H7 is much more advanced and supports the CAN Flexible Data Rate, which many systems and devices to not utilize. My hope is there can be two stages where standard CAN 2.0A/B is supported with the new peripheral before full CAN FD functionality is worried about.

I personally do not have the time to work on the libraries, but willing to contribute to funding at least some of the efforts. CAN is used in almost all my products and projects and need it on a device to consider it.

While waiting to hear back from Damien on the next step with this I created an issue in their repo to help show support for the efforts on CAN for the H7.
https://github.com/micropython/micropython/issues/4774

If there are things I can do to help speed this up I would like to know. The price on the H7 chip is sometimes cheaper than the F7, and the CAN peripheral is the main thing in the way of me using it and working in the OpenMV H7 into some of my vision work.

Thanks
___________
Travis
User avatar
iabdalkader
Posts: 840
Joined: Sun May 24, 2015 3:53 pm

Re: h7 CAN not available

Postby iabdalkader » Fri May 10, 2019 8:03 pm

Hi, there's not much to do right now (unless you want start writing the driver) I've ordered some CAN transceivers and I'm going to work on adding basic CAN support for the H7 over the next weekend.
User avatar
kwagyeman
Posts: 3048
Joined: Sun May 24, 2015 2:10 pm

Re: h7 CAN not available

Postby kwagyeman » Sat May 11, 2019 3:42 pm

Hi, I can work on getting the CAN operational. I already have the new CAN shield prototypes at home we are about to release. I'll just make the default normal CAN stuff work.

(Looks like Ibrahim might get to this before me).
Nyamekye,
User avatar
travist
Posts: 2
Joined: Fri May 10, 2019 5:49 pm

Re: h7 CAN not available

Postby travist » Sun May 12, 2019 8:50 pm

Hello thanks for he help with supporting this.

Whether it is buying some boards or donating a little bit of funds to make this a higher priority I am happy to do one or both.

I hope the goal is that we can mimic the CAN capability of the F4/F7 on with Micropython, that would be ideal. FD functionality is probably needed by few at the moment, and where I believe most of the new complexity would come in.

Right now I am swamped with little projects I am already committed to, and for now the F7 and F4 chips work, so I do not have to move to the H7... but I want to :-)

I also want to use the new H7 OpenMV with some basic automation tools I am working on, and knowing the performance gain (latest silicon goes up to 480MHz now) This would be many times better than the current platforms that have CAN support.

Which transceivers are you planning to use/test with?

Thanks again and If we want/need to move a conversation off the forums just message me your email.

Thanks
___________
Travis
User avatar
iabdalkader
Posts: 840
Joined: Sun May 24, 2015 3:53 pm

Re: h7 CAN not available

Postby iabdalkader » Sun May 12, 2019 10:24 pm

I ordered MCP2551 but I think we're using something else in our CAN shields.
User avatar
kwagyeman
Posts: 3048
Joined: Sun May 24, 2015 2:10 pm

Re: h7 CAN not available

Postby kwagyeman » Sun May 12, 2019 10:43 pm

Here's the design. It's tested and works.

https://github.com/openmv/openmv-boards ... an/can.pdf
Nyamekye,
inno
Posts: 5
Joined: Thu May 09, 2019 9:18 am

Re: h7 CAN not available

Postby inno » Tue May 14, 2019 5:41 am

iabdalkader wrote:
Fri May 10, 2019 8:03 pm
Hi, there's not much to do right now (unless you want start writing the driver) I've ordered some CAN transceivers and I'm going to work on adding basic CAN support for the H7 over the next weekend.
Sounds great :-)
Can you keep us posted on how things are turning out?
Especially if you don't find the time to work on it, so we know if we have to find a plan B to finish our project on time.

Best
Stefan
User avatar
kwagyeman
Posts: 3048
Joined: Sun May 24, 2015 2:10 pm

Re: h7 CAN not available

Postby kwagyeman » Wed May 15, 2019 12:37 am

The production run of the CAN shields are done. I will get samples soon. I'll send some to Ibrahim so he can write his driver.
Nyamekye,
User avatar
iabdalkader
Posts: 840
Joined: Sun May 24, 2015 3:53 pm

Re: h7 CAN not available

Postby iabdalkader » Sat May 18, 2019 7:06 pm

Hi can anyone help me test the FDCAN driver ? If you have 2x H7 and 2x CAN transceivers let me know and I'll send you a firmware image for testing.
inno
Posts: 5
Joined: Thu May 09, 2019 9:18 am

Re: h7 CAN not available

Postby inno » Tue May 21, 2019 4:54 am

Great :-)
I have two h7 and two can transceiver which were working with the M7 here.

Best
Stefan
User avatar
iabdalkader
Posts: 840
Joined: Sun May 24, 2015 3:53 pm

Re: h7 CAN not available

Postby iabdalkader » Tue May 21, 2019 10:05 am

Great, attached a firmware image that enables FDCAN. You just need to test with something like this:

Code: Select all

from pyb import CAN
can = CAN(2, CAN.LOOPBACK)
can.send('Hello', 123)# send message with id 123

Code: Select all

from pyb import CAN
can = CAN(2, CAN.LOOPBACK)
print(can.recv(0, timeout=10000))  # receive message on FIFO 0
Attachments
firmware.zip
(935.83 KiB) Downloaded 202 times
inno
Posts: 5
Joined: Thu May 09, 2019 9:18 am

Re: h7 CAN not available

Postby inno » Fri May 24, 2019 3:42 am

Hi,

I'm afraid the image does not work yet. At least there is no signal appearing on neither the GPIOs nor the transceiver output, when sending data.
Could you maybe push your changes to a branch on your fork, so we can debug what's happening?

Best
Stefan
User avatar
iabdalkader
Posts: 840
Joined: Sun May 24, 2015 3:53 pm

Re: h7 CAN not available

Postby iabdalkader » Fri May 24, 2019 10:09 am

Hi Stefan,

There's an open PR here with all my changes:

https://github.com/micropython/micropython/pull/4793

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 7 guests