this post was submitted on 17 Oct 2024
1379 points (98.9% liked)

RetroGaming

19631 readers
224 users here now

Vintage gaming community.

Rules:

  1. Be kind.
  2. No spam or soliciting for money.
  3. No racism or other bigotry allowed.
  4. Obviously nothing illegal.

If you see these please report them.

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] mynameisigglepiggle@lemmy.world 16 points 1 month ago (1 children)

I dabbled with making a fairly complex program for a microcontroller the other day and quickly hit the stack limit for a simple object.

It wasn't so much that it was a large object, but to provide flexibility I was amazed how fast I filled the memory.

I've done heaps with memory managed languages in the past but shit as soon as I had to think about what I was doing under the hood everything got hard af.

So serious question - does anyone have any good resources for a competent programmer, but with no clue whatsoever how to manage memory in a microcontroller space and avoid fragmentation etc?

I got it to work but I'm sure I did shit job and want to be better at it.

[–] BigDanishGuy@sh.itjust.works 8 points 1 month ago (1 children)

The best book I've ever bought on programming, and the second best book I bought for a class in uni, was https://dl.acm.org/doi/book/10.5555/1824214 it may be worth checking out on libgen and buy if it suits your needs.

Whenever I do low-level programming on the AVR architecture, I'll make a memory map. As in I'll map out where I'll put what. It may not be suitable for more complex programs, but it does the job for me. And it has enabled teamwork in assembly in the past.

If you want to work in a language that doesn't offer memory management, but manually mapping memory isn't feasible either, how about building your own memory management? Or perhaps use an RTOS? I've used freeRTOS before on various arm-based micros, and it does take a bit to get started, but after that it's easy sailing.

Sorry for the following tangent, all semi intelligent content in this comment is found above this line.
BTW I tried CoOS once, I wouldn't recommend it... OK it was 12 years ago, I can't remember exactly what was wrong other than the documentation was crap, but I don't need to remember why to hold a grudge.

[–] mynameisigglepiggle@lemmy.world 1 points 4 weeks ago

Bought the book! Thanks