Mleaf / stm32flash

Automatically exported from code.google.com/p/stm32flash
0 stars 0 forks source link

Incorrect flash size detected #56

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am trying to flash a STM32L151R8 which has 64k flash, but stm32flash shows it 
as 128k.

If I read the contents of flash, it produces a 128k file.

Here is the output:

$ ./stm32flash  -b 115200  -i -25,25 -r read.bin /dev/ttyAMA0

stm32flash 0.3

http://stm32flash.googlecode.com/

Serial Config: 115200 8E1
Version      : 0x30
Option 1     : 0x00
Option 2     : 0x00
Device ID    : 0x0416 (L1xxx6(8/B))
- RAM        : 16KiB  (2048b reserved by bootloader)
- Flash      : 128KiB (sector size: 16x256)
- Option RAM : 16b
- System RAM : 4KiB

Read address 0x08020000 (100.00%) Done.

Resetting device... done.

Original issue reported on code.google.com by quacks...@gmail.com on 9 Sep 2014 at 4:39

GoogleCodeExporter commented 9 years ago
This issue seems to be known:
https://gitorious.org/stm32flash/stm32flash/commit/0255c1cf4bcc4412c4cdd1e60be35
ab2aedcffa8

My stm32f030f6 with (offically) 16 kByte flash gets reported like this:
MacBook-Air:Release koepi$ ./flash.sh 
stm32flash 0.3

http://stm32flash.googlecode.com/

Using Parser : Intel HEX
Serial Config: 57600 8E1
Version      : 0x31
Option 1     : 0x00
Option 2     : 0x00
Device ID    : 0x0444 (STM32F030/F031)
- RAM        : 8KiB  (4096b reserved by bootloader)
- Flash      : 64KiB (sector size: 4x1024)
- Option RAM : 12b
- System RAM : 3KiB

Wrote and verified address 0x080014f0 (100.00%) Done.

A stm32f103c8 with 64 kByte flash as having 128 kByte flash.

It is possible that this amount of flash is indeed available. The data sheet 
only talks about _guaranteed_ values. So anything above 16/64 kByte may be 
prone to error. The eeproms for example in the stm32f030f6 have been tested to 
hold 640 bytes instead of 128 byte from the specs; a test of writing some bytes 
at 20 kByte flash on the stm32f030f6 has been successful as well ( 
http://www.eevblog.com/forum/microcontrollers/stm32-ghetto-style/msg511442/#msg5
11442 ).

Original comment by dmk...@gmail.com on 12 Sep 2014 at 5:01

GoogleCodeExporter commented 9 years ago
It is quite possible that physically more flash is available, however it it 
likely either untested, or does not meet spec.

The ST-Link utility (from ST) is able to correctly detect the flash size. I'm 
not sure if they do so just using the device ID.

Ideally stm32flash would also report the "official" flash size, with some 
option flags to read/write outside of these values.

Original comment by quacks...@gmail.com on 12 Sep 2014 at 5:11

GoogleCodeExporter commented 9 years ago
Yes, I don't know if it possible to read out the official flash size through 
the serial bootloader. ST-Link uses JWD (like JTAG) to talk with the chip.

Original comment by lists.to...@gmail.com on 12 Sep 2014 at 7:11

GoogleCodeExporter commented 9 years ago
The STM32L1 has a "flash size register" which when combined with the device ID 
provides the flash memory size.

A bit of additional logic is needed, as the location of this register varies 
depending on the device.

I think all modern STM32 variants include such registers, but the earlier ones 
(eg F103?) do not

Original comment by quacks...@gmail.com on 5 Oct 2014 at 10:04