bmapflash
v1.2.2
Published
Flash an image using a `.bmap` file
Downloads
1,857
Maintainers
Readme
bmapflash
Flash an image using a
.bmap
file
Installation
Install bmapflash
by running:
$ npm install --save bmapflash
Documentation
bmapflash.flashImageToFileDescriptor(imageStream, deviceFileDescriptor, bmapContents, [options]) ⇒ EventEmitter
Kind: static method of bmapflash
Summary: Flash image to file descriptor
Returns: EventEmitter - event emitter
Access: public
| Param | Type | Default | Description | | --- | --- | --- | --- | | imageStream | ReadableStream | | image stream | | deviceFileDescriptor | Number | | device file descriptor | | bmapContents | String | | bmap contents | | [options] | Object | {} | options | | [options.bytesToZeroOutFromTheBeginning] | Number | 0 | bytes to zero out from the beginning |
Example
fs.open('/dev/rdisk2', 'rs+', (error, fd) => {
if (error) {
throw error;
}
fs.readFile('my/image.bmap', {
encoding: 'utf8'
}, (error, bmapContents) => {
if (error) {
throw error;
}
const image = fs.createReadStream('path/to/image.img');
const flasher = bmapflash.flashImageToFileDescriptor(image, fd, bmapContents);
flasher.on('progress', (state) => {
console.log(state);
});
flasher.on('error', (error) {
throw error;
});
flasher.on('done', () => {
console.log('Done!');
});
});
});
bmapflash.validateFlashedImage(deviceFileDescriptor, bmapContents) ⇒ EventEmitter
This function reads all the mapped blocks as specified by the .bmap
file, generates checksums, and compares them to the checksums specified
in the .bmap
file.
The returned event emitter might emit the following events:
done (Object[])
: Emitted when all the blocks have been scanned. This event passes as an argument an array of objects containing the ranges that did not pass validation.error (Error)
: Emitted when an error happened.progress (Object)
: Emitted regularly, passing an object containing progress state information.
Kind: static method of bmapflash
Summary: Validate flashed image
Returns: EventEmitter - event emitter
Access: public
| Param | Type | Description | | --- | --- | --- | | deviceFileDescriptor | Number | device file descriptor | | bmapContents | String | bmap contents |
Example
fs.open('/dev/rdisk2', 'rs+', (error, fd) => {
if (error) {
throw error;
}
fs.readFile('my/image.bmap', {
encoding: 'utf8'
}, (error, bmapContents) => {
if (error) {
throw error;
}
const validator = bmapflash.validateFlashedImage(fd, bmapContents);
validator.on('progress', (state) => {
console.log(state);
});
validator.on('error', (error) {
throw error;
});
validator.on('done', (invalidRanges) => {
if (invalidRanges.length !== 0) {
console.log('Validation was not successful');
}
});
});
});
Support
If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.
Tests
Run the test suite by doing:
$ npm test
Contribute
- Issue Tracker: github.com/resin-io-modules/bmapflash/issues
- Source Code: github.com/resin-io-modules/bmapflash
Before submitting a PR, please make sure that you include tests, and that jshint runs without any warning:
$ npm run lint
License
bmapflash
is free software, and may be redistributed under the terms specified in the license.