dapjs icon indicating copy to clipboard operation
dapjs copied to clipboard

the execute() can not support execute code large than 4K bytes.

Open wjzhang opened this issue 5 years ago • 4 comments

Hi: because the execute use the writeBlock() API, it'll limited execute code size <= 4K bytes.

wjzhang avatar Mar 18 '19 07:03 wjzhang

if want support execute code size has no limited(ofcourse has RAM limited). could try these: /**

  • @hidden / const MAX_BLOCK_COUNT = 1024; /*

  • @hidden */ const MAX_BLOCK_ADDRESS_MASK = 0x3FF;

    /**

    • read big Block(>1K Uint32Array) from target
    • @param register ID of register to read from
    • @param count The count of values to read
    • @returns Promise of register data */ public readBigBlock(register: number, count: number): Promise<Uint32Array> { let chain: Promise<Uint32Array[]> = Promise.resolve([]); // split big block to 1K Uint32Array chunks let remainder = count; let index = 0; while (remainder > 0) { const readRegister = register + index * 4; const maxBlockCount = MAX_BLOCK_COUNT - ((readRegister >> 2) & MAX_BLOCK_ADDRESS_MASK); const chunkSize = Math.min(remainder, maxBlockCount); chain = chain.then(results => this.readBlock(readRegister, chunkSize).then(result => [...results, result])); remainder -= chunkSize; index += chunkSize; } return chain .then(arrays => this.concatTypedArray(arrays)); }

    /**

    • write big Block(>1K Uint32Array) the target
    • @param register ID of register to write to
    • @param values The values to write
    • @returns Promise */ public writeBigBlock(register: number, values: Uint32Array): Promise { let chain: Promise = Promise.resolve(); // split big block to 1K Uint32Array chunks let index = 0; while (index < values.length) { const writeRegister = register + index * 4; const maxBlockCount = MAX_BLOCK_COUNT - ((writeRegister >> 2) & MAX_BLOCK_ADDRESS_MASK); const chunk = values.slice(index, index + maxBlockCount); chain = chain.then(() => this.writeBlock(writeRegister, chunk)); index += maxBlockCount; } return chain; }

wjzhang avatar Mar 18 '19 07:03 wjzhang

Could these somehow replace the existing readBlock/writeBlock implementations?

thegecko avatar May 23 '19 19:05 thegecko

yes! but i just give some code if someone need execute code large than 4KB. mostly code running in RAM less than 4KB. my case is special, it need initialize some SoC hardware peripherals, so the execute code very big.

wjzhang avatar May 24 '19 00:05 wjzhang

writeBlock() now properly handles TAR auto-increment boundaries (https://github.com/ARMmbed/dapjs/commit/601e982f19951cc3773067bb27cf97f6cf0561c2) so this issue should be solved.

ccattuto avatar Dec 17 '21 08:12 ccattuto