PSoC3 reentrant issue: I get a build error when I use the CYREENTRANT keyword on a function

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted


I'm trying to convert code that works very well on a PSoC5 over to a PSoC3.

I have a function that is recursive.   I place the CYREENTRANT keyword on the end of the function.



const menu_cmd *Term_MenuCmds_search(const menu_cmd menu_array[], uint8 c) CYREENTRANT;
const menu_cmd *Term_MenuCmds_search(const menu_cmd menu_array[], uint8 c) CYREENTRANT



 I receive a elf file conversion phase error:


Program Size: data=25.4 xdata=2028 const=99 code=41460
OHx51.exe DVDAC14_Demo_PSoC3.omf HEXFILE(DVDAC14_Demo_PSoC3.ihx)
c8051-elf-omf2elf.exe DVDAC14_Demo_PSoC3.omf DVDAC14_Demo_PSoC3.elf
The command 'c8051-elf-omf2elf.exe' failed with exit code '3221225477'.

If I remove the CYREENTRANT keyword, the project compiles and loads into the PSoC3.  However, I get improper results when the function calls itself then returns from the recursive call (the variables used or passed are not placed on the stack as it does in the ARM environment) 

I've consulted previous REENTRANT topics with no good results.   Eg: KBA/Making-PSoC-3-5-functions-reentrant 

I've read much of the Keil docs about REENTRANT declarations and it left me confused.

What is the proper way to make a function reentrant.   Note:  I'm not sharing the function with any other task or interrupt.   It's just a function that calls itself if needed.

Update: (12/28/2021)


I changed the code to the following that worked and allowed a complete build.


const menu_cmd *Term_MenuCmds_search(const menu_cmd menu_array[], uint8 c) CYSMALL CYREENTRANT


I had to declare the memory model to be used (CYSMALL).   This built and the code is running properly with recursive operation.

"Engineering is an Art. The Art of Compromise."
0 Replies