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

STM32H7A3ZI: Flash verification fails if UART/USART interface is enabled #1249

Closed
5 tasks done
EmanueleGiacomini opened this issue May 18, 2022 · 10 comments
Closed
5 tasks done

Comments

@EmanueleGiacomini
Copy link

EmanueleGiacomini commented May 18, 2022

  • Programmer/board type: [STLINK V3]
  • Operating system an version: [Linux]
  • stlink tools version and/or git commit hash: [v1.7.0-195-g951859c]
  • stlink commandline tool name: [st-flash]
  • Target chip (and board, if applicable): [STM32H7A3ZI (Nucleo-H7A3ZI-Q)]

Further we kindly ask you to describe the detected problem as detailed as possible and to add debug output if available, by using the following template:

Commandline output:

$st-flash --reset write build/h7a3zi_test.bin 0x08000000

st-flash 1.7.0-195-g951859c
Failed to parse flash type or unrecognized flash type
2022-05-18T11:23:19 INFO common.c: STM32H7Ax_H7Bx: 128 KiB SRAM, 2048 KiB flash in at least 8 KiB pages.
file build/h7a3zi_test.bin md5 checksum: f56fd507ca1329599bac3afb7c645, stlink checksum: 0x00152999
2022-05-18T11:23:19 INFO common_flash.c: Attempting to write 13832 (0x3608) bytes to stm32 address: 134217728 (0x8000000)
-> Flash page at 0x8000000 erased (size: 0x2000)
-> Flash page at 0x8002000 erased (size: 0x2000)

2022-05-18T11:23:19 INFO flashloader.c: Starting Flash write for H7
13832/13832 bytes written
2022-05-18T11:23:19 INFO common_flash.c: Starting verification of write complete
2022-05-18T11:23:19 ERROR common_flash.c: Verification of flash failed at offset: 6144
stlink_fwrite_flash() == -1

Expected/description:
While testing the board, we noticed that st-flash fails during the verification phase if a UART/USART interface is enabled through STM32CubeMX.
By flashing the same build with STM32CubeProgrammer, no issues appears during the write and the verification phases.

The code is fully generated by STM32CubeMX with a small addition by ours to transmit a sample text on USART3 every 100 ms

We replicated this behavior on two different machines (Pop!_OS 20.04 on Intel i7-9850H and Ubuntu 20.04.4 on Intel i7-7700HQ)

@Ant-ON
Copy link
Collaborator

Ant-ON commented May 18, 2022

@EmanueleGiacomini Can you try use connect under reset?
st-flash --connect-under-reset --reset write build/h7a3zi_test.bin 0x08000000

@EmanueleGiacomini
Copy link
Author

EmanueleGiacomini commented May 18, 2022

@EmanueleGiacomini Can you try use connect under reset? st-flash --connect-under-reset --reset write build/h7a3zi_test.bin 0x08000000

We've just tested but the output seems unchanged

$st-flash --connect-under-reset --reset write build/h7a3zi_test.bin 0x08000000
st-flash 1.7.0-195-g951859c
Failed to parse flash type or unrecognized flash type
2022-05-18T12:30:40 INFO common.c: STM32H7Ax_H7Bx: 128 KiB SRAM, 2048 KiB flash in at least 8 KiB pages.
file build/h7a3zi_test.bin md5 checksum: f56fd507ca1329599bac3afb7c645, stlink checksum: 0x00152999
2022-05-18T12:30:40 INFO common_flash.c: Attempting to write 13832 (0x3608) bytes to stm32 address: 134217728 (0x8000000)
-> Flash page at 0x8000000 erased (size: 0x2000)
-> Flash page at 0x8002000 erased (size: 0x2000)

2022-05-18T12:30:40 INFO flashloader.c: Starting Flash write for H7
13832/13832 bytes written
2022-05-18T12:30:40 INFO common_flash.c: Starting verification of write complete
2022-05-18T12:30:40 ERROR common_flash.c: Verification of flash failed at offset: 6144
stlink_fwrite_flash() == -1

Edit: If it can be of help, we have the same issue on another project which wrote and verified on STM32H723ZG (Nucleo-H723ZG). After a porting on the current board, we started facing this issue.

@Nightwalker-87
Copy link
Member

@defyingphysics Please also take a look at #1184. Thanks.
It is yet unclear if there is a connection between current H7-related issues.
We need to investigate.

@Nightwalker-87 Nightwalker-87 changed the title [STM32H7A3ZI]: Flash verification fails if UART/USART interface is enabled STM32H7A3ZI: Flash verification fails if UART/USART interface is enabled Jan 6, 2023
@Ant-ON
Copy link
Collaborator

Ant-ON commented Jan 7, 2023

@Nightwalker-87 Used correct value of cmp_size. There not is a significant difference between comparing by a page or a part of page.

It's strange that UART affects. Perhaps UART used together with DMA. DMA clocking must be disabled in RCC (perhaps something is not working correctly...):

case STM32_FLASH_TYPE_H7:
rcc = STM32H7_RCC_AHB1ENR;
rcc_dma_mask = STM32H7_RCC_DMAEN;
break;

@Nightwalker-87
Copy link
Member

@Ant-ON I see. Can you check with applicable (maybe not the same) hardware?
What do you have available BTW? I do have a STM32VL Discovery Board, a self equipped STM32F103 Bluepill (so no-fake chip!) and a Blackpill-Board, but they do not appear to be helpful here due to their device families.

@defyingphysics
Copy link

@defyingphysics Please also take a look at #1184. Thanks. It is yet unclear if there is a connection between current H7-related issues. We need to investigate.

Left a message on the thread, hope it is what you are after. As mentioned, I have a H7A3ZI-Q that I can help run other tests on.
An update to this is I noticed it was not just the UART that was causing the issue, Enabling SPI seems to have a similar effect. These tests are all done with default projects, simply disabling and enabling functionality and trying to flash.

@Nightwalker-87
Copy link
Member

Nightwalker-87 commented Jun 18, 2023

Following recent refactoring work, the code snippet in #1249 (comment) is now located in flash_loader.c:563.

@Nightwalker-87
Copy link
Member

Nightwalker-87 commented Jun 29, 2023

@Nightwalker-87
Copy link
Member

The provided references indicate that this topic is a more general issue and not (specifically) related to the stlink toolset.
As additional information has been given to address this issue, I am closing this issue now as it appears to be resolved.

@Nightwalker-87
Copy link
Member

Closes #1294.

@stlink-org stlink-org locked as resolved and limited conversation to collaborators Dec 24, 2023
@Nightwalker-87 Nightwalker-87 unpinned this issue Dec 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants