{"id":3177,"date":"2011-02-22T23:53:37","date_gmt":"2011-02-23T07:53:37","guid":{"rendered":"http:\/\/multimedia.cx\/eggs\/?p=3177"},"modified":"2011-04-05T22:12:29","modified_gmt":"2011-04-06T05:12:29","slug":"notes-on-linux-for-dreamcast","status":"publish","type":"post","link":"https:\/\/multimedia.cx\/eggs\/notes-on-linux-for-dreamcast\/","title":{"rendered":"Notes on Linux for Dreamcast"},"content":{"rendered":"<p>I wanted to write down some notes about compiling Linux on Dreamcast (which I have yet to follow through to success). But before I do, allow me to follow up on <a href=\"http:\/\/multimedia.cx\/eggs\/decoding-vp8-on-a-sega-dreamcast\/\">my last post where I got Google&#8217;s libvpx library decoding VP8 video on the DC<\/a>. Remember when I said the graphics hardware could only process variations of RGB color formats? I was mistaken. Reading over some old documentation, I noticed that the DC&#8217;s PowerVR hardware can also handle packed YUV textures (UYVY, specifically):<\/p>\n<p><center><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2011\/02\/sega-dreamcast-vp8-color.jpg\" alt=\"\" title=\"VP8 playing in proper color on the Sega Dreamcast\" width=\"400\" height=\"180\" class=\"aligncenter size-full wp-image-3178\" srcset=\"https:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2011\/02\/sega-dreamcast-vp8-color.jpg 400w, https:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2011\/02\/sega-dreamcast-vp8-color-300x135.jpg 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><br \/>\n<\/center><\/p>\n<p>The video looks pretty sharp in the small photo. Up close, less so, due to the low resolution and high quantization of the test vector combined with the naive chroma upscaling. For the curious, the grey box surrounding the image highlights the 256-square texture that the video frame gets plotted on. Texture dimensions have to be powers of 2.<\/p>\n<p><strong>Notes on Linux for Dreamcast<\/strong><br \/>\nI&#8217;ve <a href=\"http:\/\/multimedia.cx\/eggs\/dreamcast-operating-systems\/\">occasionally dabbled<\/a> with <a href=\"http:\/\/multimedia.cx\/eggs\/further-dreamcast-hacking\/\">Linux on my Dreamcast<\/a>. There&#8217;s an ancient (circa 2001) distro based around a build of kernel 2.4.5 out there. But I wanted to try to get something more current compiled. Thus far, I have figured out how to cross compile kernels pretty handily but have been unsuccessful in making them run.<\/p>\n<p>Here are notes are the compilation portion:<br \/>\n<!--more--><\/p>\n<ul>\n<li>kernel.org provides a very useful <a href=\"http:\/\/www.kernel.org\/pub\/tools\/crosstool\/\">set of cross compiling toolchains<\/a><\/li>\n<li>get the gcc 4.5.1 cross toolchain for SH-4 (the gcc 4.3.3 one won&#8217;t work because the binutils is too old; it will fail to assemble certain instructions <a href=\"http:\/\/multimedia.cx\/eggs\/further-dreamcast-hacking\/\">as described in this post<\/a>)<\/li>\n<li>working off of Linux kernel 2.6.37, edit the top-level Makefile; find the ARCH and CROSS_COMPILE variables and set appropriately:\n<pre>\r\nARCH            ?= sh\r\nCROSS_COMPILE   ?= \/path\/to\/gcc-4.5.1-nolibc\/sh4-linux\/bin\/sh4-linux-\r\n<\/pre>\n<\/li>\n<li><code>$ make dreamcast_defconfig<\/code><\/li>\n<li><code>$ make menuconfig<\/code> &#8230; if any changes to the default configuration are desired<\/li>\n<li>manually edit arch\/sh\/Makefile, changing:\n<pre>\r\ncflags-$(CONFIG_CPU_SH4)                := $(call cc-option,-m4,) \\\r\n        $(call cc-option,-mno-implicit-fp,-m4-nofpu)\r\n<\/pre>\n<p>to:<\/p>\n<pre>\r\ncflags-$(CONFIG_CPU_SH4)                := $(call cc-option,-m4,) \\\r\n        $(call cc-option,-mno-implicit-fp)\r\n<\/pre>\n<p>I.e., remove the <code>'-m4-nofpu'<\/code> option. According to the gcc man page, this will &#8220;Generate code for the SH4 without a floating-point unit.&#8221; Why this is a default is a mystery since the DC&#8217;s SH-4 has an FPU and compilation fails when enabling this option.\n<\/li>\n<li>On that note, I was always under the impression that the DC sported an SH-4 CPU with the model number SH7750. According to <a href=\"http:\/\/www.linux-sh.org\/shwiki\/Dreamcast\">this LinuxSH wiki page<\/a> as well as the Linux kernel help, it actually has an SH7091 variant. <a href=\"http:\/\/www.chipdb.org\/img-hitachi-sh-4-_sega-dreamcast-cpu_-6346.htm\">This photo of the physical DC hardware corroborates<\/a> the model number.<\/li>\n<li><code>$ make<\/code> &#8230; to build a Linux kernel for the Sega Dreamcast<\/li>\n<\/ul>\n<p><strong>Running<\/strong><br \/>\nSo I can compile the kernel but running the kernel (the resulting vmlinux ELF file) gives me trouble. The default kernel ELF file reports an entry point of 0x8c002000. Attempting to upload this through the serial uploading facility I have available to me triggers a system reset almost immediately, probably because that&#8217;s the same place that the bootloader calls home. I have attempted to alter the starting address via &#8216;make menuconfig&#8217; -> System type -> Memory management options -> Physical memory start address. This allows the upload to complete but it still does not run. It&#8217;s worth noting that the 2.4.5 vmlinux file from the old distribution can be executed when uploaded through the serial loader, and it begins at 0x8c210000.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Trying to get a modern Linux kernel compiled for the Sega Dreamcast<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[221,219],"tags":[],"class_list":["post-3177","post","type-post","status-publish","format-standard","hentry","category-sega-dreamcast","category-vp8"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/3177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/comments?post=3177"}],"version-history":[{"count":9,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/3177\/revisions"}],"predecessor-version":[{"id":3244,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/3177\/revisions\/3244"}],"wp:attachment":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/media?parent=3177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/categories?post=3177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/tags?post=3177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}