Skip to content

Commit

Permalink
fixup! dfu_f4: List datasheets in references, update comments and 1024U
Browse files Browse the repository at this point in the history
  • Loading branch information
ALTracer committed Jan 8, 2024
1 parent 7ccfd51 commit 619f745
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/platforms/common/stm32/dfu_f4.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,32 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/*
* References, ST datasheets:
*
* DS8626 - STM32F405xx/407xx Rev 9 pg108, Table 40. Flash memory programming
* https://www.st.com/resource/en/datasheet/stm32f407vg.pdf
* (f4discovery:stm32f407vg, 128/1024 KiB;
* hydrabus:stm32f405rg, 128/1024 KiB)
*
* DS9716 - STM32F401xB/xC Rev 11 pg85, Table 45. Flash memory programming
* https://www.st.com/resource/en/datasheet/stm32f401cb.pdf
* (blackpill-f4:stm32f401cc, 64/256 KiB)
*
* DS10086 - STM32F401xD/xE Rev 3 pg86, Table 45. Flash memory programming
* https://www.st.com/resource/en/datasheet/stm32f401re.pdf
* (blackpill-f4:stm32f401ce, 96/512 KiB;
* 96b_carbon:stm32f401re, 96/512 KiB)
*
* DS10314 - STM32F411xC/xE Rev 7 pg92, Table 45. Flash memory programming
* https://www.st.com/resource/en/datasheet/stm32f411ce.pdf
* (blackpill-f4:stm32f411ce, 128/512 KiB)
*
* DS11853 - STM32F722xx/723xx Rev 9 pg138, Table 53. Flash memory programming
* https://www.st.com/resource/en/datasheet/stm32f723ie.pdf
* (stlinkv3:stm32f723ie, 256/512 KiB; and F7 has slightly smaller timings than F4 family)
*/

#include "general.h"
#include "usbdfu.h"

Expand Down Expand Up @@ -104,16 +130,18 @@ void dfu_flash_program_buffer(const uint32_t baseaddr, const void *const buf, co

uint32_t dfu_poll_timeout(uint8_t cmd, uint32_t addr, uint16_t blocknum)
{
/* Erase for big pages on STM2/4 needs "long" time
Try not to hit USB timeouts*/
/*
* Sector erase for big pages of STM32 F2/F4/F7 needs "long" time,
* up to 1-2 seconds. Try not to hit USB timeouts.
*/
if (blocknum == 0 && cmd == CMD_ERASE) {
get_sector_num(addr);
if (addr == sector_addr[sector_num])
return sector_erase_time[sector_num];
}

/* Programming 256 words (32-bit) with 16 us(typ), 100 us(max) per word */
return 16 * 1024 / 4 / 1000;
return 16U * 1024U / 4U / 1000U;
}

void dfu_protect(bool enable)
Expand Down

0 comments on commit 619f745

Please sign in to comment.