diff --git a/components/badge23/display.c b/components/badge23/display.c
index afaffd34acc23612c56551581d84250c5974e0f3..b8c5da869b98e29c8a72c7947dd38660ab263387 100644
--- a/components/badge23/display.c
+++ b/components/badge23/display.c
@@ -15,7 +15,7 @@
 
 #include "../../usermodule/uctx/uctx/ctx.h"
 
-Ctx *the_ctx = NULL;
+volatile Ctx *the_ctx = NULL;
 
 uint16_t *pixels;
 
diff --git a/components/badge23/include/badge23/display.h b/components/badge23/include/badge23/display.h
index e2946a47c711e84e73982053045ea07ed903aae2..213257aa075b35725e6d46737391d81adaa87b2d 100644
--- a/components/badge23/include/badge23/display.h
+++ b/components/badge23/include/badge23/display.h
@@ -12,4 +12,4 @@ void display_draw_pixel(uint8_t x, uint8_t y, uint16_t col);
 uint16_t display_get_pixel(uint8_t x, uint8_t y);
 void display_fill(uint16_t col);
 
-extern Ctx *the_ctx;
+extern volatile Ctx *the_ctx;
diff --git a/usermodule/mp_hardware.c b/usermodule/mp_hardware.c
index 632d35ef4fa4fed19a4f7489e561d8762fbfccf3..37d9994d4bb72a81cec2606ce57875f18f06f305 100644
--- a/usermodule/mp_hardware.c
+++ b/usermodule/mp_hardware.c
@@ -20,7 +20,6 @@
 #include "badge23_hwconfig.h"
 
 mp_obj_t mp_ctx_from_ctx(Ctx *ctx);
-mp_obj_t mp_ctx = NULL;
 
 STATIC mp_obj_t mp_init_done(void) {
     return mp_obj_new_int(hardware_is_initialized());
@@ -190,7 +189,12 @@ STATIC mp_obj_t mp_version(void) {
 STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_version_obj, mp_version);
 
 STATIC mp_obj_t mp_get_ctx(size_t n_args, const mp_obj_t *args) {
-    mp_ctx = mp_ctx_from_ctx(the_ctx);
+    // This might be called before the ctx is ready.
+    // HACK: this will go away with the new drawing API.
+    while (the_ctx == NULL) {
+        vTaskDelay(100 / portTICK_PERIOD_MS);
+    }
+    mp_obj_t mp_ctx = mp_ctx_from_ctx(the_ctx);
     return mp_ctx;
 }
 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_get_ctx_obj, 0, 0, mp_get_ctx);