-
Notifications
You must be signed in to change notification settings - Fork 89
Jlink and other fw detection #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jlink and other fw detection #299
Conversation
mbed_lstools/platform_database.py
Outdated
@@ -47,7 +47,13 @@ | |||
u'0003': u'LPC2368', | |||
u'0004': u'LPC2368', | |||
u'0005': u'LPC2368', | |||
u'0006': u'LPC2368', | |||
u'0006': { | |||
u'default': 'daplink', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when this default is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone invokes the platform_db.get
api without specifying a device_type
, then we need to know which platform mapping we need to use. I'm open to restructuring that bit if needed, it was just a quick pass at it.
Bad news: I've tried flashing a KL25Z, a KL27Z, and a KL43Z using the JLink binaries found here: https://www.segger.com/downloads/jlink/#JLinkOpenSDABoardSpecificFirmwares All of them have a usb target ID of But the point is my modifications to the platform database won't work. Instead the DB needs to have some significant changes to it most likely. |
This actually works! But it needs some polish, some comments, and most importantly tests. @theotherjimmy How do you feel about the platform database changes? I don't love them but they work. |
e6d3713
to
b5b91ec
Compare
I got more tests to write |
I'm actually starting to become reasonably happy with this! A few things to note:
|
👍
As usual, it should respect the FsInteraction.whatever options. |
It does do this currently. But in the case where the files don't match a JLink device, it will default to daplink. I should also mention this changes the format of the platform database. Previously it was this:
Now it's this:
I believe this should work on systems that already have a platform db on the filesystem, but it does change how you interact with it when not using daplink devices. |
@bridadan The changes to the platform DB should be fine. I forgot that it already gracefully upgrades. |
@theotherjimmy at this point I'm pretty much done with the work I had in mind, let me know if you see any issues or want anything changed |
Given that you don't use the |
Agreed, I've reverted the change to the parameter. |
Awesome. Thanks! |
This seems to work 👍 One thing to consider. We would like to use the mbedls platform_name for JLinkExe device parameter. |
@juhhov, that should definitely be possible, although we'll have to return it as a separate data value instead of the In the case of the NRF52_DK, what is the correct device name from that list? There seems to be four options: nRF52810_xxAA, nRF52832_xxAA, nRF52832_xxAB, and nRF52840_xxAA. |
Thanks @bridadan , separate value is fine. |
It's an nRF52832_xxaa, ab is a device with smaller memory that has no separate dev kit. |
@simtind do you know if there is way to detect board/chip model from dev kit using usb port ? Which can be used for |
Nothing for the general case. What you can do is connect as some generic cpu (Cortex-m0 fex.) and check the cpuid register. That should tell you at least what core you're working on. Then you can reconnect as the correct core, which should give you access to memory. For nRF devices we base the Jlink snr on the dev kit as you've guessed in the issue. |
f44a467
to
52a60d7
Compare
Ok, rebased and added jlink information to the platform db. Probably need to add a few more tests for some missing coverage. |
Coveralls is taking its sweet time but I added the coverage back 👍 |
@bridadan this works for us. Could this move forward? |
@bridadan Could you rebase? I'll review it right now, assuming that little has to change when rebasing. |
mbed_lstools/lstools_base.py
Outdated
@@ -110,7 +110,7 @@ def list_mbeds_ext(self): | |||
def list_mbeds( | |||
self, fs_interaction=FSInteraction.BeforeFilter, | |||
filter_function=None, unique_names=False, | |||
read_details_txt=False): | |||
read_details_txt=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you revert this change? It seems like a "style-like" thing to me. I don't think this code explicitly looks for None
instead of any falsey value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops good catch. That was from when I had initially renamed the parameter.
mbed_lstools/lstools_base.py
Outdated
@@ -151,6 +151,7 @@ def list_mbeds( | |||
platform_count[name] += 1 | |||
device['platform_name_unique'] = ( | |||
"%s[%d]" % (name, platform_count[name])) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove this formatting change?
mbed_lstools/lstools_base.py
Outdated
if not filter_function or filter_function(device): | ||
return device | ||
else: | ||
return None | ||
|
||
def _fs_after_id_check(self, device, filter_function, read_details_txt): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove this formatting change?
mbed_lstools/lstools_base.py
Outdated
else: | ||
device['platform_name'] = None | ||
|
||
def _update_device_details_jlink(self, device, read_details_txt): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change read_details_txt
to _
to indicate that you are not using that parameter?
mbed_lstools/lstools_base.py
Outdated
@param read_details_txt A boolean controlling the presense of the | ||
output dict attributes read from other files present on the 'mount_point' | ||
""" | ||
files = os.listdir(device['mount_point']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we list the directory only once some how? We could do the listdir outside this function and _detect_device_type
and pass it into both. I think that this may have an impact on performance (we're somewhat performance critical to RAAS, IIRC) and we want to avoid making things any slower than they have to be.
u'jlink': { | ||
u'X349858SLYN': { | ||
u'platform_name': u'NRF52_DK', | ||
u'jlink_device_name': u'nRF52832_xxaa' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this data? Is it important to keep?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed for the reason specified in this comment: #299 (comment)
a02440d
to
ee98c12
Compare
ee98c12
to
ba99fc8
Compare
Rebased! |
so how json result looks like now for jlink based board? |
@jupe Like so: $ mbedls -j
[
{
"device_type": "jlink",
"jlink_device_name": "nRF52832_xxaa",
"mount_point": "D:",
"platform_name": "NRF52_DK",
"platform_name_unique": "NRF52_DK[0]",
"serial_port": "COM32",
"target_id": "000682961642",
"target_id_usb_id": "000682961642",
"url": "http://www.nordicsemi.com/X349858SLYN"
}
] |
looks good. Is |
Yup! $ mbedls -j
[
{
"daplink_auto_reset": "0",
"daplink_automation_allowed": "1",
"daplink_bootloader_crc": "0xa65218eb",
"daplink_bootloader_version": "0242",
"daplink_daplink_mode": "Interface",
"daplink_git_sha": "67f8727a030bcc585e982d899fb6382db56d673b",
"daplink_hic_id": "97969900",
"daplink_interface_crc": "0xe4422294",
"daplink_interface_version": "0244",
"daplink_local_mods": "0",
"daplink_overflow_detection": "1",
"daplink_remount_count": "0",
"daplink_unique_id": "0240000032044e4500257009997b00386781000097969900",
"daplink_usb_interfaces": "MSD, CDC, HID",
"daplink_version": "0244",
"device_type": "daplink",
"mount_point": "D:",
"platform_name": "K64F",
"platform_name_unique": "K64F[0]",
"serial_port": "COM18",
"target_id": "0240000032044e4500257009997b00386781000097969900",
"target_id_mbed_htm": "0240000032044e4500257009997b00386781000097969900",
"target_id_usb_id": "0240000032044e4500257009997b00386781000097969900"
}
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
@bridadan Are you happy with this implementation? |
Yup! |
This is a proposal to address #283.
One thing that needs more investigation is how to properly identify JLink devices. Currently I'm assuming that the target id is unique and corresponds with the
platform_name
, just like DAPLink. I need to check other platforms running JLink to verify this.