Page 1 of 1

Shell chThdCreateFromHeap + SPI does not work

Posted: Sun Feb 21, 2021 11:30 am
by error414
Hi Giovanni,

I tried call "spiSend(&SPID4, 1, &data);" from shell command function, but it does not work.

Code: Select all

static void cmd_spitest(BaseSequentialStream *chp, int argc, char *argv[]) {
   uint8_t data = 0x0b;
   spiSelect(&SPID4);
   spiSend(&SPID4, 1, &data);
   spiUnselect(&SPID4);
}


I noticed that it works if I rewrite shell to static thread initialization.

Static shell initialization
spitest_static_shell.png


Dynamic shell initialization
spitest_dynamic_shell.png


It sends 0x55, it's value for fill free space in thread stack, so it's definitely problem with pointer. See attachement with debug, there is right variable address in each step, M0AR register is set to right address to.

debug_part3.png


I have no clue what can be wrong. It seems that DMA cna't access to address, is it possible?

--------------------------------------------------------------------
Test 1:

* Latest CHibiOs from github
* STM32F764Zi nucleo 144
1) compiled by CMAKE (gcc-arm-none-eabi-10-2020-q4-major)
2) compiled by MAKE (usedMakefile from chibios Demo, default gcc flags) (start_gcc90)

SPI does not work from dynamic created shell

-------
Test 2:

* Latest ChibiOs from github
* STM32F401RE nucleo
1) compiled by CMAKE (gcc-arm-none-eabi-10-2020-q4-major)
2) compiled by MAKE (usedMakefile from chibios Demo, default gcc flags) (start_gcc90)

SPI works from dynamic created shell

Re: Shell chThdCreateFromHeap + SPI does not work

Posted: Sun Feb 21, 2021 1:31 pm
by Giovanni
Hi,

On the F7 the stack is not DMA-accessible by default, place your buffers in static variables.

Giovanni

Re: Shell chThdCreateFromHeap + SPI does not work

Posted: Sun Feb 21, 2021 2:14 pm
by error414
OMG, it's a such good support. Thank you very much to explain, I will keep shell static. No big deal.