~increscent/funos

Fun with the PinePhone
Added attributions; hitting a dead-end on the gpu driver
Re-arranging memory layout
Trying the mmu without paging first

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~increscent/funos
read/write
git@git.sr.ht:~increscent/funos

You can also use your local clone with git send-email.

#funos

The wee, small beginnings of an OS for my PinePhone.

#Rule

I must write all the code for funos.

Exceptions:

  • I don't have to write firmware for proprietary, undocumented hardware (modem, Wifi/Bluetooth)
  • I can use a compiler/linker (but no standard library)

#Dependencies

  • make
  • arm-none-eabi-gcc,objcopy,objdump
  • rustc (with target aarch64-unknown-none)
  • gcc

#Building

make

#Flashing

To flash SD card:

# !Warning! writes to /dev/mmcblk0
# !Warning! overwrites the last 16MiB on the SD card (and the bootloader)
# However, it does save the bootloader so you can return to the previous OS
make sd-flash-all

#Runtime Update Over USB

To flash over USB (with funos running):

make usb-flash

To flash over USB and persist on the next reboot:

make usb-flash-persist

#Runtime Shell

To interact with the shell over USB:

make usb

A couple shell commands:

  • power off
  • restore uboot: restore previous bootloader and power off (to go back to previous OS)

#Boot Process

The A64 BROM loads a 32KiB bootloader into SRAM at address 0x10000 and then executes it. This bootloader needs to be located at offset 8192 on the SD card. The bootloader has a required header generated by the mksunxiboot tool.

  • Starts at boot_entry32.S at address 0x10040; switch to aarch64 mode
  • aarch64 mode jumps to address 0x100A0 and starts executing boot_entry.S
  • Jump to main in boot.rs
  • Init clock, led, uart, pmic, dram, mmc
  • Read the OS binary into DRAM from the SD card and jump to it
  • The OS binary starts in entry.S; it sets up the vectors and zeroes out BSS
  • Jump to main in funos.rs
  • Init clock, led, uart, mmu (caching and translation), increase clock speed, pmic, gic, usb, display
  • Event loop

#Credits

Thank you: