I am trying to test out the sample/demo code for ThreadX on an STM32L0 Cortex M0+ controller. Specifically the sample_thread.c code found on GitHub. I used the example code for the cortex M0 port and compiled the code. At this point all is good, or so I think, the port looks like it is mapped correctly for my controller; i.e. memory start address and RAM are correct.
The issue I am having is that I am getting a hardfault during some functions for dynamic memory allocation, when allocating space for threads. I find that the hardfault is triggered within the function _tx_byte_pool_search(), it happens when the block pointers are checked, in one instance here:
*next_block_link_ptr = *this_block_link_ptr;
When this line is executed, one of the block pointers ends up with an invalid address outside of the memory area, usually with 0xAAAAAAAA. I'm trying to understand how exactly ThreadX is constructing these blocks of memory, but I shouldn't have to. This function should work as intended but it isn't. So I'm thinking that I am doing something wrong, but have run out of ideas to check. If someone with some more experience can provide some direction or ideas that would be helpful.
I have setup the startup code in _tx_initialize_low_level.S to provide the address of first_unused_memory, which is used for tx_application_define(). I thought that this address was basically what was required for the memory allocation stuff to work. Maybe I am missing something.
Thank you all for the help.