Comments (3)
It sounds like you're possibly programming an image that protects the flash? You will need to erase unless you're writing to a region of flash that is already erased. Some sample code would help.
from pylink.
Hello again!
I am not using images with security enabled. In fact, the idea is to program a very basic image and then put the necessary data in memory. And, in case this process is completed correctly, then write into memory the necessary data to activate the flash protection.
Example K64/KE15:
import pylink
Import time
Import sys
try:
jlink = pylink.JLink()
jlink.open()
print(jlink.product_name)
print(jlink.oem)
print('Open connection? %s' % jlink.opened())
print('JLink connected? %s' % jlink.connected())
print('Jlink found -> %s' %
jlink.connected_emulators())
print('Connected device: %s' % jlink.target_connected())
except Exception as e:
print('ERROR: error when opening connection...', str(e)) jlink.close()
sys.exit()
Target connection
try:
print('Specifying target interface...') jlink.set_tif(pylink.enums.JLinkInterfaces.SWD)
except Exception as e:
print('ERROR: debugg...', str(e))
jlink.close()
sys.exit()
try:
print('Establishing the connection...') jlink.connect(microJLink, 'auto', True)
print(' -> Target connected')
except Exception as e:
print('ERROR: error when connecting, first attempt...', str(e))
jlink.close()
sys.exit()
try:
print('Unlocking...')
pylink.unlockers.unlock(jlink, 'Kinetis')
print(' -> Unlocked')
except Exception as e:
print('ERROR: error when unlocking...', str(e)) jlink.close()
sys.exit()
Target erase
jlink.halt()
print('CPU halted')
time.sleep(1)
try:
print('Erasing memory content...')
jlink.erase()
print(' -> Memory Erased')
except Exception as e:
print('ERROR: error when erasing...', str(e))
jlink.close()
sys.exit()
Target connection
try:
print('Establishing the connection...') jlink.connect(microJLink, 'auto', True)
print(' -> Connection established')
except Exception as e:
print('ERROR: error when connecting after erasing...', str(e))
jlink.close()
sys.exit()
try:
print('Unlocking...')
pylink.unlockers.unlock(jlink, 'Kinetis')
print(' -> Unlocked')
except Exception as e: print('ERROR: error when unlocking...', str(e))
jlink.close()
sys.exit()
Flashing .s19
time.sleep(1)
try:
print ('Programming module...')
jlink.flash_file(file_path, 0)
print(' -> Module programmed')
except Exception as e:
print('ERROR: error when programming...', str(e)) jlink.close()
sys.exit()
time.sleep(2)
Memory Write
try:
print('Memory write data1: %s (bytes)' % jlink.memory_write8(dirdata1, data1))
print('Memory write data2: %s (bytes)' % jlink.memory_write8(dirdata2, data2))
except Exception as e:
print('ERROR: error when modifying data...', str(e)) jlink.close()
sys.exit()
Read Modified Memory
try:
print('Reading memory...')
resultMemoryModifiedData1 = jlink.memory_read8(dirdata1, bytesdata1)
resultMemoryModifiedData2 = jlink.memory_read8(dirdata2, bytesdata2)
except Exception as e:
print('ERROR: error when reading memory...', str(e)) jlink.close()
sys.exit()
check mem
print('Checking memory...')
if data1 != resultMemoryModifiedData1: print('ERROR: data1 FAILURE'); jlink.close(); sys.exit()
if data2 != resultMemoryModifiedData2: print('ERROR: data2 FAILURE'); jlink.close(); sys.exit()
print(' -> Memory checked')
Security
try:
print('Memory write SEC: %s (bytes)' % jlink.memory_write8(dirSEC, SEC))
except Exception as e:
print('ERROR: error when modifying SEC...', str(e)) jlink.close()
sys.exit()
Close connection
jlink.close()
print('OK: boot done')
As I said, this same or similar code works in LPC and iMX.
In the Kinetis family, the error I was talking about occurs.
The steps I am trying seem simple:
Connect, unlock in case you have security enabled, clear memory, reconnect, program the image, program data on the image... and if everything is ok then arm the security.
It si true that normally using JLink Lite or JFlash with Kinetis family, it appears a popup talking about flash protection when programming or erasing, in case you want a mass erase you should press 'Yes'.
That pop-up does not appear in LPC or iMX.
An extra info in case that has something yo do with the problem!
Hope your answer soon :)
Thank you very much un advance
from pylink.
Hm. I'm having a hard time following. There is OTP that permanently locks flash on the Kinetis chips, so even if your image doesn't enable flash security, if you flashed one at one point that did, then flash access would be permanently locked. In terms of the code, I'm having a hard time following. Could you paste a block like:
jlink = pylink.Jlink()
jlink.connect(...)
<...>
Then point out the specific line in that block that is causing the issue and whether it is on the first time you run it or subsequent runs.
from pylink.
Related Issues (20)
- RTT Autodetect works with J-Link RTT Viewer, but for pylink I have to explicitly provide the address HOT 1
- AttributeError: module 'pylink' has no attribute 'JLink'. HOT 9
- Loading library on Aarch64 fails because pylink attempts to load 32-bit library HOT 2
- pylink.errors.JLinkFlashException: Could not write target memory when trying to flash a .hex file. HOT 1
- pylink.errors.JLinkException: Could not find supported CPU HOT 25
- pylink.JLink.rtt_read blocks indefinitely when no data is available? HOT 1
- Specify JLinkScript file HOT 9
- CORESIGHT_AddAP doesn't execute HOT 6
- Can support C-JTAG HOT 14
- Unlocking STM32L0 HOT 1
- custom ResetTarget function in pylink HOT 7
- Error "Failed to perform RAMCode-sided Prepare()" Fail "JLinkFlashException: Unspecified error." HOT 2
- rtt_write only working when I have JLink RTT viewer open HOT 8
- Downloading Firmware image to Cortex Fails HOT 2
- 1.2.0: Some tests are incompatible with Python 3.12 HOT 4
- Do I need to use jlink.connect before doing jlink.rtt_start? HOT 2
- Square: Thanks For Developing pylink (Not An Issue - Just Kudos) HOT 1
- REQ: Please Add Support For: Keil JLinkEFM8.dll HOT 3
- pylink.errors.JLinkException: Unspecified error - during connect() HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pylink.