I am off the mbed module and programming a LPC1768 on my prototype target, so the mbed interface chip is not in the loop. I program using the serial ISP interface with Flash Magic so for me the JTAG interface is not used.
I understand that. However, you need to keep in mind that the main target of mbed compiler is mbed modules.
As for post-processing the bin file, a simple Python script should do it:
import sys, struct
if len(sys.argv) < 2:
print "Usage: crp.py file.bin [CRP1|CRP2|CRP3]"
else:
infile = open(sys.argv[1], "rb")
infile.seek(0x2FC)
crp = struct.unpack("<I", infile.read(4))
infile.close()
print "Current CRP value: 0x%08X" % crp
if len(sys.argv)>2:
opt = sys.argv[2]
crp = None
if opt == 'CRP1':
crp = 0x12345678
elif opt == 'CRP2':
crp = 0x87654321
elif opt == 'CRP2':
crp = 0x43218765
else:
print "Bad CRP value name"
if crp:
infile = open(sys.argv[1], "r+b")
infile.seek(0x2FC)
infile.write(struct.pack("<I", crp))
infile.close()
print "New CRP value 0x%08X written" % crp
How do you set code read protection? Can you do it by a statement in the code?