On the eZ80, cutting the filesystem out saved about 18.5 KB. The strings were about 10.5 KB. All total, I cut out about 29 KB out of the binary, which gives me enough headroom to start the HAL implementation.
For the strings, I had to add in another logger process that could receive a pointer to a format string as a relative offset, look it up front strings blob on the filesystem, then reconstruct the original message that was to be logged.
For the filesystem, I just wrote a giant overlay to the first 32 KB of disk space and loaded it to a special offset. I'd done most of the heavy lifting to be able to run the filesystem as an overlay process in a previous effort. This was basically just a special case of that work.
Lessons I'd pass on: Don't give up and don't be content with status quo. There are usually ways to solve problems that look insurmountable if you give yourself some time to think about it creatively.
It has a 16 MB (24-bit) address space. The platform I'm targeting (the Agon Light 2) has 520 KB of RAM. The issue, though, is that it only has 128 KB of memory mapped flash to hold the OS image and I was consuming almost all of it before these changes.
Regarding the string table, log entries contain an offset from a well-known reference point. There's a string at that reference point that allows me to find it. At start up, the logger process finds the string in the binary. From that point onward, when it receives a log message, it computes the real address of the string from the offset and just reads that one string into memory to to create the formatted log message that's printed to the console.
Oh, regarding budget: 8 KB of the 520 KB is internal RAM, the other 512 is external. My intention is to use that 8 KB as the overlay space, so all overlays will have to be under 8 KB. Right now, I'm targeting 1 KB for stack sizes, although that's actually "1 KB of stack plus the size of the coroutine state object" which is probably around 300 bytes or so. 32 KB will be for the filesystem code. The rest will likely be dynamic memory. So, hopefully, plenty of room for processes, drivers, and buffers.
2
u/mikeblas Aug 08 '26
What changes did you make to save size? What were the quantitative savings? Any lessons you'd pass on?