Skip to content

Instantly share code, notes, and snippets.

@DhruvaG2000
Created July 12, 2021 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DhruvaG2000/eccbb9ee60c014dafc366555230f326d to your computer and use it in GitHub Desktop.
Save DhruvaG2000/eccbb9ee60c014dafc366555230f326d to your computer and use it in GitHub Desktop.
#!/bin/bash
set -xe
[ -z "$1"] && echo "Pass one argument: .p file" >&2 && exit 1
PRU_FILE=$1
PRU_FILE_BIN=$(basename ${PRU_FILE%.*}.bin)
SOURCE=template.pru1_1
rm -rf $SOURCE.o* included_assembly.h
pasm -V2 -b $PRU_FILE
prudis $PRU_FILE_BIN | sed 's/^\(.*\)$/" \1\\n"/' > included_assembly.h
clpru -fe $SOURCE.o $SOURCE.c -v3 --endian=little --asm_listing --c_src_interlist --include_path=common --include_path=/usr/lib/ti/pru-software-support-package/include
lnkpru -o $SOURCE.out $SOURCE.o --stack_size=0x0 --heap_size=0x0 -m $SOURCE.map am57xx_pru.cmd
# the above prudis -> clpru step was to generate a dummy .out file. However,
# clpru may have screwed up some of the QB instructions.
# now replace the relevant section in that file with the correct binary blob
cp $SOURCE.out $SOURCE.out-bak
dd if=$PRU_FILE_BIN of=$SOURCE.out bs=1 obs=1 seek=52 conv=notrunc
# file is now ready to go.
cp $SOURCE.out /lib/firmware/am57xx-pru1_1-fw
echo stop > /dev/remoteproc/pruss1-core1/state 2> /dev/null || true
echo start > /dev/remoteproc/pruss1-core1/state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment