cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 linker - how to use _sbrk function

Posted on October 16, 2017 at 22:39

Hi,

  I've found a brillant OCR source code made for the STM32F429-DISCO board. I had to rebuilt the project, using the KEIL V5, because the original source code doesn't bring the project files or the linker files. The autor, Petr Machala, mention on his thesis paper that, he had to alter the linker file to increase the heap capacity, using the '_sbrk' function in the syscalls.c file.

  My doubt is about the alteration of the linker file, what do I need to change to make the compiler use the '_sbrk' function?

  I've searched a lot but don't found any specific tutorial (spetially for KEIL) about that amazing resource, of use the external SDRAM to expand heap memory used by the malloc function. I'd like to use that tool for image processing, maybe fingerprint or facial identification and recognition.

  Here is the link for the original project.

 

https://www.vutbr.cz/studium/zaverecne-prace?zp_id=84664

  and a demostration video

 

https://www.youtube.com/watch?v=7bmGsCYSGvk

  I successfuly compiled the project and pratically all functions are working, the TFT, touch menu and DCMI interface with the OV7670 are working perfectly. But the ocr_algorithm throws to Hardfault when it start to process the image. Increasing the heap memory, until to the microcontroler limit, make it process a little more time, but it still failure at function 'scan_boxes'.

  

  Thanks in advance.

#linker-file #stm32f429-disco #sbrk #stm32 #ocr
1 REPLY 1
Posted on October 16, 2017 at 22:51

The heap size in Keil is typically defined in startup_stm324xx.s, you'd then use your scatter file to describe the SDRAM memory region, have it be the destination for the HEAP section, and initialize the SDRAM in code you have in, or called by, SystemInit.

Alternatively, if you understand the Keil allocator you can insert the SDRAM region once you have initialized it in main()

_sbrk is a GNU/GCC thing.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..