Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32H743XX HIC #966

Merged
merged 14 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/hic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ Support for these HICs has been recently added.
|-------------------------------|:----:|--------:|-------:|-------:|:---:|
| [stm32f072x8](stm32f072xx.md) | M0 | 48 Mhz | 16 KB | 64 KB | FS |
| [stm32f072xb](stm32f072xx.md) | M0 | 48 Mhz | 16 KB | 128 KB | FS |
| [stm32h743xx](stm32h743xx.md) | M7 | 480 Mhz | 1 MB | 2 MB | HS |
50 changes: 50 additions & 0 deletions docs/hic/stm32h743xx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# stm32h743xx HIC

Based on STM32H743IIK6TR chip ([Datasheet](https://www.st.com/resource/en/datasheet/stm32h743ii.pdf)):
- Cortex-M7 480 Mhz
- 2 MBytes Flash
- 1 MByte RAM
- High-speed USB 2.0 device controller: up to 9 bi-directional endpoints including EP0 (*)
- UFBGA176+25 packaging

(*) "main features in peripheral-mode are the following: 1 bidirectional control endpoint0, 8 IN endpoints (EPs) configurable to support bulk, interrupt or isochronous transfers, 8 OUT endpoints configurable to support bulk, interrupt or isochronous transfers" (source: [RM0433](https://www.st.com/resource/en/reference_manual/rm0433-stm32h742-stm32h743753-and-stm32h750-value-line-advanced-armbased-32bit-mcus-stmicroelectronics.pdf))

## Memory Map

| Region | Size | Start | End |
|----------|--------|-------------|-------------|
| Flash | 2048 KB| 0x0800_0000 | 0x1FF0_0000 |
| DTCM | 128 KB | 0x2000_0000 | 0x2400_0000 |
| AXI-SRAM | 384 KB | 0x2400_0000 | 0x3000_0000 |
| SRAM1 | 32 KB | 0x3000_0000 | 0x3002_0000 |
| SRAM2 | 16 KB | 0x3002_0000 | 0x3800_0000 |
| SRAM4 | 64 KB | 0x3800_0000 | 0x3880_0000 |

Bootloader size is 128 KB

## DAPLink default pin assignment

| Signal | I/O | Symbol | Pin |
|-------------|:---:|---------|:---:|
| SWD / JTAG |
| SWCLK / TCK | O | PD7 | 56 |
| SWDIO / TMS | I/O | PD2 | 51 |
| SWO / TDO | I | PB7 | 24 |
| nRESET | O | PB0 | 17 |
| UART |
| UART RX | I | PD9 | 58 |
| UART TX | O | PD8 | 57 |
| Button |
| NF-RST But. | I | PI4 | 132 |
| LEDs |
| Connect. LED| O | PG0 | 96 |
| HID LED | O | PG2 | 98 |
| CDC LED | O | PG3 | 99 |
| MSC LED | O | PG4 | 100 |

## UDB (Universal Debug Board) Additions
UDB is a special flavor of the stm32h743xx HIC, which enriches the DAPLink experience with additional features such as:
- A new USB CDC endpoint to flash and get logs from a second target.
- Another new USB CDC endpoint to interact with the HIC. Users can send easy shell commands to toggle pins, or to get any info from the HIC.
- Additional DAPLink debugging functionality: persistent fault info, breakpoints on asserts when debugger is connected to debug UDB, watchdog, backtraces
- Target power measurement
23 changes: 23 additions & 0 deletions projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ module:
- records/rtos/rtos-cm3.yaml
- records/hic_hal/stm32f103xb.yaml
- records/usb/usb-hid.yaml
hic_stm32h743xx: &module_hic_stm32h743xx
- records/rtos/rtos-cm4.yaml
- records/hic_hal/stm32h743xx.yaml
- records/usb/usb-hid.yaml

projects:
# HIC bootloaders and all target interfaces
Expand Down Expand Up @@ -220,6 +224,16 @@ projects:
- *module_hic_stm32f103xb
- records/family/all_family.yaml
- records/usb/usb-bulk.yaml
stm32h743xx_bl: &stm32h743xx_bl
- *module_bl
- records/hic_hal/stm32h743xx.yaml
- records/board/stm32h743xx_bl.yaml
stm32h743xx_if: &stm32h743xx_if
- *module_if
- *module_hic_stm32h743xx
- records/family/all_family.yaml
- records/usb/usb-bulk.yaml


# Other projects
k20dx_ep_agora_if:
Expand Down Expand Up @@ -618,6 +632,15 @@ projects:
- *module_if
- *module_hic_stm32f103xb
- records/board/ublox_evk_odin_w2.yaml
stm32h743xx_udb_bl:
- *stm32h743xx_bl
- records/board/stm32h743xx_udb_bl.yaml
stm32h743xx_udb_if:
- *module_if
- *module_hic_stm32h743xx
- records/family/all_family.yaml
- records/usb/usb-bulk.yaml
- records/board/stm32h743xx_udb_if.yaml # extends DAPLink with additional features for the UDB project


# Test projects
Expand Down
4 changes: 4 additions & 0 deletions records/board/stm32h743xx_bl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
common:
sources:
board:
- source/board/stm32h743xx_bl.c
12 changes: 12 additions & 0 deletions records/board/stm32h743xx_udb_bl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
common:
macros:
- UDB
includes:
- source/board/udb/include/udb_version.h
sources:
hic_hal:
- source/board/udb/source/udb_version.c
tool_specific:
gcc_arm:
linker_file:
- source/board/udb/include/udb.ld
30 changes: 30 additions & 0 deletions records/board/stm32h743xx_udb_if.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
common:
macros:
# Add DAPLink macros below
- MAIN_TASK_STACK=2048
# - DAPLINK_BOOTLOADER_UPDATE
- ASSERT_BUF_SIZE=65
- USB_CDC_ACM_EP_COUNT=3
- OVERRIDE_USB2UART
- DISABLE_DRAG_N_DROP
# Add UDB config macros below
- UDB
- SUPPORT_CMD_HISTORY
- NLUIF_PRINT_RESULT
# Add build feature macros below
- BUILD_FEATURE_UDB_ASSERT
includes:
# - projectfiles/make_gcc_arm/stm32h743xx_udb_bl/build/bootloader_image.c
- source/board/udb/console/include
- source/board/udb/include
- source/board/udb/lib/nlbacktrace/include
- source/board/udb/lib/nlutilities/include
sources:
board:
- source/board/stm32h743xx.c
hic_hal:
- source/board/udb/console/source
- source/board/udb/lib/nlbacktrace/source
- source/board/udb/lib/nlutilities/source
- source/board/udb/source
- source/board/udb/usb
66 changes: 66 additions & 0 deletions records/hic_hal/stm32h743xx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
common:
target:
- Cortex-M7
core:
- Cortex-M7
macros:
- INTERFACE_STM32H743
- USE_HAL_DRIVER
- STM32H743xx
- DAPLINK_HIC_ID=0x97969940 # DAPLINK_HIC_ID_STM32H743II
- __packed=__packed # Prevent redefinition of __packed with ARMCC
- DAPLINK_NO_ASSERT_FILENAMES
- OS_CLOCK=240000000
- OS_ROBIN_ENABLE=1
- SECTOR_BUFFER_SIZE=32 # this is a small write buffer used in settings_rom.c
- DAPLINK_RELOCATE_SECTOR_BUF # this is relocating another sector buffer in iap_flash_intf.c which has to hold an entire sector and doesn't fit into our default DTCM RAM
includes:
- source/hic_hal/stm32/hal/STM32H7xx_HAL_Driver
- source/hic_hal/stm32/hal/STM32H7xx_HAL_Driver/Inc
- source/hic_hal/stm32/stm32h743xx
- source/hic_hal/stm32/stm32h743xx/cmsis

sources:
hic_hal:
- source/hic_hal/stm32/hal/STM32H7xx_HAL_Driver/Src
- source/hic_hal/stm32/stm32h743xx
- source/hic_hal/stm32/stm32h743xx/cmsis

tool_specific:
uvision:
misc:
ld_flags:
- --predefine="-I..\..\..\source\hic_hal\stm32\stm32h743xx"
c_flags:
- --no_unaligned_access
cxx_flags:
- --no_unaligned_access
asm_flags:
- --no_unaligned_access
sources:
hic_hal:
- source/hic_hal/stm32/stm32h743xx/armcc
armcc:
misc:
ld_flags:
- --predefine="-Isource/hic_hal/stm32/stm32h743xx"
c_flags:
- --no_unaligned_access
cxx_flags:
- --no_unaligned_access
asm_flags:
- --no_unaligned_access
sources:
hic_hal:
- source/hic_hal/stm32/stm32h743xx/armcc
gcc_arm:
misc:
ld_flags:
# for some reason GCC links in the non-thumb version,
# so need to manually tell it to use the right one
- -L /usr/lib/arm-none-eabi/newlib/thumb/
sources:
hic_hal:
- source/hic_hal/stm32/stm32h743xx/gccarm
linker_file:
- source/hic_hal/stm32/stm32h743xx/stm32h743xx.ld
166 changes: 166 additions & 0 deletions source/board/stm32h743xx.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
/**
* @file stm32h743xx.c
* @brief board ID for the STM32 NUCLEO-F103RB board
*
* DAPLink Interface Firmware
* Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "target_family.h"
#include "target_board.h"
#include <stdio.h>

#ifdef UDB
#include "i2c.h"
#include "udb_version.h"
#include "udb_extended_features_task.h"
#include "udb_power_measurement.h"
#include "udb_log.h"
#include "udb_version.h"
#include "nluif_udb-daplink.h"
#include "util.h"
#include "udb_fault_info.h"
#include "udb_watchdog.h"
#include "udb_fault_info.h"
#include "udb_uptime.h"

#define UDB_WATCHDOG_TIMEOUT_S (10U)

#define UDB_30MS_MULTIPLIER_TO_30SEC (1000)
#define UDB_30MS_MULTIPLIER_TO_10MIN (1000 * 20)

#define UDB_LED_30MS_MULTIPLER_NORMAL (50ULL)
#define UDB_LED_30MS_MULTIPLER_UNCLEARED_FAULT_INFO (5ULL)

#ifdef UDB_DEBUG
#define UDB_CHECK_FAULT_INFO_TARGET_COUNT UDB_30MS_MULTIPLIER_TO_30SEC
#else
#define UDB_CHECK_FAULT_INFO_TARGET_COUNT UDB_30MS_MULTIPLIER_TO_10MIN
#endif

static uint64_t s_30ms_hook_counter = 0;
static uint64_t s_connected_led_blink_period = UDB_LED_30MS_MULTIPLER_NORMAL;

extern void udb_config_init(void);

static void udb_welcome_message(void)
{
char ver_buf[UDB_VERSION_MAX_LENGTH];

printf("Welcome to\n");
printf("\t ______ ______ \n");
printf("\t|\\ /|( __ \\ ( ___ \\ \n");
printf("\t| ) ( || ( \\ )| ( ) ) \n");
printf("\t| | | || | ) || (__/ / \n");
printf("\t| | | || | | || __ ( \n");
printf("\t| | | || | ) || ( \\ \\ \n");
printf("\t| (___) || (__/ )| )___) ) \n");
printf("\t(_______)(______/ |/ \\___/ \n\n");

udb_get_interface_version((uint8_t*)ver_buf, UDB_VERSION_MAX_LENGTH);
printf("Interface version: %s\n", ver_buf);
udb_get_bootloader_version((uint8_t*)ver_buf, UDB_VERSION_MAX_LENGTH);
printf("Bootloader version: %s\n", ver_buf);

printf("To know more about udb, visit go/udb.\n");
printf("Please report issues at go/udb-bug.\n");
printf("You can start typing commands.\n");

uif_prompt();
}

static void prerun_board_config(void)
{
int status;

udb_uptime_init();

status = i2c_init();
util_assert(status == UDB_SUCCESS);

udb_read_hw_version();
udb_config_init();

udb_extended_features_task_create();

status = udb_power_measurement_init();
util_assert(status == UDB_SUCCESS);

udb_check_unexpected_watchdog_reset();
}

void board_30ms_hook()
{
udb_uptime_update();
if (udb_is_fault_info_uncleared())
{
s_connected_led_blink_period = UDB_LED_30MS_MULTIPLER_UNCLEARED_FAULT_INFO;
}
else
{
s_connected_led_blink_period = UDB_LED_30MS_MULTIPLER_NORMAL;
}

if (s_30ms_hook_counter == 0)
{
// Code that needs to run once after the bootloader update and all other
// initialization finished

udb_watchdog_init(UDB_WATCHDOG_TIMEOUT_S);
udb_welcome_message();
}

udb_watchdog_refresh();

if ((s_30ms_hook_counter % s_connected_led_blink_period) == 0)
{
HAL_GPIO_TogglePin( CONNECTED_LED_PORT, CONNECTED_LED_PIN);
}

if (((s_30ms_hook_counter % UDB_CHECK_FAULT_INFO_TARGET_COUNT) == 0) && udb_is_fault_info_uncleared())
{
udb_print_fault_info();
}

if (udb_log_cdc_ready())
{
udb_log_flush();
}

s_30ms_hook_counter++;
}
#endif // UDB

// return non-zero value to make all image incompatible
uint8_t board_detect_incompatible_image(const uint8_t *data, uint32_t size)
{
return 1;
}

const board_info_t g_board_info =
{
.info_version = kBoardInfoVersion,
.board_id = "0000",
.family_id = kStub_HWReset_FamilyID,
.daplink_drive_name = "DAPLINK_APP",
.prerun_board_config = prerun_board_config,
// TODO(https://github.com/ARMmbed/DAPLink/issues/963):
// MSC sometimes fails for unknown reason.
// Disable mass storage as a workaround temporarily.
#if 0
.target_cfg = &target_device,
#endif
};
Loading
Loading