diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7a506193..6572435a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -131,7 +131,7 @@ jobs: - if: ${{ env.GO == 1 }} run: sudo apt -y update; sudo apt -y install gcc-arm-none-eabi - if: ${{ env.GO == 1 }} - run: make -C examples/stm32/nucleo-f746zg-baremetal test VCON_API_KEY=${{secrets.VCON_API_KEY}} + run: make -C examples/stm32/nucleo-f746zg-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} - if: ${{ env.GO == 1 }} run: make -C examples/stm32/nucleo-f746zg-freertos test VCON_API_KEY=${{secrets.VCON_API_KEY}} - if: ${{ env.GO == 1 }} @@ -153,7 +153,7 @@ jobs: - if: ${{ env.GO == 1 }} run: sudo apt -y update; sudo apt -y install gcc-arm-none-eabi - if: ${{ env.GO == 1 }} - run: make -C examples/stm32/nucleo-f429zi-baremetal test VCON_API_KEY=${{secrets.VCON_API_KEY}} + run: make -C examples/stm32/nucleo-f429zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} - if: ${{ env.GO == 1 }} run: make -C examples/stm32/nucleo-f429zi-freertos test VCON_API_KEY=${{secrets.VCON_API_KEY}} - run: echo GO=0 >> $GITHUB_ENV ; if ./test/match_changed_files.sh '^src|examples/stm32/nucleo-f4.*-cube-'; then echo GO=1 >> $GITHUB_ENV ; fi @@ -173,7 +173,7 @@ jobs: - if: ${{ env.GO == 1 }} run: sudo apt -y update; sudo apt -y install gcc-arm-none-eabi - if: ${{ env.GO == 1 }} - run: make -C examples/stm32/nucleo-h743zi-baremetal test VCON_API_KEY=${{secrets.VCON_API_KEY}} + run: make -C examples/stm32/nucleo-h743zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} - run: echo GO=0 >> $GITHUB_ENV ; if ./test/match_changed_files.sh '^src|examples/stm32/nucleo-h7.*-cube-'; then echo GO=1 >> $GITHUB_ENV ; fi - if: ${{ env.GO == 1 }} run: make -C test/cube test PROJECTS=../../examples/stm32/nucleo-h743zi-cube-baremetal VCON_API_KEY=${{secrets.VCON_API_KEY}} DEVICE=6 @@ -215,15 +215,15 @@ jobs: - path: esp32/device-dashboard - path: esp32/uart-bridge - path: esp8266/http-client-server - - path: stm32/nucleo-h743zi-baremetal + - path: stm32/nucleo-h743zi-make-baremetal-builtin - path: stm32/stm32-nucleo-f746z - path: stm32/stm32-nucleo-f746zg - path: stm32/stm32-nucleo-f429z - path: stm32/stm32-nucleo-h743z - - path: stm32/nucleo-f429zi-baremetal + - path: stm32/nucleo-f429zi-make-baremetal-builtin - path: stm32/nucleo-f429zi-freertos - path: stm32/nucleo-f429zi-rndis - - path: stm32/nucleo-f746zg-baremetal + - path: stm32/nucleo-f746zg-make-baremetal-builtin - path: stm32/nucleo-f746zg-freertos - path: stm32/nucleo-f746zg-freertos-tcp - path: stm32/nucleo-f746zg-rndis diff --git a/examples/stm32/nucleo-f429zi-baremetal/README.md b/examples/stm32/nucleo-f429zi-baremetal/README.md deleted file mode 100644 index d7bb6138..00000000 --- a/examples/stm32/nucleo-f429zi-baremetal/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Baremetal web device dashboard on NUCLEO-F429ZI - -See https://mongoose.ws/tutorials/stm32/nucleo-f429zi-baremetal/ diff --git a/examples/stm32/nucleo-f429zi-baremetal/Makefile b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/Makefile similarity index 100% rename from examples/stm32/nucleo-f429zi-baremetal/Makefile rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin/Makefile diff --git a/examples/stm32/nucleo-f429zi-make-baremetal-builtin/README.md b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/README.md new file mode 100644 index 00000000..cb49b015 --- /dev/null +++ b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/README.md @@ -0,0 +1,3 @@ +# Baremetal web device dashboard on NUCLEO-F429ZI + +See https://mongoose.ws/tutorials/stm32/all-make-baremetal-builtin/ diff --git a/examples/stm32/nucleo-f429zi-baremetal/hal.h b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/hal.h similarity index 83% rename from examples/stm32/nucleo-f429zi-baremetal/hal.h rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin/hal.h index 5d59e96b..58e24069 100644 --- a/examples/stm32/nucleo-f429zi-baremetal/hal.h +++ b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/hal.h @@ -1,6 +1,7 @@ // Copyright (c) 2022 Cesanta Software Limited // All rights reserved // https://www.st.com/resource/en/reference_manual/dm00031020-stm32f405-415-stm32f407-417-stm32f427-437-and-stm32f429-439-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf +// https://www.st.com/resource/en/datasheet/stm32f429zi.pdf #pragma once @@ -11,12 +12,19 @@ #include #include + #define BIT(x) (1UL << (x)) #define SETBITS(R, CLEARMASK, SETMASK) (R) = ((R) & ~(CLEARMASK)) | (SETMASK) #define PIN(bank, num) ((((bank) - 'A') << 8) | (num)) #define PINNO(pin) (pin & 255) #define PINBANK(pin) (pin >> 8) +#define LED1 PIN('B', 0) // On-board LED pin (green) +#define LED2 PIN('B', 7) // On-board LED pin (blue) +#define LED3 PIN('B', 14) // On-board LED pin (red) + +#define LED LED2 // Use blue LED for blinking + // 6.3.3: APB1 clock <= 45MHz; APB2 clock <= 90MHz // 3.5.1, Table 11: configure flash latency (WS) in accordance to clock freq // 33.4: The AHB clock must be at least 25 MHz when Ethernet is used @@ -88,7 +96,6 @@ static inline void irq_exti_attach(uint16_t pin) { #endif static inline void uart_init(USART_TypeDef *uart, unsigned long baud) { - // https://www.st.com/resource/en/datasheet/stm32f429zi.pdf uint8_t af = 7; // Alternate function uint16_t rx = 0, tx = 0; // pins uint32_t freq = 0; // Bus frequency. UART1 is on APB2, rest on APB1 @@ -130,6 +137,22 @@ static inline uint32_t rng_read(void) { return RNG->DR; } +static inline void ethernet_init(void) { + // Initialise Ethernet. Enable MAC GPIO pins, see + // https://www.farnell.com/datasheets/2014265.pdf section 6.10 + uint16_t pins[] = {PIN('A', 1), PIN('A', 2), PIN('A', 7), + PIN('B', 13), PIN('C', 1), PIN('C', 4), + PIN('C', 5), PIN('G', 11), PIN('G', 13)}; + for (size_t i = 0; i < sizeof(pins) / sizeof(pins[0]); i++) { + gpio_init(pins[i], GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_INSANE, + GPIO_PULL_NONE, 11); // 11 is the Ethernet function + } + NVIC_EnableIRQ(ETH_IRQn); // Setup Ethernet IRQ handler + SYSCFG->PMC |= SYSCFG_PMC_MII_RMII_SEL; // Use RMII. Goes first! + RCC->AHB1ENR |= + RCC_AHB1ENR_ETHMACEN | RCC_AHB1ENR_ETHMACTXEN | RCC_AHB1ENR_ETHMACRXEN; +} + #define UUID ((uint8_t *) UID_BASE) // Unique 96-bit chip ID. TRM 39.1 // Helper macro for MAC generation diff --git a/examples/stm32/nucleo-f429zi-baremetal/link.ld b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/link.ld similarity index 100% rename from examples/stm32/nucleo-f429zi-baremetal/link.ld rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin/link.ld diff --git a/examples/stm32/nucleo-f746zg-baremetal/main.c b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/main.c similarity index 70% rename from examples/stm32/nucleo-f746zg-baremetal/main.c rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin/main.c index 58f669fb..f1b2457b 100644 --- a/examples/stm32/nucleo-f746zg-baremetal/main.c +++ b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/main.c @@ -5,11 +5,6 @@ #include "mongoose.h" #include "net.h" -#define LED1 PIN('B', 0) // On-board LED pin (green) -#define LED2 PIN('B', 7) // On-board LED pin (blue) -#define LED3 PIN('B', 14) // On-board LED pin (red) - -#define LED LED2 // Use blue LED for blinking #define BLINK_PERIOD_MS 1000 // LED blinking period in millis static volatile uint64_t s_ticks; // Milliseconds since boot @@ -37,22 +32,6 @@ static void timer_fn(void *arg) { ifp->ndrop, ifp->nerr)); } -static void ethernet_init(void) { - // Initialise Ethernet. Enable MAC GPIO pins, see - // https://www.farnell.com/datasheets/2014265.pdf section 6.10 - uint16_t pins[] = {PIN('A', 1), PIN('A', 2), PIN('A', 7), - PIN('B', 13), PIN('C', 1), PIN('C', 4), - PIN('C', 5), PIN('G', 11), PIN('G', 13)}; - for (size_t i = 0; i < sizeof(pins) / sizeof(pins[0]); i++) { - gpio_init(pins[i], GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_INSANE, - GPIO_PULL_NONE, 11); // 11 is the Ethernet function - } - NVIC_EnableIRQ(ETH_IRQn); // Setup Ethernet IRQ handler - SYSCFG->PMC |= SYSCFG_PMC_MII_RMII_SEL; // Use RMII. Goes first! - RCC->AHB1ENR |= - RCC_AHB1ENR_ETHMACEN | RCC_AHB1ENR_ETHMACTXEN | RCC_AHB1ENR_ETHMACRXEN; -} - int main(void) { gpio_output(LED); // Setup green LED uart_init(UART_DEBUG, 115200); // Initialise debug printf diff --git a/examples/stm32/nucleo-f429zi-baremetal/mongoose.c b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/mongoose.c similarity index 100% rename from examples/stm32/nucleo-f429zi-baremetal/mongoose.c rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin/mongoose.c diff --git a/examples/stm32/nucleo-f429zi-baremetal/mongoose.h b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/mongoose.h similarity index 100% rename from examples/stm32/nucleo-f429zi-baremetal/mongoose.h rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin/mongoose.h diff --git a/examples/stm32/nucleo-f429zi-baremetal/net.c b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/net.c similarity index 100% rename from examples/stm32/nucleo-f429zi-baremetal/net.c rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin/net.c diff --git a/examples/stm32/nucleo-f429zi-baremetal/net.h b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/net.h similarity index 100% rename from examples/stm32/nucleo-f429zi-baremetal/net.h rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin/net.h diff --git a/examples/stm32/nucleo-f429zi-baremetal/packed_fs.c b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/packed_fs.c similarity index 100% rename from examples/stm32/nucleo-f429zi-baremetal/packed_fs.c rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin/packed_fs.c diff --git a/examples/stm32/nucleo-f429zi-baremetal/syscalls.c b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/syscalls.c similarity index 100% rename from examples/stm32/nucleo-f429zi-baremetal/syscalls.c rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin/syscalls.c diff --git a/examples/stm32/nucleo-f429zi-baremetal/sysinit.c b/examples/stm32/nucleo-f429zi-make-baremetal-builtin/sysinit.c similarity index 100% rename from examples/stm32/nucleo-f429zi-baremetal/sysinit.c rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin/sysinit.c diff --git a/examples/stm32/nucleo-f746zg-baremetal/README.md b/examples/stm32/nucleo-f746zg-baremetal/README.md deleted file mode 100644 index 6ea1a30c..00000000 --- a/examples/stm32/nucleo-f746zg-baremetal/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Baremetal web device dashboard on NUCLEO-F746ZG - -See https://mongoose.ws/tutorials/stm32/nucleo-f746zg-baremetal/ diff --git a/examples/stm32/nucleo-f746zg-baremetal/Makefile b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/Makefile similarity index 100% rename from examples/stm32/nucleo-f746zg-baremetal/Makefile rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin/Makefile diff --git a/examples/stm32/nucleo-f746zg-make-baremetal-builtin/README.md b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/README.md new file mode 100644 index 00000000..7dc3200f --- /dev/null +++ b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/README.md @@ -0,0 +1,3 @@ +# Baremetal web device dashboard on NUCLEO-F746ZG + +See https://mongoose.ws/tutorials/stm32/all-make-baremetal-builtin/ diff --git a/examples/stm32/nucleo-f746zg-baremetal/hal.h b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/hal.h similarity index 83% rename from examples/stm32/nucleo-f746zg-baremetal/hal.h rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin/hal.h index a29353d7..57605a09 100644 --- a/examples/stm32/nucleo-f746zg-baremetal/hal.h +++ b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/hal.h @@ -1,6 +1,7 @@ // Copyright (c) 2022 Cesanta Software Limited // All rights reserved // https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf +// https://www.st.com/resource/en/datasheet/stm32f746zg.pdf #pragma once @@ -17,6 +18,12 @@ #define PINNO(pin) (pin & 255) #define PINBANK(pin) (pin >> 8) +#define LED1 PIN('B', 0) // On-board LED pin (green) +#define LED2 PIN('B', 7) // On-board LED pin (blue) +#define LED3 PIN('B', 14) // On-board LED pin (red) + +#define LED LED2 // Use blue LED for blinking + /* System clock 5.3.3: APB1 clock <= 54MHz; APB2 clock <= 108MHz 3.3.2, Table 5: configure flash latency (WS) in accordance to clock freq @@ -90,7 +97,6 @@ static inline void irq_exti_attach(uint16_t pin) { #endif static inline void uart_init(USART_TypeDef *uart, unsigned long baud) { - // https://www.st.com/resource/en/datasheet/stm32f746zg.pdf uint8_t af = 7; // Alternate function uint16_t rx = 0, tx = 0; // pins uint32_t freq = 0; // Bus frequency. UART1 is on APB2, rest on APB1 @@ -132,6 +138,22 @@ static inline uint32_t rng_read(void) { return RNG->DR; } +static inline void ethernet_init(void) { + // Initialise Ethernet. Enable MAC GPIO pins, see + // https://www.farnell.com/datasheets/2014265.pdf section 6.10 + uint16_t pins[] = {PIN('A', 1), PIN('A', 2), PIN('A', 7), + PIN('B', 13), PIN('C', 1), PIN('C', 4), + PIN('C', 5), PIN('G', 11), PIN('G', 13)}; + for (size_t i = 0; i < sizeof(pins) / sizeof(pins[0]); i++) { + gpio_init(pins[i], GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_INSANE, + GPIO_PULL_NONE, 11); // 11 is the Ethernet function + } + NVIC_EnableIRQ(ETH_IRQn); // Setup Ethernet IRQ handler + SYSCFG->PMC |= SYSCFG_PMC_MII_RMII_SEL; // Use RMII. Goes first! + RCC->AHB1ENR |= + RCC_AHB1ENR_ETHMACEN | RCC_AHB1ENR_ETHMACTXEN | RCC_AHB1ENR_ETHMACRXEN; +} + #define UUID ((uint8_t *) UID_BASE) // Unique 96-bit chip ID. TRM 41.1 // Helper macro for MAC generation diff --git a/examples/stm32/nucleo-f746zg-baremetal/link.ld b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/link.ld similarity index 100% rename from examples/stm32/nucleo-f746zg-baremetal/link.ld rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin/link.ld diff --git a/examples/stm32/nucleo-f429zi-baremetal/main.c b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/main.c similarity index 70% rename from examples/stm32/nucleo-f429zi-baremetal/main.c rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin/main.c index 58f669fb..f1b2457b 100644 --- a/examples/stm32/nucleo-f429zi-baremetal/main.c +++ b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/main.c @@ -5,11 +5,6 @@ #include "mongoose.h" #include "net.h" -#define LED1 PIN('B', 0) // On-board LED pin (green) -#define LED2 PIN('B', 7) // On-board LED pin (blue) -#define LED3 PIN('B', 14) // On-board LED pin (red) - -#define LED LED2 // Use blue LED for blinking #define BLINK_PERIOD_MS 1000 // LED blinking period in millis static volatile uint64_t s_ticks; // Milliseconds since boot @@ -37,22 +32,6 @@ static void timer_fn(void *arg) { ifp->ndrop, ifp->nerr)); } -static void ethernet_init(void) { - // Initialise Ethernet. Enable MAC GPIO pins, see - // https://www.farnell.com/datasheets/2014265.pdf section 6.10 - uint16_t pins[] = {PIN('A', 1), PIN('A', 2), PIN('A', 7), - PIN('B', 13), PIN('C', 1), PIN('C', 4), - PIN('C', 5), PIN('G', 11), PIN('G', 13)}; - for (size_t i = 0; i < sizeof(pins) / sizeof(pins[0]); i++) { - gpio_init(pins[i], GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_INSANE, - GPIO_PULL_NONE, 11); // 11 is the Ethernet function - } - NVIC_EnableIRQ(ETH_IRQn); // Setup Ethernet IRQ handler - SYSCFG->PMC |= SYSCFG_PMC_MII_RMII_SEL; // Use RMII. Goes first! - RCC->AHB1ENR |= - RCC_AHB1ENR_ETHMACEN | RCC_AHB1ENR_ETHMACTXEN | RCC_AHB1ENR_ETHMACRXEN; -} - int main(void) { gpio_output(LED); // Setup green LED uart_init(UART_DEBUG, 115200); // Initialise debug printf diff --git a/examples/stm32/nucleo-f746zg-baremetal/mbedtls_config.h b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/mbedtls_config.h similarity index 100% rename from examples/stm32/nucleo-f746zg-baremetal/mbedtls_config.h rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin/mbedtls_config.h diff --git a/examples/stm32/nucleo-f746zg-baremetal/mongoose.c b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/mongoose.c similarity index 100% rename from examples/stm32/nucleo-f746zg-baremetal/mongoose.c rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin/mongoose.c diff --git a/examples/stm32/nucleo-f746zg-baremetal/mongoose.h b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/mongoose.h similarity index 100% rename from examples/stm32/nucleo-f746zg-baremetal/mongoose.h rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin/mongoose.h diff --git a/examples/stm32/nucleo-f746zg-baremetal/net.c b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/net.c similarity index 100% rename from examples/stm32/nucleo-f746zg-baremetal/net.c rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin/net.c diff --git a/examples/stm32/nucleo-f746zg-baremetal/net.h b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/net.h similarity index 100% rename from examples/stm32/nucleo-f746zg-baremetal/net.h rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin/net.h diff --git a/examples/stm32/nucleo-f746zg-baremetal/packed_fs.c b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/packed_fs.c similarity index 100% rename from examples/stm32/nucleo-f746zg-baremetal/packed_fs.c rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin/packed_fs.c diff --git a/examples/stm32/nucleo-f746zg-baremetal/syscalls.c b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/syscalls.c similarity index 100% rename from examples/stm32/nucleo-f746zg-baremetal/syscalls.c rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin/syscalls.c diff --git a/examples/stm32/nucleo-f746zg-baremetal/sysinit.c b/examples/stm32/nucleo-f746zg-make-baremetal-builtin/sysinit.c similarity index 100% rename from examples/stm32/nucleo-f746zg-baremetal/sysinit.c rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin/sysinit.c diff --git a/examples/stm32/nucleo-h743zi-baremetal/README.md b/examples/stm32/nucleo-h743zi-baremetal/README.md deleted file mode 100644 index e510ffcf..00000000 --- a/examples/stm32/nucleo-h743zi-baremetal/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Baremetal web device dashboard on NUCLEO-H743ZI - -See https://mongoose.ws/tutorials/stm32/nucleo-h743zi-baremetal/ diff --git a/examples/stm32/nucleo-h743zi-baremetal/Makefile b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/Makefile similarity index 100% rename from examples/stm32/nucleo-h743zi-baremetal/Makefile rename to examples/stm32/nucleo-h743zi-make-baremetal-builtin/Makefile diff --git a/examples/stm32/nucleo-h743zi-make-baremetal-builtin/README.md b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/README.md new file mode 100644 index 00000000..92686842 --- /dev/null +++ b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/README.md @@ -0,0 +1,3 @@ +# Baremetal web device dashboard on NUCLEO-H743ZI + +See https://mongoose.ws/tutorials/stm32/all-make-baremetal-builtin/ diff --git a/examples/stm32/nucleo-h743zi-baremetal/hal.h b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/hal.h similarity index 86% rename from examples/stm32/nucleo-h743zi-baremetal/hal.h rename to examples/stm32/nucleo-h743zi-make-baremetal-builtin/hal.h index 26effcb9..54ae2909 100644 --- a/examples/stm32/nucleo-h743zi-baremetal/hal.h +++ b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/hal.h @@ -20,6 +20,12 @@ #define PINNO(pin) (pin & 255) #define PINBANK(pin) (pin >> 8) +#define LED1 PIN('B', 0) // On-board LED pin (green) +#define LED2 PIN('E', 1) // On-board LED pin (yellow) +#define LED3 PIN('B', 14) // On-board LED pin (red) + +#define LED LED2 // Use yellow LED for blinking + // System clock (2.1, Figure 1; 8.5, Figure 45; 8.5.5, Figure 47; 8.5.6, Figure // 49) CPU_FREQUENCY <= 480 MHz; hclk = CPU_FREQUENCY / HPRE ; hclk <= 240 MHz; // APB clocks <= 120 MHz. D1 domain bus matrix (and so flash) runs at hclk @@ -153,6 +159,21 @@ static inline char chiprev(void) { return '?'; } +static inline void ethernet_init(void) { + // Initialise Ethernet. Enable MAC GPIO pins, see + // https://www.st.com/resource/en/user_manual/um2407-stm32h7-nucleo144-boards-mb1364-stmicroelectronics.pdf + uint16_t pins[] = {PIN('A', 1), PIN('A', 2), PIN('A', 7), + PIN('B', 13), PIN('C', 1), PIN('C', 4), + PIN('C', 5), PIN('G', 11), PIN('G', 13)}; + for (size_t i = 0; i < sizeof(pins) / sizeof(pins[0]); i++) { + gpio_init(pins[i], GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_INSANE, + GPIO_PULL_NONE, 11); // 11 is the Ethernet function + } + NVIC_EnableIRQ(ETH_IRQn); // Setup Ethernet IRQ handler + SETBITS(SYSCFG->PMCR, 7 << 21, 4 << 21); // Use RMII (12.3.1) + RCC->AHB1ENR |= BIT(15) | BIT(16) | BIT(17); // Enable Ethernet clocks +} + #define UUID ((uint8_t *) UID_BASE) // Unique 96-bit chip ID. TRM 61.1 // Helper macro for MAC generation diff --git a/examples/stm32/nucleo-h743zi-baremetal/link.ld b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/link.ld similarity index 100% rename from examples/stm32/nucleo-h743zi-baremetal/link.ld rename to examples/stm32/nucleo-h743zi-make-baremetal-builtin/link.ld diff --git a/examples/stm32/nucleo-h743zi-baremetal/main.c b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/main.c similarity index 70% rename from examples/stm32/nucleo-h743zi-baremetal/main.c rename to examples/stm32/nucleo-h743zi-make-baremetal-builtin/main.c index 432000d2..13c51fbc 100644 --- a/examples/stm32/nucleo-h743zi-baremetal/main.c +++ b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/main.c @@ -5,11 +5,6 @@ #include "mongoose.h" #include "net.h" -#define LED1 PIN('B', 0) // On-board LED pin (green) -#define LED2 PIN('E', 1) // On-board LED pin (yellow) -#define LED3 PIN('B', 14) // On-board LED pin (red) - -#define LED LED2 // Use blue LED for blinking #define BLINK_PERIOD_MS 1000 // LED blinking period in millis static volatile uint64_t s_ticks; // Milliseconds since boot @@ -37,21 +32,6 @@ static void timer_fn(void *arg) { ifp->ndrop, ifp->nerr)); } -static void ethernet_init(void) { - // Initialise Ethernet. Enable MAC GPIO pins, see - // https://www.st.com/resource/en/user_manual/um2407-stm32h7-nucleo144-boards-mb1364-stmicroelectronics.pdf - uint16_t pins[] = {PIN('A', 1), PIN('A', 2), PIN('A', 7), - PIN('B', 13), PIN('C', 1), PIN('C', 4), - PIN('C', 5), PIN('G', 11), PIN('G', 13)}; - for (size_t i = 0; i < sizeof(pins) / sizeof(pins[0]); i++) { - gpio_init(pins[i], GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_INSANE, - GPIO_PULL_NONE, 11); // 11 is the Ethernet function - } - NVIC_EnableIRQ(ETH_IRQn); // Setup Ethernet IRQ handler - SETBITS(SYSCFG->PMCR, 7 << 21, 4 << 21); // Use RMII (12.3.1) - RCC->AHB1ENR |= BIT(15) | BIT(16) | BIT(17); // Enable Ethernet clocks -} - int main(void) { gpio_output(LED); // Setup green LED uart_init(UART_DEBUG, 115200); // Initialise debug printf diff --git a/examples/stm32/nucleo-h743zi-baremetal/mongoose.c b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/mongoose.c similarity index 100% rename from examples/stm32/nucleo-h743zi-baremetal/mongoose.c rename to examples/stm32/nucleo-h743zi-make-baremetal-builtin/mongoose.c diff --git a/examples/stm32/nucleo-h743zi-baremetal/mongoose.h b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/mongoose.h similarity index 100% rename from examples/stm32/nucleo-h743zi-baremetal/mongoose.h rename to examples/stm32/nucleo-h743zi-make-baremetal-builtin/mongoose.h diff --git a/examples/stm32/nucleo-h743zi-baremetal/net.c b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/net.c similarity index 100% rename from examples/stm32/nucleo-h743zi-baremetal/net.c rename to examples/stm32/nucleo-h743zi-make-baremetal-builtin/net.c diff --git a/examples/stm32/nucleo-h743zi-baremetal/net.h b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/net.h similarity index 100% rename from examples/stm32/nucleo-h743zi-baremetal/net.h rename to examples/stm32/nucleo-h743zi-make-baremetal-builtin/net.h diff --git a/examples/stm32/nucleo-h743zi-baremetal/packed_fs.c b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/packed_fs.c similarity index 100% rename from examples/stm32/nucleo-h743zi-baremetal/packed_fs.c rename to examples/stm32/nucleo-h743zi-make-baremetal-builtin/packed_fs.c diff --git a/examples/stm32/nucleo-h743zi-baremetal/syscalls.c b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/syscalls.c similarity index 100% rename from examples/stm32/nucleo-h743zi-baremetal/syscalls.c rename to examples/stm32/nucleo-h743zi-make-baremetal-builtin/syscalls.c diff --git a/examples/stm32/nucleo-h743zi-baremetal/sysinit.c b/examples/stm32/nucleo-h743zi-make-baremetal-builtin/sysinit.c similarity index 100% rename from examples/stm32/nucleo-h743zi-baremetal/sysinit.c rename to examples/stm32/nucleo-h743zi-make-baremetal-builtin/sysinit.c diff --git a/examples/stm32/stm32-nucleo-f429z/Makefile b/examples/stm32/stm32-nucleo-f429z/Makefile deleted file mode 100644 index e067c811..00000000 --- a/examples/stm32/stm32-nucleo-f429z/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -NAME ?= $(notdir $(CURDIR)) - -$(NAME): - git clone --depth 1 https://github.com/mongoose-examples/$(NAME) - -build: | $(NAME) - cp ./../../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/ - make -C $(NAME) build - -clean: - rm -rf $(NAME) - -flash: - make -C $(NAME) flash - -.PHONY: flash - diff --git a/examples/stm32/stm32-nucleo-f746z/Makefile b/examples/stm32/stm32-nucleo-f746z/Makefile deleted file mode 100644 index e067c811..00000000 --- a/examples/stm32/stm32-nucleo-f746z/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -NAME ?= $(notdir $(CURDIR)) - -$(NAME): - git clone --depth 1 https://github.com/mongoose-examples/$(NAME) - -build: | $(NAME) - cp ./../../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/ - make -C $(NAME) build - -clean: - rm -rf $(NAME) - -flash: - make -C $(NAME) flash - -.PHONY: flash - diff --git a/examples/stm32/stm32-nucleo-f746zg/Makefile b/examples/stm32/stm32-nucleo-f746zg/Makefile deleted file mode 100644 index a6d5a013..00000000 --- a/examples/stm32/stm32-nucleo-f746zg/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -NAME ?= $(notdir $(CURDIR)) - -$(NAME): - git clone --depth 1 https://github.com/mongoose-examples/$(NAME) - -build: | $(NAME) - cp ./../../../mongoose.c $(NAME)/Core/Src/ - cp ./../../../mongoose.h $(NAME)/Core/Inc/ - make -C $(NAME) build - -clean: - rm -rf $(NAME) - -flash: - make -C $(NAME) flash - -.PHONY: flash - diff --git a/examples/stm32/stm32-nucleo-h743z/Makefile b/examples/stm32/stm32-nucleo-h743z/Makefile deleted file mode 100644 index 92b4174e..00000000 --- a/examples/stm32/stm32-nucleo-h743z/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -NAME ?= $(notdir $(CURDIR)) - -build: - git clone --depth 1 https://github.com/mongoose-examples/$(NAME) - cp ./../../../mongoose.[ch] $(NAME)/Middlewares/Third_Party/Mongoose/ - make -C $(NAME) build - -clean: - rm -rf $(NAME) diff --git a/examples/stm32/stm32-nucleo-h743z/README.md b/examples/stm32/stm32-nucleo-h743z/README.md deleted file mode 100644 index 0d7f36ba..00000000 --- a/examples/stm32/stm32-nucleo-h743z/README.md +++ /dev/null @@ -1 +0,0 @@ -See detailed tutorial at https://mongoose.ws/tutorials/stm32/stm32-nucleo-h743z/