NordicPlayground / nRF5-universal-prog

The nrfjprog command line tool implemented in Python.
BSD 3-Clause "New" or "Revised" License
29 stars 6 forks source link

missing some device version mappings #24

Open zerog2k opened 7 years ago

zerog2k commented 7 years ago

Not sure if this is missing some device version mappings, which pynrfjprog seems to have.

example, I currently get this exception:

$ python nrfjprog_cli.py program -f ~/Downloads/mbed_blinky_NRF51822.hex 
Programs the device.
Traceback (most recent call last):
  File "nrfjprog_cli.py", line 39, in <module>
    main()
  File "/Users/jens/build/nrf/nRF5-universal-prog/nrfjprog/__main__.py", line 479, in main
    cli.run()
  File "/Users/jens/build/nrf/nRF5-universal-prog/nrfjprog/__main__.py", line 109, in run
    getattr(perform_command, self.args.command)(self.args)
  File "/Users/jens/build/nrf/nRF5-universal-prog/nrfjprog/model/perform_command_jlink.py", line 215, in program
    nrf = SetupCommand(args)
  File "/Users/jens/build/nrf/nRF5-universal-prog/nrfjprog/model/perform_command_jlink.py", line 56, in __init__
    elif self._setup('NRF51'):
  File "/Users/jens/build/nrf/nRF5-universal-prog/nrfjprog/model/perform_command_jlink.py", line 126, in _setup
    self.device = device.NRF5xDevice(self.device_version)
  File "/Users/jens/build/nrf/nRF5-universal-prog/nrfjprog/model/device.py", line 81, in __init__
    self.flash_size = FLASH_SIZE[device_version]
KeyError: 'NRF51xxx_xxAC_REV3'

I think my version NRF51xxx_xxAC_REV3 maps to NRF51_XLR3P per this: https://github.com/NordicSemiconductor/pynrfjprog/blob/master/pynrfjprog/API.py#L65-L98

however I don't see these versions in this repo: https://github.com/NordicSemiconductor/nRF5-universal-prog/blob/master/nrfjprog/__main__.py#L292-L301

However, if I attempt to use --deviceversion NRF51_XLR3P (or any of the others listed here), I get: pynrfjprog.API.APIError: An error was reported by NRFJPROG DLL: -5 WRONG_FAMILY_FOR_DEVICE. and NRF51xxx_xxAC_REV3 is not allowed as an option.

zerog2k commented 7 years ago

I also tried hacking in support at NRF51xxx_xxAC_REV3 on nrfjprog/__main__.py and nrfjprog/model/device.py, and it executes, but get this back:

$ python nrfjprog_cli.py program -f ~/Downloads/mbed_blinky_NRF51822.hex  --deviceversion NRF51xxx_xxAC_REV3
Programs the device.
Traceback (most recent call last):
  File "nrfjprog_cli.py", line 39, in <module>
    main()
  File "/Users/jens/build/nrf/nRF5-universal-prog/nrfjprog/__main__.py", line 480, in main
    cli.run()
  File "/Users/jens/build/nrf/nRF5-universal-prog/nrfjprog/__main__.py", line 109, in run
    getattr(perform_command, self.args.command)(self.args)
  File "/Users/jens/build/nrf/nRF5-universal-prog/nrfjprog/model/perform_command_jlink.py", line 234, in program
    nrf.api.write(start_addr, data.tolist(), True)
  File "/Library/Python/2.7/site-packages/pynrfjprog-9.5.0-py2.7.egg/pynrfjprog/API.py", line 788, in write
    raise APIError(result)
pynrfjprog.API.APIError: An error was reported by NRFJPROG DLL: -5 WRONG_FAMILY_FOR_DEVICE.

any ideas on what I'm missing?

fwiw: other operations like halt/reset/readregs all work fine.. here is my version info:

$ python nrfjprog_cli.py version
Display the nrfjprog and JLinkARM DLL versions.
JLink version: (6L, 16L, ' ')
nRFjprog version: 0.3.0
zerog2k commented 7 years ago

ok, seems that once I hacked in the support for NRF51xxx_xxAC_REV3 (copied settings from NRF51_XLR3P), and do NOT pass in --deviceversion, then program (followed by reset) works as expected.

should I just submit a PR with my hwrev or also for the rest here (for completeness): https://github.com/NordicSemiconductor/pynrfjprog/blob/master/pynrfjprog/API.py#L65-L84

zerog2k commented 7 years ago

also found this from Jlink Command line by exporting device list (ExpDevList):

"Manufacturer", "Device", "Core", {Flash areas}, {RAM areas}
...
"Nordic Semi", "nRF51422_xxAA", "Cortex-M0", { {0x00000000, 0x00040000}, {0x10001000, 0x00000400} }, {0x20000000, 0x00004000}
"Nordic Semi", "nRF51422_xxAB", "Cortex-M0", { {0x00000000, 0x00020000}, {0x10001000, 0x00000400} }, {0x20000000, 0x00004000}
"Nordic Semi", "nRF51422_xxAC", "Cortex-M0", { {0x00000000, 0x00040000}, {0x10001000, 0x00000400} }, {0x20000000, 0x00008000}
"Nordic Semi", "nRF51801_xxAB", "Cortex-M0", { {0x00000000, 0x00030000}, {0x10001000, 0x00000400} }, {0x20000000, 0x00004000}
"Nordic Semi", "nRF51802_xxAA", "Cortex-M0", { {0x00000000, 0x00040000}, {0x10001000, 0x00000400} }, {0x20000000, 0x00004000}
"Nordic Semi", "nRF51822_xxAA", "Cortex-M0", { {0x00000000, 0x00040000}, {0x10001000, 0x00000400} }, {0x20000000, 0x00004000}
"Nordic Semi", "nRF51822_xxAB", "Cortex-M0", { {0x00000000, 0x00020000}, {0x10001000, 0x00000400} }, {0x20000000, 0x00004000}
"Nordic Semi", "nRF51822_xxAC", "Cortex-M0", { {0x00000000, 0x00040000}, {0x10001000, 0x00000400} }, {0x20000000, 0x00008000}
"Nordic Semi", "nRF52832_xxAA", "Cortex-M4", { {0x00000000, 0x00080000}, {0x10001000, 0x00001000} }, {0x20000000, 0x00010000}
"Nordic Semi", "nRF52832_xxAB", "Cortex-M4", { {0x00000000, 0x00040000}, {0x10001000, 0x00001000} }, {0x20000000, 0x00008000}
"Nordic Semi", "nRF52840_xxAA", "Cortex-M4", { {0x00000000, 0x00100000}, {0x10001000, 0x00001000} }, {0x20000000, 0x00040000}
...