07-01-2025, 05:33 AM
background: 2 years ago, I was following along with @lupyuen great series of articles to get LVGL running on PinePhone. I was emulating the same journey but using Zig for all the hardware interfacing (and I got quite far). But at the time I was stuck on an old version of Zig and lost motivation. Now I finally have some hardware to run latest Zig, and I decided to port my project over to Zig 0.14 including it's new build system.
I've struggled for a few days to recreate the environment I had running (I also switched from macos to to Linux and still learning!). So I decided to go back to basics, and try to understand how NuttX interects with the JumpDrive image.
This is what I tried:
1. compiling some very simple Zig code, that should toggle the phone LEDs.
2. build the above as an elf file for arm freestanding with a target of cortex_a53
3. created a simple .ld linker file that ensure my entry point is at 0x40080000
4. using objCopy extract hex via the -O binary
5. gzip the resulting binary file into Image.gz
I was expecting that whatever the JumpDrive util does, it somehow jumps to executing the code directly from Image.gz. However now I suspect that this .gz might be a bit more complicated than straight arm machine code. But I have no idea what? and I struggle to follow the NuttX build (maybe something to do with a util called binfmt? but also I saw mention of nxflat).
Ultimately it would be nice to find a way to deploy to PinePhone as 'baremetal'. But for now the JumpDrive 'hack' would be enough, allowing me to hop between SDCards to compare/debug different images.
Does anyone have any idea how to wrap my baremetal code into something JumpDrive can recognize from the Image.gz file please.
I've struggled for a few days to recreate the environment I had running (I also switched from macos to to Linux and still learning!). So I decided to go back to basics, and try to understand how NuttX interects with the JumpDrive image.
This is what I tried:
1. compiling some very simple Zig code, that should toggle the phone LEDs.
2. build the above as an elf file for arm freestanding with a target of cortex_a53
3. created a simple .ld linker file that ensure my entry point is at 0x40080000
4. using objCopy extract hex via the -O binary
5. gzip the resulting binary file into Image.gz
I was expecting that whatever the JumpDrive util does, it somehow jumps to executing the code directly from Image.gz. However now I suspect that this .gz might be a bit more complicated than straight arm machine code. But I have no idea what? and I struggle to follow the NuttX build (maybe something to do with a util called binfmt? but also I saw mention of nxflat).
Ultimately it would be nice to find a way to deploy to PinePhone as 'baremetal'. But for now the JumpDrive 'hack' would be enough, allowing me to hop between SDCards to compare/debug different images.
Does anyone have any idea how to wrap my baremetal code into something JumpDrive can recognize from the Image.gz file please.