Skip to content
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

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

Open
wjzhang opened this issue Mar 18, 2019 · 4 comments
Open

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

wjzhang opened this issue Mar 18, 2019 · 4 comments

Comments

@wjzhang
Copy link

wjzhang commented Mar 18, 2019

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

@wjzhang
Copy link
Author

wjzhang commented Mar 18, 2019

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 {
      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;
      }

@thegecko
Copy link
Member

Could these somehow replace the existing readBlock/writeBlock implementations?

@wjzhang
Copy link
Author

wjzhang commented May 24, 2019

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.

@ccattuto
Copy link
Contributor

ccattuto commented Dec 17, 2021

writeBlock() now properly handles TAR auto-increment boundaries (601e982) so this issue should be solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants