PXT for the Micro:Bit locally on macOS

This is out-of-date. Just follow the instructions at https://github.com/Microsoft/pxt-microbit

I’ve been looking into the Micro:Bit and Microsoft’s PXT (Programmer eXperience Toolkit). PXT and all the required build tools can be installed on macOS, but the official instructions are a little weak. Here are the required steps:

Installation / Running

All these commands need to be run in a terminal:

  1. Install Homebrew


    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  2. Install Node.js (using homebrew)


    brew install node

  3. Install Yotta


    brew tap ARMmbed/homebrew-formulae
    brew install python cmake ninja arm-none-eabi-gcc
    pip install yotta

  4. Install srecord


    brew install srecord

  5. Clone the pxt repo. (Replace the repo URL with the URL of a fork if desired)


    git clone https://github.com/Microsoft/pxt-microbit

  6. Change your directory to be within the cloned repo. For the above:


    cd pxt-microbit

  7. Install pxt


    npm install -g pxt
    npm install

  8. Run the local pxt server.


    pxt serve

    This will download the needed components, do compilation, and eventually launch the PXT environment in your default browser. Watch the terminal window though. Downloads may exceed github limits and it may require you to paste a URL to login in and complete downloads (something like https://yotta.mbed.com/?provider=github#login/...).

Adding a Library

  1. Stop the pxt server (if running)
  2. Create the sub directory in ROOT/libs. Ex:


    cd pxt-microbit/libs
    git clone https://github.com/Microsoft/pxt-bluetooth-temperature-sensor
    mv pxt-bluetooth-temperature-sensor bluetooth-temperature-sensor

  3. Add the new directory to bluetooth-temperature-sensor in pxt-microbit/pxtarget.json


    ...
    "bundleddirs": [
    ... ,
    "libs/bluetooth-temperature-sensor"
    ],
    ...

  4. If needed, update the pxt.json of the new library. For example, for the above update the path of the dependencies:


    ...
    "dependencies": {
    "core": "file:../core",
    "bluetooth": "file:../bluetooth"
    ...

  5. Restart the server to build it.

Leave a Reply

Your email address will not be published. Required fields are marked *