diff --git a/board/reMarkable/zero-sugar/epd_display_init.c b/board/reMarkable/zero-sugar/epd_display_init.c index 182296538f..1f3abd799e 100644 --- a/board/reMarkable/zero-sugar/epd_display_init.c +++ b/board/reMarkable/zero-sugar/epd_display_init.c @@ -10,6 +10,7 @@ #include #include #include +#include static int epd_splash(void); static int splash_init(void); @@ -92,14 +93,44 @@ struct splash_functions { int (*blit_gc)(uint32_t*, const uint8_t*, int, int, int, int, int); }splash; +static bool mmc_set_dev_part(int dev, int part) +{ + struct mmc *mmc; + int ret; + + mmc = find_mmc_device(dev); + if (!mmc) { + printf("%s: no mmc device at slot %x\n", __func__, dev); + return false; + } + mmc->has_init = 0; + + if (mmc_init(mmc)) { + printf("%s: Unable to initialize mmc\n", __func__); + return false; + } + + ret = blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part); + if (ret) { + printf("%s: Unable to switch partition, returned %d\n", __func__, ret); + return false; + } + + return true; +} + static int splash_init(void) { - // Load main.gz to 0x1C000000 const char *filename = "zplash"; + const int mmc_dev = 0; + const int mmc_part = 0; const u32 max_inflated_size = 100*1024; void *addr = (void*)0x80300000; - // Check if it exists + if (!mmc_set_dev_part(mmc_dev, mmc_part)) + return -1; + + // Check if splash file exists if (!fat_exists(filename)) { printf("%s: %s not found\n", __func__, filename); return -1;