NRF52 How to erase a protected firmware program (knowing the protected password) - nrf52

I'm trying to deploy a new firmware to my hardware device but I get the following error in the nrf Connect (v3.6.1) Programmer (v1.4.8):
16:47:36.937
Error when getting device info: Error: Error: Error occured when get device info. Errorcode: CouldNotCallFunction (0x9) Lowlevel error: NOT_AVAILABLE_BECAUSE_PROTECTION (ffffffa6)
16:47:36.937
Could not fetch memory size of target devkit: Cannot read property 'family' of undefined
I cannot read nor erase from the device through the programmer because of this error.
I assume this is because the device is password protected. I know this password, is there a way to erase the device's current firmware?
(I'm using the NRF52-DK to connect/program with it, and the pins are accessible, which is how I'm connecting and I know the chipset is a nrf52840)
Wiring now is as followed:
So I'm currently not using the debug output to connect with the device
I've provided power to the custom device by batteries now, no change in the result.

It's unclear what you mean by a "device password" for the nRF52840.
NOT_AVAILABLE_BECAUSE_PROTECTION occurs when the APPROTECT register has been enabled. According to the nRF52840 product spec
Access port protection is disabled by issuing an ERASEALL command via CTRL-AP
Alternatively, if you are using pynrfjprog, the recover() method removes the protection.
No matter what, flash will always be erased when clearing APPROTECT (unless utilizing the APPROTECT power glitch, but that's another topic)

Related

Core Bluetooth: Cannot get iPhone (the central) and Mac (the peripheral) to pair

I am developing an iPhone application and a Mac application that communicate with each other via Bluetooth LE. The iPhone is the central, and the Mac is the peripheral. I would like the iPhone application to be able to reconnect to the Mac application after a relaunch. Therefore, I save the UUID of the peripheral representing the Mac in NSUserDefaults, and then when the iPhone app launches, I call -[CBCentralManager retrievePeripheralsWithIdentifiers:], passing in the UUID. Although this method returns the peripheral, when I call -[CBCentralManager connectPeripheral:options:], the iPhone never reconnects to the Mac. According to this SO post, the problem is that the two devices need to be paired so that the UUID of the Mac is persistent. This brings me to my problem. I cannot for the life of me get the iPhone and the Mac to pair. According to this page of the Core Bluetooth Programming Guide, the way to require a paired connection is for the peripheral to set the characteristic's properties and permissions to the appropriate values. I quote:
You can ensure that only trusted devices have access to sensitive characteristic values by setting the appropriate characteristic properties and permissions. To continue the example above, to allow only trusted devices to retrieve a member’s email address, set the appropriate characteristic’s properties and permissions, like this:
emailCharacteristic = [[CBMutableCharacteristic alloc]
initWithType:emailCharacteristicUUID
properties:CBCharacteristicPropertyRead
| CBCharacteristicPropertyNotifyEncryptionRequired
value:nil permissions:CBAttributePermissionsReadEncryptionRequired];
However, this does not work. Even when I set the correct permissions and properties for the characteristic, the iPhone can still read/write to it without a pairing dialog being displayed. Elsewhere I am told that the way to initiate pairing is for the peripheral to reject a read/write request with an insufficient authentication error. According to this post,
To pair, you need to respond to a write request with an insufficient authentication error. For example, for an iOS peripheral you would write something like:
- (void)peripheralManager:(CBPeripheralManager *)peripheralManager didReceiveWriteRequests:(NSArray *)requests {
...
[peripheralManager respondToRequest:request withResult:CBATTErrorInsufficientAuthentication];
...
}
But this still doesn't work! When the Mac rejects the write request with an insufficient authentication error, the iPhone receives a -[CBPeripheralDelegate peripheral:didWriteValueForCharacteristic:error:] callback with an error that says, "Authentication is insufficient." No pairing dialog. I have no idea what to do and am considering dropping Core Bluetooth altogether if I cannot get this to work. If you have any idea how to get this to work, please let me know.
From Apple DTS:
"I have checked with other engineers here and we don’t believe that the pairing popup is possible between two iOS devices, but an iOS device and a BLE peripheral."
So, pairing popup happens only between a iOS/Mac app and a peripheral. rdar time.

Is it possible to programmatically access the error codes logged by CoreBluetooth?

I am implementing a BLE central device on the iPhone, using as peripheral a custom BLE device developed (whose firmware has been written by a colleague).
The peripheral for some operation will return a BLE error code, conforming to the standard Bluetooth ATT error codes as defined in BLE specifications.
On the iPhone side, where I'm using the CoreBluetooth stack to develop the central device, I am notified of such errors on the debugger output window of xCode as:
CoreBluetooth[WARNING] Unknown error: XX
and then I receive in the callbacks a CBError* object. My problem is that the CBError* object which I get in the callback (e.g., in CBPeripheralDelegate's didWriteValueForCharacteristic callback) just contains code=0 and localizedDescription="Unknown error".
Is it possible to retrieve somehow the error code which is logged on the debugger output window by the CoreBluetooth stack?
From my research it appears that CoreBluetooth maps almost all BLE standard error codes into "unknown errors" (with internal code 0, see CBError reference); I would like to get more detailed error codes, like those coded by CBAttError.
In an application you can only use the CoreBluetooth APIs. Those expose only CBError which, as you see it right in many cases can mask the real error. So the answer for officially accessing the source errors is that you can't do it.
However, if you want, you can access the Apple System Logs programmatically. (See post: Using Objective C to read log messages posted to the device console) You can define a query to return the items you are interested in and try to deduct the real reason of the error. This is a heuristic method but at the moment, unfortunately, we have no other way to do it.

Enable iOS On-Disk Encryption

For my iOS 6+-only app, I would like to enable the On-Disk Encryption offered from iOS.
I read this guide and I saw the "Protecting the User's Data" video of the WWDC 2012 (Session 714). However, I could not make it work.
Here are the steps I followed:
1- In the iOS Dev Center, I created a new App ID with:
2- In Xcode, I added an Entitlements file with the key:
3- On the device, I activated a passcode lock.
If I'm not wrong, this should be all. I now expect that while the device (in my case: an iPhone 5) is locked, protected files are inaccessible. But... if I use iExplorer, I can easily access the files created by my app, even when the device is locked. But this is exactly what I want to avoid. Did I forgot something?
The reason you can access files without unlocking your device is that an escrow keybag has been created. This is explained in Apple's iOS Security Guide (pdf):
Escrow keybag is used for iTunes syncing and Mobile Device Management (MDM). This keybag allows iTunes to back up and sync without requiring the user to enter a passcode, and it allows an MDM server to remotely clear a user’s passcode. It is stored on the computer that’s used to sync with iTunes, or on the MDM server that manages the device.
The Escrow keybag improves the user experience during device synchronization, which potentially requires access to all classes of data. When a passcode-locked device is first connected to iTunes, the user is prompted to enter a passcode. The device
then creates an Escrow keybag and passes it to the host. The Escrow keybag contains exactly the same class keys used on the device, protected by a newly generated key. This key is needed to unlock the Escrow keybag, and is stored on the device in the Protected Until First User Authentication class. This is why the device passcode must be entered before backing up with iTunes for the first time after a reboot.
If you reboot your phone, you will not be able to access files without unlocking it once.
If you want that files to be available only when device is unlocked(+about 10 seconds of grace period), set file protection to NSFileProtectionComplete. Be sure to implement delegate methods to know when data will become [un]available.

iphone- error in uploading app at device anywhere studio

I'm trying to upload an iphone application to device anywhere studio.
But when im clicking on the "Data cable" button to deliver my application, it gives me this error:
Unable to upload application(error code:ensemble_error_unknown_error).
I'm following all steps correctly as given in this forum post
Where im gonig wrong?
you have to send the zip file to device anywhere friend. have you ever work before on device anywhere ?? first you have to allocate or reserve a device then that zip is added to your application so you can test it..
Were you able to resolve the issue, for the error, you need to configure/update your ensemble server address in Device Anywhere Studio. Get in touch with the customer support to check for the ensemble server address you are using is correct.
-Prasad

Unexpected error while trying to connect to iPhone

Your mobile device has encountered an unexpected error(0xE800002E)
Try disconnecting and powering off the device;then power the device on and reconnect it.
I received these message so many times. How can I fix it?
Although you can see this error when you connect in XCode, it is not actually an Xcode defect.
See this thread at Apple's discussion boards. You basically need to reset you phone. I'm not sure but Ithink there may be a link between seeing this error and using your phone for development but I have no concrete evidence.
I find that if I plug my device in and its set to automatically run iPhoto - then you must let iPhoto load and let it try to sync photos before you quit it. Then you should be able to use XCode to load an application on to your phone.
If you do get the error - unplug the device, turn it off and then back on, and that usually clears up the problem