If you’re sticking with heap_3 with newlib for now, then see this post for some helpful code (if I do say so myself ).