diff --git a/stmhal/boards/stm32f4xx-prefix.c b/stmhal/boards/stm32f4xx-prefix.c
index 4d2313075a9bf2bc60d63a65bb5783fef846485b..3bbb6bda0e3823633fbe1f33c2d7a6f323b0c3f3 100644
--- a/stmhal/boards/stm32f4xx-prefix.c
+++ b/stmhal/boards/stm32f4xx-prefix.c
@@ -5,8 +5,8 @@
 
 #include "stm32f4xx_hal.h"
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "pin.h"
diff --git a/stmhal/bufhelper.c b/stmhal/bufhelper.c
index dd726555202f6b5e0ec6325e0683a39213e453d7..1f823ea96300629efec4bc84f041182c753dd979 100644
--- a/stmhal/bufhelper.c
+++ b/stmhal/bufhelper.c
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "bufhelper.h"
diff --git a/stmhal/diskio.c b/stmhal/diskio.c
index cde58749464d585256dce2aad02a2648b0421723..35b9eab99fa0b2dbc023869e4e603ffafa9c0d89 100644
--- a/stmhal/diskio.c
+++ b/stmhal/diskio.c
@@ -32,8 +32,8 @@
 
 #include "stm32f4xx_hal.h"
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "systick.h"
diff --git a/stmhal/gccollect.c b/stmhal/gccollect.c
index 79082e2f2eecc4a4d28002677d7aa90038252279..721aa062d1ba116429ea1f2bed3b979772329903 100644
--- a/stmhal/gccollect.c
+++ b/stmhal/gccollect.c
@@ -28,8 +28,8 @@
 
 #include <stm32f4xx_hal.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "gc.h"
diff --git a/stmhal/import.c b/stmhal/import.c
index abc618bef0fca0c38f46b69b2857fbaab6cfc724..88ddaefacf8e554b9917ce3e880f17ad13117063 100644
--- a/stmhal/import.c
+++ b/stmhal/import.c
@@ -27,8 +27,8 @@
 #include <stdio.h>
 #include <stdint.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "lexer.h"
 #include "ff.h"
diff --git a/stmhal/lexerfatfs.c b/stmhal/lexerfatfs.c
index 6a0e83fb1381ef01dd6c315005b4c5a51e9e8c4d..c578b13af65960e5799aca661c736121d5cc59b0 100644
--- a/stmhal/lexerfatfs.c
+++ b/stmhal/lexerfatfs.c
@@ -27,8 +27,8 @@
 #include <stdint.h>
 #include <stdio.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "lexer.h"
 #include "lexerfatfs.h"
diff --git a/stmhal/main.c b/stmhal/main.c
index 9f48fbfd65782e6b3efae5688be15c7c2b090b97..d6c12602e001ae360b9e617f5351d75a2ccaebdc 100644
--- a/stmhal/main.c
+++ b/stmhal/main.c
@@ -29,10 +29,10 @@
 
 #include "stm32f4xx_hal.h"
 
+#include "mpconfig.h"
 #include "misc.h"
 #include "systick.h"
 #include "pendsv.h"
-#include "mpconfig.h"
 #include "qstr.h"
 #include "misc.h"
 #include "nlr.h"
diff --git a/stmhal/pendsv.c b/stmhal/pendsv.c
index f8e3b30072849a26f9e17e24670f4232f0570f9f..a0eff7e5deff07f253bf5c690ca0929f1b2a21f3 100644
--- a/stmhal/pendsv.c
+++ b/stmhal/pendsv.c
@@ -27,8 +27,8 @@
 #include <stdlib.h>
 #include <stm32f4xx_hal.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "pendsv.h"
diff --git a/stmhal/pin_named_pins.c b/stmhal/pin_named_pins.c
index 3a1794e1d9ee1f6ecc7490e043d93c46ff7fb95a..d59ba8d11d1c5d4d00799b479128502f3bcfaa30 100644
--- a/stmhal/pin_named_pins.c
+++ b/stmhal/pin_named_pins.c
@@ -30,8 +30,8 @@
 
 #include "stm32f4xx_hal.h"
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "runtime.h"
diff --git a/stmhal/printf.c b/stmhal/printf.c
index 26c552039f77abd2267c722ca2f1d73cda7283f0..c4731aa88d676e4538518f8ed21b75e83b9f4cb0 100644
--- a/stmhal/printf.c
+++ b/stmhal/printf.c
@@ -28,10 +28,10 @@
 #include <string.h>
 #include <stdarg.h>
 
+#include "mpconfig.h"
 #include "std.h"
 #include "misc.h"
 #include "systick.h"
-#include "mpconfig.h"
 #include "qstr.h"
 #include "obj.h"
 #include "pfenv.h"
diff --git a/stmhal/pybstdio.c b/stmhal/pybstdio.c
index 05ea06eb445561353c7881bb36c7c9ee3a620f0a..13057a8a0615ca163a71728cb3a9a73c280d32b7 100644
--- a/stmhal/pybstdio.c
+++ b/stmhal/pybstdio.c
@@ -28,8 +28,8 @@
 
 #include <stm32f4xx_hal.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "misc.h"
 #include "obj.h"
diff --git a/stmhal/readline.c b/stmhal/readline.c
index d40bd4219b9d4773bf373cea38c452e46aaa0e4a..0e7ed2d644c6d561e804fc15f358d9228eccd7e2 100644
--- a/stmhal/readline.c
+++ b/stmhal/readline.c
@@ -29,8 +29,8 @@
 
 #include <stm32f4xx_hal.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "misc.h"
 #include "obj.h"
diff --git a/stmhal/rng.c b/stmhal/rng.c
index 69fcb9d6ff6fb3f0e3a88af6ef5b447266dda5d1..ea636770c0f8b9bbf4b4158f236c8562c8d4752b 100644
--- a/stmhal/rng.c
+++ b/stmhal/rng.c
@@ -28,8 +28,8 @@
 
 #include "stm32f4xx_hal.h"
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "rng.h"
diff --git a/stmhal/rtc.c b/stmhal/rtc.c
index 412816c396f944c38c34e17477cb9ad6c1091989..8f0d0073273f2479caad4cbdc440f55ffd182b94 100644
--- a/stmhal/rtc.c
+++ b/stmhal/rtc.c
@@ -28,8 +28,8 @@
 
 #include "stm32f4xx_hal.h"
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "runtime.h"
diff --git a/stmhal/sdcard.c b/stmhal/sdcard.c
index bd45af3a140e011a232c86f980b6bdb60c5ea987..204dbe3b46b38f9f4da0cc5d60a0f9f30d1b5ccd 100644
--- a/stmhal/sdcard.c
+++ b/stmhal/sdcard.c
@@ -28,8 +28,8 @@
 
 #include <stm32f4xx_hal.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "runtime.h"
diff --git a/stmhal/stm32f4xx_hal_msp.c b/stmhal/stm32f4xx_hal_msp.c
index 5816249e256097aaf21517885679e2ad4a924acb..90baa41f822ff1c324dbb36605ab5e0d8f177fb7 100644
--- a/stmhal/stm32f4xx_hal_msp.c
+++ b/stmhal/stm32f4xx_hal_msp.c
@@ -66,8 +66,8 @@
 
 #include "stm32f4xx_hal.h"
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "servo.h"
diff --git a/stmhal/stm32f4xx_it.c b/stmhal/stm32f4xx_it.c
index 17cdaf5fa2d59e08ff4cab0c931db5c5a24c461b..5fa7f8289d83ae427306e2b655932a29dead8265 100644
--- a/stmhal/stm32f4xx_it.c
+++ b/stmhal/stm32f4xx_it.c
@@ -70,8 +70,8 @@
 #include "stm32f4xx_it.h"
 #include "stm32f4xx_hal.h"
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "extint.h"
diff --git a/stmhal/storage.c b/stmhal/storage.c
index ba7e303e213c6b0801932b264c59ca9130c6ba6d..001d87afe0c40e15f4a280d6111a35bc3f14b956 100644
--- a/stmhal/storage.c
+++ b/stmhal/storage.c
@@ -28,9 +28,9 @@
 #include <string.h>
 #include <stm32f4xx_hal.h>
 
+#include "mpconfig.h"
 #include "misc.h"
 #include "systick.h"
-#include "mpconfig.h"
 #include "qstr.h"
 #include "obj.h"
 #include "led.h"
diff --git a/stmhal/systick.c b/stmhal/systick.c
index 8a8d6403dc2928f2d42c58f493c11f9196af2a3c..196f1fbcae66136147e4c9c580d81b405fb41fb4 100644
--- a/stmhal/systick.c
+++ b/stmhal/systick.c
@@ -25,6 +25,7 @@
  */
 
 #include <stm32f4xx_hal.h>
+#include "mpconfig.h"
 #include "misc.h"
 #include "systick.h"
 
diff --git a/stmhal/usrsw.c b/stmhal/usrsw.c
index 4ed9e3abe4abd8c8a162a548d3fe06125cdc8b94..8a082eac9594c22cdca4e0b23449ca4301f492f3 100644
--- a/stmhal/usrsw.c
+++ b/stmhal/usrsw.c
@@ -28,8 +28,8 @@
 
 #include "stm32f4xx_hal.h"
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "runtime.h"