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

Compatibility with micro:bit v2 #2

Closed
microbit-sam opened this issue Nov 18, 2020 · 24 comments
Closed

Compatibility with micro:bit v2 #2

microbit-sam opened this issue Nov 18, 2020 · 24 comments

Comments

@microbit-sam
Copy link

Hi @KitronikLtd ,

As you might have seen from microsoft/pxt-microbit#3506 this extension is currently not compiling against the latest version of Micro:bit CODAL. This means it will not work with micro:bit V2.

Software for micro:bit V2 boards is built using CODAL rather than the DAL, and no longer includes the mbed layer. We’ve implemented the most frequently used mbed classes to support easy porting of existing extensions, but there may still be corner cases with this compatibility layer.

As your extension is currently not building, it will be disabled for micro:bit V2. People attempting to use your extension with a micro:bit V2 board will get error 929. This extension will only be re-enabled on micro:bit V2 once it is fixed.

There are details on how to ensure extensions work on both version of the micro:bit here (lancaster-university/codal-microbit-v2#31).

Looking at your extension source I believe that your extension falls under this category:

Use of mbed APIs that are not included in the compatibility layer, or microbit-dal APIs that need different constructors

@KitronikLtd
Copy link
Owner

@microbit-sam I opened an issue about this some time ago, and have had no help as to how to go about fixing the issue:
microsoft/pxt-microbit#3532
What is required to switch to the new button stuff?

@microbit-sam
Copy link
Author

Hi again,

I'm taking another look at this, an additional Buttton constructor was added that we thought would cover this issue but perhaps not lancaster-university/codal-microbit-v2@24a9295

The build log throws this error:

/home/build/prjclone/pxtapp/pxt-kitronik-zip-64/zip64.cpp:18:61: error: invalid conversion from 'codal::PinNumber {aka unsigned char}' to 'PinName' [-fpermissive]
 #define ALLOC_PIN_BUTTON(id) new MicroBitButton(getPin(id)->name, id, MICROBIT_BUTTON_ALL_EVENTS, PullUp);

Am I right in thinking getPin(id)->name is returning a codal::PinNumber..?

d387077a7e10a1ae3fb623cb603075e1b2815e2e3d670d3c682ede1001e97881.log

@microbit-sam
Copy link
Author

Tracking Button in the generic issue:
lancaster-university/codal-microbit-v2#31 (comment)

@KitronikLtd
Copy link
Owner

Am I right in thinking getPin(id)->name is returning a codal::PinNumber..?

I'm pretty sure that's what it's doing.

How do I access the new button constructor?

@microbit-sam
Copy link
Author

Ok I've spoken with @finneyj and it's a weird, but correct, DAL->CODAL workaround

You won't need to change your code to use the new constructor, it should just work once MakeCode pulls in this change:
lancaster-university/codal-microbit-v2@5e38360

If you've got a local PXT/MakeCode environment for development you can try building with the #master branch rather than the usual MakeCode tags

@AlasdairAtKitronik
Copy link
Collaborator

I've tried an offline build with this version of MakeCode:
image

This is the program I'm writing with the :GAME ZIP64 extension as is, no modifications:

GAME_ZIP64.onButtonPress(GAME_ZIP64.ZIP64ButtonPins.Up, GAME_ZIP64.ZIP64ButtonEvents.Down, function () {
    basic.showIcon(IconNames.Heart)
})

I'm still getting a "Compilation failed, please check your code for errors message".
I also tried the same program with :GAME Controller extension, and still had the same issue.

@microbit-sam
Copy link
Author

Hmm.. ok, looks like it's still building off the latest tag, which doesn't included the additional constructor

Previously, I had a local MakeCode building with the latest master branches but it's no longer working. I'll see if I can get it running and test this for you

@AlasdairAtKitronik
Copy link
Collaborator

Thanks.

@AlasdairAtKitronik
Copy link
Collaborator

@microbit-sam This has become a more major concern now, as it appears V3 MakeCode has gone live (with barely any notice). I have changed the WS2812B related things to be V3 compatible, and hoped the button thing would just work like you'd hoped, but when I try to download, MakeCode just hangs (presumably forever, it's been about 10mins now) with this:
image

@microbit-sam
Copy link
Author

I've requested a new tagged release of CODAL which will include the Button fix, but the hang is unrelated
Same as the other issue, could you try recreating in a new project and see if the build completes

Could you also copy the output from the browser console, it may be useful for debugging (also are you in Chrome/FF/IE?)

I've seen a hang issue with WS2182b this morning - MakeCode now uses 'light' as a variable internally and if a project uses a variable of the same name it won't compile. Could that be happening here?

@AlasdairAtKitronik
Copy link
Collaborator

I've been rapidly switching all our WS2812B related repos over to the new internal "light" driver, and all of the other extensions work just fine, it's only this one, KitronikLtd/pxt-kitronik-zip-tile#3 and KitronikLtd/pxt-kitronik-game-controller#2 which don't (I'm aware the Controller doesn't use the WS2812B stuff). It's all our extensions which have C++ components.

@AlasdairAtKitronik
Copy link
Collaborator

Also, I've created several new projects for all the tests I've done, not opening any previous programs.

@AlasdairAtKitronik
Copy link
Collaborator

This is the Chrome console output:

---serviceworker:1 Installing service worker...
---serviceworker:1 Opened cache
---serviceworker:1 Caching:
https://makecode.microbit.org/
https://trg-microbit.userpxt.io/---simulator
https://pxt.azureedge.net/blob/b304cfcb06c2278a75092380fbb8ba0c4211c55f/semantic.js
https://pxt.azureedge.net/blob/5d9eb71a9f5a03538833b2d07eb04b0f0d869753/main.js
https://pxt.azureedge.net/blob/cd6f2fb5d3ebbad2eed435b28e41ba09de50c475/pxtapp.js
https://pxt.azureedge.net/blob/e96324d2b0cfaa9739cb263c987c9d5f649bd035/typescript.js
https://pxt.azureedge.net/blob/555c1dc1d9da18154cb48388d5e494f3f16119f8/marked/marked.min.js
https://pxt.azureedge.net/blob/1cbbd44d2be928820a5f00da52d73269abf22aab/highlight.js/highlight.pack.js
https://pxt.azureedge.net/blob/59b6fdd3f393f03f174c1879cd8372c501c7ff40/jquery.js
https://pxt.azureedge.net/blob/a6bef869f995509bf4db8fa63f1c7b5df948195e/pxtlib.js
https://pxt.azureedge.net/blob/55da86cabc482903700a0acc6220a26aa7afb9ca/pxtcompiler.js
https://pxt.azureedge.net/blob/c3152a444c30a1d74e1f6e9aa78951edb3c8bebb/pxtpy.js
https://pxt.azureedge.net/blob/d3591bdcb2148b8fb353352beff47fff62952533/pxtblockly.js
https://pxt.azureedge.net/blob/1513ca8e3e0b362f79497d1125c0cdbc71a80130/pxtwinrt.js
https://pxt.azureedge.net/blob/5903a3c1a6e347ed1cf7db881fe748b7a4015bca/pxteditor.js
https://pxt.azureedge.net/blob/4c55735d9815769ff69b66b5670a7a5df38d4584/pxtsim.js
https://pxt.azureedge.net/blob/f1ee18d0f0b6fa5b1735aa912467844c45d4ee00/pxtembed.js
https://pxt.azureedge.net/blob/b1af32a94e736aa81a41c9f22b01acf58d39bc09/pxtworker.js
https://pxt.azureedge.net/blob/a5c002868171ec99ffc2e3d1dbb1b3423a22ddda/pxtweb.js
https://pxt.azureedge.net/blob/2d7b5739d997abbd38c2cedeec9959e64ebd6d1d/blockly.css
https://pxt.azureedge.net/blob/439d107ab83b0b553d7c1a7e38b463d5466ba81d/semantic.css
https://pxt.azureedge.net/blob/25ccfa55bb1f3943c77ae1aea9cb2e24abbb4f38/rtlsemantic.css
https://pxt.azureedge.net/commit/6ae1fbffd82f9ad8669b5ea89ab263741c922548/blockly/media/sprites.png
https://pxt.azureedge.net/commit/6ae1fbffd82f9ad8669b5ea89ab263741c922548/blockly/media/click.mp3
https://pxt.azureedge.net/commit/6ae1fbffd82f9ad8669b5ea89ab263741c922548/blockly/media/disconnect.wav
https://pxt.azureedge.net/commit/6ae1fbffd82f9ad8669b5ea89ab263741c922548/blockly/media/delete.mp3
https://pxt.azureedge.net/blob/2ef592490db2172a393f660ad03a7b4cf27032ee/vs/loader.js
https://pxt.azureedge.net/blob/02c229bd3186f79db7a4c7f0c3b82e71206c9f52/vs/base/worker/workerMain.js
https://pxt.azureedge.net/blob/f8da2b83e96824babdd0681305c5b9c82d67e4ee/vs/basic-languages/bat/bat.js
https://pxt.azureedge.net/blob/dd0e27faae3eef78f947c707f73ee8c41f570da0/vs/basic-languages/cpp/cpp.js
https://pxt.azureedge.net/blob/850955e63d303ab7f476f9f0e0993bbf7dd4c251/vs/basic-languages/python/python.js
https://pxt.azureedge.net/blob/c4c2d1d96348e1a663a0ece649ba4ddbf9224d31/vs/basic-languages/markdown/markdown.js
https://pxt.azureedge.net/blob/f18988093920168a0879277026f07f987eb20ce6/vs/editor/editor.main.css
https://pxt.azureedge.net/blob/f91a098a99088ba6bf0e4dcd346518f53f575b71/vs/editor/editor.main.js
https://pxt.azureedge.net/blob/5b3c1560d1a3a88d898e5211dd7f9bc37309e9a4/vs/editor/editor.main.nls.js
https://pxt.azureedge.net/blob/ed83df41b47178ff9c4a39f07c6460733159076a/vs/language/json/jsonMode.js
https://pxt.azureedge.net/blob/cd1685860e190dda44400fa30d39f44cea516dfa/vs/language/json/jsonWorker.js
https://pxt.azureedge.net/blob/1d99c2ee5b93a196114b16ef01bcf4be000c7ede/smoothie/smoothie_compressed.js
https://pxt.azureedge.net/blob/dca777a9bb1807a01b123602e1453b5bddba4900/images/Bars_black.gif
https://pxt.azureedge.net/blob/15eaf38ac1eee2b2e4810a1ac13e8dbee035e546/gifjs/gif.js
https://pxt.azureedge.net/blob/19d7a44717e709a6fe934f77d3d67efcc8e226e9/ai.0.js
https://pxt.azureedge.net/blob/29556f82653368c7942b50760de5efc0c31d4f8f/target.js
https://pxt.azureedge.net/commit/6ae1fbffd82f9ad8669b5ea89ab263741c922548/fieldeditors.js
https://pxt.azureedge.net/commit/6ae1fbffd82f9ad8669b5ea89ab263741c922548/editor.js
https://makecode.microbit.org/---monacoworker
https://makecode.microbit.org/---worker
https://pxt.azureedge.net/blob/d955ce94fc3f7d2c6573300c71a56dc1d92c9bf0/static/logo.portrait.white.svg
https://pxt.azureedge.net/blob/3403510141da69da71b1fbb1024619a3ba88ac29/static/logo.square.white.svg
https://pxt.azureedge.net/blob/642175ae61e6822c948990e15570e590d2e0ecf1/static/logo.portrait.black.svg
https://pxt.azureedge.net/blob/4de54063603c8d16531078818a83f7c29a3588fa/static/icons/apple-touch-icon.png
https://pxt.azureedge.net/blob/f5f83b8c33d027642954f4f833432de810768249/static/Microsoft-logo_rgb_c-gray-square.png
https://pxt.azureedge.net/blob/e0a49fdb57be4b7e22d974e8e37171a47fa2fd0f/static/Microsoft-logo_rgb_c-white.png
https://pxt.azureedge.net/blob/eff23d2922b288041bf1a92de95043541480c27d/static/hero.png
---serviceworker:1 Activating service worker...
(index):2 [Deprecation] Application Cache API manifest selection is deprecated and will be removed in M85, around August 2020. See https://www.chromestatus.com/features/6192449487634432 for more details.
(index):1 Creating Application Cache with manifest https://makecode.microbit.org/---manifest
(index):1 Application Cache Checking event
pxtapp.js:1 Browser: chrome 86.0.4240.198 on windows
sim.webmanifest:1 Manifest: property 'start_url' ignored, should be same origin as document.
sim.webmanifest:1 Manifest: property 'scope' ignored. Start url should be within scope of scope URL.
pxtapp.js:1 PouchDB adapter: idb
(index):1 Application Cache Error event: Invalid or missing manifest origin trial token: https://makecode.microbit.org/---manifest
pxtapp.js:1 packetio: mk wrapper dap wrapper
pxtapp.js:1 webusb: get devices
pxtapp.js:1 packetio: mk wrapper dap wrapper
pxtapp.js:1 webusb: get devices
trg-microbit.userpxt.io/---simulator#sim-frame-10245697969270536780.3564727104833614:2 [Deprecation] Application Cache API manifest selection is deprecated and will be removed in M85, around August 2020. See https://www.chromestatus.com/features/6192449487634432 for more details.
pxtsim.js:1 Simulator ServiceWorker registration successful with scope:  https://trg-microbit.userpxt.io/
pxtapp.js:1 webusb: get devices
pxt.azureedge.net/compile/74985db2fb00c5525125e1d01bd102090383bb13c70ccf9f6181e3d7f4f04b23.hex:1 Failed to load resource: the server responded with a status of 404 ()
pxtapp.js:1 polling C++ build https://makecode.com/compile/74985db2fb00c5525125e1d01bd102090383bb13c70ccf9f6181e3d7f4f04b23.json
DevTools failed to load SourceMap: Could not load content for https://pxt.azureedge.net/commit/6ae1fbffd82f9ad8669b5ea89ab263741c922548/dapjs.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load SourceMap: Could not parse content for https://pxt.azureedge.net/blob/b1af32a94e736aa81a41c9f22b01acf58d39bc09/purify.min.js.map: Unexpected token ; in JSON at position 12
74985db2fb00c5525125e1d01bd102090383bb13c70ccf9f6181e3d7f4f04b23.json:1 Failed to load resource: the server responded with a status of 404 (Not Found)
pxtapp.js:1 polling C++ build https://makecode.com/compile/74985db2fb00c5525125e1d01bd102090383bb13c70ccf9f6181e3d7f4f04b23.json
pxtapp.js:1 GET https://makecode.com/compile/74985db2fb00c5525125e1d01bd102090383bb13c70ccf9f6181e3d7f4f04b23.json 404 (Not Found)
(anonymous) @ pxtapp.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
S @ main.js:1
(anonymous) @ pxtapp.js:1
c @ pxtapp.js:1
(anonymous) @ pxtapp.js:1
r @ pxtapp.js:1
setTimeout (async)
(anonymous) @ pxtapp.js:1
s @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
Promise.then (async)
r @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
Promise.then (async)
r @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
Promise.then (async)
r @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ pxtapp.js:1
pxtapp.js:1 polling C++ build https://makecode.com/compile/74985db2fb00c5525125e1d01bd102090383bb13c70ccf9f6181e3d7f4f04b23.json
pxtapp.js:1 GET https://makecode.com/compile/74985db2fb00c5525125e1d01bd102090383bb13c70ccf9f6181e3d7f4f04b23.json 404 (Not Found)
(anonymous) @ pxtapp.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
S @ main.js:1
(anonymous) @ pxtapp.js:1
c @ pxtapp.js:1
(anonymous) @ pxtapp.js:1
r @ pxtapp.js:1
setTimeout (async)
(anonymous) @ pxtapp.js:1
s @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
Promise.then (async)
r @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
Promise.then (async)
r @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
Promise.then (async)
r @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ pxtapp.js:1
XMLHttpRequest.send (async)
(anonymous) @ pxtapp.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
S @ main.js:1
(anonymous) @ pxtapp.js:1
c @ pxtapp.js:1
(anonymous) @ pxtapp.js:1
r @ pxtapp.js:1
setTimeout (async)
(anonymous) @ pxtapp.js:1
s @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
Promise.then (async)
r @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
Promise.then (async)
r @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
Promise.then (async)
r @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ pxtapp.js:1
pxtapp.js:1 polling C++ build https://makecode.com/compile/74985db2fb00c5525125e1d01bd102090383bb13c70ccf9f6181e3d7f4f04b23.json
pxtapp.js:1 packetio: mk wrapper dap wrapper
pxtapp.js:1 webusb: get devices

@DaveAtKitronik
Copy link
Contributor

@microbit-sam Any update on this? We are getting user reports of the error in the field

@microbit-sam
Copy link
Author

The fix for #define ALLOC_PIN_BUTTON(id) new MicroBitButton(getPin(id)->name, id, MICROBIT_BUTTON_ALL_EVENTS, PullUp); is now in codal-microbit-v2

We'll be tagging a new release later today, to remove the 'disabled' message from MakeCode please submit an issue to Microsoft
https://github.com/microsoft/pxt-microbit/issues

@microbit-sam
Copy link
Author

Fix is in the latest codal-microbit-v2 tag, and will need to be pulled through to MakeCode
lancaster-university/codal-microbit-v2@2dc5d29

@AlasdairAtKitronik
Copy link
Collaborator

Fix is in the latest codal-microbit-v2 tag, and will need to be pulled through to MakeCode
lancaster-university/codal-microbit-v2@2dc5d29

@microbit-sam Any update on when this is happening, as this isn't just breaking V2 stuff, this has broken the ZIP64 and Controller extensions for all micro:bits.

@microbit-sam
Copy link
Author

https://makecode.microbit.org/beta has been updated, and we're waiting for Microsoft to move this to live

The majority of the MS team are based in Redmond, WA, so I don't think this will happen until later this afternoon

@microbit-sam
Copy link
Author

Hey @AlasdairAtKitronik , there also appears to be an ongoing issue with the MakeCode compile service

Normal (no extension) builds should be unaffected as the PXT hex is cached, but anything containing C++ will hang
As far as I'm aware your extensions should still work on V1 despite currently being on the v2 disabled list, and it's the compilation server that is causing the issue

Apologies for the frustration this is causing you

Related issue:
microsoft/pxt-microbit#3755

@AlasdairAtKitronik
Copy link
Collaborator

@microbit-sam Thanks, it's helpful just knowing people are looking into this.

@microbit-sam
Copy link
Author

microbit-sam commented Nov 25, 2020 via email

@AlasdairAtKitronik
Copy link
Collaborator

No problem I’m now able to compile and flash a hex including the extension, but I can’t validate that it runs correctly on a V1 as I don’t have your hardware On a V2 I still get a 927 error, we're waiting for the V2 list to be updated

Was that on live MakeCode, or in /beta? It doesn't hang in the compile anymore, but it gives me a compilation error, and then highlights the button press block in red.

@AlasdairAtKitronik
Copy link
Collaborator

I've tested both this extension and the :GAME Controller on /beta and they compile, download and run as expected on V2 micro:bits with the actual devices.

Live MakeCode still doing this:
image
image

@AlasdairAtKitronik
Copy link
Collaborator

:GAME ZIP64 now works correctly with V2 micro:bit.

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

4 participants