diff --git a/stmhal/file.c b/stmhal/file.c
index a00c9a8f8f81adabe5126d44ff16accb7fbed1b4..079ab3965b944066adb68b2f8a56d479e33fb20b 100644
--- a/stmhal/file.c
+++ b/stmhal/file.c
@@ -70,7 +70,7 @@ typedef struct _pyb_file_obj_t {
 } pyb_file_obj_t;
 
 void file_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
-    printf("<io.%s %p>", mp_obj_get_type_str(self_in), self_in);
+    print(env, "<io.%s %p>", mp_obj_get_type_str(self_in), self_in);
 }
 
 STATIC machine_int_t file_obj_read(mp_obj_t self_in, void *buf, machine_uint_t size, int *errcode) {
diff --git a/stmhal/printf.c b/stmhal/printf.c
index e95f23abaea46fb42f1b701154b6737722bee590..26c552039f77abd2267c722ca2f1d73cda7283f0 100644
--- a/stmhal/printf.c
+++ b/stmhal/printf.c
@@ -195,7 +195,7 @@ int pfenv_printf(const pfenv_t *pfenv, const char *fmt, va_list args) {
     return chrs;
 }
 
-void stdout_print_strn(void *data, const char *str, unsigned int len) {
+STATIC void stdout_print_strn(void *data, const char *str, unsigned int len) {
     // TODO this needs to be replaced with a proper stdio interface ala CPython
     // send stdout to UART and USB CDC VCP
     if (pyb_uart_global_debug != PYB_UART_NONE) {
diff --git a/stmhal/pybstdio.c b/stmhal/pybstdio.c
index 59e1ead5672853b8162299ccc19dd45ca2b4d5fc..05ea06eb445561353c7881bb36c7c9ee3a620f0a 100644
--- a/stmhal/pybstdio.c
+++ b/stmhal/pybstdio.c
@@ -96,7 +96,7 @@ typedef struct _pyb_stdio_obj_t {
 
 void stdio_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
     pyb_stdio_obj_t *self = self_in;
-    printf("<io.FileIO %d>", self->fd);
+    print(env, "<io.FileIO %d>", self->fd);
 }
 
 STATIC machine_int_t stdio_read(mp_obj_t self_in, void *buf, machine_uint_t size, int *errcode) {