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

fix write for microcontroler with RAM size less or equal to 32K #637

Merged
merged 1 commit into from
Sep 16, 2017
Merged

fix write for microcontroler with RAM size less or equal to 32K #637

merged 1 commit into from
Sep 16, 2017

Conversation

trabucayre
Copy link
Contributor

This fix is due to a problem to flash STM32F410 with large .bin (for example nuttx.bin). The result is :
st-flash 1.4.0-8-g1700e6a
2017-09-16T17:15:20 INFO src/common.c: Loading device parameters....
2017-09-16T17:15:20 INFO src/common.c: Device connected is: F410 device, id 0x10006458
2017-09-16T17:15:20 INFO src/common.c: SRAM size: 0x8000 bytes (32 KiB), Flash: 0x20000 bytes (128 KiB) in pages of 16384 bytes
2017-09-16T17:15:20 INFO src/common.c: Attempting to write 57728 (0xe180) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x0800c000 erasedEraseFlash - Sector:0x3 Size:0x4000
2017-09-16T17:15:21 INFO src/common.c: Finished erasing 4 pages of 16384 (0x4000) bytes
2017-09-16T17:15:21 INFO src/common.c: Starting Flash write for F2/F4/L4
2017-09-16T17:15:21 INFO src/flash_loader.c: Successfully loaded flash loader in sram
enabling 32-bit flash writes
size: 32768
2017-09-16T17:15:24 ERROR src/flash_loader.c: flash loader run error
2017-09-16T17:15:24 ERROR src/common.c: stlink_flash_loader_run(0x8000000) failed! == -1
stlink_fwrite_flash() == -1

This issue is related to the buffer size : in src/common.c this size is fixed to 32KB.
To be able to use this size the target needs to have a RAM greater this value.
Indeed the flash loader is located at the begin of the RAM, on F4, it is written in SRAM at 0x2000000 and use 36b, then fl->buf_addr is fixed to 0x20000024.

For a F410RB with 32KB of RAM it's consequently not possible to load a buffer with the default size.

This patch check if the target has at least 32KB of RAM. If not the size is divided by 2.

@xor-gate xor-gate added this to the v1.5.0 milestone Sep 16, 2017
@xor-gate
Copy link
Member

LGTM

@xor-gate xor-gate merged commit 6511a7e into stlink-org:master Sep 16, 2017
@stlink-org stlink-org locked as resolved and limited conversation to collaborators Apr 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants