Looking to port a device to MakeCode

Trying to find information that would help me port MakeCode to a physical device, anyone got any hints?

Hi @paulsk08, do you have more details about request? Is it to add an arcade board or a new editor? Have you looked at maker.makecode.com ?

Hi Peli,

We met a few years back at BETT, hope you are staying safe and well. I want to be able to control a Robot. Specifically the EZ-Robot series

Paul

Paul Smith-Keitley FRSA

Microsoft Innovative Education Expert

Co-Founder STEAM Centre UK

www.steamuk.org

This section covers how to setup the editor; but not so much about getting a new hardware in place. https://makecode.com/target-creation. How do you communicate with your robot? Is it compiled code, what architecture?

Hi Peli,

Sorry for the delay, the ‘bot is connected via WiFi and is based on Cortex processor. Already has Blockly, Javascript and Python, I just want to make it compatible with MakeCode.

Thanks for getting back.

Paul

MakeCode compiles to ARM thumb so it would be important to know what Cortex you have. M0, M4, M7?

Hi Peli,

Thx again for sped response, it is a 100MHz M4

Paul

Paul Smith-Keitley FRSA

Microsoft Innovative Education Expert

Co-Founder STEAM Centre UK

www.steamuk.org

It would be easier to jump on a call to discuss this. You will need an implementation of CODAL for robot, support a way to flash the code into your robot, then develop a set of MakeCode Apis.
Maker is an interresting example: https://github.com/microsoft/pxt-maker

I have a similar question. An ex-work colleague has offered me some contract work to port MakeCode onto a custom board using RP2040 which is a DUAL-Core M0+ (NOT M4F). I’m concerned MakeCode doesn’t have the wherewithal to make use of two CPU cores and moreover probably requires the M4F’s floating point unit (though maybe this doesn’t matter if the toolchain will just target the M0+ it will do slow software floating point).

I cannot find any proper documentation about this kind of thing. For example, does MakeCode compile and download directly to the target using the bootloader only? (ie, cross-compile to bare metal) or does it have an actual runtime on the target silicon?

Where is the source code for it? I find a whole lot of related bits in github but no central source or explanation of how the whole system bootstraps… I did find the docs on adding your own custom PCB with the CF4, but it assumes you’re already just using a supported display and microcontroller and all you’re really doing is specifying the PCB pinout configuration.

Would be great to see more docs on this before agreeing to what might turn out to be a death march project.

@xjordanx let me try and answer as much of this as I can:

MakeCode uses software floats. An FPU should not be needed.

MakeCode compiles down to bare metal, but we do link the user’s code with an RTOS that we precompile called CODAL. More info about CODAL can be found here.

MakeCode’s compilation toolchain roughly works like this:

  1. First the PXT compiler compiles the user’s TypeScript down to an IR
  2. Next this IR is passed to one of our emitters for the target architecture which spits out machine code. The majority of our supported hardware targets ARM’s thumb instruction set
  3. Next the machine code is linked to a binary file which is precompiled from CODAL and all of the C++ associated with that editor.
  4. The end result is a UF2 file which can be flashed onto a supported board using the UF2 bootloader

All of this happens client-side in the browser except for the compilation of the C++, which is done ahead of time.

There are three relevant repos for any MakeCode editor

  1. pxt - which contains all the source code for the compiler and webapp
  2. pxt-common-packages - which contains code that is shared between several of our editors. The code in this repo is a combination of Static TypeScript and C++ which is compiled onto the device. It also contains the simulator implementations of the C++ code, but that’s a topic for another discussion
  3. The target repo - This contains all of the code specific to an editor. That includes CSS, config files, editor extensions (like extra field editors for blocks), and some library code depending on the target. Some example target repos are pxt-maker and pxt-arcade

Typically you bootstrap a makecode setup like this:

  1. Install node, python, and a couple global npm packages: (npm install -g pxt gulp)
  2. Clone the target repo, pxt, and pxt-common-packages all in the same subdirectory
  3. Run npm install in all three repos
  4. Inside pxt, run gulp to build the repo
  5. Inside the target, link the two other repos like so: npm link ../pxt ../pxt-common-packages
  6. Now run pxt serve in the target repo to launch a local version of the webapp
1 Like

Thanks for the detailed answer. I’m reading through all the recommended bits now. I discovered some folks have already a branch for getting RP2040 support going in the pct-arcade repo, so I’m launching from there. Seems like this is already well under way.

Thanks again!