Undefined reference to `HAL_SPI_DMA_Transfer' [Bug report][RESOLVED]

Hi there, whilst trying to use the DMA SPI transfer function I’ve noticed that it does not appear to work

uint8_t tx[255];
uint8_t rx[255];
void rc(){

}
void setup() {
    SPI.begin(D7);
    SPI.transfer(tx, rx, 255, rc);
}

void loop() {

}

/home/sleziak/photon/firmware/wiring/src/spark_wiring_spi.cpp:160: undefined reference to `HAL_SPI_DMA_Transfer'

Same happens in the online IDE

Am I missing something? Kind regards

EDIT: I found the reason why this was happening, the hal_dynalib_spi.h file was missing a reference to the said function.
This has fixed the problem:

DYNALIB_BEGIN(hal_spi)
DYNALIB_FN(hal_spi,HAL_SPI_Begin)
DYNALIB_FN(hal_spi,HAL_SPI_End)
DYNALIB_FN(hal_spi,HAL_SPI_Set_Bit_Order)
DYNALIB_FN(hal_spi,HAL_SPI_Set_Data_Mode)
DYNALIB_FN(hal_spi,HAL_SPI_Set_Clock_Divider)
DYNALIB_FN(hal_spi,HAL_SPI_DMA_Transfer) //Added
DYNALIB_FN(hal_spi,HAL_SPI_Send_Receive_Data)
DYNALIB_FN(hal_spi,HAL_SPI_Is_Enabled_Old)
DYNALIB_FN(hal_spi,HAL_SPI_Init)
DYNALIB_FN(hal_spi,HAL_SPI_Is_Enabled)
DYNALIB_FN(hal_spi,HAL_SPI_Info)
DYNALIB_END(hal_spi)

Hi @Sleziak

It’s ok to add to the HAL layer but you need to add between the previous last entry and the end statement. Otherwise the Hal layer will not be backward compatible. If you are submitting a pull request I think you should move that call.

1 Like

Thanks for this report. I’m puzzled how this has slipped by, since all our APIs are supposed to have linker checks. I’ve added this in the develop branch.

No problem whatsoever, this will save someone else some confusion :smile:

Mind me asking something? Is it possible to run SPI1 at 30 MHz instead of 15?

//spiMap[spi]->SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;//60/4=15 
spiMap[spi]->SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;//60/4=15 

Using DMA + interrupts I am able to receive and reply 10.2551Megabits per second while the /2 prescaler actually results in a slighlty slower transfer rate (10.0122)

I might be having signal integrity issues however, unfortunately neither my scope or logic analyzer are up to the job of 30Mhz square waves

Regards

SPI1 is already at 30MHz, with SPI at 60MHz. This was changed recently - you’ll see the prescaler is now 2 rather than 4 (the SPI1 clock is SYSCLK/2 so 60MHz, and with a prescaler of 2 gives SPI1 at 30MHz). The committer didn’t update the comment! :person_frowning: I’ll take care of that.

1 Like

This problem still exists, after 6-days !
How do I add (what-ever I need to add) to get this to work ?

I am using the on-line IDE.

…/…/…/build/target/wiring/platform-6-m//libwiring.a(spark_wiring_spi.o): In function SPIClass::transfer(void*, void*, unsigned int, void (*)())': /spark/compile_service/shared/workspace/6_photon_18_1/firmware/wiring/src/spark_wiring_spi.cpp:164: undefined reference toHAL_SPI_DMA_Transfer’
collect2: error: ld returned 1 exit status
make: *** [30f71e3f80d3da2ab9df5c721a19123e7f3cfa6f7cd448ecdc88ed858fd3.elf] Error 1

Hi @donvukovic

This is fixed in the develop branch where active development and integration happens. It will come to the stable branch in the next release (0.4.6) which I believe is coming out soon.

If you want to get it sooner, you can setup to compile locally and get the develop branch from github.

Thanks, how do I do this ?

Is there a page on where to get the github files ?

If you search here in the forum for “photon local build” you will find lots of hints for different PC/Mac/Linux platforms.