diff --git a/stmhal/ffconf.c b/stmhal/ffconf.c
index b8dada3cca3060cf34ca385c53cbfb1debabf8f7..4a51d193c6d8aba54f37b5598c1278343b4a14b2 100644
--- a/stmhal/ffconf.c
+++ b/stmhal/ffconf.c
@@ -31,10 +31,6 @@
 #include "ffconf.h"
 #include "fsusermount.h"
 
-#if _FS_RPATH
-extern BYTE ff_CurrVol;
-#endif
-
 STATIC bool check_path(const TCHAR **path, const char *mount_point_str, mp_uint_t mount_point_len) {
     if (strncmp(*path, mount_point_str, mount_point_len) == 0) {
         if ((*path)[mount_point_len] == '/') {
diff --git a/stmhal/gccollect.h b/stmhal/gccollect.h
index c2955b92990b61af7d018c1752c9502e967d8700..07797be7e4db70e03637e728230cb716f915a6e0 100644
--- a/stmhal/gccollect.h
+++ b/stmhal/gccollect.h
@@ -37,5 +37,3 @@ extern uint32_t _heap_start;
 extern uint32_t _heap_end;
 extern uint32_t _estack;
 extern uint32_t _ram_end;
-
-void gc_collect(void);
diff --git a/stmhal/lexerfatfs.c b/stmhal/lexerfatfs.c
index ddab89a5c3fa7b9cc6eed39de0cbeeb22fc39634..39b8fefa92c242098d9752c4b17ab910c7a70d26 100644
--- a/stmhal/lexerfatfs.c
+++ b/stmhal/lexerfatfs.c
@@ -28,7 +28,6 @@
 
 #include "py/lexer.h"
 #include "lib/fatfs/ff.h"
-#include "lexerfatfs.h"
 
 typedef struct _mp_lexer_file_buf_t {
     FIL fp;
diff --git a/stmhal/lexerfatfs.h b/stmhal/lexerfatfs.h
deleted file mode 100644
index 3c8ebacb1e80709c659f140f9b7a49a3eadf43e0..0000000000000000000000000000000000000000
--- a/stmhal/lexerfatfs.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * This file is part of the Micro Python project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013, 2014 Damien P. George
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-mp_lexer_t *mp_lexer_new_from_file(const char *filename);
diff --git a/stmhal/modnetwork.h b/stmhal/modnetwork.h
index 9bde29f73db0bd9c859454e7347c4f07ebb4cd84..f306f877a5a62ce9f067ac7e4163c3f47098926d 100644
--- a/stmhal/modnetwork.h
+++ b/stmhal/modnetwork.h
@@ -82,5 +82,4 @@ void mod_network_convert_ipv4_endianness(uint8_t *ip);
 void mod_network_parse_ipv4_addr(mp_obj_t addr_in, uint8_t *out_ip);
 mp_uint_t mod_network_parse_inet_addr(mp_obj_t addr_in, uint8_t *out_ip);
 mp_obj_t mod_network_format_ipv4_addr(uint8_t *ip);
-mp_obj_t mod_network_format_ipv4_addr(uint8_t *ip);
 mp_obj_t mod_network_format_inet_addr(uint8_t *ip, mp_uint_t port);
diff --git a/stmhal/pendsv.c b/stmhal/pendsv.c
index 68455b2752e03adec7ccdba841b9aad73b38243a..48fb79e20e8be84f5910812bf9807d59b9ef5a02 100644
--- a/stmhal/pendsv.c
+++ b/stmhal/pendsv.c
@@ -59,10 +59,6 @@ void pendsv_nlr_jump(void *o) {
     }
 }
 
-// since we play tricks with the stack, the compiler must not generate a
-// prelude for this function
-void pendsv_isr_handler(void) __attribute__((naked));
-
 void pendsv_isr_handler(void) {
     // re-jig the stack so that when we return from this interrupt handler
     // it returns instead to nlr_jump with argument pendsv_object
diff --git a/stmhal/pendsv.h b/stmhal/pendsv.h
index f91a7c1d78b56fdda328167d0e4e08a14f5bd4e3..7886d9f9842bbb168015bfd3580bc1c3cad1ca32 100644
--- a/stmhal/pendsv.h
+++ b/stmhal/pendsv.h
@@ -26,4 +26,7 @@
 
 void pendsv_init(void);
 void pendsv_nlr_jump(void *val);
-void pendsv_isr_handler(void);
+
+// since we play tricks with the stack, the compiler must not generate a
+// prelude for this function
+void pendsv_isr_handler(void) __attribute__((naked));
diff --git a/stmhal/sdcard.c b/stmhal/sdcard.c
index 5686f949a3561e9eab198b639f485b8650223590..0eac1615c8d148f3056964ab5f1a36511bedd8a3 100644
--- a/stmhal/sdcard.c
+++ b/stmhal/sdcard.c
@@ -261,7 +261,6 @@ STATIC mp_obj_t sd_power(mp_obj_t self, mp_obj_t state) {
 STATIC MP_DEFINE_CONST_FUN_OBJ_2(sd_power_obj, sd_power);
 
 STATIC mp_obj_t sd_info(mp_obj_t self) {
-    HAL_SD_ErrorTypedef HAL_SD_Init(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypedef *SDCardInfo);
     if (sd_handle.Instance == NULL) {
         return mp_const_none;
     }
diff --git a/stmhal/stm32f4xx_it.c b/stmhal/stm32f4xx_it.c
index 9be180a051f8bfb4b2f0fa7fa26d5eb391fc422e..3db2019cbfbedde1062601087a27553c91909c08 100644
--- a/stmhal/stm32f4xx_it.c
+++ b/stmhal/stm32f4xx_it.c
@@ -71,6 +71,7 @@
 #include "stm32f4xx_hal.h"
 
 #include "py/obj.h"
+#include "pendsv.h"
 #include "extint.h"
 #include "timer.h"
 #include "uart.h"
@@ -162,7 +163,6 @@ void DebugMon_Handler(void) {
   * @retval None
   */
 void PendSV_Handler(void) {
-    extern void pendsv_isr_handler(void);
     pendsv_isr_handler();
 }
 
diff --git a/stmhal/usbd_cdc_interface.c b/stmhal/usbd_cdc_interface.c
index 66bfe1a229b52b272d1bbf9734f7c2c688416529..8b088660ff111554e37d5ea245a02c414c177d5f 100644
--- a/stmhal/usbd_cdc_interface.c
+++ b/stmhal/usbd_cdc_interface.c
@@ -42,6 +42,7 @@
 #include "pendsv.h"
 
 #include "py/obj.h"
+#include "timer.h"
 #include "usb.h"
 
 // CDC control commands
diff --git a/stmhal/usbd_cdc_interface.h b/stmhal/usbd_cdc_interface.h
index 5a5d4cf004a2ef4ee8571d09d821de33722f0e65..0585d06c8c420126c94bf20d90d437d6bca6179a 100644
--- a/stmhal/usbd_cdc_interface.h
+++ b/stmhal/usbd_cdc_interface.h
@@ -29,7 +29,6 @@
   ******************************************************************************
   */
 
-extern TIM_HandleTypeDef TIM3_Handle;
 extern const USBD_CDC_ItfTypeDef USBD_CDC_fops;
 
 void USBD_CDC_HAL_TIM_PeriodElapsedCallback(void);