* SubmitSystemData.c: Initial "Submit System Data" function.
This will allow users to submit anonymized system information, including
a masked-off serial number and MLC manufacturer, so we can try to figure
out which serial numbers correspond to which MLC manufacturer, among
other things.
This screen has been implemented using a separate .c file instead of
adding it somewhere in menu.c. I'll split other screens into separate
.c files later.
imports.ld: Added IOSC_GenerateHash() from Gary.
TODO: gethostbyname() for DNS lookup.
* SubmitSystemData.c: Use an array of strings for the description.
Code size difference:
text data bss dec hex filename
27208 0 9696 36904 9028 ios_mcp.elf [before]
26992 0 9696 36688 8f50 ios_mcp.elf [after]
-216 0 0 -216 -d8 Difference
* SubmitSystemData.c: Add some more stuff to the hash.
* SubmitSystemData.c: Submit the system data to wiiu.gerbilsoft.com.
Using http instead of https due to the complexity of using https within
the recovery_menu environment, and Wii U doesn't support TLS 1.2 natively.
TODO:
- Implement gethostbyname().
- Check the HTTP response code.
* StartWupserver.c: Split option_StartWupserver() out of menu.c.
* menu.c: Split netconf init from StartWupserver and SubmitSystemData into initNetconf().
Takes an 'index' (Y position) parameter and returns a new Y position,
or 0 if an error occurred.
Removed the "+ 4" from the Wupserver version. Added "+ 4" to the
other messages in Wupserver.
* SystemInformation.c: Split out option_SystemInformation() into a separate file.
* DebugSystemRegion.c: Split out option_DebugSystemRegion() into a separate file.
* Makefile: Add -Werror=implicit-function-declaration.
An implicit function declaration almost always means a header is missing,
and will likely result in a link error later on.
* menu.c: Add a GitHub repository link to the bottom of the main menu.
Well, it's a link in that it's blue and underlined, but you can't exactly
click it here...
* SubmitSystemData.c: Set ddr3Size and ddr3Speed.
* SubmitSystemData.c: Look up the domain name instead of using a hard-coded IP address.
netdb.c: gethostbyname() implementation by @GaryOderNichts.
* SubmitSystemData.c: Parse the HTTP response to show actual successes or failures.
Only the response code is parsed and the response message is shown.
TODO: Show the actual message from the server.
* gfx.h: Add a new attribute GfxPrintFlag_Underline.
This prints an underscore character on top of every character that's
printed, resulting in an underline effect.
Removed the manual underlining code elsewhere.
Code size difference:
text data bss dec hex filename
29068 0 10400 39468 9a2c ios_mcp.elf [before]
28996 0 10400 39396 99e4 ios_mcp.elf [after]
-72 0 0 -72 -48 Difference
* SystemInformation.c: Display the BSP revision.
This uses bspGetHardwareVersion(). [imports.ld value provided by Gary]
The BSP version is roughly equivalent to the Console Type value found
on Wii and GameCube, though libogc doesn't set it properly...
Most retail systems will be 0x25100028. (A5X Cafe)
Rearranged System Information to use three columns for the main data.
MLC information is still shown below the main data.
* SubmitSystemData: Add the BSP revision to the submitted data.
* Use gfx_print() instead of gfx_printf() when formatting isn't needed.
* PairDRC.c: Split "Pair DRC" into a separate file.
* SubmitSystemData.c: Get the HTTP message body and print it on screen.
Only the HTTP response code and message body will be displayed in either
green or red. The message printed afterwards will be white.
NOTE: We need to use a fairly large buffer for the HTTP response because
Cloudflare adds a ton of headers. For example, an HTTP/1.1 200 OK response
with the following message:
"System ID is #1. This system was already submitted."
has a 648-byte HTTP response, mostly due to Cloudflare's "Report-To"
header.
To be on the safe side, we'll allow use of the entire buffer allocated
for OTP, SEEPROM, and the POST data struct, since none of those are
needed after sending the HTTP request header. (2,048 bytes)
* gfx_print(): Add support for newlines. ('\n')
If a newline is encountered in a string, the x position will be reset to
the original x position specified by the caller, and the y position will
be advanced by one line. The final y position is returned by the function.
This allows us to consolidate many individual calls to gfx_print() and/or
gfx_printf() into a single call.
Code size differences:
text data bss dec hex filename
29332 0 10400 39732 9b34 ios_mcp.elf [before]
29364 0 10400 39764 9b54 ios_mcp.elf [add '\n' to gfx_print]
29220 0 10400 39620 9ac4 ios_mcp.elf [update SubmitSystemData.c]
-112 0 0 -112 -70 Difference
Simply updating SubmitSystemData.c to take advantage of the newline
support wiped out the code size increase from adding it.
NOTE: The newline support currently only supports adding a single line,
not CHAR_SIZE_DRC_Y + 4. +4 is commonly used for menus, which can't take
advantage of the newline support anyway.
* SystemInformation.c: Make use of newlines for part of the MLC information display.
New flag GfxPrintFlag_NewlinePlus4 that adds CHAR_SIZE_DRC_Y + 4 for
newlines instead of just CHAR_SIZE_DRC_Y.
Code size difference:
text data bss dec hex filename
29220 0 10400 39620 9ac4 ios_mcp.elf [before]
29148 0 10400 39548 9a7c ios_mcp.elf [after]
-72 0 0 -72 -48 Difference
* DebugSystemRegion.c: Some minor optimizations.
Code size difference:
text data bss dec hex filename
29148 0 10400 39548 9a7c ios_mcp.elf [before]
29124 0 10400 39524 9a64 ios_mcp.elf [after]
-24 0 0 -24 -18 Difference
* SubmitSystemData.c: Make dataBuffer uint8_t*; use it instead of otp for the recv buffer.
This reduces confusion, even though otp and dataBuffer are technically
the same buffer.
Fix a one-byte overflow when ensuring dataBuffer is NULL-terminated.
* initNetconf(): Use a pointer for index and return an actual error code.
* Makefile: Add -Werror=int-conversion.
* SubmitSystemData.c: Submit ddr3Vendor and MLC CID.
Using empty space in the POST data structure instead of shuffling it
around to preserve compatibility (for now).
* SystemInformation.c: Display BSP revision name and DDR3 information.
* SystemInformation.c: Fix text alignment of Column 2's data.
* SubmitSystemData.c: Verify the send() return values.
* SubmitSystemData.c: Use RSA+AES encryption when submitting data.
Since we can't use https, use the next best thing.
NOTE: mini-gmp puts us very close to the 40K .text limit:
text data bss dec hex filename
39612 0 10400 50012 c35c ios_mcp.elf
TODO: Investigate using Thumb mode later.
* imports.h: Clarify that these IOSC_GenerateHash() flags are for SHA-256.
Also add SHA-1 flags.
* SubmitSystemData.c: Send MS, CA, NG, and NG key IDs, and device certificate.
Device certificate is recommended in order to really verify the system
information is authentic. It will be checked against MS, CA, NG, and
NG key IDs.
Rearrange the POST data struct to work better.
Remove MLC name1, since the device name is part of the CID.
NOTE: This requires a server-side change.
* SubmitSystemData.c: Make the submitted info screen match WiiUIdent.
* SubmitSystemData.c: Handle newlines in the server's response message.
* menu.c: New menu drawing function drawMenu().
This function takes an array of Menu objects, which consist of a
description and a 64-bit parameter. It returns the selected index.
The parameter can be either a callback or a title ID. The callback
is a 32-bit pointer, so this does waste a bit of space, but I think
consolidating the menu code is worth it.
* fixup! menu.c: New menu drawing function drawMenu().
Cache the 'y' value; otherwise, selecting another index will go offscreen.
* option_SetColdbootTitle(): Use drawMenu().
drawMenu(): Add flags:
- MenuFlag_ShowTID: Append the title ID in hi-lo format.
- MenuFlag_NoClearScreen: Don't clear the screen. Useful if other stuff
is displayed on the menu.
* drawMenu(): Optimize drawing by only redrawing changed items.
Split out the individual menu item drawing code into a separate function,
drawMenuItem().
The menu no longer flickers when selecting items.
FIXME: Set Coldboot Title's messages at the bottom aren't cleared
properly.
* option_SetColdbootTitle(): Clear the background behind the status text.
FIXME: Add a background color option to gfx_printf()?
* option_SetColdbootTitle(): Also clear behind the titles at the top.
* option_EditParental(): Use drawMenu().
* drawMenu(): Add a 'selected' parameter.
This lets us keep the same item selected when entering a submenu,
or even when applying an option and staying in the same submenu.
* option_FixRegionBrick(): Initial "Fix Region Brick" function.
Currently shows the system region code and installed Wii U Menu.
TODO:
- If they don't match, offer to fix it.
- Also verify that gameRegion contains productArea.
* option_FixRegionBrick(): Display game region and show errors.
Checking that both productArea and gameRegion match Wii U Menu.
For gameRegion, the Wii U Menu's region bit needs to be set, but it
doesn't need to be exclusive; however, the repair functionality will
make it exclusive.
* option_FixRegionBrick(): Prompt the user if they want to fix the region brick.
* option_FixRegionBrick(): Actually set the new region code.
Worked on the first try. 😄
mcp_misc.h: Implemented MCP_SetSysProdSettings().
* waitButtonInput(): Clear the message area before printing the text.
Otherwise, it might end up corrupted after fixing a region brick.
* waitButtonInput(): Blank out the entire screen width.
Otherwise, "POWER: Choose" will remain onscreen.
* option_FixRegionBrick(): Detect multiple install Wii U Menus and fail if found.
* gfx.h: Add the printf format attribute to gfx_printf().
menu.c: Fix gfx_printf() formats.
* menu.c: Use gfx_print() for constant strings with no format specifiers.
This slightly improves performance because gfx_printf() prints to an
internal buffer before calling gfx_print(), so calling gfx_print()
bypasses that step.
Removed the "Waiting for network connection... 5s" string by making it
use a printf() specifier. This adds some runtime overhead, but it
eliminates that string from the binary.
Code size difference:
text data bss dec hex filename
23068 0 8224 31292 7a3c ios_mcp.elf [before]
23032 0 8224 31256 7a18 ios_mcp.elf [after]
-36 0 0 -36 -24 Difference
* option_InstallWUP(): Print the title ID in hi-lo format.
* option_FixRegionBrick(): Minor code optimization.
Code size difference:
text data bss dec hex filename
23040 0 8224 31264 7a20 ios_mcp.elf [before]
23016 0 8224 31240 7a08 ios_mcp.elf [after]
-24 0 0 -24 -18 Difference
* README.md: Mention "Fix Region Brick".
* option_FixRegionBrick(): Pass 0 as 'selected' instead of the newly-declared 'selected'.
The newly-declared 'selected' will be uninitialized at this point.
* s/MCP_SetTargetUsb/MCP_InstallSetTargetUsb/
MCP_InstallSetTargetUsb() is the name listed on WiiUBrew:
https://wiiubrew.org/wiki//dev/mcp
* gfx_printf(): Replace 'alignRight' with a flags bitfield.
GfxPrintFlag_AlignRight does what alignRight did.
GfxPrintFlag_ClearBG clears the background before printing.
(TODO: Do this in gfx_draw_char() instead of calling
gfx_draw_rect_filled().)
menu.c: Use GfxPrintFlag_ClearBG in some places instead of manually
clearing the background.
Code size difference:
text data bss dec hex filename
23016 0 8224 31240 7a08 ios_mcp.elf [before]
22928 0 8224 31152 79b0 ios_mcp.elf [after]
-88 0 0 -88 -58 Difference
* Move ARRAY_SIZE() from menu.c to utils.h.
* option_FixRegionBrick(): A few string simplifications.
- Use the same string for system and game region errors, with "%s" to
differentiate them.
- Change the menu item from "Set Region to %s" to "Fix Region".
"Set Region to %s" is redundant, since the question already says
what region it will be changed to.
* option_EditParental(): A few more GfxPrintFlag_ClearBG uses.
* option_InstallWUP(): Fix error message for MCP_InstallSetTargetUsb().
* option_FixRegionBrick(): Combine two sets of if/else into one.
* menu.c: "Fix Region Brick" -> "Debug System Region"
* gfx.c: Optimize drawing routines.
- Use pointer arithmetic instead of calling gfx_draw_pixel() for each
pixel.
- gfx_draw_rect_filled(): Draw each rectangle inline, and use 1.5x scaling
for the TV framebuffer.
- gfx_draw_char(): Likewise. A makeshift scaling algorithm is being used
for now. The font will be replaced with two fonts next in order to
eliminate scaling artifacts:
- Terminus 8x16 bold for the gamepad
- Terminus 12x24 bold for the TV
* menu.c: Factor out top/bottom bar drawing.
Code size difference:
text data bss dec hex filename
17624 0 8224 25848 64f8 ios_mcp.elf [before]
16948 0 8224 25172 6254 ios_mcp.elf [after]
-676 0 0 -676 -2a4 Difference
* Replace the font with Termins 8x16 bold (DRC) and 12x24 bold (TV).
The TV font is drawn without scaling, so it's much more readable than
the previous 8x8 font drawn with nearest-neighbor scaling.
NOTE: Since we're storing two fonts now, the font size has increased
significantly. I should compress it somehow, maybe with MiniLZO.
Code size difference:
text data bss dec hex filename
16948 0 8224 25172 6254 ios_mcp.elf [before]
22368 0 8224 30592 7780 ios_mcp.elf [after]
+5420 0 0 +5420 +152c Difference
* Compress the Terminus font using lzo1x.
This requires adding MiniLZO to decompress it, but the resulting size
is still significantly smaller than uncompressed.
Code size difference:
text data bss dec hex filename
22368 0 8224 30592 7780 ios_mcp.elf [before]
19232 0 8224 27456 6b40 ios_mcp.elf [after]
-3136 0 0 -3136 0 Difference
This effectively means the increase from switching to Terminus is:
5420 - 3136 = 2284 bytes
* option_SetColdbootTitle(): Print the current title IDs in hi/lo notation instead of as a single 64-bit hex value.
I think hi/lo is easier to read than a single 64-bit hex value.
* Remove some LZO debug code.
I was having weird crashes when testing LZO earlier. It turns out
that the "lzopack" example tool adds its own custom header, which
we don't want here. "precomp2" doesn't add a header, so I used that
for the Terminus font data.
Code size difference:
text data bss dec hex filename
19232 0 8224 27456 6b40 ios_mcp.elf [before]
19196 0 8224 27420 6b1c ios_mcp.elf [after]
-36 0 0 -36 -24 Difference
* Add a "System Information" screen.
Currently shows model, serial, keyset, boardType, sataDevice,
consoleType, and productArea.
TODO: gameRegion is 0 in all the SEEPROMs I've checked.
Maybe map in the MCP_GetSysProdSettings() function?
* Some minor optimizations.
- gfx.c: Use IOS_HeapAlloc() instead of IOS_HeapAllocAligned().
We don't need an aligned allocation for lzo1x decompression.
- option_SetColdbootTitle(): Factor out the setDefaultTitleId() call.
- option_StartWupserver(): Use %u instead of %d for the IPv4 octets.
Code size difference:
text data bss dec hex filename
20276 0 8224 28500 6f54 ios_mcp.elf [before]
20192 0 8224 28416 6f00 ios_mcp.elf [after]
-84 0 0 -84 -54 Difference
* option_SetColdbootTitle(): Allow setting SCT, DEVMENU, or Kiosk Menu if the system is using the Debug keyset.
Fixes#9: Coldboot Title: Add DEVMENU, System Config Tool, Kiosk Menu
* option_SystemInformation(): productArea in SEEPROM is wrong.
On one of my CAT-Is, it's showing 2 (EUR), but the system is set to
1 (USA).
Remove it for now.
* isSystemUsingDebugKeyset(): Check for != 0x10 instead of == 0x08.
This will include Factory and Invalid. I doubt we'll ever find any
systems set to Factory, and Invalid wouldn't boot.
* network_parse_config_value(): Use CHAR_SIZE_DRC_Y.
* option_SystemInformation(): Show the Wii U Menu version.
NOTE: On my CAT-I, all three region-specific version titles are
present, and they all have "11.0.0". I'll need to check the sys_prod.xml
region data later to find the actual region codes.
* option_SystemInformation(): Show sataDevice and consoleType names in parentheses.
* option_SystemInformation(): Show "Kiosk" instead of "CAT-I".
I believe CAT-SES has the same consoleType value.
* option_SystemInformation(): Show the manufacturing date if it's available.
Some development units have this field completely blank, so it won't be
shown if it's all zeroes.
* option_SystemInformation(): Use uint32_t for the version magic.
Code size difference:
text data bss dec hex filename
20996 0 8224 29220 7224 ios_mcp.elf [before]
20988 0 8224 29212 721c ios_mcp.elf [after]
-8 0 0 -8 -8 Difference
* option_SystemInformation(): Show productArea and gameRegion.
productArea is a single region; gameRegion can be multiple regions.
It's normally only a single region on retail, though.
mcp_misc.c: Implement MCP_GetSysProdSettings().
* option_SystemInformation(): Use productArea to determine the version.bin title to use.
This might break if productArea is set to a region that doesn't match
the version.bin title that's installed, but that's an unlikely occurrence.
* option_SystemInformation(): Add a space between the version number and the region code.
Wii U System Settings does this. 3DS does not, but 3DS has an extra
"NVer" value that has the region code appended to it.
* Fixes requested in PR #10.
- Remove an obsolete TODO: the Terminus font is LZO1X compressed.
- Use "uint32_t* p" format instead of "uint32_t *p".
- Remove some debug LZO variables that I forgot to remove earlier.
- gfx.c: Add some more DC_INIT checks.
- gfx.c: Explicitly specify 1.5f instead of 1.5 to use 32-bit float.
Interestingly, the 32-bit float change reduced the code size a bit:
text data bss dec hex filename
21424 0 8224 29648 73d0 ios_mcp.elf [before]
20752 0 8224 28976 7130 ios_mcp.elf [after]
-672 0 0 -672 -2a0 Difference
* option_EditParental(): Missed some text height changes.
* menuThread(): No need to flush FSA if gfx_init_font() fails.
* Use #pragma once instead of #ifndef __header__.