diff --git a/fusee/fusee-secondary/src/nxboot.c b/fusee/fusee-secondary/src/nxboot.c index b333157c0..88b3bfc08 100644 --- a/fusee/fusee-secondary/src/nxboot.c +++ b/fusee/fusee-secondary/src/nxboot.c @@ -936,7 +936,7 @@ uint32_t nxboot_main(void) { size_t sd_meso_size = get_file_size("atmosphere/mesosphere.bin"); if (sd_meso_size != 0) { if (sd_meso_size > PACKAGE2_SIZE_MAX) { - fatal_error("Error: atmosphere/kernel.bin is too large!\n"); + fatal_error("Error: atmosphere/mesosphere.bin is too large!\n"); } mesosphere = malloc(sd_meso_size); if (mesosphere == NULL) { diff --git a/fusee/fusee-secondary/src/package2.c b/fusee/fusee-secondary/src/package2.c index 00417b720..f4948ae1a 100644 --- a/fusee/fusee-secondary/src/package2.c +++ b/fusee/fusee-secondary/src/package2.c @@ -96,20 +96,27 @@ void package2_rebuild_and_copy(package2_header_t *package2, uint32_t target_firm } /* Use mesosphere instead of Nintendo's kernel when present. */ - if (mesosphere != NULL && mesosphere_size != 0) { + const bool is_mesosphere = mesosphere != NULL && mesosphere_size != 0; + if (is_mesosphere) { kernel = mesosphere; kernel_size = mesosphere_size; /* Patch mesosphere to use our rebuilt ini. */ *(volatile uint64_t *)((uintptr_t)mesosphere + 8) = (uint64_t)mesosphere_size; + /* Place the kernel section at the correct location. */ + package2->metadata.section_offsets[PACKAGE2_SECTION_KERNEL] = 0x60000; + package2->metadata.entrypoint = 0x60000; + print(SCREEN_LOG_LEVEL_DEBUG, "Using Mesosphere...\n"); } print(SCREEN_LOG_LEVEL_DEBUG, "Rebuilding the INI1 section...\n"); if (target_firmware < ATMOSPHERE_TARGET_FIRMWARE_8_0_0) { package2_get_src_section((void *)&orig_ini1, package2, PACKAGE2_SECTION_INI1); - } else { + } + + if (target_firmware >= ATMOSPHERE_TARGET_FIRMWARE_8_0_0 || is_mesosphere) { /* On 8.0.0, place INI1 right after kernelldr for our sanity. */ package2->metadata.section_offsets[PACKAGE2_SECTION_INI1] = package2->metadata.section_offsets[PACKAGE2_SECTION_KERNEL] + kernel_size; }