I'm working on porting Linux to a fiber modem (actually a family of modems), and I just finally made it to the end of what turned out to be a much more complex thing than I had anticipated.
I tried using someone else's code but I was not happy with their error handling, and as I was refactoring it at some point I realized they didn't understand the problem at all. What ensued was a 3 or 5 day bender which culminated in a 1300 line file that begins with this comment:
Now that I can actually get it working (by moving it up in memory), I'm going to do two things:
1. Print the stack pointer just to be 100% sure it didn't somehow end up where it's not supposed to be.
2. Fill the unused memory below the image with a pattern, and then check for that pattern in the zboot, and perhaps even in the kernel init. If that pattern is not corrupted then I can at least feel confident that it's not *writing* below it's load address.
This really really REALLY looks like the stack is placed on the boundary of invalid memory, but I checked that rather carefully and the stack is being placed above the top of the loader binary. Maybe something else is changing it (?)
I guess I shouldn't get down on myself for not making impact.
I wonder out of every LoC I've ever written which one actually gets used the most. It's probably some small bug-fix or something I forgot I ever did...
This processor is EcoNet EN7526, but if I can make it work, the same port SHOULD work for EN7512, EN7513, EN7520 and EN7521 out of the box. With minimal reworking it should also work for EN7516, EN7527 and EN7528 as well.
So this port will bring linux compatibility to quite a bit of hardware.
Some years ago I was investigating it as a possible product for Routie ( https://routie.io ) to sell. Then I had one at home, and I wanted to come back and conquer porting linux to a new platform.
This is a pretty unique platform. The interrupt controller is something that no open source driver exists for (unless you count the Linux 2.6 era hacky trash you find in GPL dumps).
The timer is also unique, it runs at 200Mhz so it has a 5 nanosecond tick rate, but again, no drivers exist. I suspect this might be because good timing is required for the fiber protocol ¯\_(ツ)_/¯