sfyip / STM32F103_MSD_BOOTLOADER

STM32F103 Mass Storage Device Bootloader
MIT License
69 stars 45 forks source link

BUG for program size greater than 64K #1

Closed stefanofante closed 3 years ago

stefanofante commented 3 years ago

Hello, there is a bug for program size greater than 64K You need to add a extended linear record (code 04) if the address range exceeded 64K

something like that: extended_address = false; inside the loop: if (extended_address) { print "EXTENDED LINEAR RECORD" with args address >> 16 extended_address = false; }

write data records..... ..... increment address ..... if ((address & 0x0000FFFF) == 0) { extended_address = true; }

sfyip commented 3 years ago

STM32F103C8T6 is 64 KB flash size, not 128KB. Sorry for the typo. Therefore, the user code only allows ~48KB only.

By default, it supports 32bit extended linear record. uint32_t address = TRANSFORM_ADDR(address_hi, address_lo); // if extended linear address: ( (((uint32_t)(addr_hi)) << 16) | ((uint32_t)(addr_lo)) )

stefanofante commented 3 years ago

I ported the code to STM32F103Z and I faced this problem :-) To solve the problem I add a piece of code to the pc code in order to manage flash code greater than 64K.

Hhamid1991 commented 3 years ago

Hi, I also encountered this problem and failed to fix the bug. Can anyone modify the code?

sfyip commented 3 years ago

In btldr_config.h, please try to extend the flash size. Currently it is set to 64KB.

define DEV_FLASH_SIZE (64*1024)

Hhamid1991 commented 3 years ago

I tried this but unfortunately the problem has not been resolved yet

RadioOperator commented 3 years ago

@sfyip and All, Hi, I use this repo code, generated 4 ICs MSD Bootloader, flash size should be not a problem, please check: YAB_STM32F103_F407_L433_F723

sfyip commented 3 years ago

Hi,

I tried the ihex file (fill to 128KB). During parsing ihex EOF record type, soft reset is called immediately inside the USB interrupt handler which caused Windows reported the file is corrupt and stop at 67%. (Actually, the flash is already prog)

Please try the updated one.

Thanks :)