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

newinst hm2_soc_ol hm2-socfpga0 already_programmed=1 -- config="num_pwmgens=1 num_stepgens=4" failed: -1 - Operation not permitted #326

Closed
the-snowwhite opened this issue Oct 19, 2020 · 3 comments

Comments

@the-snowwhite
Copy link
Contributor

the-snowwhite commented Oct 19, 2020

An initial placeholder for implementing a uio search for hm2-socfpga0 string in driver name across all uio devices
like:

This problem presents itself as following:

halcmd: newinst hm2_soc_ol hm2-socfpga0 already_programmed=1 -- config="num_pwmgens=1 num_stepgens=4"
1:rtapi_app:3642:user hal_call_usrfunct(newinst,already_programmed=1 -- config="num_pwmgens=1 num_stepgens=4") 
failed: -1 - Operation not permitted
<stdin>:2: rc=-1: hal_call_usrfunct(newinst,already_programmed=1 -- config="num_pwmgens=1 num_stepgens=4") failed: -1 - 
Operation not permitted

The same function that works fine on my ultra96v1 which only has 1 uio port (/dev/uio0) gives this error
on my upcomming fz3 soc board that has 5 uio ports (hm2_socfpga0 port is /dev/uio4)

@the-snowwhite the-snowwhite changed the title Handle more than 1 uio device in hm2_soc_ol (mksocfpga related) newinst hm2_soc_ol hm2-socfpga0 already_programmed=1 -- config="num_pwmgens=1 num_stepgens=4" failed: -1 - Operation not permitted Oct 19, 2020
@the-snowwhite
Copy link
Contributor Author

machinekit@mksocfpga-nano-soc:~$ export DEBUG=5
machinekit@mksocfpga-nano-soc:~$ halrun -I

gives following:

halcmd: loadrt hostmot2
4:rtapi_app:3792:user Loaded module hostmot2 from path /usr/lib/machinekit/modules/hostmot2.so
4:rtapi_app:3792:user hostmot2 default iparms: ''
4:rtapi_app:3792:user hostmot2: loaded from /usr/lib/machinekit/modules/hostmot2.so
<stdin>:1: Realtime module 'hostmot2' loaded
halcmd: newinst hm2_soc_ol hm2-socfpga0 already_programmed=1 -- config="num_pwmgens=1 num_stepgens=4"
4:rtapi_app:3792:user Loaded module hm2_soc_ol from path /usr/lib/machinekit/modules/hm2_soc_ol.so
4:rtapi_app:3792:user hm2_soc_ol default iparms: 'debug=0 no_init_llio=0 num=0 already_programmed=0'
4:rtapi_app:3792:user hm2_soc_ol: loaded from /usr/lib/machinekit/modules/hm2_soc_ol.so
<stdin>:2: Realtime module 'hm2_soc_ol' loaded
4:rtapi_app:3792:user do_newinst_cmd: instargs='already_programmed=1 -- config="num_pwmgens=1 num_stepgens=4"'
1:rtapi_app:3792:user hal_call_usrfunct(newinst,already_programmed=1 -- config="num_pwmgens=1 num_stepgens=4") failed: -1 - Operation not permitted
<stdin>:2: rc=-1: hal_call_usrfunct(newinst,already_programmed=1 -- config="num_pwmgens=1 num_stepgens=4") failed: -1 - Operation not permitted

/var/log/hal.log:

...
Oct 19 14:28:07 localhost rtapi:0: 4:rtapi_app:3710:user Loaded module hostmot2 from path /usr/lib/machinekit/modules/hostmot2.so
Oct 19 14:28:07 localhost rtapi:0: 4:rtapi_app:3710:user hostmot2 default iparms: ''
Oct 19 14:28:07 localhost rtapi:0: 4:rtapi_app:3710:user hostmot2: loaded from /usr/lib/machinekit/modules/hostmot2.so
Oct 19 14:28:07 localhost msgd:0: hal_lib:3710:rt hm2: loading Mesa HostMot2 driver version 0.15
Oct 19 14:28:07 localhost msgd:0: hal_lib:3710:rt halg_xinitfv:84 HAL: initializing component 'hostmot2' type=1 arg1=0 arg2=0/0x0
Oct 19 14:28:12 localhost rtapi:0: 4:rtapi_app:3710:user Loaded module hm2_soc_ol from path /usr/lib/machinekit/modules/hm2_soc_ol.so
Oct 19 14:28:12 localhost rtapi:0: 4:rtapi_app:3710:user hm2_soc_ol default iparms: 'debug=0 no_init_llio=0 num=0 already_programmed=0'
Oct 19 14:28:12 localhost rtapi:0: 4:rtapi_app:3710:user hm2_soc_ol: loaded from /usr/lib/machinekit/modules/hm2_soc_ol.so
Oct 19 14:28:12 localhost rtapi:0: 4:rtapi_app:3710:user do_newinst_cmd: instargs='already_programmed=1 -- config="num_pwmgens=1 num_stepgens=4"'
Oct 19 14:28:12 localhost rtapi:0: hal_call_usrfunct(newinst,already_programmed=1 -- config="num_pwmgens=1 num_stepgens=4") failed: -1 - Operation not permitted
Oct 19 14:28:12 localhost rtapi:0: 1:rtapi_app:3710:user hal_call_usrfunct(newinst,already_programmed=1 -- config="num_pwmgens=1 num_stepgens=4") failed: -1 - Operation not permitted
Oct 19 14:28:12 localhost msgd:0: hal_lib:3710:rt halg_xinitfv:84 HAL: initializing component 'hm2_soc_ol' type=1 arg1=0 arg2=0/0x0
Oct 19 14:28:12 localhost msgd:0: hal_lib:3710:rt hm2_soc_ol: loading Mesa AnyIO HostMot2 socfpga overlay driver version 0.9
Oct 19 14:28:12 localhost msgd:0: hal_lib:3710:rt halg_inst_create:59 HAL: rtapi: creating instance 'hm2-socfpga0' size 368
Oct 19 14:28:12 localhost msgd:0: hal_lib:3710:rt hm2_soc_ol: mapping pre-programmed hm2_soc_ol_board hm2-socfpga0
Oct 19 14:28:12 localhost msgd:0: hal_lib:3710:rt hm2_soc_ol: mmap failed: Invalid argument
Oct 19 14:28:12 localhost msgd:0: hal_lib:3710:rt hm2_soc_ol: preloaded_soc_mmap_fail hm2-socfpga0, err=-22
Oct 19 14:28:12 localhost msgd:0: hal_lib:3710:rt hm2_soc_ol: error registering UIO driver: -22
...

Code to Debug/fix: hm2_soc_ol.c

@the-snowwhite
Copy link
Contributor Author

So It seems that the culprit is somewhere in the FZ3's vivado design.
I added some hm2_soc_ol driver stuff to help facilitate my debugging efforts:
#327

Most noticeable is this much needed new debug message:

Oct 19 22:51:17 localhost msgd:0: hal_lib:3885:rt hm2_soc_ol: located hm2-socfpga0 on /dev/uio4

@the-snowwhite
Copy link
Contributor Author

OK by slogging through the ultra96 setup stuff I finally found out the issue was related to petalinux's mysterial ways of how to generate device tree entries.

Culprit was the hm2-socfpga0 devicetree entry being obscured by some automated dts generation.

Good news is that I now also have a working mksocfpga petalinux bsp for the ultra96's.
(just need to test and finalize correct power off for v2).

These bsp's are used to generate the:
boot.bin (u-boot, bitfile,cpu config) and i
mage.ub (kernel and device tree),
needed for booting linux.

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

1 participant