#PowerBlocks (OS for Wii)

1 messages · Page 1 of 1 (latest)

signal marlin
#

I have been working on OS/Library/SDK type project for the Wii as a replacement to libogc to support my Minecraft clone for the Wii ever since it became risky to use libogc due to stolen code.

I will post things as they come as well as a Github repository once the first release is done. I am excited to put work here to stay motivated on the tedious but required Sisyphean task this will be.

It is to be built on FreeRTOS and provides video, graphics, controllers, and audio. So its really more or less a FreeRTOS port and a lot of work to support all of the hardware. With outside of the core system, the IO provided as "blocks."

So far we have a Hello World working on actual hardware. This still uses devkitpro's compilers and libc so now I will be moving it over to Clang for future support for paired single SIMD.

signal marlin
#

I now have a build system build around clang. There are now no dependencies on devkitpro or libogc.

signal marlin
#

First pre-release of PowerBlocks SDK published on github

signal marlin
#

Currently working on finishing the visual debug console, the heap, and interrupts.

This will be pushed once those are complete.

signal marlin
#

Upcoming releases should bring communication with starlet, that will be big.
As well as a FreeRTOS port to start carying some of the scheduling loads.

#

Once there is communication with starlet the video interface will be able to get the correct video mode on its own. It will also open up communications to wiimotes, wifi, and SD card for filesystem.

#

Will still be a second before we see proper 3d graphics and audio though. Those come later.

signal marlin
#

Added syscalls. Not much time to work on it latly. Got sick and busy with work. But good progress on the FreeRTOS implementation in the background. Not too much has to be done there.

signal marlin
signal marlin
#

This is on actuall hardware ofc!

low kernel
#

it's cool

#

but i dont know how to use it bruh

signal marlin
#

Ive pushed the GX implementation and updated documentation to the github.
No new release though till GX is in a more complete state.

signal marlin
#

A half version. 0.0.4 is on github as a docker package

#

glad to say it works well

#

I am not the docker pro. this was setup for me. Very happy its working.

tight spade
#

woah, I didn't know you had a thread for PowerBlocks here
I've been tracking the progress on GitHub for a while - been hoping to move the few homebrew apps I do maintain, over from libogc, for a while now
I will definitely keep an eye on this thread too, looks like some awesome updates here already :P

signal marlin
signal marlin
ashen cedar
#

I love it

signal marlin
ashen cedar
#

Does this also work on a vWii?

signal marlin
ashen cedar
signal marlin
#

Thank you. Let me know how far it gets!

tight spade
#

I do actually have a fully functional Wii U, I could try it

#

I also have 3 Wiis with varying hardware details

  • Wii #1
    • RVL-CPU-60
    • patched boot1
    • patched DVD drive
  • Wii #2
    • RVL-CPU-40
    • patched boot1
    • patched DVD drive
    • DVD drive removed
    • WiFi Card removed
    • Bluetooth card removed
    • Fan removed
  • Wii #3
    • RVL-CPU-01
    • Unpatched boot1 (BootMii as boot2 installed)
    • Unpatched DVD drive
#

I'm especially interested to see how it works on Wii #2

#

I also am friends with someone who has a GameCube and a way to load homebrew on it, so if you ever do a GameCube port, I could have him test it

signal marlin
#

Ooo wow, much to be found out.
The GameCube will be interesting. I will definitly need gamecube support at some point, but a few things here and there will need to change.

#

Gamecube will need a seperate linker script, though that already needs to be revised heavily.

Detecting video modes will need to work a bit differently.

And im not sure what there is in terms of processer interface and graphics. Those should not be too big of an issue I hope.

tight spade
#

oh yeah I also have a USB Gecko, so if you ever need to get serial logs on real hardware, just ask :P

#

forgot to mention that

signal marlin
#

After much work there is now the ground work for wiimote support. I ended up writing my own Bluetooth stack since I could not find a Bluetooth stack that would work with a compatible licensing model. Same case for the wiimotes themselves. In its current state devices can connect through discovery, load drivers, and the wiimotes do your standard stuff.

There needs to be more testing on hardware, IR and extension support on the wiimotes, and allowing wiimotes to disconnect gracefully and reconnect themselves.

#

I have pushed the half done implementation since I have not pushed it out to github in a while. I will be working to fill in the remaining wiimote support over the next few weeks for the next version of PowerBlocks. The wiimote support is planned to be pretty complete, just not fully tested. Definitly regarding the extensions.

low kernel
#

cool!

signal marlin
#

Wiimotes and the bluetooth stack now work as intended on real hardware. IR and motion controls are supported too.
It was a long and treaterouse jurney to get the bluetooth stack running well. A long list a bugs, and ive probably only seen half of it.

#

What remains until wiimotes are done:

  • Add extensions
  • Test 4 wiimotes on real hardware.
  • Faster and more clean connection on startup.

What remains until the next update of PowerBlocks:

  • Wiimote Support
  • SDIO Support
signal marlin
#

Documentation page for PowerBlocks has been created.
It will be expaneded in the future with an API reference and more into each example.
Let me know what you think. I feel this is my first time really getting deep into documentation, so hopefully its not too rough around the edges.
https://rainbain.github.io/PowerBlocks-Docs/

ruby ginkgo
#

very nice, original 🙂

tight spade
#

Btw, what hardware does PowerBlocks not fully initialize that trips up Dolphin?
I saw this note in the docs:

Currently, the Homebrew Channel is required to launch applications on emulator. PowerBlocks currently does not fully initialize the hardware and needs a launcher in front of it to do this.
I've built code that runs fully bare-metal with no SDK that works fine across Dolphin as well as real hardware (both GCN and Wii), so i find it intriguing that PowerBlocks doesn't work ootb in Dolphin

#

The only thing I can think of that might trip Dolphin up is the addresses if:

  • LMAs != VMAs (I have a PR open to fix that)
  • entrypoint is a physical address instead of virtual
#

Either of those would make it fail either very early or immediately upon launching the ELF/DOL

#

heh, it looks like it relies on the stack pointer being valid immediately?

#

ooh no no no
it calls into what would appear to be C code immediately
no wonder it blows up 😅

#

this would also blow up on real hardware if you were loaded by IOS directly (e.g. as a channel/game) as opposed to via HBC, since it literally resets Broadway into your code
HBC does not do this, so it leaves the stack "valid" (albeit probably not pointing somewhere desirable, it may clobber existing memory)

#

checklist of things that you really should do in asm before you call anything C:

  • switch to real mode (MMU off), which you may or may not already be in depending on how you were started
  • set up BATs (or real paging if you're feeling fancy) how you want them
  • switch address translation (back) on
  • set up stack
  • enable and flush & invalidate the caches if you want them
  • clear BSS
  • set up SDA/TLS pointers if you're using EABI stuff

with all of the above, you can ensure you have at least a consistent memory and CPU state before doing anything else, rather than assuming that it might by chance already be vaguely sane (hint: in many cases, it very much isn't)

#

I have a working impl of all of the above that I made for #1421414518034006066 that I could provide if you want it
it's GPL'd over there, but if you want it, since its all my own code, I'd be happy to relicense it under MIT for this project, just ask :)

signal marlin
# tight spade I have a working impl of all of the above that I made for <#1421414518034006066>...

Thank you for your input on this. Its is definitely one of those things I had been putting off because I had not quite put the puzzle pieces together on how to do it.

I would be happy to use your initialization code relicensed with what you would like to be credited. I am happy to accept any thing of the matter, (definitely for something like this since it will help lower the room for error on something very important.)

Im also having the same issue on the return to wii menu function and how exactly that works. If you would happen to know where there is documentation for this system that would be extreamly helpful. My wii will thank you too for less hard restarts.

tight spade
#

Sure thing, I'll try to integrate my code when I get a spare minute then

as for returning to the Wii Menu, that usually involves sending an IOS IPC request to launch the title - there's no easy shortcut (unlike return-to-loader)
returning to the homebrew loader, on the other hand, is different - HBC (and most loaders) leave a small bit of executable code at 0x00001800 in MEM1, identified by ASCII 'STUBHAXX' at 0x1804 and 0x1808
usually the recommended method for return-to-loader is:

  • check for STUBHAXX ID
  • if found, execute the stub
  • otherwise, whatever fallback like load sysmenu, hard-reset, hang, etc
signal marlin
#

Ooo ok let me add the return to loader function real quick! ❤️

tight spade
#

Is there any problem with using preprocessable assembly files (.S) vs unpreprocessable ones (.s)? PowerBlocks currently seems to use only unpreprocessable assembly files (.s)
My existing code use some preprocessor definitions for MSR and HID0 bits
I could precompute it to drop the dependency easily but then it'd just be some magic values :P

#

so Dolphin still seems to get caught up somewhere

#

it no longer crashes, and actually seems to get relatively far into the code

#

but it ends up getting stuck somewhere, it's caught in what would appear to be a loop

#

works fine on real hardware though so I suspect this is just some other Dolphin issue

tight spade
# tight spade Is there any problem with using preprocessable assembly files (.S) vs unpreproce...

https://github.com/rainbain/PowerBlocks/pull/3
I'm going to assume that this is fine (it's not mentioned in the docs that I could see), so I left it as preprocessable, since I need to get going and wanted to get that PR out before I left
Feel free to let me know if that's a problem

GitHub

These were adapted a bit from my code in NPLL. Allows Dolphin to get further into initialization (though seemingly still not fully successful), and causes no regressions on real hardware.

signal marlin
#

Sorry for the late response. Feel free to ping me for a quicker reply. .S is indeed fine. I dont quite know why I was using .s actully.
I will investigate where dolphin is hanging up real quick.

#

I see. seems good. i will go ahead and merge it and then investigate further. indeed seems to be at a weird point.

#

Im ceriouse if this will clear up 2 of the other bugs too. It will also help out an issue someone else was having. So exited to go ahead and resolve any remaining later issues.

#

Hm ok its a bit weird. I will need to look more before I really know.

signal marlin
#

Looks like its not starting up IOS as it should. I will continue working on fixing that tomorrow. Also found another bug while going though that. The main app thread has a stack of 16 MB. I will need to fix that too.

signal marlin
#

I have fixed the issue with it not working on dolphin.

So after messing with IOS not responding. I noticed for some reason HLE was sending my heart emojis.
Turns out dolphin was launching the elf as a GameCube executable, not a Wii one, and thus IOS was quite unresponsive.

Dolphin looks for code touching HID4 for, or more specifically, something masked with 0xfc1fffff equating to 0x7c13fba6. So I just added:

.long 0x7c13fba6

And it works now.

signal marlin
#

Now that I have gotten it working and ready. I can finally say thank you so much for the initialization code. This will help with many things. I am not very experienced with PowerPC so I really do appreciate the help.

tight spade
#

no problem

#

btw, iirc the thing Dolphin is looking for is for the code to be setting up HID4

#

that's illegal on Gekko (so no GameCube software would do it), but something that most official and homebrew Wii applications would do

#

hence why they check for it

#

I could double check again shortly, but I'm 90% sure that's what it's checking for, since I had to deal with this exact problem in the past

signal marlin
#

I belive so. This is what I was referencing to make that fix.

tight spade
#

ah, yup

#

so the "real" fix would be to actually set up HID4
notably you may want to flip the SBE bit (bit 25 if you use sane numbering, or bit 6 if you use IBM's crappy numbering) on the Wii

#

it gives you access to 4 more pairs of BATs

#

so you can map more fine-grained memory regions if you really wanted

#

there's also some bits in HID4 that the PPC750CL manual suggests you need to flip in order to use to use Paired Singles, though that's actually not the case on Broadway; it's one of the few things they actually changed from the 750CL

signal marlin
#

Release of PowerBlocks 0.6.0 is up including the docker package.
This version now supports the following additions:

  • Wiimote Support

    • Numchuck
  • Classic Controller

  • SDIO Support

    • ChanN FATFS port included with some POSIX wrappers (incomplete.)
  • Updated start.S (By TechFlash), so you no longer need to use launcher.

  • General bug Fixes

https://github.com/rainbain/PowerBlocks/releases/tag/0.0.6-pre

GitHub

Sixth pre-release of PowerBlocks SDK.
Docker package also provided under packages.
Change Log:
Added Wiimote Support
Added File System Support