2022-08-02 09:12 AM
I have a working project that was running in STM32CubeIDE v1.7.0, with STM32CubeMX v6.3.0 and TouchGFX v4.18. After updating to STM32CubeIDE v1.10.1, STM32CubeMX v6.6.1, and TouchGFX v4.20, the program is getting stuck in HAL_Delay when HAL::initialize() is initializing the touchscreen.
I watch uwTick variable up until the HAL::initialize() call, and it is updating. It is no longer updating in the Hal_GetTick function during touchscreen initialization.
I have not changed any settings in the project or in CubeMX. I am not doing any overrides of the system tick initialization. Any ideas why this is happening?
Solved! Go to Solution.
2022-08-11 08:14 AM
ST technical support finally got back to me with the following response:
You are talking about TouchGFX 4.18 now we are on 4.20. TouchGFX 4.20 is the latest, this is for STM32CubeMX 6.5.0.
As recommendation as things are changing constantly between CubeMX and TouchGFX I do not recommend to migrate the IOC file to newer version just stick to old and use the “Continue�? not “migrate�?. As example for other bord, the problem when migrating was just at the RTOS timer no calling HAL ISR timer handler.
If you do not migrate sill can open IOC file, do modifications, generate code with CubeMX and all should be OK. As the TouchGFX project was created for that version.
The example I sent them uses TouchGFX 4.18, but the same problem exists with TouchGFX 4.20. The only reason I sent them a 4.18 example project is because there are other problems encountered when going to 4.20.
About all I can take away from this is that if you are using FreeRTOS with TouchGFX and CubeIDE and CubeMX, you had better not update CubeMX beyond version 6.5. It would be nice to have known that before I spent so much time trying to get everything to work.
2022-08-02 09:25 AM
>>Any ideas why this is happening?
Priorities changed?
Software counters need to be brief, and preempt everything, especial with unfettered usage in interrupt and callback contexts.
Make sure the interrupt is enabled and firing. Make sure interrupts are enabled on the MCU. So watch for boot-loaders, or control transfers done from interrupt context, or RTOS's
2022-08-02 09:33 AM
Thanks for the quick reply. Like I said, I made no changes to the project or its configuration. And uwTick was ticking until the TouchGFX initialization. Do you know of any changes made to TouchGFX between 4.18 and 4.20 that could cause this? I'm going to try just the IDE and CubeMX update without the TouchGFX update and see if that works.
2022-08-02 11:59 AM
OK, so I started back with the original project, which was in STM32CubeIDE v1.7.0, with STM32CubeMX v6.3.0 and TouchGFX v4.18. (NOTE: for the following information: CubeIDE 1.10.1 is associated with CubeMX6.6.1 whan I do a Help->About in the IDE, but I also have CubeMX 6.50 installed in a different folder.
From all of this, one has to assume there is something different between CubeMX 6.5.0 and 6.6.1 that is causing a failure.
2022-08-03 06:42 AM
Latest update: The last time I see uwTick updated is when it increments by one count between the calling and returning of osSemaphoreNew() in OsWrappers::initialize().
I am not seeing it update anymore after that, and the software later gets hung in the HAL_Delay() that gets called in the touchscreen driver initialization.
2022-08-03 08:54 AM
Apparently the uwTick counter stops updating somewhere within the osSemaphoreNew() call. I modified osWrapper.cpp to add some Hal_Delay calls as follows:
/*
* Initialize frame buffer semaphore and queue/mutex for VSYNC signal.
*/
void OSWrappers::initialize()
{
// Create a queue of length 1
HAL_Delay(5);
frame_buffer_sem = osSemaphoreNew(1, 1, NULL); // Binary semaphore
assert((frame_buffer_sem != NULL) && "Creation of framebuffer semaphore failed");
HAL_Delay(5);
// Create a queue of length 1
vsync_queue = osMessageQueueNew(1, 4, NULL);
assert((vsync_queue != NULL) && "Creation of vsync message queue failed");
HAL_Delay(5);
}
The uwTick count was 283 at a breakpoint set for the first HAL_Delay(). After stepping over it, it was at 290. After stepping over the osSemaphoreNew() call, it was at 291. It was no longer incrementing when the 2nd HAL_Delay() call was made, and the program remained in that 2nd call.
2022-08-03 10:04 AM
Well, I found out why the system is hanging, but I haven't chased down the differences between the project that works and the one that doesn't.
There is a variable used by FreeRTOS called uxCriticalNesting. It is initialized in its declaration to 0xaaaaaaaa. It is initialized to zero when the Scheduler is started with an osKernelStart() call. That's fine, but the problem is it is used in the call to MX_TouchGFX_Init(), which sets up a semaphore and a queue. I followed the osSemaphoreNew() code, and within this function we reach the following code (see the call stack as well):
here, interrupts are disabled and uxCriticalNesting gets increment not from 0 to 1, but from 0xaaaaaaaa to 0xaaaaaaab.
Later, when vPortExitCritical is called (see image above), uxCriticalNesting is decremented not from 1 to 0, but from 0xaaaaaaab to 0xaaaaaaaa. And.... interrupts do not get re-enabled.
I tried temporarily initializing the uxCriticalNesting variable to 0 at its declaration, and the code runs fine. Perhaps this was initialized to zero earlier in the earlier release of all the software, but this is definitely a problem in this release, because MX_TouchGFX_Init() is called before osStartKernel() is called. These two calls are made in auto-generated code, so I think something needs to change, ST.
2022-08-03 11:27 AM
Well, that may have made the program work, but I also tried single-stepping through the program that uses CubeMX 6.5, and osSemaphoreNew exhibits the same behavior with the uwCriticalNesting value of 0xaaaaaaaa, yet the uwTick keeps updating. I'm really at a loss now.
2022-08-04 05:57 AM
It looks like I have to move this to a tech support case. I've created two versions of a simple test case that just displays a 'SUCCESSFUL TEST' screen on the STM32F469i-DISCO if successful. The version using CubeMX 6.5.0 displays the screen, and the version using CubeMX 6.6.1 does not, because it gets hung up in MX_TouchGFX_Init due to the uwTick updates stopping once it is called. Will post an update if there is a resolution to this. If anyone is curious enough about this to see for themselves and you have a STM32F469i-DISCO board, just reply to this and I will provide the two projects.
2022-08-04 10:50 AM
After submitting the case to ST, I continued my investigation. I instrumented the failing software using CubeMX 6.6.1, and discovered that the HAL quit updating after the first call to portDISABLE_INTERRUPTS() in FreeRTOS port.c. This led to me thinking that there is a priority issue or something related to the HAL timer 6 initialization. I compared HAL_InitTick() from 6.5.0 to the same function in 6.6.1, and they are quite a bit different. I replaced the HAL_InitTick() function that was being called with the one from 6.5.0 and everything works. See the attached file, where both functions are present, but the 6.6.1 version is commented out. When I run the 6.6.1 version of the project, but with this one function replaced with the 6.5.0 version, the program works. So the question for ST is... why the change?