Code Monkey home page Code Monkey logo

g5_ppc64-linux's Introduction

Linux on a PowerMac G5, ppc64

License: GPL v3 master

VNC session

Fedora 25

Debian 8.6.0

boot setup

This section decribe a working boot setup by using an updated GRUB as default bootloader (no need for yaboot).
Notes:
- Tools must work for Big Endian machines, writing data accordingly, setups written by Little Endians machines will be swapped.
- This boot setup can be readed also as: "yaboot to grub2 bootloader migration"

Booting an installer directly on TARGET can leave you in an unbootable system:

  • Debian installer will do the job and will fail at configuring yaboot setup
  • Fedora installer will fail at missing required yaboot

We can do a full manual setup, or modify installs, we need:

  • kernelspace and userspace support to edit mac partition, for ppc64
  • a bootable grub image, for ppc64
  • hfs-util, for ppc64

I'm using buildroot to build a minimal kernel + initrd with needed tools to perform this tasks

partition map

OpenFirmare load the default ofprogram from the first HFS partition (Apple_Bootstrap) from a mac partition table.

below I use about 16M on sda2 due default partition is smaller to store grub2 image later.

parted /dev/sda
  GNU Parted 3.2
  Using /dev/sda
  Welcome to GNU Parted! Type 'help' to view a list of commands.
  (parted) p free                                    
  Model: ATA Hitachi HTS54251 (scsi)
  Disk /dev/sda: 160GB
  Sector size (logical/physical): 512B/512B
  Partition Table: mac
  Disk Flags: 
  Number  Start     End    Size  File system  Name   Flags
  
    1      512B  32.8kB  32.3kB               Apple
         32.8kB  1049kB  1016kB  Free Space
    2    1049kB  16.8MB  15.7MB  hfs                 boot
    3    16.8MB   256MB   239MB  ext4
    4     256MB  16.4GB  16.1GB  ext4         root   root
    ...
lsblk -o NAME,FSTYPE,SIZE,LABEL,UUID -x NAME

  NAME FSTYPE   SIZE LABEL    UUID
  sda         149.1G          
  sda1         31.5K          
  sda2 hfs       15M MAC_BOOT 
  sda3 ext4     228M BOOT     26507748-8918-49e0-9d3e-8e8c7b3da04d
  sda4 ext4      15G ROOT     46026799-c14a-4ae0-98fd-d5d70cd21c4c
  ...

Same result, from Cockpit's point-of-view

grub2

grub.img can be cross-compiled on a 32bit HOST too, checkout https://github.com/crosstool-ng/crosstool-ng

  • Write a first grub.cfg that points to the final grub.cfg, located at (...hd,apple3)\boot\grub2\grub.cfg, using UUID:
    Note: paths here does not contain 'boot' since /boot is a mountpoint (to /dev/sda3 partition) for linux (ROOT on /dev/ sda4) when it's booted (off OpenFirmware).
cat grub.cfg
  search.fs_uuid 26507748-8918-49e0-9d3e-8e8c7b3da04d root
  set prefix=($root)/grub2
  configfile /grub2/grub.cfg
  • Build a GRUB2 image, embedding the configfile
grub2-mkimage -c grub.cfg -o grub -O powerpc-ieee1275 -C xz -p /usr/lib/grub/powerpc-ieee1275/*.mod
file grub
  grub: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, stripped

This way, everytime OpenFirmware loads our GRUB, it will parse the configfile from /boot/grub2/grub.cfg

  • Just for info, you can check OpenFirmware path from linux:
grub2-ofpathname /dev/sda2
  /ht@0,f2000000/pci@7/k2-sata-root@c/disk@0:b

mac-blessing with hfsutils

hmount /dev/sda2
  Volume name is "MAC_BOOT"
  Volume was created on Thu Jan  1 03:01:17 1970
  Volume was last modified on Tue Dec 20 19:34:16 2016
  Volume has 12086784 bytes free

hcopy grub :grub

hattrib -t tbxi :grub

hattrib -b :

hdir :
  f  tbxi/UNIX         0   1698620 Dec 20 19:23 grub
  f  tbxi/UNIX         0   1691400 Jan  1  1970 another_grub.img

humount /dev/sda2

boot from OpenFirmware

manually

enter OpenFirmware command prompt, run grub from default HFS (Apple_Bootstrap) partition:
0 > boot hd:,grub

auto

store in nvram your default, OpenFirmware looks at first HFS partition, we have grub2 image there:

  • from OpenFirmware:
0 > printenv ok
will display nvram values, to set:
0 > setenv boot-volume 2 ok
0 > setenv boot-device hd:,grub ok
0 > setenv boot-file grub ok
  • from linux:
nvram --print-config --partitions
will display nvram values plus OpenFirmware known partitions, to set:
nvram --update-config boot-volume 2 -p "common"
nvram --update-config boot-device hd:,grub -p "common"
nvram --update-config boot-file grub -p "common"

Note: man nvram is some chars away...

linux

cat /etc/fedora-release
  Fedora release 25 (Twenty Five)
  • autoload modules
cat /etc/sysconfig/modules/something.modules
  modprobe i2c-powermac
  modprobe rack-meter
  • thermal and scaling are working
find /sys -iname "*temp*"
  /sys/kernel/debug/tracing/events/thermal/thermal_temperature
  /sys/devices/platform/windfarm.0/cpu-amb-temp-1
  /sys/devices/platform/windfarm.0/cpu-diode-temp-0
  /sys/devices/platform/windfarm.0/cpu-amb-temp-0
  /sys/devices/platform/windfarm.0/hd-temp
  /sys/devices/platform/windfarm.0/cpu-diode-temp-1
  /sys/devices/platform/windfarm.0/backside-temp
  /sys/devices/platform/temperature
  /sys/firmware/devicetree/base/u3@0,f8000000/i2c@f8001000/temp-monitor@96
  /sys/firmware/devicetree/base/u3@0,f8000000/i2c@f8001000/temp-monitor@96/temperature@0
  /sys/firmware/devicetree/base/u3@0,f8000000/i2c@f8001000/temp-monitor@94
  /sys/firmware/devicetree/base/u3@0,f8000000/i2c@f8001000/temp-monitor@94/temperature@0
  /sys/firmware/devicetree/base/u3@0,f8000000/i2c@f8001000/supply-monitor@5a/temperature@0
  /sys/firmware/devicetree/base/u3@0,f8000000/i2c@f8001000/supply-monitor@58/temperature@0
  /sys/firmware/devicetree/base/u3@0,f8000000/i2c@f8001000/temp-monitor@98
  /sys/firmware/devicetree/base/u3@0,f8000000/i2c@f8001000/temp-monitor@98/external-temperature@1
  /sys/firmware/devicetree/base/u3@0,f8000000/i2c@f8001000/temp-monitor@98/internal-temperature@0
  /sys/firmware/devicetree/base/sep/temperatures
  /sys/firmware/devicetree/base/sep/temperatures/cpu-b-diode-temp@10
  /sys/firmware/devicetree/base/sep/temperatures/cpu-a-diode-temp@b
  /sys/firmware/devicetree/base/sep/thermostats/overtemp*-signal@5800
  /sys/bus/platform/devices/temperature
    
cat /sys/devices/platform/windfarm.0/cpu-diode-temp-*
  34.794
  31.604
    
cat /proc/cpuinfo
  processor       : 0
  cpu             : PPC970, altivec supported
  clock           : 1304.400000MHz
  revision        : 2.2 (pvr 0039 0202)

  processor       : 1
  cpu             : PPC970, altivec supported
  clock           : 1304.400000MHz
  revision        : 2.2 (pvr 0039 0202)

  timebase        : 33333333
  platform        : PowerMac
  model           : PowerMac7,3
  machine         : PowerMac7,3
  motherboard     : PowerMac7,3 MacRISC4 Power Macintosh 
  detected as     : 336 (PowerMac G5)
  pmac flags      : 00000000
  L2 cache        : 512K unified
  pmac-generation : NewWorld

lscpu 
  Architecture:          ppc64
  CPU op-mode(s):        32-bit, 64-bit
  Byte Order:            Big Endian
  CPU(s):                2
  On-line CPU(s) list:   0,1
  Thread(s) per core:    1
  Core(s) per socket:    1
  Socket(s):             2
  NUMA node(s):          1
  Model:                 2.2 (pvr 0039 0202)
  Model name:            PPC970, altivec supported
  CPU max MHz:           2000.0000
  CPU min MHz:           1304.4000
  L1d cache:             32K
  L1i cache:             64K
  L2 cache:              512K
  NUMA node0 CPU(s):     0,1

g5_ppc64-linux's People

Contributors

masterzorag avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.