pyocd / pyOCD

Open source Python library for programming and debugging Arm Cortex-M microcontrollers
https://pyocd.io
Apache License 2.0
1.13k stars 484 forks source link

Can not program KW36 Dflash #687

Open JingsaiLu opened 5 years ago

JingsaiLu commented 5 years ago

I have a binary which size is larger than 256kB, so need to program both Pflash and Dflash. The KW36 memory map is as below image. image I try to use pyocd flash command to program my binary with below command: pyocd flash -b 0251000041114e45002d3007bcf900209e51000097969900 -a 0x00000000 "D:\mcu\wireless_uart_frdmkw.bin" but it report an error as below: image

So, I check the flash algo file at pyocd\target\builtin\target_MKW36Z512xxx4.py and find something is not aligned with MCU user manual, marked as red: image

I want to fix this issue, so I try to generate flash algo for alisa flash and D flash from FLM files, and modify this target_MKW36Z512xxx4.py script as bolow: image I assign different flash algo for Pflahs / alisa Dflash and Dflash from 3 FLMs in Kinetis_KWxx_DFP 1.9. I try to program this 3 part flash with a small image seperately with different target address, like; pyocd flash -b 0251000041114e45002d3007bcf900209e51000097969900 -a 0x10000000 "hello.bin pyocd flash -b 0251000041114e45002d3007bcf900209e51000097969900 -a 0x00004000 "hello.bin pyocd flash -b 0251000041114e45002d3007bcf900209e51000097969900 -a 0x00000000 "hello.bin They are all OK in flashing binary progress as below: image

But when I try to program my big binary(larger than 256kB), it still report an error after a while as below: image

JingsaiLu commented 5 years ago

@flit Do you have any idea about this issue? Does pyocd support the feature to change flash algo dynamically according to different programming address?

flit commented 5 years ago

Really sorry for the slow reply! Yes, pyOCD can have a different flash algo for each flash region. Everything you are describing should work.

There is obviously some bug when programming an image that crosses flash region boundaries. I thought I had fixed that a while back. What version of pyOCD are you using?

Could you create a pull request with your changes? Or attach a patch file to this issue. Also please attach the test image binary that you are using.