Replies: 1 comment 2 replies
-
Hi @jfolerka! I guess you saw the CMSIS-Pack for the FM0+ family, since you used the FLM algo? Did you try using the pack's device support directly? Although, that probably won't help much since the flash is being troublesome. Pyocd expects flash sectors to be evenly divisible by the page size. I haven't read the MCU reference manual yet, but it certainly seems like I need to. I've never before encountered or heard of a device with flash that doesn't meet this requirement, but your statements that "This device supports writing across sector boundaries" and "a device such a this one with an oddly-sized sector" makes me suspect my view will soon be challenged! 😉 Given that, pyocd's flash programming logic will result in attempts to write at very unhappy addresses when the page and sector sizes don't align. To answer other questions:
I'll read up on this device over the next few days so I understand how the flash works, and what the appropriate programming algorithm is. Unfortunately, this is one MCU family that I don't have, so I can't reproduce the issues. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm trying to set up a development environment for a S6E1C32D MCU from Cypress semiconductor. My development hardware is the FM0-64L-S6E1C3 starter kit. I'm using Visual Studio Code and the GNU Arm Embedded Toolchain along with pyOCD.
I created the following pyOCD_user.py script to add support for my target by following the memory map of the device and by running the generate_flash_algo.py script to create a flash algorithm Python dictionary out of the FLM file for the target. The problem I'm seeing is that only the first sector is programmed. This device supports writing across sector boundaries and my test firmware image doesn't contain any holes from 0x0 to 0x99F0.
Initially I did not have the
page_size
attribute set on any of theFlashRegion
elements. When I first put them in, I would get this error:pyocd.core.exceptions.FlashFailure: attempt to program invalid flash address (address 0x00000000)
here is a complete log file: pyOCD_log0.log
I then added option
-O keep_unwritten=False
to the command line and the error went away but something looks suspicious:===0012580:DEBUG:flash:call erase_sector(6000)
Is a call to
erase_sector
at0x6000
appropriate when the base address was set to0x1FF0
by theInit
function?Here is the log: pyOCD_log1.log
Likewise, the first write at
0x1c00
would put it back in the sector that was previously programmed (writing flash twice?). Shouldn't this first write be to0x0
if the base address was set to0x1FF0
?0012674:DEBUG:flash:start_program_page_with_buffer(addr=1c00, len=400, data=20001000)
The flash is correctly programmed for the first sector only. The rest of the memory is left blank.
If I disable double-buffering and change the page size to
0x2000
:I get the same result, only the first sector is flashed. Here is the log file: pyOCD_log2.log
I also added
-O smart_flash=False
and also got the same result. Here is the log file: pyOCD_log3.logTo remove a "black box" from the picture I created a very simple flash algorithm for this device using the guidance provided here and the procedures in this document.
Using "my" algorithm in the pyOCD_user.py script yielded some interesting results. Log file here: pyOCD_log4.log
0x1FF0
starts at0x3FE0
and goes to0x7FEF
(the data that should have been in0x5FFF
is in0x7FEF
, all of the data is correct but shifted by0x1FF0
bytes)0x6000
to0x7FEF
is not programmed0x7FF0
starts at0xFFE0
(offset by0x7FF0
)I may not have understood what the purpose of the device base address passed to
Init
is supposed to do. This version of my code keeps the base address as an offset to any subsequent calls to the memory clear/write/check functions. For a device such a this one with an oddly-sized sector and two other sector sizes, this seemed like a sensible interpretation since it makes everything else so much easier.I changed "my" algorithm to take the address passed in from pyOCD as the absolute flash address to be programmed (base address always = 0) but the flash hardware times out and the programming fails. See log: pyOCD_log6.log
The following call is made twice:
0018338:DEBUG:flash:start_program_page_with_buffer(addr=7c00, len=400, data=20000430)
0019575:DEBUG:flash:start_program_page_with_buffer(addr=7c00, len=400, data=20000430)
Init
?keep_unwritten
feature also failed because of a bug with the page address calculation?Thank you so much in advance!
Beta Was this translation helpful? Give feedback.
All reactions