[BBB] PRU using uio on recent kernels - solution

This forum is for supported devices using an ARMv7 Texas Instruments (TI) SoC.

[BBB] PRU using uio on recent kernels - solution

Postby Zeno » Wed Jul 03, 2019 1:07 pm

Hello all,
over last week I was able to put old pruss_uio way operable. In recent kernels, device trees structure is changed, uio support in kernel is disabled and the new ti-sysc way of handling stuff is not implemented properly or more precisely not present in official kernel. So for all those interested, here is the solution on how to set it up:
1) Links to useful stuff, which I used so far:
https://github.com/izaakschroeder/uio_pruss - basis for the uio and uio_pruss dkms kernel modules
https://github.com/rogerq/linux/commits/for-v5.1/pruss-2.0 - github with TI patches and implementations of new DT structure and ti-sysc support
https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/ - sources archives that arch PKGBuild uses, uio and uio_pruss module sources and module.lds file
https://github.com/archlinuxarm/PKGBUILDs/blob/master/core/linux-am33x/PKGBUILD - to match uio dkms module sources for my kernel

2) What is needed to prepare:
- Install dkms and linux kernel headers via pacman
- Create /usr/lib/modules/"version"-ARCH/build/arch/arm/kernel/module.lds file with contents as in your kernel sources or from here (https://elixir.bootlin.com/linux/v5.1.12/source/arch/arm/kernel/module.lds) so you do not need to search, this file is the same in all linux releases for a long time already.
- Download attached uio_pru.zip archive with uio and uio_pruss module sources for dkms and device tree overlay, extract them into any folder of your liking (on BBB)
- change directory into your folder

3) Prepare DT overlay:
- Compile overlay using $this->bbcode_second_pass_code('', 'dtc -O dtb -o pru_uio_cape-00A0.dtbo -b 0 -@ pru_uio_cape-00A0.dts') or use it as a basis to extend your own overlay, both fragments are necessary

- Copy compiled overlay to firmware using something like $this->bbcode_second_pass_code('', 'cp pru_uio_cape-00A0.dtbo /usr/lib/firmware/')
- Modify boot.txt to load proper overlay and afterwards apply using $this->bbcode_second_pass_code('', './mkscr')
- Reboot to apply DT modifications

4) Prepare modules:
- Enter the folder containing directories with those two uio modules and pruss overlay file again
- Add modules using $this->bbcode_second_pass_code('', 'dkms add uio') and $this->bbcode_second_pass_code('', 'dkms add uio_pruss')
- Install them with $this->bbcode_second_pass_code('', 'dkms install uio/5.1.15') and $this->bbcode_second_pass_code('', 'dkms install uio_pruss/5.1.15') respectively

- Modprobe them using $this->bbcode_second_pass_code('', 'modprobe uio') and $this->bbcode_second_pass_code('', 'modprobe uio_pruss')
- Now you should see uio devices under /dev/uio0-7
- Old prussdrv based programs should work again

5) Final thoughts:
- Most important thing is the reset control that is added in pru uio overlay, it is based on rogerq git modifications for ti-sysc, otherwise PRUSS module is not initialized/powered and you will see errors in dmesg while trying to use it, something like this:
$this->bbcode_second_pass_quote('', 'U')nhandled fault: external abort on non-linefetch (0x1018) at 0xaa983000
pgd = 4d36da66
[aa983000] *pgd=9a872831, *pte=4a304303, *ppte=4a304a33

as I have seen in other threads and forums, this error truly means that target module is not active/powered. Registers of this reset control could be found and checked against in TI docs Spruh73c.pdf, page 1178, section 8.1.3.2 PRM_PER Registers.
- Module uio_pruss is based on regular kernel source of uio_pruss.c, with modified driver entries .of_match_table to recognize it as old ti,pruss-vX driver (at the end of used uio_pruss.c module source file), memory maps and sram pools are ommited, just like in original github module source from izaakschroeder, pruss_clk clock is actively enabled and its name is changed to "pruss_ocp_gclk" that corresponds to new DT node names, some other includes have been added to work with new reset control and some other minor changes usually taken from ti-sysc.c source and through debugging, finally device tree property reset was added to overlay pruss module, this is used (deasserted) to power on the pruss inside the module.
- extram_pool_sz module parameter should be working, folder /sys/class/uio/uioX/maps/map1/ then contains info about allocated ddr space address and size.
- After kernel upgrade, it is necessary to rebuild modules manually, as dkms points to old kernel version sources which are no longer present, this should therefore work after reboot to new kernel version and recreation of module.lds file which is usually missing again in new sources.
That is all, enjoy and have a nice day.
Zeno
Attachments
uio_pru.zip
uio, uio_pruss and uio DT overlay
(11.42 KiB) Downloaded 672 times
Zeno
 
Posts: 14
Joined: Wed May 03, 2017 5:00 pm

Return to Texas Instruments (TI)

Who is online

Users browsing this forum: No registered users and 8 guests