it is normal when i use other obj. but when I create a ta(text area) obj, The Stm32 is died(into hardfault)
What MCU/Processor/Board and compiler are you using?
stm32f746
What do you want to achieve?
What have you tried so far?
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
Your display is 1024x600? maybe memory allocation problems. Also do you use RTOS?
Try to just run lvgl with nothing displayed or try to comment out each line everytime to see which triggers the hardfault because I see nothing wrong.
I find the problem. it is happen when function lv_area_copy run.
i simulate, i find the func(lv_area_copy) just have a function (memcpy) ,and i check, the all params is legal(src addr dst addr len),But program will died if run the function.
i attempt to use my_mem_cpy function to replace the memcpy func ,last the program is work Okay.
it is a very strange problem.
Can you tell me what values the parameters had? If they’re unaligned the built-in memory functions on STM32 have often caused issues for me. In that case, this will no longer be an issue in 7.0 as we use our own memory functions now.
The source address is not aligned, as I suspected. That’s interesting. I’ll have to try this on my board and see if I can reproduce it. Can you get a backtrace in the debugger at this point?
char* is used in @FreeChase’s custom mem_cpy function. The crash only happens when the built-in memcpy function from Newlib is used (which, in my experience, frequently fails to handle unaligned addresses).
So, I’d think that the source area should be aligned by the compiler, as it’s a struct. However, we have already seen similar issues with -Os optimization. In this case, the compiler might pack the structs “as close as possible” resulting in unaligned structs. Do you use -Os optimization?
I use either -Os or -Og in my projects, depending on whether I’m trying to debug something or not. I’ve never seen GCC choose to pack structs based on optimization before, though. That seems like it would break a lot of code.
I’m suspicious that whatever heap is in use is returning an unaligned pointer when the ext structure gets allocated. This then means that everything in the structure is also going to be unaligned.
We had an issue due to size optimization earlier and as a workaround, we introduced LV_ATTRIBUTE_MEM_ALIGN config option which is added to images in some other places too.
lv_mem_alloc returns aligned memories and I’d be really surprised if normal malloc wouldn’t do the same especially on an embedded system. But we will see what’s going on when @FreeChase tells the address of ext the optimization level.