Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for variable-sized mailbox buffer #1

Open
thebel1 opened this issue Nov 6, 2020 · 8 comments
Open

Add support for variable-sized mailbox buffer #1

thebel1 opened this issue Nov 6, 2020 · 8 comments

Comments

@thebel1
Copy link
Owner

thebel1 commented Nov 6, 2020

Currently, only a fixed-size buffer of 32 bytes is supported. This prevents acquiring the VideoCore command line or the clock list.

@mvwieringen
Copy link

mvwieringen commented Nov 18, 2020

Is this still a problem in the fbuf branch version ?

I'm trying to set the pwm for the POE hat.

That is register 0x00030049 for the GET and 0x00030050 for the set.
The buffer seems to be 3 bytes according to the Linux kernel driver. The GET somewhat works
but the SET is barking that the mailbox send failed.

I'm doing the following in python:

+            ioctlData = bytearray(struct.pack('<IIIIIII',
+                                              RPIQ_SHORT_BUFFER_LEN,
+                                              RPIQ_SET_REQ,
+                                              RPIQ_MBOX_TAG_SET_POE_HAT,
+                                              RPIQ_MBOX_SET_POE_HAT_LEN,
+                                              reg, value, 0))

the RPIQ_SHORT_BUFFER_LEN is set to 24

@thebel1
Copy link
Owner Author

thebel1 commented Nov 19, 2020

The fbuf branch in fact does support variable-sized buffers, since I needed them to implement the framebuffer mailbox interface. The buffer is allocated based on the number of bytes supplied in the buffer len field (as you have done): https://github.com/thebel1/thpimon/blob/fbuf/pimon_charDev.c#L447

Having said that, the mailbox interface is not for interacting with memory-mapped registers, but rather with the VideoCore GPU via a mailbox interface. The struct you're building in Python is the mailbox buffer you're sending to the VideoCore. See the following for a list of supported mailbox properties: https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface . Currently, only channel 8 is supported.

I hope that helps.

@mvwieringen
Copy link

I said register but essentially those are the mailbox properties but it seems the wiki doesn't mention these higher ones e.g. it ends at 0x00030020 and then goes on with 0x00040001

@thebel1
Copy link
Owner Author

thebel1 commented Dec 1, 2020

In that case, it should work. Can you paste the code around the snippet you sent earlier and the tail of the /var/log/vmkernel.log after running your script please. I'll need to have a look at the logging.

@mvwieringen
Copy link

mvwieringen commented Dec 1, 2020

0001-Add-test-version-of-setting-pwm-for-POE-hat.txt

attached the current quick hack. The log looks like the following:

2020-12-01T12:01:36.118Z cpu3:133881)thpimon: pimon_charDevOpen:351: opened file; priv 0x4304d9001340 lock 0x4304d90013c0
2020-12-01T12:01:36.118Z cpu3:133881)WARNING: thpimon: pimon_charDevIoctl:455: failed to allocate memory for ioctl data: Out of memory
2020-12-01T12:01:36.118Z cpu3:133881)thpimon: pimon_charDevIoctl:462: copying ioctl data from 0x36509f31f70 (UW) to 0x4304d9001370 (vmk)
2020-12-01T12:01:36.118Z cpu3:133881)thpimon: pimon_charDevIoctl:480: executing ioctl cmd 8 with data 0x36509f31f70
2020-12-01T12:01:36.118Z cpu3:133881)WARNING: thpimon: rpiq_mboxSend:359: transaction error: 0x80000001
2020-12-01T12:01:36.118Z cpu3:133881)thpimon: pimon_charDevIoctl:462: copying ioctl data from 0x36509f31f70 (UW) to 0x4304d9001370 (vmk)
2020-12-01T12:01:36.118Z cpu3:133881)thpimon: pimon_charDevIoctl:480: executing ioctl cmd 8 with data 0x36509f31f70
2020-12-01T12:01:36.118Z cpu3:133881)WARNING: thpimon: rpiq_mboxSend:359: transaction error: 0x80000001
2020-12-01T12:01:36.119Z cpu3:133881)thpimon: pimon_charDevFileDestroy:726: destroying file 0x4304d9001340

e.g. that was running the pimon_setpwm.py script. So it seems that it gets send but the mailbox responds with an error.

For now I soldered some wires to the 5v and GND pin and plugged the POE HAT fan onto that and then it runs and keeps
things cool but eventually it would be nice to be able to write some python scripting that reads out the temp and sets the pwm.

@thebel1
Copy link
Owner Author

thebel1 commented Dec 7, 2020

Yeah, we're going to need some additional data here, to get the contents of the buffer before it gets sent. If dynamic VProbes were available on Arm this would be easy. Hopefully, they'll be supported soon.

Can you send me the entirety of your script plus the pimon library's init.py file? I'd like to repro this on my Pi.

@mvwieringen
Copy link

I already attached the patch to my previous message which you can just apply and that will give you the extra code and the two scripts. I can also attach that again if that helps.

@mvwieringen
Copy link

init.txt
pimon_getpwm.txt
pimon_setpwm.txt

The python files renamed to .txt extension instead of .py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants