From 6ef60570b169aeedcfff5c736d13055dd2af5860 Mon Sep 17 00:00:00 2001 From: Erik Anggard Date: Wed, 18 Mar 2026 09:37:24 +0100 Subject: [PATCH 1/3] Added AF parameter to stm32h7_i2c_create Added a parameter for alternate function (AF) for setups where it is something other than 4 that is used. --- src/platform/stm32h7/stm32h7_i2c.c | 6 +++--- src/platform/stm32h7/stm32h7_i2c.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platform/stm32h7/stm32h7_i2c.c b/src/platform/stm32h7/stm32h7_i2c.c index 5db5e1cb..1c9633e2 100644 --- a/src/platform/stm32h7/stm32h7_i2c.c +++ b/src/platform/stm32h7/stm32h7_i2c.c @@ -56,7 +56,7 @@ void irq_96(void) { i2c_irq(g_i2c[3]); } i2c_t * stm32h7_i2c_create(unsigned int instance, gpio_t scl, gpio_t sda, - gpio_pull_t pull, int scl_freq) + gpio_pull_t pull, int scl_freq, int af) { instance--; if(instance > ARRAYSIZE(i2c_configs)) @@ -74,8 +74,8 @@ stm32h7_i2c_create(unsigned int instance, gpio_t scl, gpio_t sda, panic("i2c-%d: Unsupported timing", instance + 1); } - gpio_conf_af(scl, 4, GPIO_OPEN_DRAIN, GPIO_SPEED_HIGH, pull); - gpio_conf_af(sda, 4, GPIO_OPEN_DRAIN, GPIO_SPEED_HIGH, pull); + gpio_conf_af(scl, af, GPIO_OPEN_DRAIN, GPIO_SPEED_HIGH, pull); + gpio_conf_af(sda, af, GPIO_OPEN_DRAIN, GPIO_SPEED_HIGH, pull); clk_enable(c->clk_id); diff --git a/src/platform/stm32h7/stm32h7_i2c.h b/src/platform/stm32h7/stm32h7_i2c.h index 5cdafe20..b8e03f85 100644 --- a/src/platform/stm32h7/stm32h7_i2c.h +++ b/src/platform/stm32h7/stm32h7_i2c.h @@ -3,4 +3,4 @@ #include i2c_t *stm32h7_i2c_create(unsigned int instance, gpio_t scl, gpio_t sda, - gpio_pull_t pull, int scl_freq); + gpio_pull_t pull, int scl_freq, int af); From 38f741cdd072f371eeb1a9dd55eb821783775c0a Mon Sep 17 00:00:00 2001 From: Erik Anggard Date: Thu, 19 Mar 2026 15:52:57 +0100 Subject: [PATCH 2/3] Added make flag for adding build timestamp in version info This is useful during incremental development when you get unsure if you are running the latest code or not. To use it do: make BTS=1 --- Makefile | 7 +++++++ src/version.c | 3 +++ 2 files changed, 10 insertions(+) diff --git a/Makefile b/Makefile index 106da718..dabe04c9 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,13 @@ LDFLAGS += -nostartfiles -nodefaultlibs ${CFLAGS} -lgcc CFLAGS += -ffunction-sections -fdata-sections -Wno-attributes LDFLAGS += -Wl,--gc-sections -Wl,--build-id=sha1 +ifdef BTS +BUILD_TIMESTAMP := $(shell date "+%Y-%m-%d %H:%M:%S") +CFLAGS += -DMIOS_BUILD_TIMESTAMP="\"${BUILD_TIMESTAMP}\"" +# Make sure the version.c gets recompiled for new timestamp +.PHONY: ${SRC}/version.c +endif + # Needed for linker script includes LDFLAGS += -L${SRC} diff --git a/src/version.c b/src/version.c index 42188e10..4a1cc87e 100644 --- a/src/version.c +++ b/src/version.c @@ -70,6 +70,9 @@ mios_print_version(stream_t *s) stprintf(s, "Mios version:"); stprintversion(s, _miosversion); +#ifdef MIOS_BUILD_TIMESTAMP + stprintf(s, "Build time: %s\n", MIOS_BUILD_TIMESTAMP); +#endif stprintf(s, "BuildID: "); sthexstr(s, mios_build_id(), 20); From 1bbcfe878d110c371bce39b3803a7ffc554943ba Mon Sep 17 00:00:00 2001 From: Erik Anggard Date: Thu, 19 Mar 2026 15:57:29 +0100 Subject: [PATCH 3/3] Fixed PHY reset times for stm32h7 According to reset timing table in datasheet for PHY DP83826 the reset signal should be at least 25us and the reset to SMI ready is 2ms (I doubled those values for some margin). --- src/platform/stm32h7/stm32h7_eth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/stm32h7/stm32h7_eth.c b/src/platform/stm32h7/stm32h7_eth.c index 08534439..64400a3b 100644 --- a/src/platform/stm32h7/stm32h7_eth.c +++ b/src/platform/stm32h7/stm32h7_eth.c @@ -674,9 +674,9 @@ stm32h7_eth_init(gpio_t phyrst, const uint8_t *gpios, size_t gpio_count, gpio_conf_output(phyrst, GPIO_PUSH_PULL, GPIO_SPEED_LOW, GPIO_PULL_NONE); gpio_set_output(phyrst, 0); - udelay(10); + udelay(50); gpio_set_output(phyrst, 1); - udelay(10); + udelay(4000); } clk_enable(CLK_ETH1MACEN);