Reload a new PRU program in the PRU using pruss_remoteproc

Hello all,

first post hoping you can help me.

I have finally got my PRU working on my BBB Debian 4.1.17-ti-rt-r46.

I used the PRU_gpioToggle example from https://git.ti.com/pru-software-support-package/pru-software-support-package/trees/master/examples/am335x/PRU_gpioToggle which I compiled with CCS6.1

I copied the PRU_gpioToggle.out to the BBB in /lib/firmware/ and I made an symbolic link as /lib/firmware/am335x-pru0-fw

my uEnv.txt is as follows:
uname_r=4.1.17-ti-rt-r46

dtb=am335x-boneblack-overlay.dtb

cape_enable=bone_capemgr.enable_partno=cape-univ-audio,cape-univ-emmc,cape-univ-hdmi

When I start up the the firmware is loaded onto the PRU:

[ 20.181078] pruss-rproc 4a300000.pruss: 8 PRU interrupts parsed
[ 20.181178] pruss-rproc 4a300000.pruss: memory dram0: pa 0x4a300000 size 0x2000 va e0b04000
[ 20.181206] pruss-rproc 4a300000.pruss: memory dram1: pa 0x4a302000 size 0x2000 va e0b08000
[ 20.181230] pruss-rproc 4a300000.pruss: memory shrdram2: pa 0x4a310000 size 0x3000 va e0b0c000
[ 20.181253] pruss-rproc 4a300000.pruss: memory intc: pa 0x4a320000 size 0x2000 va e0b10000
[ 20.181275] pruss-rproc 4a300000.pruss: memory cfg: pa 0x4a326000 size 0x2000 va e0b14000
[ 20.228354] pruss-rproc 4a300000.pruss: creating platform devices for PRU cores
[ 20.307883] pru-rproc 4a334000.pru0: memory iram: pa 0x4a334000 size 0x2000 va e0b18000
[ 20.307951] pru-rproc 4a334000.pru0: memory control: pa 0x4a322000 size 0x400 va e09fe000
[ 20.307977] pru-rproc 4a334000.pru0: memory debug: pa 0x4a322400 size 0x100 va e0b02400
[ 20.319303] remoteproc1: 4a334000.pru0 is available
[ 20.353277] remoteproc1: Note: remoteproc is still under development and considered experimental.
[ 20.362293] remoteproc1: THE BINARY FORMAT IS NOT YET FINALIZED, and backward compatibility isn’t yet guaranteed.
[ 20.475842] pru-rproc 4a334000.pru0: booting the PRU core manually
[ 20.482081] remoteproc1: powering up 4a334000.pru0
[ 20.517432] remoteproc1: Booting fw image am335x-pru0-fw, size 33132
[ 20.566849] remoteproc1: starting PRU0: entry-point = 0x0
[ 20.566872] remoteproc1: remote processor 4a334000.pru0 is now up
[ 20.602059] pru-rproc 4a334000.pru0: PRU rproc node /ocp/pruss@4a300000/pru@4a334000 probed successfully
[ 20.649346] pru-rproc 4a338000.pru1: memory iram: pa 0x4a338000 size 0x2000 va e0b30000
[ 20.649419] pru-rproc 4a338000.pru1: memory control: pa 0x4a324000 size 0x400 va e0b34000
[ 20.649460] pru-rproc 4a338000.pru1: memory debug: pa 0x4a324400 size 0x100 va e0b36400
[ 20.655799] remoteproc2: 4a338000.pru1 is available
[ 20.660810] remoteproc2: Note: remoteproc is still under development and considered experimental.
[ 20.706800] remoteproc2: THE BINARY FORMAT IS NOT YET FINALIZED, and backward compatibility isn’t yet guaranteed.
[ 20.729074] remoteproc2: Direct firmware load for am335x-pru1-fw failed with error -2
[ 20.737528] remoteproc2: failed to load am335x-pru1-fw
[ 20.743186] pru-rproc 4a338000.pru1: booting the PRU core manually
[ 20.749404] remoteproc2: powering up 4a338000.pru1
[ 20.755598] remoteproc2: Direct firmware load for am335x-pru1-fw failed with error -2
[ 20.763983] remoteproc2: request_firmware failed: -2
[ 20.769068] pru-rproc 4a338000.pru1: rproc_boot failed
[ 20.775630] remoteproc2: releasing 4a338000.pru1
[ 20.780579] pru-rproc: probe of 4a338000.pru1 failed with error -2

And the led begins to blink when I enable the pin as pruout
sudo config-pin 8_28 pruout

Now it should be possible to unload the pru code en point the symbolic link /lib/firmware/am335x-pru0-fw towards a new block and reload it again

but when I’m trying to reload my pru with
sudo rmmod -f pruss_remoteproc.ko

sudo insmod /drivers/remoteproc/pruss_remoteproc.ko

I get the following output in my dmesg

[ 476.862186] Disabling lock debugging due to kernel taint
[ 476.868205] pru-rproc 4a334000.pru0: pru_rproc_remove: removing rproc 4a334000.pru0
[ 476.875941] pru-rproc 4a334000.pru0: stopping the manually booted PRU core
[ 476.890699] remoteproc1: stopping PRU0
[ 476.890752] remoteproc1: stopped remote processor 4a334000.pru0
[ 476.900523] remoteproc1: releasing 4a334000.pru0
[ 476.917068] pruss-rproc 4a300000.pruss: remove platform devices for PRU cores
[ 517.877498] pruss-rproc 4a300000.pruss: 8 PRU interrupts parsed
[ 517.877733] pruss-rproc 4a300000.pruss: memory dram0: pa 0x4a300000 size 0x2000 va e0ccc000
[ 517.877819] pruss-rproc 4a300000.pruss: memory dram1: pa 0x4a302000 size 0x2000 va e0cd0000
[ 517.877897] pruss-rproc 4a300000.pruss: memory shrdram2: pa 0x4a310000 size 0x3000 va e0cd4000
[ 517.877972] pruss-rproc 4a300000.pruss: memory intc: pa 0x4a320000 size 0x2000 va e0cd8000
[ 517.878047] pruss-rproc 4a300000.pruss: memory cfg: pa 0x4a326000 size 0x2000 va e0cdc000
[ 517.878124] Unable to handle kernel NULL pointer dereference at virtual address 0000000c
[ 517.896746] pgd = dce20000
[ 517.899515] [0000000c] *pgd=00000000

[ 517.903170] Internal error: Oops: 5 [#1] PREEMPT SMP THUMB2
[ 517.903276] Modules linked in: pruss_remoteproc(+) usb_f_ecm g_ether usb_f_rndis u_ether libcomposite omap_rng rng_core snd_soc_davinci_mcasp snd_soc_edma spi_omap2_mcspi uio_pdrv_genirq uio [last unloaded: pruss_remoteproc]
[ 517.903304] CPU: 0 PID: 828 Comm: insmod Tainted: G R 4.1.17-ti-rt-r46 #1
[ 517.903315] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 517.903330] task: dc1a1680 ti: ddd90000 task.ti: ddd90000
[ 517.903380] PC is at omap_device_deassert_hardreset+0x10/0x38
[ 517.903442] LR is at pruss_probe+0x27a/0x470 [pruss_remoteproc]
[ 517.903462] pc : [] lr : [] psr: 60010133
sp : ddd91cd0 ip : 00000000 fp : ddd91d20
[ 517.903475] r10: 00000005 r9 : c0b68e80 r8 : dc205e24
[ 517.903488] r7 : dda08010 r6 : dda08000 r5 : 00000000 r4 : dc205e10
[ 517.903501] r3 : c0024b9d r2 : dc8ba311 r1 : c094126c r0 : dda08000
[ 517.903520] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA Thumb Segment user
[ 517.903535] Control: 50c5387d Table: 9ce20019 DAC: 00000015
[ 517.903549] Process insmod (pid: 828, stack limit = 0xddd90218)
[ 517.903563] Stack: (0xddd91cd0 to 0xddd92000)
[ 517.903585] 1cc0: dc205e10 00000008 dda08000 bf893e53
[ 517.903610] 1ce0: dc205e38 00002000 e0cdc000 c0175873 df93a7a4 bf895514 bf895680 dc205e10
[ 517.903635] 1d00: 00000008 c0b68e80 dda07fa0 bf8951f8 bf895200 bf895208 bf895214 bf89521c
[ 517.903660] 1d20: c0b3b384 dda08010 dda08010 bf895430 fffffdfb c0cf3ff0 bf895430 00000038
[ 517.903685] 1d40: bf895818 c0464acd c0464a99 dda08010 c0c21ea8 00000000 c0cf3fdc c0463613
[ 517.903710] 1d60: c0464cad dda08010 dda08010 bf895430 dda08044 c04637d9 bf895430 00000000
[ 517.903735] 1d80: ddc10f88 c0463829 dda08010 00000000 00000001 c04620ef dd8a946c dd9e8bc8
[ 517.903759] 1da0: bf895430 ddc51100 00000000 c0bde7e8 bf898001 c0462e77 bf895238 bf895430
[ 517.903784] 1dc0: c0b49148 bf895430 c0b49148 c0b4d960 ddc104c0 c0463e19 00000000 c0b4d960
[ 517.903809] 1de0: c0b49148 bf898011 c0b4d960 c00096bd dfda0218 c011c1b7 00000000 c011c1b7
[ 517.903833] 1e00: c0b4a270 c0033179 dddd6a40 0040003e 00000001 00000001 c0b42e60 000000d0
[ 517.903858] 1e20: dd801e40 c011cd25 c06baa23 c011cd25 0040003f dddd67c0 c0110a31 c0b4a270
[ 517.903883] 1e40: dd801e40 dc8ba311 0040003e bf8957d0 bf8957d0 ddc10240 00000001 00000001
[ 517.903908] 1e60: 223ef09c ddc10f88 bf895818 c06baa4d 00000001 00000001 ddd91f58 bf8957d0
[ 517.903933] 1e80: ddc10f80 c0096b53 bf8957dc 00007fff c0094731 c01287e5 c0b49148 bf895818
[ 517.903957] 1ea0: 7f655e80 bf895958 c0b491ec 00000000 00000103 c0c1d5d0 00000000 c012c5c3
[ 517.903980] 1ec0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 517.904004] 1ee0: 00000000 00000000 6e72656b 00006c65 00000000 00000000 00000000 00000000
[ 517.904027] 1f00: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 517.904052] 1f20: 00000000 dc8ba311 00000038 00000000 00000003 7f655e80 0000017b c000ea44
[ 517.904076] 1f40: ddd90000 00000000 00000000 c00971cb ddd91f5c 00000000 e0cc1000 00006b74
[ 517.904101] 1f60: e0cc755c e0cc4847 e0cc59fc 00002968 000033c8 bf895680 0000000e 00000000
[ 517.904125] 1f80: 00000025 00000026 0000001e 00000019 00000015 00000000 4d7c1300 7f651cdc
[ 517.904149] 1fa0: b6ff5f10 c000e8a1 4d7c1300 7f651cdc 00000003 7f655e80 00000000 00000002
[ 517.904174] 1fc0: 4d7c1300 7f651cdc b6ff5f10 0000017b 00000000 7f651cdc 7f668000 00000000
[ 517.904198] 1fe0: bec01530 bec01520 7f64c6c3 b6f70972 80000030 00000003 00000000 00000000
[ 517.904273] [] (omap_device_deassert_hardreset) from [] (pruss_probe+0x27a/0x470 [pruss_remoteproc])
[ 517.904361] [] (pruss_probe [pruss_remoteproc]) from [] (platform_drv_probe+0x35/0x74)
[ 517.904401] [] (platform_drv_probe) from [] (driver_probe_device+0x177/0x314)
[ 517.904437] [] (driver_probe_device) from [] (__driver_attach+0x51/0x54)
[ 517.904470] [] (__driver_attach) from [] (bus_for_each_dev+0x43/0x64)
[ 517.904503] [] (bus_for_each_dev) from [] (bus_add_driver+0xe3/0x170)
[ 517.904534] [] (bus_add_driver) from [] (driver_register+0x39/0x8c)
[ 517.904593] [] (driver_register) from [] (pruss_init+0x10/0x63 [pruss_remoteproc])
[ 517.904655] [] (pruss_init [pruss_remoteproc]) from [] (do_one_initcall+0xa5/0x194)
[ 517.904701] [] (do_one_initcall) from [] (do_init_module+0x49/0x13c)
[ 517.904752] [] (do_init_module) from [] (load_module+0x13b7/0x18ec)
[ 517.904791] [] (load_module) from [] (SyS_finit_module+0x4f/0x70)
[ 517.904832] [] (SyS_finit_module) from [] (ret_fast_syscall+0x1/0x4c)
[ 517.904860] Code: 4605 b108 f8d0 51ec (7b2b) 460e
[ 518.588108] —[ end trace 0000000000000002 ]—

Does anybody get any idea how to reload the pru using remotepro?

This is a known problem. Back on Oct 6, I wrote the following:

Thank you for your respons. To bad you hadn’t heard from Pantelis yet.

Unfortunately my knowledge is lacking in this area. But I will off course keep investigating. If I find a solution I will let you know.

Regards,
Jelle