microsoft / pxt-robotis

Microsoft MakeCode for ROBOTIS
https://5d8c71b7-aa36-4a68-a9cb-288b989efb08.pxt.io/
MIT License
3 stars 7 forks source link

It seems that the modified CODAL code is not properly applied as a runtime HEX file. #38

Closed OpusK closed 4 years ago

OpusK commented 4 years ago

Hi, @pelikhan, @mmoskal.

Describe the bug Although the member function of a specific class not implemented in codal-core was implemented in a class that inherited the class, MakeCode does not link the proper runtime HEX file. Of course, these work without problems when using only the CODAL build system.

The CODAL code related to the previously modified Serial package or the newly added DYNAMIXEL worked well. Is there anything different about the core package?

To Reproduce Steps to reproduce the behavior:

  1. Modify member function of CODAL Core Class
  2. Commit & Push to GitHub.
  3. pxt serve or pxt serve --localbuild
  4. Write code at MakeCode (eg. MakeCode ROBOTIS)
    forever(function () {
    serial.writeValue("V", pins.VOLTAGE.analogRead())
    pause(500)
    })
  5. Download & Upload to target board (The code has changed, so it must be compiled, not the cached hex file, but it is not recompiled. If you delete the "built/hexcache" folder and clear the browser's cache, it will be recompiled, but the hex hash value is the same.)
  6. Look at the behavior of the board (The changed member function was not applied)

Expected behavior I wrote it as a more specific example.

  1. The getAnalogValue() function in Pin.h of codal-core is not implemented.
  2. Therefore, we implemented getAnalogValue() in NRF52Pin of codal-nrf52.
  3. We implemented to print 4444 instead of -1013(DEVICE_NOT_IMPLEMENTED) value.
  4. Now it is applied. (We have confirmed that this compiles normally through various methods and creates a .hex file in the dockercodal or codal folder. We made sure that this compiles normally, such as by creating additional functions, inserting error codes or checking the .map file.)
  5. Now, the value that was output as -1013 should be output as 4444. But...

Screenshots

image

Desktop:

Additional context

mmoskal commented 4 years ago

The field branch here really needs to be a tag to get proper caching. I know the name is confusing.

In your codal folder, where you were doing your implementation, run ./build.py -l - this will create a new tag in the target ( https://github.com/ROBOTIS-GIT/codal-cm300 ). Then put that tag in branch field.

Let me know if that helps!

mmoskal commented 4 years ago

Also, make sure to use ./build -l and not create tag with git tag - the build.py will also link to correct versions in all dependent repos.

mmoskal commented 4 years ago

It's best to test locally like you did before, without ./build.py -l. The ./build.py -l is needed to publish the fix at the end.

To test locally, I usually build from command line.

First, I suggest you add the following environment variables to your computer setup:

PXT_FORCE_LOCAL=1
PXT_RUNTIME_DEV=1
PXT_ASMDEBUG=1

The first one will force a non-cloud build, the second will force re-running cmake on every build - this is useful if you make changes in codal, and the third adds additional debug information to generated binary.asm (you may not need that, but it doesn't hurt).

Then, head to pxt-robotis/projects/my-project. You can use an existing project created from localhost:3232 or create a new one. The pxt.json should be modified to look something like this:

{
    "name": "my-project",
    "dependencies": {
        "robotis-cm-300": "file:../../libs/robotis-cm-300"
    },
    "description": "",
    "files": [
        "main.ts"
    ]
}

The crucial part is "file:../../libs/..." instead of "*" - this will let you modify .cpp files in your target and pxt-common-packages and have these be picked up by build.

BTW, never edit files under built/dockercodal/pxtapp - these will be overwritten.

If you edited pxtarget.json, delete pxt-robotis/built/target* that you may have left from previous pxt serve or pxt buildtarget.

Now, you should be ready to build, in pxt-robotis/projects/my-project just run pxt.

Then, run code build/dockercodal/libraries/*, checkout appropriate branches in all repos (usually master), do your changes, run pxt to test, and eventually do the steps with ./build.py -l and editing pxtarget.json to publish the fixes.

Let me know if this helps!

mmoskal commented 4 years ago

BTW, the critical bit is building your .uf2 file using pxt command, not the web app.

ajtwlsdlqp commented 4 years ago

@mmoskal.

hello, mmoskal. It was very helpful.

It seems that the problem occurred because the changes were not reflected as the cache was twisted.

Thank you.

pelikhan commented 4 years ago

I am closing this. Please reopen if the issue continues.