Using atv-bootloader w/ Linux kernel 3.5 & hacking the bootloader for better support

226 views
Skip to first unread message

Joey Korkames

unread,
Jul 24, 2012, 8:55:29 PM7/24/12
to atv-boo...@googlegroups.com
Hi all. I just updated my 4 year old linux install to Ubuntu Precise and the mainline Linux 3.5 kernel*. It works OK (video, wifi, IR, RCA sound, all using built-in drivers) but I'd like to make some tweaks to atv-bootloader to make it even better.


I've normally used my ATV as a low-power headless server, but now I'm trying to interface it with my 2006ish plasma tv.
I'm sticking with the built-in Nouveau drivers which have come a long way. My old TV overscans everything (no setting for 1:1 mode), and the nouveau driver offers no "underscan" (overscan-compensation) for the HDMI output. It does offer some compensation on the TV output, but it was auto-detecting it as a SCART output instead of a component out, which screws up the colors.

Attached is a little patch to the nouveau driver that allows it to autodetect the TV-out as component. It just twiddles one bit in the NVIDIA VBios. You can use the linked kernel headers and just rebuild the nouveau module in a 3.5 source tree from kernel.org without building a whole new kernel. Paraphrasing how to use the patch:

wget <the headers and i386 kernel package .deb urls>
dpkg -i *.deb
<adjust your boot_linux.sh to kexec /boot/vmlinuz-3.5.0-030500-generic, reboot your ATV into the new kernel>

tar -xjf linux-3.5.tar.bz2
cd linux-3.5
patch -Np1 < appletv_nouveau_component_video.patch
cp /boot/config-3.5.0-030500-generic .config
cp /usr/src/linux-headers-3.5.0-030500-generic/Module.symvers ./
make modules_prepare
make M=drivers/gpu/drm/nouveau
mkdir /lib/modules/3.5.0-030500-generic/updates/
cp drivers/gpu/drm/nouveau/nouveau.ko /lib/modules/3.5.0-030500-generic/updates/
depmod -a
modprobe nouveau tv_norm=hd720p #use "modinfo nouveau" to see your options


Long-term, I think changes to the VBIOS is something that the atv-bootloader should do instead of adding a quirk to the linux driver. It should also be copying the VBIOS to the traditional address as well. I read on the atv-bootlaoder blog that Scott has hacked the code to do this. I'm trying to recreate that functionality but am having trouble understanding how to change the E820 map to reserve the VBIOS & VRAM address spaces against use by the kernel.

If I could get that VBIOS copied, I'm thinking of then running "vbetool post" from ramboot-linux ("penbuntu") to initialize the card and then kexec'ing into the ubuntu kernel in pure text mode (vgacon driver). I think this would allow one to change resolution of nouveau's console framebuffer using fbset, currently the console works but the mode cannot be adjusted. X11 mode setting does currently work using the xrandr command, but it seems to be based on scaling, the TV's mode does not actually change. Down the road, POSTing the VBIOS straight from atv-bootlaoder using v86 mode would be even better, but I'm still getting my feet wet with real-mode stuff.
I'm contemplating porting coreboot if I get a spare ATV on the cheap, rending these hacks useless :-). The EEPROM can be reflashed with a $30 Bus Pirate and coreboot has been ported to the Pentium-M, i945, ICH7 combo before.

If you have any questions on the 3.5 install, fire away. I haven't made a tutorial yet but I might if enough are interested. I'd also appreciate any hints on extending the bootloader.
-joey


appletv_nouveau_component_video.patch

Scott D. Davilla

unread,
Jul 25, 2012, 10:34:40 AM7/25/12
to Joey Korkames, atv-boo...@googlegroups.com
>Long-term, I think changes to the VBIOS is something that the
>atv-bootloader should do instead of adding a quirk to the linux
>driver. It should also be copying the VBIOS to the traditional
>address as well. I read on the atv-bootlaoder blog that Scott has
>hacked the code to do this. I'm trying to recreate that
>functionality but am having trouble understanding how to change the
>E820 map to reserve the VBIOS & VRAM address spaces against use by
>the kernel.

the attached files might help :) I attempted this many years ago and
got stalled in real-mode. To init vbios, you have to be in real-mode,
so you have to swap to it, then swap back.


>If I could get that VBIOS copied, I'm thinking of then running
>"vbetool post" from ramboot-linux ("penbuntu") to initialize the
>card and then kexec'ing into the ubuntu kernel in pure text mode
>(vgacon driver). I think this would allow one to change resolution
>of nouveau's console framebuffer using fbset, currently the console
>works but the mode cannot be adjusted. X11 mode setting does
>currently work using the xrandr command, but it seems to be based on
>scaling, the TV's mode does not actually change. Down the road,
>POSTing the VBIOS straight from atv-bootlaoder using v86 mode would
>be even better, but I'm still getting my feet wet with real-mode
>stuff.
>I'm contemplating porting coreboot if I get a spare ATV on the
>cheap, rending these hacks useless :-). The EEPROM can be reflashed
>with a $30 Bus Pirate and coreboot has been ported to the Pentium-M,
>i945, ICH7 combo before.
>
>If you have any questions on the 3.5 install, fire away. I haven't
>made a tutorial yet but I might if enough are interested. I'd also
>appreciate any hints on extending the bootloader.
>-joey
>

I have the complete compiling code for vgabios too. Maybe I should
push that to a dev-tag.
elilo_code.c
linux_code.c

Scott D. Davilla

unread,
Jul 25, 2012, 10:44:29 AM7/25/12
to Joey Korkames, atv-boo...@googlegroups.com
>Long-term, I think changes to the VBIOS is something that the
>atv-bootloader should do instead of adding a quirk to the linux
>driver. It should also be copying the VBIOS to the traditional
>address as well. I read on the atv-bootlaoder blog that Scott has
>hacked the code to do this. I'm trying to recreate that
>functionality but am having trouble understanding how to change the
>E820 map to reserve the VBIOS & VRAM address spaces against use by
>the kernel.

the complete patch https://dl.dropbox.com/u/14341410/vbios.patch

Joey Korkames

unread,
Jul 25, 2012, 5:09:33 PM7/25/12
to atv-boo...@googlegroups.com

On Jul 25, 2012, at 7:34 AM, Scott D. Davilla wrote:

>> Long-term, I think changes to the VBIOS is something that the atv-bootloader should do instead of adding a quirk to the linux driver. It should also be copying the VBIOS to the traditional address as well. I read on the atv-bootlaoder blog that Scott has hacked the code to do this. I'm trying to recreate that functionality but am having trouble understanding how to change the E820 map to reserve the VBIOS & VRAM address spaces against use by the kernel.
>
> the attached files might help :) I attempted this many years ago and got stalled in real-mode. To init vbios, you have to be in real-mode, so you have to swap to it, then swap back.
>

Very nice, I'll fiddle with it and get my kernel hack moved into the bootloader. Then I'll hit the books and see if I can get the return to protected mode working.


> I have the complete compiling code for vgabios too. Maybe I should push that to a dev-tag.

vgabios seems to have gotten further merged into coreboot itself. If you have something that can be put into atv-bootloader, I'd mess with it. But ideally I would get coreboot ported and flashed for "any-OS" compatibility.
http://patchwork.coreboot.org/patch/1111/

Thanks again Scott, long live the OG AppleTV!
-joey
Reply all
Reply to author
Forward
0 new messages