diff --git a/stmhal/lcd.c b/stmhal/lcd.c
index a47fffcd94d5a2952b03560744ea5ce48dd5c888..dbe2be9ecc8f2a4dceb10d97f4ed12fdab8eb088 100644
--- a/stmhal/lcd.c
+++ b/stmhal/lcd.c
@@ -389,7 +389,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_lcd_light_obj, pyb_lcd_light);
 /// Write the string `str` to the screen.  It will appear immediately.
 STATIC mp_obj_t pyb_lcd_write(mp_obj_t self_in, mp_obj_t str) {
     pyb_lcd_obj_t *self = self_in;
-    uint len;
+    mp_uint_t len;
     const char *data = mp_obj_str_get_data(str, &len);
     lcd_write_strn(self, data, len);
     return mp_const_none;
@@ -461,7 +461,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_lcd_pixel_obj, 4, 4, pyb_lcd_pixe
 STATIC mp_obj_t pyb_lcd_text(mp_uint_t n_args, const mp_obj_t *args) {
     // extract arguments
     pyb_lcd_obj_t *self = args[0];
-    uint len;
+    mp_uint_t len;
     const char *data = mp_obj_str_get_data(args[1], &len);
     int x0 = mp_obj_get_int(args[2]);
     int y0 = mp_obj_get_int(args[3]);
diff --git a/stmhal/modpyb.c b/stmhal/modpyb.c
index 8252b057a03db37fe7f1ce431ede173a1a80d99e..522f95017cd62146f22aa7fb241f8352654f97d4 100644
--- a/stmhal/modpyb.c
+++ b/stmhal/modpyb.c
@@ -126,7 +126,7 @@ STATIC mp_obj_t pyb_info(mp_uint_t n_args, const mp_obj_t *args) {
     {
         mp_uint_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes;
         qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes);
-        printf("qstr:\n  n_pool=%u\n  n_qstr=%u\n  n_str_data_bytes=%u\n  n_total_bytes=%u\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes);
+        printf("qstr:\n  n_pool=" UINT_FMT "\n  n_qstr=" UINT_FMT "\n  n_str_data_bytes=" UINT_FMT "\n  n_total_bytes=" UINT_FMT "\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes);
     }
 
     // GC info
diff --git a/stmhal/modtime.c b/stmhal/modtime.c
index 1bf8c30c4fb7161c44f1dc4dabcd1e841dffd724..89df6ae994eb2599ad21a79b1ed8e8934e619da1 100644
--- a/stmhal/modtime.c
+++ b/stmhal/modtime.c
@@ -233,7 +233,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(time_localtime_obj, 0, 1, time_localtime);
 /// the number of seconds since Jan 1, 2000.
 STATIC mp_obj_t time_mktime(mp_obj_t tuple) {
 
-    uint len;
+    mp_uint_t len;
     mp_obj_t *elem;
 
     mp_obj_get_array(tuple, &len, &elem);
diff --git a/stmhal/printf.c b/stmhal/printf.c
index db611f3d9708103cde8ef9043057e18dd33260e8..86b756f7d4455e50f0e5bf116a283819e53462f8 100644
--- a/stmhal/printf.c
+++ b/stmhal/printf.c
@@ -48,7 +48,7 @@
 
 int pfenv_vprintf(const pfenv_t *pfenv, const char *fmt, va_list args);
 
-STATIC void stdout_print_strn(void *dummy_env, const char *str, unsigned int len) {
+STATIC void stdout_print_strn(void *dummy_env, const char *str, mp_uint_t len) {
     stdout_tx_strn_cooked(str, len);
 }
 
@@ -97,7 +97,7 @@ typedef struct _strn_pfenv_t {
     size_t remain;
 } strn_pfenv_t;
 
-void strn_print_strn(void *data, const char *str, unsigned int len) {
+STATIC void strn_print_strn(void *data, const char *str, mp_uint_t len) {
     strn_pfenv_t *strn_pfenv = data;
     if (len > strn_pfenv->remain) {
         len = strn_pfenv->remain;
diff --git a/stmhal/pyexec.c b/stmhal/pyexec.c
index 0ce4882e20153f19fdc033318b3adc4e004f3d25..f458bd0ff38cba218121ae8e0d498d0e84ccc5c7 100644
--- a/stmhal/pyexec.c
+++ b/stmhal/pyexec.c
@@ -101,9 +101,9 @@ bool parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t input_kind, bo
         gc_collect();
         // qstr info
         {
-            uint n_pool, n_qstr, n_str_data_bytes, n_total_bytes;
+            mp_uint_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes;
             qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes);
-            printf("qstr:\n  n_pool=%u\n  n_qstr=%u\n  n_str_data_bytes=%u\n  n_total_bytes=%u\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes);
+            printf("qstr:\n  n_pool=" UINT_FMT "\n  n_qstr=" UINT_FMT "\n  n_str_data_bytes=" UINT_FMT "\n  n_total_bytes=" UINT_FMT "\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes);
         }
 
         // GC info
diff --git a/stmhal/timer.c b/stmhal/timer.c
index f33fe5afb3411b28b523710092f899f5a91c47a3..787a6dd98188ee0baae17cc2592564d2478cc94e 100644
--- a/stmhal/timer.c
+++ b/stmhal/timer.c
@@ -1157,11 +1157,9 @@ STATIC void timer_handle_irq_channel(pyb_timer_obj_t *tim, uint8_t channel, mp_o
                     tim->callback = mp_const_none;
                     __HAL_TIM_DISABLE_IT(&tim->tim, irq_mask);
                     if (channel == 0) {
-                        printf("Uncaught exception in Timer(" UINT_FMT
-                               ") interrupt handler\n", tim->tim_id);
+                        printf("uncaught exception in Timer(%u) interrupt handler\n", tim->tim_id);
                     } else {
-                        printf("Uncaught exception in Timer(" UINT_FMT ") channel "
-                               UINT_FMT " interrupt handler\n", tim->tim_id, channel);
+                        printf("uncaught exception in Timer(%u) channel %u interrupt handler\n", tim->tim_id, channel);
                     }
                     mp_obj_print_exception((mp_obj_t)nlr.ret_val);
                 }