SDRAM Malloc and printf / sinit crash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-02-07 5:49 AM
Hello,
I'm using an STM32H743-EVAL2 board, I want to access the LCD screen to draw a PNG image, so I'm using a png library to load the image, and this library use "malloc".
Unfortunately the RAM of the H743 is too small for handling large pictures, so I redirected the malloc heap to SDRAM by modifying the function _sbrk.
This is working fine, however when I try to use printf to output to UART1, the prinf calls _puts_r, which call __sinit, __sfp, __sfmoreglue, _malloc_r, _sbrk_r, and that returns an address in SDRAM, but it seems like this space allocated in SDRAM is not suitable for the function sinit because it crash (OnError_Handler is called)
If the malloc is not redirected to SDRAM, then printf is working fine.
Can someone tell me why ? and how can I make the 2 work from SDRAM ?
Thank you
- Labels:
-
DEBUG
-
STM32H7 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-02-07 8:34 AM
Suggest: Two different malloc
Rename malloc in the new code to something like malloc_sdram() so it doesn't conflict with other code.
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-02-07 4:12 PM
Perhaps instrument malloc/free to understand what's happening there, and debug what's actually failing in the C libraries.
Validate the SDRAM thoroughly, especially unaligned accesses.
Make sure the SDRAM is up early, in SystemInit() no halfway thru main()
Up vote any posts that you find helpful, it shows what's working..
