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

STM32H743XX HIC #966

merged 14 commits into from
Aug 4, 2023

Conversation

gaborcsapo
Copy link

Hi, please find below the changes for the STM32H743XX HIC that we've been working on. There is also an extension of of the usual DAPLink code in the "source/hic_hal/stm32/stm32h743ii/extended_features" folder which are used by the UDB (Universal Debug Board) stm32h743ii HIC. The additional features include:

  • 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

Let me know how you'd like to review these changes. We touched the common code only to fix bugs and to change USB CDC stack to support 3 endpoints. If needed, I can give a demo of the UDB features.

@mathias-arm
Copy link
Collaborator

Hi @gaborcsapo, this pull-request needs to simplified. One of the first step would be to rebase the branch to remove all duplicated commits (due merge from main/develop or cherry-picked). Second step would be to re-group and possibly squash commits into different categories:

  • Changes that modify existing code / other HIC
  • Adding stm32h743ii HIC (generic part)
  • Adding UDB board source (source/hic_hal/stm32/stm32h743ii/extended_features should probably be source/board/udb) and tests.

@gaborcsapo
Copy link
Author

@mathias-arm, finished with cleanup. I hope this is what you meant.

@gaborcsapo
Copy link
Author

Hey, any updates on the review?

mathias-arm and others added 14 commits August 4, 2023 17:01
From MDKCM525.EXE (https://www2.keil.com/mdk5/legacy)
% shasum -a 256 ARM/RL/USB/Drivers/usbd_STM32F4xx_FS.c ARM/RL/USB/Drivers/usbd_STM32F4xx_HS.c
ee5c4f8eb7b5f11bcb6405420da39c5e69d5d77977c720b548ed2a6d5f836844  ARM/RL/USB/Drivers/usbd_STM32F4xx_FS.c
85cbce361c4e3ffec2c067a92d17b67f747e2934353337e1f940adf987286d7f  ARM/RL/USB/Drivers/usbd_STM32F4xx_HS.c
dos2unix + add Apache 2.0 license header (OSO #81216531)
If any future HICs want multiple CDC EPs, they can just follow the example of the stm32h743xx
HIC's UDB flavour.

These are the overall steps to add new CDC EPs:
- define OVERRIDE_USB2UART to disable default usb2uart.yaml
- define USB_CDC_ACM_EP_COUNT to the desired number
- make sure the HIC's USB driver can support multiple CDCs
- add the CDC EP definitions to the HIC's USB config
- define the user code that uses the new CDC EPs' data

Co-authored-by: Yangte Chen <[email protected]>
Co-authored-by: Eric Lee <[email protected]>
Co-authored-by: Yangte Chen <[email protected]>
Co-authored-by: Eric Lee <[email protected]>
UDB 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

For more details see the source/board/udb folder.

Co-authored-by: Yangte Chen <[email protected]>
Co-authored-by: Eric Lee <[email protected]>
…UDB flavour

Fixes include:
- intercept_page_write had a bad return value logic that didn't work if the update had a one sector size. The stm32h743 has large sectors, which fit the bootloader in one sector.
- in sync_assert_usb_thread, the referenced issue was causing intermittent assert and on UDB assert cause a reset to avoid going undetected.
- add ability for HIC's to define custom ASSERT_BUF_SIZE
- added a note to interface_image_valid for future devs who try to enable bootloader update and flash their test HIC from the elf file
- make _util_assert WEAK so that HIC's can define their own assert behaviour
- replace yaml.load with safe_load
- added add_macro_to_record.py. Can be used for example by build scripts to add production flags

Co-authored-by: Yangte Chen <[email protected]>
Co-authored-by: Eric Lee <[email protected]>
…flavour

UDB has a number of custom features that need to be tested before any UDB FW or HW release.

## How to run the tests?
All test are stadalone with no additional hardware setup required. Run these quick tests before committing changes.

Setup using: `python3 -m pip install -r "{path_to_test_folder}/requirements.txt"`.
Then run: `python udb_test_main.py --test_bin_path {path-to-binary-running-on-device-that-you-want-test} --dummy_bin_path {path-to-binary-that-has-a-different-version-from-the-test-image} --serial_port_path {path-to-serial-port}`
Example with full paths: `python source/hic_hal/stm32/stm32h743ii/extended_features/test/udb_test_main.py --test_bin_path ~/Downloads/test_0.12_local_stm32h743ii_udb_if_crc.bin --dummy_bin_path ~/Downloads/old_0.11_udb_stm32h743ii_if_crc.bin --serial_port_path /dev/serial/by-id/usb-Arm_DAPLink_CMSIS-DAP_00000081004400413330511331373438a5a5a5a597969940-if02`
You can additionally add -d for detailed logs and --run-all to run tests that require special attention.

## How to add new tests?
The test suite uses the standard python unittest library with the same standards. Add your tests to the test/udb_integration_test/tests folder. Each test needs to extend the TestCase class or a subclass of it. You can use any of the udb devices that are implemented to make it easier to talk to UDB through DAP, serial or the file system.

Before submitting your changes run mypy on the tests for type checking. Some libaries might have errors, but the test suite should have none.

Co-authored-by: Yangte Chen <[email protected]>
Co-authored-by: Eric Lee <[email protected]>
TODO(ARMmbed#963):
MSC sometimes fails for unknown reason on stm32h743. We disabled mass
storage as a workaround for it earlier. Repalce the previous UDB flag
with sth more generic. This is only an issue for UDB because UDB is
configured to crash on asserts.
Reduce the reserved space for the interface to 2 sectors so that the
total size becomes 512kB. There are some stm32h743 chips which have only
512kB flash, so this way we can support those. Luckily the even the UDB
IF fits into 2 sectors.
Execute out of DTCM and put the sector_buf named 128kB buffer into
AXI-SRAM because there isn't enough space in DTCM. This change should
make execution faster.
…eric HIC

The UDB IF needs to know the UDB BL version. This version is different
from the DAPLINK_VERSION, it is a string that contains info about the
last git commit, local modifications and can be injected through a CI
pipeline.

However, this doesn't need to be in the generic STM32H743xx HIC and this
frees up additional flash.
This function is called frequently during DAP transactions and the
original implementation in the HAL loops through all the pins to arrive
at the one it wants to change.

Optimize the loop into a simple calculation to find the corrent bit
position to change.
Just adding some changes that happened earlier in the UDB code. No
impact on DAPLink.
@mathias-arm mathias-arm merged commit beb5984 into ARMmbed:develop Aug 4, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants