You are reading a single comment by @parasquid and its replies. Click here to read the full conversation.
  • I finally got a couple of these and found the time to look into making a board file.

    #!/bin/false
    # This file is part of Espruino, a JavaScript interpreter for Microcontrollers
    #
    # Copyright (C) 2013 Gordon Williams <gw@pur3.co.uk>
    #
    # This Source Code Form is subject to the terms of the Mozilla Public
    # License, v. 2.0. If a copy of the MPL was not distributed with this
    # file, You can obtain one at http://mozilla.org/MPL/2.0/.
    #
    # ----------------------------------------­----------------------------------------­--------
    # This file contains information for a specific board - the available pins, and where LEDs,
    # Buttons, and other in-built peripherals are. It is used to build documentation as well
    # as various source and header files for Espruino.
    # ----------------------------------------­----------------------------------------­--------
    
    
    '''
    source ./scripts/provision.sh ALL
    rm bin/*.hex
    make clean && BOARD=XIAOBLE RELEASE=1 make
    uf2conv.py ./bin/*.hex -c -f 0xADA52840
    mv flash.uf2 ~/Desktop/
    '''
    
    import pinutils;
    
    info = {
      'name' : "Seeed Xiao BLE",
      'link' :  [ "https://www.seeedstudio.com/Seeed-XIAO-­BLE-nRF52840-p-5201.html" ],
      'default_console' : "EV_SERIAL1",
      'default_console_tx' : "D6",
      'default_console_rx' : "D7",
      'default_console_baudrate' : "9600",
      'variables' : 14000, # How many variables are allocated for Espruino to use. RAM will be overflowed if this number is too high and code won't compile.
      # 'bootloader' : 1,
      'binary_name' : 'espruino_%v_xiaoble.hex',
      'build' : {
        'optimizeflags' : '-Os',
        'libraries' : [
          'BLUETOOTH',
        #  'NET',
          'GRAPHICS',
        # 'NFC',
          'NEOPIXEL',
          'JIT',
        ],
        'makefile' : [
          'DEFINES += -DCONFIG_GPIO_AS_PINRESET', # Allow the reset pin to work
          'DEFINES += -DNRF_USB=1 -DUSB',
          'DEFINES += -DNEOPIXEL_SCK_PIN=33 -DNEOPIXEL_LRCK_PIN=34', # nRF52840 needs LRCK pin defined for neopixel
          'DEFINES += -DBLUETOOTH_NAME_PREFIX=\'"XIAOBLE"\'',
          'DEFINES += -DSPIFLASH_READ2X', # Read SPI flash at 2x speed using MISO and MOSI for IO
          'DEFINES += -DESPR_UNICODE_SUPPORT=1',
          'NRF_SDK15=1',
        ]
      }
    };
    
    
    chip = {
      'part' : "NRF52840",
      'family' : "NRF52",
      'package' : "AQFN73",
      'ram' : 256,
      'flash' : 1024,
      'speed' : 64,
      'usart' : 1,
      'spi' : 1,
      'i2c' : 2,
      'adc' : 1,
      'dac' : 0,
      'saved_code' : {
        'address' : ((0xf4 - 2 - 96) * 4096), # Bootloader at 0xF4000
        'page_size' : 4096,
        'pages' : 96,
        'flash_available' : 1024 - ((0x26 + 0x20 + 2 + 96)*4) # Softdevice 140 uses 38 pages of flash, bootloader 8, FS 2, code 10. Each page is 4 kb.
      },
    };
    
    devices = {
      'LED1' : { 'pin' : 'H0' }, # Pin negated in software
      'LED2' : { 'pin' : 'H1' }, # Pin negated in software
      'LED3' : { 'pin' : 'H2' }, # Pin negated in software
      # Pin D33 and D34 are used for clock when driving neopixels - as not specifying a pin seems to break things
    
      'SPIFLASH' : {
                'pin_cs' : 'H25',
                'pin_sck' : 'H21',
                'pin_mosi' : 'H20',
                'pin_miso' : 'H24',
                'pin_wp' : 'H22',
                'pin_rst' : 'H23',
                'size' : 4096*512, # 2MB
                'memmap_base' : 0x60000000 # map into the address space (in software)
              }
    };
    
    # left-right, or top-bottom order
    board = {
    };
    
    # schematic at https://files.seeedstudio.com/wiki/XIAO-­BLE/Seeed-Studio-XIAO-nRF52840-Sense-v1.­1.pdf
    def get_pins():
      pins = [
       { "name":"PD0",  "sortingname":"D00", "port":"D", "num":"2", "functions":{}, "csv":{} },
       { "name":"PD1",  "sortingname":"D01", "port":"D", "num":"3", "functions":{}, "csv":{} },
       { "name":"PD2",  "sortingname":"D02", "port":"D", "num":"28", "functions":{}, "csv":{} },
       { "name":"PD3",  "sortingname":"D03", "port":"D", "num":"29", "functions":{}, "csv":{} },
       { "name":"PD4",  "sortingname":"D04", "port":"D", "num":"4", "functions":{}, "csv":{} },
       { "name":"PD5",  "sortingname":"D05", "port":"D", "num":"5", "functions":{}, "csv":{} },
       { "name":"PD6",  "sortingname":"D06", "port":"D", "num":"43", "functions":{}, "csv":{} },
       { "name":"PD7",  "sortingname":"D07", "port":"D", "num":"44", "functions":{}, "csv":{} },
       { "name":"PD8",  "sortingname":"D08", "port":"D", "num":"45", "functions":{}, "csv":{} },
       { "name":"PD9",  "sortingname":"D09", "port":"D", "num":"46", "functions":{}, "csv":{} },
       { "name":"PD10", "sortingname":"D10", "port":"D", "num":"47", "functions":{}, "csv":{} },
    
       { "name":"PA0", "sortingname":"A00", "port":"A", "num":"2", "functions":{ "ADC1_IN0":0 }, "csv":{} },
       { "name":"PA1", "sortingname":"A01", "port":"A", "num":"3", "functions":{ "ADC1_IN1":0 }, "csv":{} },
       { "name":"PA2", "sortingname":"A02", "port":"A", "num":"28", "functions":{ "ADC1_IN2":0 }, "csv":{} },
       { "name":"PA3", "sortingname":"A03", "port":"A", "num":"29", "functions":{ "ADC1_IN3":0 }, "csv":{} },
       { "name":"PA4", "sortingname":"A04", "port":"A", "num":"4", "functions":{ "ADC1_IN4":0 }, "csv":{} },
       { "name":"PA5", "sortingname":"A05", "port":"A", "num":"5", "functions":{ "ADC1_IN5":0 }, "csv":{} },
    
       { "name":"PH0", "sortingname":"H0", "port":"H", "num":"26", "functions":{"NEGATED":0}, "csv":{} }, # LED1
       { "name":"PH1", "sortingname":"H1", "port":"H", "num":"30", "functions":{"NEGATED":0}, "csv":{} }, # LED2
       { "name":"PH2", "sortingname":"H2", "port":"H", "num":"6", "functions":{"NEGATED":0}, "csv":{} }, # LED3
    
       { "name":"PH25", "sortingname":"H25", "port":"H", "num":"25", "functions":{}, "csv":{} },
       { "name":"PH21", "sortingname":"H21", "port":"H", "num":"21", "functions":{}, "csv":{} },
       { "name":"PH20", "sortingname":"H20", "port":"H", "num":"20", "functions":{}, "csv":{} },
       { "name":"PH24", "sortingname":"H24", "port":"H", "num":"24", "functions":{}, "csv":{} },
       { "name":"PH22", "sortingname":"H22", "port":"H", "num":"22", "functions":{}, "csv":{} },
       { "name":"PH23", "sortingname":"H23", "port":"H", "num":"23", "functions":{}, "csv":{} },
      ];
    
      # everything is non-5v tolerant
      for pin in pins:
        pin["functions"]["3.3"]=0;
      return pins
    

    not all pin assignments are implemented yet (especially on the sense version the IMU and the mic) but everything works so far. The QSPI flash is also connected although I'm not really sure how to test if the entirety of the flash is usable.

    It's also compatible with the built-in adafruit bootloader, so if you use the u2conv.py script you can create a uf2 file you can just drag and drop onto the xiao ble to flash espruino on it (no need for SWD).


    1 Attachment

About

Avatar for parasquid @parasquid started