summaryrefslogtreecommitdiff
path: root/hw/bsp
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-09-29 15:32:08 +0700
committerhathach <[email protected]>2025-09-29 15:32:08 +0700
commitbdd557caf14b8987729fd73f11ccef7a29e7045d (patch)
tree881b6aa1361903e6d75a465e55b109468bfd86ab /hw/bsp
parent4f3a5f92fa21307b1f1c9700cd041e945a627f63 (diff)
parent5130850337c1e8e0eedfa2d7165413de27ff6d2f (diff)
Merge branch 'master' into fork/ennebi/mtp
Diffstat (limited to 'hw/bsp')
-rw-r--r--hw/bsp/board.c20
-rw-r--r--hw/bsp/board_api.h16
-rw-r--r--hw/bsp/espressif/boards/family.c14
-rw-r--r--hw/bsp/rp2040/family.c8
4 files changed, 43 insertions, 15 deletions
diff --git a/hw/bsp/board.c b/hw/bsp/board.c
index 1ba5a1b9d..e141664da 100644
--- a/hw/bsp/board.c
+++ b/hw/bsp/board.c
@@ -141,6 +141,26 @@ __strong_reference(stdin, stderr);
#endif
//--------------------------------------------------------------------+
+// Weak board API (to be optionally implemented by board)
+//--------------------------------------------------------------------+
+TU_ATTR_WEAK size_t board_get_unique_id(uint8_t id[], size_t max_len) {
+ (void) max_len;
+ // fixed serial string is 01234567889ABCDEF
+ uint32_t* uid32 = (uint32_t*) (uintptr_t)id;
+ uid32[0] = 0x67452301;
+ uid32[1] = 0xEFCDAB89;
+ return 8;
+}
+
+TU_ATTR_WEAK void board_init_after_tusb(void) {
+ // nothing to do
+}
+
+TU_ATTR_WEAK void board_reset_to_bootloader(void) {
+ // not implemented
+}
+
+//--------------------------------------------------------------------+
// Board API
//--------------------------------------------------------------------+
int board_getchar(void) {
diff --git a/hw/bsp/board_api.h b/hw/bsp/board_api.h
index 328fe9363..5ecd7797a 100644
--- a/hw/bsp/board_api.h
+++ b/hw/bsp/board_api.h
@@ -72,10 +72,10 @@ extern "C" {
void board_init(void);
// Init board after tinyusb is initialized
-void board_init_after_tusb(void) TU_ATTR_WEAK;
+void board_init_after_tusb(void);
// Jump to bootloader
-void board_reset_to_bootloader(void) TU_ATTR_WEAK;
+void board_reset_to_bootloader(void);
// Turn LED on or off
void board_led_write(bool state);
@@ -89,7 +89,7 @@ void board_led_write(bool state);
uint32_t board_button_read(void);
// Get board unique ID for USB serial number. Return number of bytes. Note max_len is typically 16
-TU_ATTR_WEAK size_t board_get_unique_id(uint8_t id[], size_t max_len);
+size_t board_get_unique_id(uint8_t id[], size_t max_len);
// Get characters from UART. Return number of read bytes
int board_uart_read(uint8_t *buf, int len);
@@ -152,15 +152,7 @@ static inline size_t board_usb_get_serial(uint16_t desc_str1[], size_t max_chars
size_t uid_len;
// TODO work with make, but not working with esp32s3 cmake
- if ( board_get_unique_id ) {
- uid_len = board_get_unique_id(uid, sizeof(uid));
- }else {
- // fixed serial string is 01234567889ABCDEF
- uint32_t* uid32 = (uint32_t*) (uintptr_t) uid;
- uid32[0] = 0x67452301;
- uid32[1] = 0xEFCDAB89;
- uid_len = 8;
- }
+ uid_len = board_get_unique_id(uid, sizeof(uid));
if ( uid_len > max_chars / 2 ) uid_len = max_chars / 2;
diff --git a/hw/bsp/espressif/boards/family.c b/hw/bsp/espressif/boards/family.c
index 2a5deed26..a837417f4 100644
--- a/hw/bsp/espressif/boards/family.c
+++ b/hw/bsp/espressif/boards/family.c
@@ -49,7 +49,7 @@ static led_strip_handle_t led_strip;
static void max3421_init(void);
#endif
-#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4)
+#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4, OPT_MCU_ESP32P4)
static bool usb_init(void);
#endif
@@ -105,7 +105,7 @@ void board_init(void) {
#endif
}
-#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
+#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4)
#endif
@@ -160,11 +160,19 @@ void board_putchar(int c) {
putchar(c);
}
+void board_init_after_tusb(void) {
+ // nothing to do
+}
+
+void board_reset_to_bootloader(void) {
+ // not implemented
+}
+
//--------------------------------------------------------------------
// PHY Init
//--------------------------------------------------------------------
-#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4)
+#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4, OPT_MCU_ESP32P4)
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
#include "esp_private/usb_phy.h"
diff --git a/hw/bsp/rp2040/family.c b/hw/bsp/rp2040/family.c
index a22924131..989140e02 100644
--- a/hw/bsp/rp2040/family.c
+++ b/hw/bsp/rp2040/family.c
@@ -286,6 +286,14 @@ void board_putchar(int c) {
stdio_putchar(c);
}
+void board_init_after_tusb(void) {
+ // nothing to do
+}
+
+void board_reset_to_bootloader(void) {
+ // not implemented
+}
+
//--------------------------------------------------------------------+
// USB Interrupt Handler
// rp2040 implementation will install appropriate handler when initializing