Skip to content

Commit

Permalink
remoteproc: pru: Fix loading of GNU Binutils ELF
Browse files Browse the repository at this point in the history
[ Upstream commit e6d9423 ]

PRU port of GNU Binutils lacks support for separate address spaces.
PRU IRAM addresses are marked with artificial offset to differentiate
them from DRAM addresses. Hence remoteproc must mask IRAM addresses
coming from GNU ELF in order to get the true hardware address.

PRU firmware used for testing was the example in:
  https://github.com/dinuxbg/pru-gcc-examples/tree/master/blinking-led/pru

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
Link: https://lore.kernel.org/r/20201230105005.30492-1-dimitar@dinux.eu
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Dimitar Dimitrov authored and gregkh committed Apr 21, 2021
1 parent ed80417 commit 8439ea0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions drivers/remoteproc/pru_rproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,24 @@ static void *pru_i_da_to_va(struct pru_rproc *pru, u32 da, size_t len)
if (len == 0)
return NULL;

/*
* GNU binutils do not support multiple address spaces. The GNU
* linker's default linker script places IRAM at an arbitrary high
* offset, in order to differentiate it from DRAM. Hence we need to
* strip the artificial offset in the IRAM addresses coming from the
* ELF file.
*
* The TI proprietary linker would never set those higher IRAM address
* bits anyway. PRU architecture limits the program counter to 16-bit
* word-address range. This in turn corresponds to 18-bit IRAM
* byte-address range for ELF.
*
* Two more bits are added just in case to make the final 20-bit mask.
* Idea is to have a safeguard in case TI decides to add banking
* in future SoCs.
*/
da &= 0xfffff;

if (da >= PRU_IRAM_DA &&
da + len <= PRU_IRAM_DA + pru->mem_regions[PRU_IOMEM_IRAM].size) {
offset = da - PRU_IRAM_DA;
Expand Down

0 comments on commit 8439ea0

Please sign in to comment.