giuliomoro / Bela-dhruva

Other
1 stars 0 forks source link

started PRU but state in /dev/remoteproc/pruss1-core1/state is offline #3

Open DhruvaG2000 opened 2 years ago

DhruvaG2000 commented 2 years ago

It seems like I am getting this error even after a reboot and a hard power on power off when I try to run any example

# make PROJECT=sinetone run CL=-v
Failed to stop bela_startup.service: Unit bela_startup.service not loaded.
No process to kill
Running /root/Bela/projects/sinetone/sinetone -v
Xenomai not explicitly inited
Xenomai is going to be inited by us
Bela_initAudio()
Starting with period size 16 ;analog enabled
DAC level 99999997952.000000 dB; ADC level 99999997952.000000 dB; headphone level 99999997952.000000 dB
could not open EEPROM for reading
Detected hardware: Bela
Hardware specified at the command line: NoHardware
Hardware specified in the user's belaconfig: NoHardware
Hardware to be used: Bela
Codec mode: 0 ()
fifoFactor: 1
core audioFrames: 16
Project name: sinetone
PRU memory mapped to ARM:
digital: 0xb62c4000 0xb62c4400
audio: 0xb62c5000 0xb62c5040 0xb62c5080 0xb62c50c0
analog: 0xb6f8b000 0xb6f8b080 0xb6f8b100 0xb6f8b180
analog offset: 0xcc8000 0xcc8080 0xcc8100 0xcc8180
Bela_startAudio
startAudioInilne
AudioCodec parameters:
slotSize: 16
startingSlot: 0
bitDelay: 0
mclk: 2e+07
samplingRate: 44100
dualRate: 0
tdmMode: 1
bclk: 1
wclk: 1
MCLK: 20.0000 MHz, fs(ref): 44100.0000, P: 2, R: 1, J: 9, D: 317, Achieved Fs: 44100.097656 (err: 0.0002%), 
Mcasp parameters:
inChannels: 2
outChannels: 2
inSerializers: {10} 
outSerializers: {11} 
numSlots: 2
slotSize: 16
dataSize: 16
bitDelay: 0
auxClkIn: 2e+07
ahclkFreq: 2e+07
ahclkIsInternal: 1
wclkIsInternal: 0
wclkIsWord: 0
wclkFalling: 0
externalSamplesRisingEdge: 0
McaspConfig: error while setting input channels
McaspConfig: error while setting output channels
Mcasp registers:
      pdir: 0x08000000
     rmask: 0x0000ffff
      rfmt: 0x00008070
   afsrctl: 0x00000100
  aclkrctl: 0x00000000
 ahclkrctl: 0x00008000
      rtdm: 0x00000003
     xmask: 0x0000ffff
      xfmt: 0x00008074
   afsxctl: 0x00000100
  aclkxctl: 0x00000000
 ahclkxctl: 0x00008000
      xtdm: 0x00000003
    srctln: 0x00000000
  wfifoctl: 0x00010101
  rfifoctl: 0x00010101
McaspConfig: error while setting input channels
McaspConfig: error while setting output channels
Not using McASP->PRU irq
Using Non-McASP IRQ embedded PRU firmware
Stopping PRU1_1
Loading firmware into PRU1_1: /lib/firmware/am57xx-pru1_1-fw symlinked from /root/Bela-dhruva/build/pru/pru_rtaudio.out
Starting PRU1_1
PruManagerRprocMmap: we started PRU but state in /dev/remoteproc/pruss1-core1/state is offline

Failed to execute PRU code
Error: unable to start PRU from 
Error: unable to start real-time audio
Stopping audio...
Failed to join audio thread: (3) No such process
Bela_cleanupAudio()
make: *** [Makefile:658: runonly] Error 1
DhruvaG2000 commented 2 years ago

Found the root cause: lrwxrwxrwx 1 root root 43 Aug 13 10:20 am57xx-pru1_1-fw -> /root/Bela-dhruva/build/pru/pru_rtaudio.out ie. the location of pru firmware is hardcoded as Bela-dhruva and then later on if the directory name is changed to Bela or something else, then the path breaks and hence it can not find the PRU fw anymore.

DhruvaG2000 commented 2 years ago

Possible solution: Instead of passing the path to the current Bela directory from the Makefile, we could make the PruManager itself use curDir = system("pwd") and then programmatically build the path to PRU firmware at runtime

giuliomoro commented 2 years ago

It's much more robust to have it hardcoded at build time I think: the user is much less likely to move around file system the Bela folder than the built binary.

giuliomoro commented 2 years ago

but we should add a check in PruManager to ensure it tests the file exists before trying to link it and produce a meaningful error if it doesn't exist