Microsoft MakeCode

Can I download the codes to EV3 via bluetooth?

After writing the codes in EV3 MakeCode, can I download the codes to EV3 via bluetooth but not USB cable?

Thanks,
Raymond

Sorry Bluetooth or WIFI downloading is not available in MakeCode.

Our team is also interested on a wireless download… Now the in First Lego League (FLL) you can program your robot with other languages, our team is really interested on MakeCode… yet the drawback at this time is having to connect the wire for every tweak on the program for every mission… in a FLL competition there are 100s of tweaks as you try your program for distance, amount to lift, push, etc. for the various missions. Is there an ETA for this capability to be supported?

1 Like

Sorry there is no ETA on BT support.

I created a C# app that uses Lego.Ev3.Desktop but unfortunately that didn’t seem to work.
await brick.SystemCommand.CopyFileAsync(@“c:\temp\PlaySound.uf2”, @"…/prjs/PlaySound.uf2");

I could see the file gets created on the brick in the LME software manager but it is still just a uf2 file. I assume something special happens to the file when copied via USB? Maybe I can read in the uf2 file then split out the .rbf and .elf files then write those directly to BrkProg_SAVE?? Any help on the format of the uf2 file would be greatly appreciated

Thanks, Jeff

1 Like

OK I’ve made some progress. I was able to read in the uf2 file then split it into the rbf and .elf files. I then did the following:
await brick.SystemCommand.CopyFileAsync(@“c:\temp\PlaySound.elf”, @"…/prjs/BrkProg_SAVE/PlaySound.elf");
await brick.SystemCommand.CopyFileAsync(@“c:\temp\PlaySound.rbf”, @"…/prjs/BrkProg_SAVE/PlaySound.rbf");
Success!

I can also use the DeleteFileAsync to delete unwanted files! What I’ll do is start the app with a brick Name input. I’ll use a FileSystem watcher on a folder and any time a new or updated .uf2 file is dropped there, I will split out the elf and rbf then send them to the EV3 brick. When I get a clean working solution I’ll throw it up somewhere.

This is awesome!

If you need any help with the UF2 format let me know. You might have already found the docs here - https://github.com/microsoft/uf2

Thanks that will help. I had just looked at the binary and made some guesses about the file format :wink:

This is awesome. Please us updated on your progress

Yes will do. I have a real job so this work is secondary. Should have something by next week. I scrapped my little console test app for something with a GUI. I’ll need to have some robustness around BT range. I’m sure the kiddos will be moving the robots all over the place.

Thank you Jeff for pointing us into the right direction. Interrestingly, the web serial api just hit the experimental channel in chrome so I was able to download the program from the makecode editor itself in the latest chrome/edge insider (with experimental flags enabled).

PR: https://github.com/microsoft/pxt-ev3/pull/920/files

The feature is now in /beta. You can read more details at https://makecode.mindstorms.com/beta

OK so I don’t need to finish my app? I do have it up and working. I basically watch a folder and then when a .uf2 is written to it I send it over to the connected brick.
I also was able to get FileList to work so now I can have a little folder manager.

Please do - the web serial is still experimental :slight_smile:

I had a little time to work on this today but ran into an issue that took me for ever to figure out.
Any time I would launch a program my brick would hard lock after the program finished. At times even after the 3 finger reset I would have to re-flash the brick to get it to connect back to BT.
app.
I spent a bunch of time looking at the Lego communication spec and the code in the library thinking that I was overwriting some flash bits or something.
I finally figured out (at least I hope) what the issue was. If there is a program running on the brick and you try to send a command (read firmware ver in my case) the brick locks up after the program exits. Oddly enough the listening callback on port information doesn’t seem to cause the issue. The data stop flowing but as soon as the program exits it starts up again. Looks like I’m removing the status indicator :slight_smile:

OK I did find that the StartProgram code that I lifted from someone else was wrong. This was also causing the brick to lock up, some times.

The webserial stack is unable to open the COM port while the program is running (or portview). The user has to make sure to be back on the main screen of the brick to get the program flashing. I also tried to send some opcode to do UI_WRITE(LED, LED_GREEN_PULSE) but ended doing 3 finger resets too.

couple of side questions:

  1. Any idea why an .rbf built from the LME software exits when complete but a makecode rbf doesn’t?
  2. Any know if there is a command code to read the bricks name. for BT that is pretty easy as it get set in the BT enumeration. I’m not sure how to get it via USB or Wifi without asking the brick. I looked through the opUiRead sub codes and didn’t see anything for name. Maybe a read line would do it?

I did end up completing the program (at least for my needs). I found that WiFi is way more robust then BT. I ended up getting a NetGear USB wifi dongle and using that. I will need to get one for each team we are running. This will work for testing in house and then maybe switch to BT when we are at the competition. I also have a little file manager that allows for viewing, running, and deleting files.

I dumped the code and bins here: https://1drv.ms/u/s!Am3UH_kcAxmjjccAqBMInimo6wdRNQ?e=8R2Dl8 sorry not GitHub. Note: This is a total hack job. I’m not a UI programmer. The code here in has no implied or expressed guarantees or warranties. The original Lego.Ev3 library was not written by me. I only did some modifications to it. I may or may not randomly update these file or complete remove the share at any time :wink:

It would be a huge help if the MakeCode programs would exit on completion.

1 Like