Difference between revisions of "Xbox Linux Tips and Tricks"
VannevarKush (talk | contribs) m |
VannevarKush (talk | contribs) m (→Unpacking and Repacking an initramfs/initrd) |
||
Line 86: | Line 86: | ||
===Unpacking and Repacking an initramfs/initrd=== | ===Unpacking and Repacking an initramfs/initrd=== | ||
The initramfs files provided with Xbox Linux can come in multiple formats. To check what format it is, type | The initramfs files provided with Xbox Linux can come in multiple formats. To check what format it is, type | ||
− | <code>file [ | + | <code>file [INITRAMFS_FILENAME]</code> |
====cramfs==== | ====cramfs==== |
Revision as of 03:12, 5 July 2022
Here are some various tips that may help you get Xbox Linux up and running, and beyond.
Contents
- 1 128MB RAM Upgrade
- 2 CPU Upgrade
- 3 hdb as Swap
- 4 USB Stick as Swap
- 5 Hard Drive on hdb as a Bootable CD
- 6 Using the Extra 2GB on a 10GB FATX Hard Drive
- 7 Using xbox7887's Serial USB Adapter (on the LPC bus)
- 8 Using USB serial devices
- 9 Using Serial (USB or xbox7887's SuperIO board) for Kernel Debugging
- 10 Unpacking and Repacking an initramfs/initrd
- 11 See Also
128MB RAM Upgrade
Yep, it helps here too. Any modern Linux distro that isn't built for lightweight hardware is probably going to assume there is a lot more memory available than the Xbox has. The more memory and the more non-lightweight services in use, the more swapping is going to happen. With 64MB of RAM a lot of swapping is going to take place during any memory-intensive operation, slowing Linux to a crawl. So the 128MB of RAM can give Linux some more breathing room. More minimal distros may be able to run fine with a (very) lightweight desktop with 64MB. The vanilla Gentoo LiveCD command line environment worked fine until compiling. But even operations like extracting files take forever and could be done faster with less disk access with more RAM.
CPU Upgrade
Although a more advanced/expensive mod, upgrading the CPU will cause Linux to run that much faster. (when it's not bottlenecked on swapping, that is). The 1.4Ghz Tualatin with a 256KB cache will result in >2x performance. Gentoo compilation was tested on a 1.4GHz 128MB Xbox and was much more than 2x faster than on a stock Xbox.
hdb as Swap
Swapping to the same drive as data is being read from is far from ideal. Instead of a DVD drive, if a hard drive is connected on hdb, it can be used exclusively (or primarily) for swap. An unlocked stock Xbox hard drive could be used for this (back it up first!) but better performance will be obtained with an SSD. Small SSDs are not very expensive, and if it's just used for swapping, it can be easily replaced if it dies. (and do you really plan to use it for swap all day every day? It would only incur wear on the storage while running Xbox Linux. Does Linux have any sort of write levelling support for swap?)
USB Stick as Swap
When booting from a liveCD, if you you don't want to alter data on hda but swap is needed to increase available memory, a USB stick can be mounted as swap. This can be added early in the startup script if needed, in the initrd. This is very slow but can work for bootstrapping things to the point of being able to create swap on a hard drive.
Hard Drive on hdb as a Bootable CD
This was tested with a Gentoo minimal install CD. A partition was created on hdb using a PC, and formatted with vfat. The partition was set as the cd root in the boot options in linuxboot.cfg (it didn't need to change if the hard drive was fomratted as a single partition. If it needs to change, e.g. to /dev/hdb1 instead of /dev/hdb, the linuxboot.cfg, kernel, and initrd from the CD can be copied to the appropriate locations your hard drive, modified, and launched from there if you want to modify them without burning a new CD.)
This may not work for all live CDs. It didn't work with historical GentooX. If it doesn't work, modification of the startup script is probably required to mount from hdb more generically instead of doing something CD or ISO oriented.
The hard drive can be formatted with multiple partitions, one for the CD files, and swap can also be set up there, so as to have swap available without needing to modify hda or use a USB stick.
Using the Extra 2GB on a 10GB FATX Hard Drive
Not all stock Xbox hard drives are 8GB, some are 10GB. Look up your model number if you're not sure. If you have a spare 10GB stock hard drive sitting around, back it up. Then small native Linux builds can be installed to the 2GB at the end of the drive (remember to have swap), and that area of the drive can also be used for experimentation. Or, install a (small) historical Xbox Linux build like X-DSL to that hard drive as a native install, which should handle the partitioning automatically. (Note that attempting a native install typically wipes out anything after drive E, and also is not compatible with XBPartitioner formatting. It will wipe out any XBPartitioner information, and a format with XBPartitioner after that will break Linux. It is fine though to wipe out the XBPartitioner information by installing native Linux, if you intend to never use XBPartitioner again on that drive)
Using xbox7887's Serial USB Adapter (on the LPC bus)
xbox7887 has created an open source SuperIO board, which connects to the LPC bus on the Xbox (more commonly known as the debug port; the place where you put a modchip.) SuperIO provides various legacy I/O technologies on a single chip, and was used on computer motherboards to provide PS/2, serial, parallel, floppy, and other interfaces. The LPC bus is a PCI device that can have various peripherals connected to it.
SuperIO was used in original Xbox dev kits (the clear ones, not the green ones.) It provided a means of doing Xbox kernel debugging over a serial connection provided by the SuperIO chip via the LPC. This is what these boards are typically used for.
Because LPC is a standard PC technology that is supported by Linux, devices on the LPC bus can be accessed from within Linux. Although xbox7887's board only provides access to one serial port, it would be theoretically possible to build out a board that supported parallel ports, floppy drives, etc... (although floppy drive support has been dropped from Linux)
An important note is that there may be very few Xbox bioses that support this board, at least if the Xbox BIOS is booted first. (not tested with Cromwell flashed to TSOP/modchip). A bios that is known to work is X2 4981.67_256k. Other BIOSes may work but there was some confusion during the testing, so this part could be wrong.
Here are the kernel config options that should needed to support this board on Xbox (not sure what's going on with formatting here.) (should these be merged into the default xbox config options? they might need to be re-tested first)
CONFIG_SERIAL_EARLYCON=y CONFIG_SERIAL_8250=y CONFIG_SERIAL_8250_DEPRECATED_OPTIONS=y # CONFIG_SERIAL_8250_16550A_VARIANTS is not set # CONFIG_SERIAL_8250_FINTEK is not set CONFIG_SERIAL_8250_CONSOLE=y # CONFIG_SERIAL_8250_PCI is not set CONFIG_SERIAL_8250_NR_UARTS=2 CONFIG_SERIAL_8250_RUNTIME_UARTS=2 CONFIG_SERIAL_8250_EXTENDED=y # CONFIG_SERIAL_8250_MANY_PORTS is not set # CONFIG_SERIAL_8250_SHARE_IRQ is not set CONFIG_SERIAL_8250_DETECT_IRQ=y # CONFIG_SERIAL_8250_RSA is not set # CONFIG_SERIAL_8250_DW is not set # CONFIG_SERIAL_8250_RT288X is not set # CONFIG_SERIAL_8250_LPSS is not set # CONFIG_SERIAL_8250_MID is not set CONFIG_SERIAL_CORE=y CONFIG_SERIAL_CORE_CONSOLE=y
Note that this board can be used for debugging the Xbox kernel over serial, if the proper kernel config options are set for that. It can also provide a console over serial, I guess if you wanted to run headless without networking.
Also note that serial over USB is a perfectly workable option if you don't have one of these boards on hand :)
Using USB serial devices
[Needs kernel config options, which once determined should probably be considered for merging into the xbox defconfig]
Using Serial (USB or xbox7887's SuperIO board) for Kernel Debugging
Kernel debugging was accomplished successfully using gdb, over both USB serial and xbox7887's board.
Note that it is often better to do kernel debugging by running your kernel a non-Xbox machine or VM, if the Xbox hardware itself isn't required during development. Text output can often be sufficient to diagnose issues without the overhead of a setup like this.
Since SSH can't connect early enough to debug the kernel on startup (can it be used at all?), a serial connection can be used as soon as it's available. Both the LPC and USB controllers are PCI devices, so they will become active at PCI init.
Here are my notes on doing this in menuconfig, which should probably be translated into actual config options:
Device Drivers -> USB Support Enable serial, Kernel Device Drivers -> Character Devices -> Serial Drivers: 8250/16550 Compatible serial support Support 8250_core.* kernel options (DEPRECATED) - default Console on 8250/16550 and compatible serial port 8250/16550 PCI device support 1 port to register at runtime
Unpacking and Repacking an initramfs/initrd
The initramfs files provided with Xbox Linux can come in multiple formats. To check what format it is, type
file [INITRAMFS_FILENAME]
cramfs
If the result of the file
command is "Linux Compressed ROM File System data", the format is cramfs. It should be little endian.
Extracting cramfs:
fsck.cramfs --extract=[DESTINATION] [TARGET]
The destination will be created if it does not exist.
Compressing cramfs:
mkcramfs [INITRAMFS_CONTENTS_DIRECTORY] [OUTPUT_FILE]