If i uncomment either of the 2 lines below, the code complies and i can start the PRU just fine. HOwever if i uncomment both at the same time, the code compiles but i cant start the PRU. I get a
The dmesg line names the cause. On K3 devices - and the PocketBeagle 2’s AM6254 is one, the device tree describes its PRUs with compatible “ti,am625-pru” - the PRU firmware is not loaded with a plain memcpy. The TI PRU remoteproc driver in the Linux kernel (drivers/remoteproc/pru_rproc.c) routes the copy through a helper, pru_rproc_memcpy, which returns EINVAL when the destination address or the copy length is not a multiple of 4 bytes. That matches your log exactly: the failing copy targets da 0x105, which is not divisible by 4, so the loader prints “PRU memory copy failed for da 0x105 memsz 0x4” and the boot aborts with -22.
The comment above that function in the driver explains why the restriction exists: on the ICSSG PRU/RTU/TX_PRU cores the IRAM ports only reflect data correctly for integer 4-byte copies; an unaligned copy zeroes the other bytes within the same 4-byte word, and 8-byte copies (which an ARM64 memcpy would emit) raise an exception. For the older AM335x generation the same driver uses a plain memcpy instead, which is why this failure mode does not show up on the classic boards.
Your padding experiment matches this pattern. Adding bytes to the struct shifts whatever the linker places behind it. The sizes that boot (3, 7, 11) are exactly the values of N congruent 3 modulo 4, i.e. consistent with the struct ending on a 4-byte boundary, while 1, 2, 4, 5, 6, 8, 9, 10 all leave it misaligned. Which particular symbol lands at 0x105 I cannot tell from here - that depends on the link map - but the pattern in your numbers is the 4-byte alignment requirement, not a size or timing problem.
A more robust fix than trial-and-error padding: force the alignment explicitly. The GCC manual (Common Variable Attributes) documents that the aligned attribute “specifies a minimum alignment for the variable or structure field, measured in bytes”. Declaring the array (or the whole struct) with attribute((aligned(4))) keeps the layout correct even when you add or remove fields later, so the firmware does not break again the next time the struct size changes.