Microsoft MakeCode

CODAL compilation failure for a nrf52840

Hi,
I’m trying to add support for the Particle Xenon, a discontinued nrf52840 device that uses the feather footprint and can be picked up for around $10 on the second hand market if you’re willing to put a UF2 boot loader on it.

However, I’m having issues compiling CODAL.

pxt.json

{
    "name": "particle_xenon",
    "description": "Support for Particle Xenon nrf52 m4 device",
    "files": [
        "README.md",
        "device.d.ts",
        "config.ts",
        "board.json",
        "board.svg",
        "boardwireframe.svg"
],
"core": true,
"compileServiceVariant": "nrf52840",
"dependencies": {
    "core---nrf52": "file:../core---nrf52"
},
"public": true,
"dalDTS": {
    "corePackage": "../core---nrf52"
},
"features": [
]
}

config.ts
namespace config {
    export const PIN_TX = DAL.P0_6;
    export const PIN_RX = DAL.P0_8;
    export const PIN_MISO = DAL.P1_14;
    export const PIN_MOSI = DAL.P1_13;
    export const PIN_SCK = DAL.P1_15;
    export const PIN_A5 = DAL.P0_31;
    export const PIN_A4 = DAL.P0_30;
    export const PIN_A3 = DAL.P0_29;
    export const PIN_A2 = DAL.P0_28;
    export const PIN_A1 = DAL.P0_4;
    export const PIN_A0 = DAL.P0_3;
    export const PIN_D8 = DAL.P1_3;
    export const PIN_D7 = DAL.P1_12;
    export const PIN_D6 = DAL.P1_11;
    export const PIN_D5 = DAL.P1_10;
    export const PIN_D4 = DAL.P1_8;
    export const PIN_D3 = DAL.P1_2;
    export const PIN_D2 = DAL.P1_1;
    export const PIN_SCL = DAL.P0_27;
    export const PIN_SDA = DAL.P0_26;
    export const PIN_LED = PIN_D7;
    export const PIN_LED_G = DAL.P0_14;
    export const PIN_LED_B = DAL.P0_15;
    export const PIN_LED_R = DAL.P0_13;
}

device.d.ts
declare namespace pins {
    //% fixedInstance shim=pxt::getPin(PIN_A0)
    const A0: PwmPin;
    //% fixedInstance shim=pxt::getPin(PIN_A1)
    const A1: PwmPin;
    //% fixedInstance shim=pxt::getPin(PIN_A2)
    const A2: PwmPin;
    //% fixedInstance shim=pxt::getPin(PIN_A3)
    const A3: PwmPin;
    //% fixedInstance shim=pxt::getPin(PIN_A4)
    const A4: PwmPin;
    //% fixedInstance shim=pxt::getPin(PIN_A5)
    const A5: PwmPin;

    //% fixedInstance shim=pxt::getPin(PIN_D2)
    const D2: PwmPin;
    //% fixedInstance shim=pxt::getPin(PIN_D5)
    const D5: PwmPin;
    //% fixedInstance shim=pxt::getPin(PIN_D6)
    const D6: PwmPin;
    //% fixedInstance shim=pxt::getPin(PIN_D9)
    const D9: PwmPin;
    //% fixedInstance shim=pxt::getPin(PIN_D10)
    const D10: PwmPin;
    //% fixedInstance shim=pxt::getPin(PIN_D11)
    const D11: PwmPin;
    //% fixedInstance shim=pxt::getPin(PIN_D12)
    const D12: PwmPin;
    //% fixedInstance shim=pxt::getPin(PIN_D13)
    const D13: PwmPin;

    //% fixedInstance shim=pxt::getPin(PIN_LED)
    const LED: DigitalInOutPin; // red
    //% fixedInstance shim=pxt::getPin(PIN_LED2)
    const LED2: DigitalInOutPin; // blue

    //% fixedInstance shim=pxt::getPin(PIN_RX)
    const RX: PwmPin;
    //% fixedInstance shim=pxt::getPin(PIN_TX)
    const TX: DigitalInOutPin;

    //% fixedInstance shim=pxt::getPin(PIN_SCL)
    const SCL: DigitalInOutPin;
    //% fixedInstance shim=pxt::getPin(PIN_SDA)
    const SDA: DigitalInOutPin;
}

declare namespace input {
    /**
     * Button connecting A0 to GND.
     */
    //% block="button A0" fixedInstance
    //% shim=pxt::getButtonByPin(PIN_A0,BUTTON_ACTIVE_LOW_PULL_UP)
    //% parts="buttons"
    const buttonA0: Button;

    /**
     * Button connecting A1 to GND.
     */
    //% block="button A1" fixedInstance
    //% shim=pxt::getButtonByPin(PIN_A1,BUTTON_ACTIVE_LOW_PULL_UP)
    //% parts="buttons"
    const buttonA1: Button;

    /**
     * Button connecting A2 to GND.
     */
    //% block="button A2" fixedInstance
    //% shim=pxt::getButtonByPin(PIN_A2,BUTTON_ACTIVE_LOW_PULL_UP)
    //% parts="buttons"
    const buttonA2: Button;

    /**
     * Button connecting A3 to GND.
     */
    //% block="button A3" fixedInstance
    //% shim=pxt::getButtonByPin(PIN_A3,BUTTON_ACTIVE_LOW_PULL_UP)
    //% parts="buttons"
    const buttonA3: Button;

    /**
     * Button connecting A4 to GND.
     */
    //% block="button A4" fixedInstance
    //% shim=pxt::getButtonByPin(PIN_A4,BUTTON_ACTIVE_LOW_PULL_UP)
    //% parts="buttons"
    const buttonA4: Button;

    /**
     * Button connecting A5 to GND.
     */
    //% block="button A5" fixedInstance
    //% shim=pxt::getButtonByPin(PIN_A5,BUTTON_ACTIVE_LOW_PULL_UP)
    //% parts="buttons"
    const buttonA5: Button;
}

board.json
{
    "driveDisplayName": "Particle Xenon",
    "visual": {
      "image": "pkg://board.svg",
      "useCrocClips": false,
      "width": 454.635986328125,
      "height": 204.54568481445312,
      "pinDist": 15,
      "pinBlocks": [
        {
          "x": 390.3089356555213,
          "y": 185.66133487166246,
          "labels": [
            "NC"
          ]
        },
        {
          "x": 367.57712618402684,
          "y": 185.66133487166246,
          "labels": [
            "TX"
          ]
        },
        {
          "x": 344.8453674879733,
          "y": 185.66133487166246,
          "labels": [
            "RX"
          ]
        },
        {
          "x": 322.1274197118498,
          "y": 185.66133487166246,
          "labels": [
            "MISO"
          ]
        },
        {
          "x": 299.3956102403554,
          "y": 185.66133487166246,
          "labels": [
            "MOSI"
          ]
        },
        {
          "x": 276.663800768861,
          "y": 185.66133487166246,
          "labels": [
            "SCK"
          ]
        },
        {
          "x": 253.94587838045797,
          "y": 185.66133487166246,
          "labels": [
            "A5"
          ]
        },
        {
          "x": 231.214094296684,
          "y": 185.66133487166246,
          "labels": [
            "A4"
          ]
        },
        {
          "x": 208.48228482518957,
          "y": 185.66133487166246,
          "labels": [
            "A3"
          ]
        },
        {
          "x": 185.7643370490661,
          "y": 185.66133487166246,
          "labels": [
            "A2"
          ]
        },
        {
          "x": 163.03255296529213,
          "y": 185.66133487166246,
          "labels": [
            "A1"
          ]
        },
        {
          "x": 140.2938126461122,
          "y": 185.66133487166246,
          "labels": [
            "A0"
          ]
        },
        {
          "x": 117.58282110539469,
          "y": 185.66133487166246,
          "labels": [
            "GND"
          ]
        },
        {
          "x": 94.84408078621478,
          "y": 185.66133487166246,
          "labels": [
            "ARF"
          ]
        },
        {
          "x": 72.13308924549726,
          "y": 185.66133487166246,
          "labels": [
            "3V3"
          ]
        },
        {
          "x": 49.394348926317335,
          "y": 185.66133487166246,
          "labels": [
            "RST"
          ]
        },
        {
          "x": 140.2938126461122,
          "y": 3.847580243078173,
          "labels": [
            "BATT"
          ]
        },
        {
          "x": 163.03255296529213,
          "y": 3.847580243078173,
          "labels": [
            "EN"
          ]
        },
        {
          "x": 185.7643370490661,
          "y": 3.847580243078173,
          "labels": [
            "USB5V"
          ]
        },
        {
          "x": 208.48228482518957,
          "y": 3.847580243078173,
          "labels": [
            "D8"
          ]
        },
        {
          "x": 231.214094296684,
          "y": 3.847580243078173,
          "labels": [
            "D7"
          ]
        },
        {
          "x": 253.94587838045797,
          "y": 3.847580243078173,
          "labels": [
            "D6"
          ]
        },
        {
          "x": 276.663800768861,
          "y": 3.847580243078173,
          "labels": [
            "D5"
          ]
        },
        {
          "x": 299.3956102403554,
          "y": 3.847580243078173,
          "labels": [
            "D4"
          ]
        },
        {
          "x": 322.1274197118498,
          "y": 3.847580243078173,
          "labels": [
            "D3"
          ]
        },
        {
          "x": 344.8453674879733,
          "y": 3.847580243078173,
          "labels": [
            "D2"
          ]
        },
        {
          "x": 367.57712618402684,
          "y": 3.847580243078173,
          "labels": [
            "SCL"
          ]
        },
        {
          "x": 390.3089356555213,
          "y": 3.847580243078173,
          "labels": [
            "SDA"
          ]
        },
        {
          "x": 169.32728592694244,
          "y": 53.193662586420714,
          "labels": [
            "RESET"
          ]
        },
        {
          "x": 170.1661215986501,
          "y": 134.42960765933591,
          "labels": [
            "MODE"
          ]
        }
      ],
      "leds": [
        {
          "x": 18.149389397826692,
          "y": 43.61284453735271,
          "w": 11.202985386627455,
          "h": 11.2099757631431,
          "color": "#ff0000",
          "label": "LED"
        },
        {
          "x": 172.03097660501453,
          "y": 103.91239010107414,
          "w": 3.681181385070222,
          "h": 3.7297298188781034,
          "color": "#ff0000",
          "label": "LED_G"
        },
        {
          "x": 171.98246067121613,
          "y": 99.91230501134156,
          "w": 3.729710012728865,
          "h": 3.6812009335143743,
          "color": "#ff0000",
          "label": "LED_B"
        },
        {
          "x": 175.99641160221137,
          "y": 103.97479344934726,
          "w": 3.7366408604143526,
          "h": 3.6812009335143743,
          "color": "#ff0000",
          "label": "LED_R"
        }
      ],
      "touchPads": [],
      "buttons": []
    },
    "gpioPinMap": {
      "NC": "NC",
      "TX": "TX",
      "RX": "RX",
      "MISO": "MISO",
      "MOSI": "MOSI",
      "SCK": "SCK",
      "A5": "A5",
      "A4": "A4",
      "A3": "A3",
      "A2": "A2",
      "A1": "A1",
      "A0": "A0",
      "GND": "GND",
      "ARF": "ARF",
      "3V3": "3V3",
      "RST": "RST",
      "BATT": "BATT",
      "EN": "EN",
      "USB5V": "USB5V",
      "D8": "D8",
      "D7": "D7",
      "D6": "D6",
      "D5": "D5",
      "D4": "D4",
      "D3": "D3",
      "D2": "D2",
      "SCL": "SCL",
      "SDA": "SDA",
      "RESET": "RESET",
      "LED": "LED_R",
      "LED_G": "LED_G",
      "G": "LED_G",
      "LED_B": "LED_B",
      "B": "LED_B",
      "LED_R": "LED_R",
      "R": "LED_R",
      "MODE": "MODE"
    },
    "groundPins": [
      "GND"
    ],
    "threeVoltPins": [
      "3V3"
    ],
    "fiveVoltPins": [
      "USB5V"
    ],
    "i2cPins": {
      "SDA": "SDA",
      "SCL": "SCL"
    },
    "onboardComponents": [],
    "marginWhenBreadboarding": [
      0,
      0,
      80,
      0
    ],
    "spiPins": {
      "MOSI": "MOSI",
      "MISO": "MISO",
      "SCK": "SCK"
    }
  }
pxt build --local --force 
    .....
    [ 90%] Building CXX object CMakeFiles/NRF52840_DK.dir/pxtapp/mixer---nrf52/sound.cpp.o
    [ 91%] Building CXX object CMakeFiles/NRF52840_DK.dir/pxtapp/screen---st7735/jddisplay.cpp.o
    [ 91%] Building CXX object CMakeFiles/NRF52840_DK.dir/pxtapp/screen---st7735/screen.cpp.o
    [ 92%] Building CXX object CMakeFiles/NRF52840_DK.dir/pxtapp/screen---st7735/panic.cpp.o
    [ 93%] Building CXX object CMakeFiles/NRF52840_DK.dir/pxtapp/settings/NRF52Flash.cpp.o
    [ 94%] Building CXX object CMakeFiles/NRF52840_DK.dir/pxtapp/settings/RAFFS.cpp.o
    [ 94%] Building CXX object CMakeFiles/NRF52840_DK.dir/pxtapp/settings/SAMDFlash.cpp.o
    [ 95%] Building CXX object CMakeFiles/NRF52840_DK.dir/pxtapp/settings/STM32Flash.cpp.o
    [ 96%] Building CXX object CMakeFiles/NRF52840_DK.dir/pxtapp/settings/settings.cpp.o
    [ 97%] Building CXX object CMakeFiles/NRF52840_DK.dir/pxtapp/thermometer/temperature.cpp.o
    [ 97%] Building CXX object CMakeFiles/NRF52840_DK.dir/pxtapp/switch/switch.cpp.o
    [ 98%] Building C object CMakeFiles/NRF52840_DK.dir/pxtapp/jacdac/jdlow.c.o
    [ 98%] Building C object CMakeFiles/NRF52840_DK.dir/pxtapp/jacdac/jdutil.c.o
    [ 99%] Linking CXX executable NRF52840_DK
    /usr/lib/gcc/arm-none-eabi/6.3.1/../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/softfp/crt0.o: In function `_start':
    /build/newlib-jo3xW1/newlib-2.4.0.20160527/build/arm-none-eabi/thumb/v7e-m/fpv4-sp/softfp/libgloss/arm/../../../../../../../../libgloss/arm/crt0.S:421: undefined reference to `__wrap_atexit'
    collect2: error: ld returned 1 exit status
    CMakeFiles/NRF52840_DK.dir/build.make:1268: recipe for target 'NRF52840_DK' failed
    make[2]: *** [NRF52840_DK] Error 1
    CMakeFiles/Makefile2:106: recipe for target 'CMakeFiles/NRF52840_DK.dir/all' failed
    make[1]: *** [CMakeFiles/NRF52840_DK.dir/all] Error 2
    Makefile:83: recipe for target 'all' failed
    make: *** [all] Error 2
    INTERNAL ERROR: Error: Exit code: 1 from cd built/codal; python build.py
        at ChildProcess.<anonymous> (/home/sredfern/projects/20200524_ms_makecode_xenon/pxt/built/nodeutil.js:85:24)
        at ChildProcess.emit (events.js:315:20)
        at maybeClose (internal/child_process.js:1051:16)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)

Looking for some directional advice here. Do I need to put a github issue to the cordal team?

Do you have a pull request already in maker? @mmoskal

Is it building with docker? otherwise, which version of arm-none-eabi-gcc do you have?

arm-none-eabi-gcc - (15:6.3.1+svn253039-1build1)

I’m following the instructions on the github page to compile without docker:

Using docker I was able to get past the pxt build part but got an error in build.py

~/projects/20200524_ms_makecode_xenon/pxt-maker/libs/particle-xenon/built/codal(d559650*) » python build.py sredfern@mcaz
codal-nrf52840-dk is already installed
Set target: codal-nrf52840-dk
Using target-locked.json
Targeting codal-nrf52840-dk
– Adding library path: (/home/sredfern/projects/20200524_ms_makecode_xenon/pxt-maker/libs/particle-xenon/built/codal/libraries)
Installing dependencies…
codal-core is already installed
codal-nrf52 is already installed
Using library: codal-nrf52840-dk
Using library: codal-core
Using library: codal-nrf52
– Configuring done
– Generating done
– Build files have been written to: /home/sredfern/projects/20200524_ms_makecode_xenon/pxt-maker/libs/particle-xenon/built/codal/build
Scanning dependencies of target codal-core
[ 1%] Building CXX object libraries/codal-core/CMakeFiles/codal-core.dir/source/drivers/HIDKeyboard.cpp.o
[ 1%] Building CXX object libraries/codal-core/CMakeFiles/codal-core.dir/source/driver-models/Serial.cpp.o
/home/sredfern/projects/20200524_ms_makecode_xenon/pxt-maker/libs/particle-xenon/built/codal/libraries/codal-core/source/driver-models/Serial.cpp:885:6: warning: #warning define API for pin swap… [-Wcpp]
#warning define API for pin swap…
^~~~~~~
[ 1%] Linking CXX static library …/…/libcodal-core.a
[ 54%] Built target codal-core
[ 66%] Built target codal-nrf52
[ 69%] Built target codal-nrf52840-dk
[ 70%] Linking CXX executable NRF52840_DK
/usr/lib/gcc/arm-none-eabi/6.3.1/…/…/…/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/softfp/crt0.o: In function _start': /build/newlib-jo3xW1/newlib-2.4.0.20160527/build/arm-none-eabi/thumb/v7e-m/fpv4-sp/softfp/libgloss/arm/../../../../../../../../libgloss/arm/crt0.S:421: undefined reference to __wrap_atexit’
collect2: error: ld returned 1 exit status
CMakeFiles/NRF52840_DK.dir/build.make:1268: recipe for target ‘NRF52840_DK’ failed
make[2]: *** [NRF52840_DK] Error 1
CMakeFiles/Makefile2:106: recipe for target ‘CMakeFiles/NRF52840_DK.dir/all’ failed
make[1]: *** [CMakeFiles/NRF52840_DK.dir/all] Error 2
Makefile:83: recipe for target ‘all’ failed
make: *** [all] Error 2