From 90636e01c638ed7bada9d2f661d4d8660c7a6619 Mon Sep 17 00:00:00 2001 From: Renze Nicolai Date: Fri, 13 May 2022 13:22:03 +0200 Subject: [PATCH] Fix wrong exit condition in ice40_init, add extra checks to main --- components/mch2022-bsp/hardware.c | 2 +- main/main.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/components/mch2022-bsp/hardware.c b/components/mch2022-bsp/hardware.c index bf0b517..3bb672a 100644 --- a/components/mch2022-bsp/hardware.c +++ b/components/mch2022-bsp/hardware.c @@ -164,7 +164,7 @@ esp_err_t bsp_ice40_init() { if (!bsp_ready) return ESP_FAIL; if (!rp2040_ready) return ESP_FAIL; if (rp2040_fw_version == 0xFF) return ESP_FAIL; // The ICE40 FPGA can only be controlled when the RP2040 is not in bootloader mode - if (rp2040_ready) return ESP_OK; + if (ice40_ready) return ESP_OK; dev_ice40.spi_bus = SPI_BUS; dev_ice40.pin_cs = GPIO_SPI_CS_FPGA; diff --git a/main/main.c b/main/main.c index cdc0ed6..9d8b981 100644 --- a/main/main.c +++ b/main/main.c @@ -309,6 +309,11 @@ void app_main(void) { } ILI9341* ili9341 = get_ili9341(); + if (ili9341 == NULL) { + ESP_LOGE(TAG, "ili9341 is NULL"); + esp_restart(); + } + display_boot_screen(pax_buffer, ili9341); @@ -319,6 +324,10 @@ void app_main(void) { } RP2040* rp2040 = get_rp2040(); + if (rp2040 == NULL) { + ESP_LOGE(TAG, "rp2040 is NULL"); + esp_restart(); + } rp2040_updater(rp2040, pax_buffer, ili9341, framebuffer); // Handle RP2040 firmware update & bootloader mode @@ -329,6 +338,10 @@ void app_main(void) { } ICE40* ice40 = get_ice40(); + if (ice40 == NULL) { + ESP_LOGE(TAG, "ice40 is NULL"); + esp_restart(); + } if (bsp_bno055_init() != ESP_OK) { ESP_LOGE(TAG, "Failed to initialize the BNO055 position sensor"); @@ -337,6 +350,10 @@ void app_main(void) { } BNO055* bno055 = get_bno055(); + if (bno055 == NULL) { + ESP_LOGE(TAG, "bno055 is NULL"); + esp_restart(); + } /* Start AppFS */ res = appfs_init();