diff --git a/stmhal/bufhelper.c b/stmhal/bufhelper.c
index 5612a048dc2bbb5f4047e9a4142e1e91318156f8..c5dcd6c1d251467d94bf0268be51667c14778822 100644
--- a/stmhal/bufhelper.c
+++ b/stmhal/bufhelper.c
@@ -4,7 +4,7 @@
 #include "obj.h"
 #include "bufhelper.h"
 
-void pyb_buf_get_for_send(mp_obj_t o, mp_buffer_info_t *bufinfo, uint8_t *tmp_data) {
+void pyb_buf_get_for_send(mp_obj_t o, mp_buffer_info_t *bufinfo, byte *tmp_data) {
     if (MP_OBJ_IS_INT(o)) {
         tmp_data[0] = mp_obj_get_int(o);
         bufinfo->buf = tmp_data;
diff --git a/stmhal/bufhelper.h b/stmhal/bufhelper.h
index 9b58e817c8a240b6d845c73c2bfb19730da82af7..53ab7ab3e0225f74e55002070fcc305994db2e5a 100644
--- a/stmhal/bufhelper.h
+++ b/stmhal/bufhelper.h
@@ -1,2 +1,2 @@
-void pyb_buf_get_for_send(mp_obj_t o, mp_buffer_info_t *bufinfo, uint8_t *tmp_data);
+void pyb_buf_get_for_send(mp_obj_t o, mp_buffer_info_t *bufinfo, byte *tmp_data);
 mp_obj_t pyb_buf_get_for_recv(mp_obj_t o, mp_buffer_info_t *bufinfo);
diff --git a/stmhal/gccollect.c b/stmhal/gccollect.c
index d40460d70cfa1536d8de4d0513057aeba2a514c9..8be531416fbd4490a51a843dafa20ad45ef86fdd 100644
--- a/stmhal/gccollect.c
+++ b/stmhal/gccollect.c
@@ -41,9 +41,9 @@ void gc_collect(void) {
         gc_info_t info;
         gc_info(&info);
         printf("GC@%lu %lums\n", start, ticks);
-        printf(" %lu total\n", info.total);
-        printf(" %lu : %lu\n", info.used, info.free);
-        printf(" 1=%lu 2=%lu m=%lu\n", info.num_1block, info.num_2block, info.max_block);
+        printf(" " UINT_FMT " total\n", info.total);
+        printf(" " UINT_FMT " : " UINT_FMT "\n", info.used, info.free);
+        printf(" 1=" UINT_FMT " 2=" UINT_FMT " m=" UINT_FMT "\n", info.num_1block, info.num_2block, info.max_block);
     }
 }
 
diff --git a/stmhal/input.c b/stmhal/input.c
index a45a36198c87269c085bc506bcbed02cb867e676..6e98ea960c4735a7837998e90c4800bf051c0a92 100644
--- a/stmhal/input.c
+++ b/stmhal/input.c
@@ -1,3 +1,5 @@
+#include <stdint.h>
+
 #include "mpconfig.h"
 #include "nlr.h"
 #include "misc.h"
diff --git a/stmhal/modos.c b/stmhal/modos.c
index 076a28782ec50bd6b197eec9f2f02f13437c76b3..3594cbc3a6984144fe11a9f12bcf6138ca64d62e 100644
--- a/stmhal/modos.c
+++ b/stmhal/modos.c
@@ -1,3 +1,4 @@
+#include <stdint.h>
 #include <string.h>
 
 #include "mpconfig.h"
diff --git a/stmhal/modpyb.c b/stmhal/modpyb.c
index 2f53bb52348d48722b75bf8b17d69e2207e705e8..6ffc92553a571420246653c9b6f0b43a013bd025 100644
--- a/stmhal/modpyb.c
+++ b/stmhal/modpyb.c
@@ -82,9 +82,9 @@ STATIC mp_obj_t pyb_info(uint n_args, const mp_obj_t *args) {
         gc_info_t info;
         gc_info(&info);
         printf("GC:\n");
-        printf("  %lu total\n", info.total);
-        printf("  %lu : %lu\n", info.used, info.free);
-        printf("  1=%lu 2=%lu m=%lu\n", info.num_1block, info.num_2block, info.max_block);
+        printf("  " UINT_FMT " total\n", info.total);
+        printf("  " UINT_FMT " : " UINT_FMT "\n", info.used, info.free);
+        printf("  1=" UINT_FMT " 2=" UINT_FMT " m=" UINT_FMT "\n", info.num_1block, info.num_2block, info.max_block);
     }
 
     // free space on flash
diff --git a/stmhal/mpconfigport.h b/stmhal/mpconfigport.h
index 24ab20b16b8262ebba5ac37054a52693fa1ab536..ad55ed632426b7e2173e81152244e6c40b26f970 100644
--- a/stmhal/mpconfigport.h
+++ b/stmhal/mpconfigport.h
@@ -1,5 +1,3 @@
-#include <stdint.h>
-
 // options to control how Micro Python is built
 
 #define MICROPY_EMIT_THUMB          (1)
@@ -51,11 +49,11 @@ extern const struct _mp_obj_module_t time_module;
 
 #define BYTES_PER_WORD (4)
 
-#define UINT_FMT "%lu"
-#define INT_FMT "%ld"
+#define UINT_FMT "%u"
+#define INT_FMT "%d"
 
-typedef int32_t machine_int_t; // must be pointer size
-typedef uint32_t machine_uint_t; // must be pointer size
+typedef int machine_int_t; // must be pointer size
+typedef unsigned int machine_uint_t; // must be pointer size
 typedef void *machine_ptr_t; // must be of pointer size
 typedef const void *machine_const_ptr_t; // must be of pointer size
 
diff --git a/stmhal/pyexec.c b/stmhal/pyexec.c
index 6a8929cb4ef0e9357fac6a491c845c2ea72fd3c1..294020cec502721291fd2ac892c20000fc930160 100644
--- a/stmhal/pyexec.c
+++ b/stmhal/pyexec.c
@@ -84,9 +84,9 @@ bool parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t input_kind, bo
             gc_info_t info;
             gc_info(&info);
             printf("GC:\n");
-            printf("  %lu total\n", info.total);
-            printf("  %lu : %lu\n", info.used, info.free);
-            printf("  1=%lu 2=%lu m=%lu\n", info.num_1block, info.num_2block, info.max_block);
+            printf("  " UINT_FMT " total\n", info.total);
+            printf("  " UINT_FMT " : " UINT_FMT "\n", info.used, info.free);
+            printf("  1=" UINT_FMT " 2=" UINT_FMT " m=" UINT_FMT "\n", info.num_1block, info.num_2block, info.max_block);
         }
     }
 
diff --git a/stmhal/timer.c b/stmhal/timer.c
index e1d55e14a0f4606a265bb846585083e78a7e1655..e92a9988f77ef0307475ad0c82e3d678c8cff02a 100644
--- a/stmhal/timer.c
+++ b/stmhal/timer.c
@@ -467,7 +467,7 @@ void timer_irq_handler(uint tim_id) {
                         // Uncaught exception; disable the callback so it doesn't run again.
                         tim->callback = mp_const_none;
                         __HAL_TIM_DISABLE_IT(&tim->tim, TIM_IT_UPDATE);
-                        printf("Uncaught exception in Timer(%lu) interrupt handler\n", tim->tim_id);
+                        printf("Uncaught exception in Timer(" UINT_FMT ") interrupt handler\n", tim->tim_id);
                         mp_obj_print_exception((mp_obj_t)nlr.ret_val);
                     }
                     gc_unlock();