{"id":18371866,"url":"https://github.com/ARMmbed/dapjs","last_synced_at":"2025-04-06T19:31:59.318Z","repository":{"id":25710234,"uuid":"97221346","full_name":"ARMmbed/dapjs","owner":"ARMmbed","description":"JavaScript interface to CMSIS-DAP","archived":false,"fork":false,"pushed_at":"2025-03-29T09:56:45.000Z","size":2251,"stargazers_count":116,"open_issues_count":7,"forks_count":53,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-29T10:31:02.396Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://armmbed.github.io/dapjs","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ARMmbed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-14T10:15:45.000Z","updated_at":"2025-03-29T09:56:42.000Z","dependencies_parsed_at":"2024-11-06T00:02:39.925Z","dependency_job_id":"6f764285-ef33-4d36-baf2-43712280774f","html_url":"https://github.com/ARMmbed/dapjs","commit_stats":{"total_commits":229,"total_committers":15,"mean_commits":"15.266666666666667","dds":0.6462882096069869,"last_synced_commit":"b048feb5afdddc366b214ac5232c11eeda375546"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMmbed%2Fdapjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMmbed%2Fdapjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMmbed%2Fdapjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMmbed%2Fdapjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ARMmbed","download_url":"https://codeload.github.com/ARMmbed/dapjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247539096,"owners_count":20955245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T00:01:07.379Z","updated_at":"2025-04-06T19:31:58.150Z","avatar_url":"https://github.com/ARMmbed.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","↔️ Interface Chip"],"sub_categories":["🎓 Machine Learning Resources \u0026 Projects"],"readme":"# DAP.js\n\n[![Build Status](https://github.com/ARMmbed/dapjs/workflows/ci/badge.svg)](https://github.com/ARMmbed/dapjs/actions)\n[![npm](https://img.shields.io/npm/dm/dapjs.svg)](https://www.npmjs.com/package/dapjs)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html)\n\nDAP.js is a JavaScript interface to [CMSIS-DAP](https://www.keil.com/pack/doc/CMSIS/DAP/html/index.html), enabling access to Arm Microcontrollers using [Node.js](https://nodejs.org/) or in the browser using [WebUSB](https://wicg.github.io/webusb/).\n\n## Prerequisites\n\n[Node.js \u003e v8.14.0](https://nodejs.org), which includes `npm`\n\n## Installation\n\nThe package is distributed using npm. To install the package in your project:\n\n```bash\n$ npm install dapjs\n```\n\n## Getting Started\n\nDecide on a transport layer to use (see below) and refer to the [examples folder](https://github.com/ARMmbed/dapjs/tree/master/examples/) to get started.\n\nThe web examples can be seen running at:\n\nhttps://armmbed.github.io/dapjs/examples/index.html\n\nRefer to the [DAPjs API Documentation](https://armmbed.github.io/dapjs/) for more information.\n\n## Supported Systems\n\n### Browsers\n\nPlease refer to the [WebUSB implementation status](https://github.com/WICG/webusb#implementation-status) for browser support.\n\n### Windows\n\nAll transports outlined below are known to work on Windows 7, 8 and 10. Please refer to the [node-usb FAQ](https://github.com/tessel/node-usb/issues/182) with any issues using the `USB` or `WebUSB` transport in `Node.js`. The `HID` transport is preferred on Windows.\n\nPlease ensure you __don't__ have the Mbed Serial driver installed on `Windows 10` as this can cause issues and isn't needed on this platform.\n\n### MacOS\n\nNo known issues with any transports in `Node.js` Tested on MacOS 10.12.\n\n### Linux\n\nBasic testing undertaken with no known issues. Please refer to the [node-usb FAQ](https://github.com/tessel/node-usb/issues/182) with any issues using the `USB` or `WebUSB` transport in `Node.js`.\n\n### Development Boards\n\nAll develoment boards supporting `CMSIS-DAP` should work. For the flash and serial `DAPLink` functionality, all [Mbed Enabled boards](https://os.mbed.com/platforms/?mbed-enabled=15) should work, but need the latest `DAPLink` firmware installed.\n\nThe latest DAPLink containing WebUSB support needs to be built from the [DAPLink source](https://github.com/ARMmbed/DAPLink) until we have prepared a new firmware release on https://armmbed.github.io/DAPLink/.\n\nAll examples have been tested with the latest DAPLink fiormware on the following hardware:\n\n- Freedom K64F\n- BBC micro:bit\n\n## Choosing a Transport\n\nIn order to use DAPjs, you need to install support for one of the transports. Use the following information to help you choose which to use:\n\n### WebUSB\n\nIf you wish to use DAPjs in a browser environment, you must use WebUSB. Please refer to the [implementation status](https://github.com/WICG/webusb#implementation-status) of WebUSB to understand browser support for this technology.\n\n__Note:__ WebUSB in the browser doesn't require any further libraries to be installed.\n\nIf you also want your program to work in a Node.js environment a [WebUSB library](https://github.com/thegecko/webusb) exists to allow your program to be ported to Node.js.\n\nTo install the library for Node.js, use:\n\n```bash\n$ npm install webusb\n```\n\n#### Example\n\nIn the browser, require the library:\n\n```html\n\u003cscript type=\"text/javascript\" src=\"dist/dap.umd.js\"\u003e\u003c/script\u003e\n```\n\nIn Node.js Require the libraries:\n\n```javascript\nconst usb = require('webusb').usb;\nconst DAPjs = require('dapjs');\n```\n\nThen in either environment:\n\n```javascript\nconst device = await \u003cnavigator\u003e.usb.requestDevice({\n    filters: [{vendorId: 0xD28}]\n});\n\nconst transport = new DAPjs.WebUSB(device);\nconst daplink = new DAPjs.DAPLink(transport);\n\ntry {\n    await daplink.connect();\n    await daplink.disconnect();\n} catch(error) {\n    console.error(error.message || error);\n}\n```\n\n#### Pros\n- Works in the browser\n- Programs are portable to Node.js environments\n\n#### Cons\n- Requires a recent version of [DAPLink](https://armmbed.github.io/DAPLink/) to be installed on your target device.\n\n### HID\n\nFor the highest level of firmware compatibility in a Node.js environment, the HID transport is recommended. This utilises the `node-hid` library and is installed as follows:\n\n```bash\n$ npm install node-hid\n```\n\n#### Example\n\n```javascript\nconst hid = require('node-hid');\nconst DAPjs = require('dapjs');\n\nlet devices = hid.devices();\ndevices = devices.filter(device =\u003e device.vendorId === 0xD28);\n\nconst device = new hid.HID(devices[0].path);\nconst transport = new DAPjs.HID(device);\nconst daplink = new DAPjs.DAPLink(transport);\n\ntry {\n    await daplink.connect();\n    await daplink.disconnect();\n} catch(error) {\n    console.error(error.message || error);\n}\n```\n\n#### Pros\n- Compatible with older CMSIS-DAP firmware.\n\n#### Cons\n- Requires HID access to JavaScript in your OS.\n\n### USB\n\nA \"pure\" USB transport exists which bypasses requiring `WebUSB` and `HID`.\nThis utilises the `usb` library and is installed as follows:\n\n```bash\n$ npm install usb\n```\n\n#### Example\n\n```javascript\nconst usb = require('usb');\nconst DAPjs = require('dapjs');\n\nlet devices = usb.getDeviceList();\ndevices = devices.filter(device =\u003e device.deviceDescriptor.idVendor === 0xD28);\n\nconst transport = new DAPjs.USB(devices[0]);\nconst daplink = new DAPjs.DAPLink(transport);\n\ntry {\n    await daplink.connect();\n    await daplink.disconnect();\n} catch(error) {\n    console.error(error.message || error);\n}\n```\n\n#### Pros\n- Doesn't require HID access to JavaScript in your OS.\n\n#### Cons\n- Requires a recent version of [DAPLink](https://armmbed.github.io/DAPLink/) to be installed on your target device.\n- Can have issues on Windows machines\n\n## Architecture\n\nThe architecture of this project is built up in layers as follows:\n\n### Transport\n\nThe `Transport` layer offers access to the USB device plugged into the host. Different transports are available based on user needs (see above).\n\n#### Implementation Status\n\n- [x] packetSize\n- [x] open()\n- [x] close()\n- [x] read()\n- [x] write()\n\n### Proxy\n\nThe `Proxy` layer uses the transport layer to expose low-level `CMSIS-DAP` commands to the next layer. A common use for the proxy is as a debug chip attached to the main processor accessed over USB.\n\nA CMSIS-DAP implementation is included, however a network proxy or similar could be introduced at this layer in order to remote commands.\n\n#### Implementation Status\n\n- [x] operationCount\n- [x] blockSize\n- [x] dapInfo()\n- [x] swjSequence()\n- [x] swjClock()\n- [x] transferConfigure()\n- [x] connect()\n- [x] disconnect()\n- [x] reconnect()\n- [x] reset()\n- [x] transfer()\n- [x] transferBlock()\n- [ ] hostStatus()\n- [ ] delay()\n- [ ] writeAbort()\n- [ ] swjPins()\n- [ ] swdSequence()\n- [ ] swdConfigure()\n- [ ] swoTransport()\n- [ ] swoMode()\n- [ ] swoBaudrate()\n- [ ] swoControl()\n- [ ] swoStatus()\n- [ ] swoExtendedStatus()\n- [ ] swoData()\n- [ ] jtagSequence()\n- [ ] jtagConfigure()\n- [ ] jtagIDCode()\n- [ ] transferAbort()\n- [ ] executeCommands()\n- [ ] queueCommands()\n\n### DAPLink\n\nThe `DAPLink` layer is a special derived implementation of the `CMSIS-DAP` proxy implementation. It adds DAPLink vendor specific functionality such as Mass Storage Device `firmware flashing` and `serial control`.\n\n#### Implementation Status\n\n- [x] flash()\n- [x] getSerialBaudrate()\n- [x] setSerialBaudrate()\n- [x] startSerialRead()\n- [x] stopSerialRead()\n- [x] serialWrite()\n\n#### Events\n\n- [x] flash_progress\n- [x] serial_data\n\n### DAP\n\nThe `DAP` (Debug Access Port) layer exposes low-level access to ports, registers and memory. An implementation exists for `ADI` (Arm Debug Interface).\n\n#### Implementation Status\n\n- [x] connect()\n- [x] disconnect()\n- [x] reconnect()\n- [x] reset()\n- [x] readDP()\n- [x] writeDP()\n- [x] readAP()\n- [x] writeAP()\n- [x] readMem8()\n- [x] writeMem8()\n- [x] readMem16()\n- [x] writeMem16()\n- [x] readMem32()\n- [x] writeMem32()\n- [x] readBlock()\n- [x] writeBlock()\n- [x] readBytes()\n- [x] writeBytes()\n\n### Processor\n\nThe `Processor` layer exposes access to the core processor registers.\n\n#### Implementation Status\n\n- [x] getState()\n- [x] isHalted()\n- [x] halt()\n- [x] resume()\n- [x] readCoreRegister()\n- [x] readCoreRegisters()\n- [x] writeCoreRegister()\n- [x] execute()\n- [ ] step()\n\n## Development\n\nAfter cloning this repository, install the development dependencies:\n\n```bash\n$ npm install\n```\n\n### Building\n\n[Gulp](https://gulpjs.com/) is used as a task runner to build the project.\nTo build the project, simply run `gulp` or to continually build as source changes, run `gulp watch`:\n\n```bash\n$ gulp\n$ gulp watch\n```\n\nA `package.json script` exists to run gulp if you don't have it installed globally:\n\n```bash\n$ npm run gulp\n$ npm run gulp watch\n```\n\n### Running\n\nA local [express](https://expressjs.com/) server is included to run the web example locally:\n\n```bash\n$ node server.js\n```\n\nThe latest build of master is always available to be installed from the `gh-pages` branch:\n\n```bash\n$ npm install ARMmbed/dapjs#gh-pages\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FARMmbed%2Fdapjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FARMmbed%2Fdapjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FARMmbed%2Fdapjs/lists"}