baremetal via Zig on PinePhone - JumpDrive help please
#1
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.
  Reply
#2
Finally, booting Zig code 'baremetal' (via JumpDrive trick used by Nuttx) Smile The Image file is the simple objCopy binary output from the elf file. To get my Zig code to run I had to link it with a bit of assembly code for setting up the arm chips. Actually just the MZ ... ARM 'header' magic number bytes seem to be enough at the moment. Probably the boot loader already did all the hard work Smile
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Movuan distribution for PinePhone merom 5 1,174 07-27-2025, 05:01 PM
Last Post: merom
  Latest firmware for PinePhone modem! Subsentient 105 177,263 02-02-2025, 08:47 PM
Last Post: bacydentir85
  Slarm64 on PinePhone [Unofficial Slackware ARM - 64 bit] acid andy 40 43,849 12-28-2024, 12:19 AM
Last Post: mara
  8/24 status of JumpDrive shengchieh 3 1,427 12-05-2024, 12:13 PM
Last Post: zetabeta
  Office applications for the Pinephone Peter Gamma 2 1,503 09-05-2024, 09:22 AM
Last Post: Peter Gamma
  Struggle to install LibreOffice on the PinePhone Peter Gamma 50 47,876 07-26-2024, 10:35 PM
Last Post: Peter Gamma
  Why does Pine64 sabotage office on the Pinephone? Peter Gamma 5 2,554 07-04-2024, 07:34 AM
Last Post: Kevin Kofler
  Which word processor to choose for the Pinephone? Peter Gamma 16 9,837 06-22-2024, 07:28 AM
Last Post: Peter Gamma
  Samba share on the Pinephone? Peter Gamma 0 1,180 06-16-2024, 10:26 PM
Last Post: Peter Gamma
  Possible Free Backup Carrier for PinePhone PineFone 0 1,119 06-13-2024, 03:45 PM
Last Post: PineFone

Forum Jump:


Users browsing this thread: 1 Guest(s)