Shell chThdCreateFromHeap + SPI does not work Topic is solved

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: utzig, lbednarz, tfAteba, barthess, RoccoMarco

error414
Posts: 12
Joined: Fri Jan 22, 2021 12:11 am
Has thanked: 3 times

Shell chThdCreateFromHeap + SPI does not work

Postby error414 » Sun Feb 21, 2021 11:30 am

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

User avatar
Giovanni
Site Admin
Posts: 13527
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 861 times
Been thanked: 743 times
Contact:

Re: Shell chThdCreateFromHeap + SPI does not work  Topic is solved

Postby Giovanni » Sun Feb 21, 2021 1:31 pm

Hi,

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

Giovanni

error414
Posts: 12
Joined: Fri Jan 22, 2021 12:11 am
Has thanked: 3 times

Re: Shell chThdCreateFromHeap + SPI does not work

Postby error414 » Sun Feb 21, 2021 2:14 pm

OMG, it's a such good support. Thank you very much to explain, I will keep shell static. No big deal.


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 4 guests