Something Useful

2021-07-19

On the previous posts I talked about my hobby kernel, and it’s long way. One of my dreams was to run Python there. Luckily I remembered that micropython exist. Thus I decided to port that first before the real python.

I was actually surprised how easy it was. Since I had working musl libc ported on the kernel, there was very little things to do to get it started. Made some shortcuts, but for now the main thing was to get it compile and run. It printed it’s prompt and I was happy.

Hello World!

Next thing was to run simple “Hello world” app from a file. That caused some problems and looks like micropython NLR (non-local return) implementation had some issue. After some debugging found out that the return address resolving from the stack goes wrong. Luckily found the issue and by switching one define got it fixed. For some reason on my compiler their defaults (i686-elf-gcc 7.1.0) doesn’t work. Might need to submit a patch to fix it once I figure out myself what would be proper fix. For now it’s just hardcoded in my implementation.

Parsing issues

Next problem was a parsing issue. So parsing my Python file failed. That turned out to be bug in my TAR based file system. I didn’t handle end of file stream properly and feed lot of zeros to the end. After fixing that one it greeted me! So I had my own kernel, made from scratch running a simple Python script it read from pseudo ATA disk with pseudo FS (TAR file).

State of the world

To continue from there I fixed a bit more complicated script. For now it also can read time from CMOS. It’s not too accurate but enough for now. So I can actually import time module and get valid values from time.time()

micropython running script

There’s still lot to do and to implement. For now I’m just happy to get it done something real. To be seen what I’ll do next with it…