Nordic "nRF52840 Dongle" Support

Posted on
Page
of 5
  • That's great! Thanks! You ok with me pulling that into the UNMAINTAINED_BOARDS branch?

  • There are still some small issues:
    Can I remove pins? Some pins are not routed to pads, and some pins are connected together to make routing easier (from the dongle manual):

    SW2 is also connected to P0.19, P0.21, P0.23, and P0.25. This is done to simplify PCB routing. These GPIOs should not be used and should be left as input with no pull or be disconnected by firmware.

    So those pins should not be toggled even accidentally. Toggling a pin that's not routed is no issue, but if someone sets these pins to different output values, that could fry the board I guess. Tiny chance, but still...

    The green LED (D6 IIRC) is turned on after boot. I can toggle it later, but strange. Any idea why?

    The LEDs are active low, so they turn off on the first toggle. Something like

     # Make buttons and LEDs negated
      pinutils.findpin(pins, "PD13", True)["functions"]["NEGATED"]=0;
    

    should solve it?

  • I answered the pin removal thing in your other post - so it should be easy enough to remove them.

    And yes, doing the negation should fix the LED thing I'd have thought.

  • Running now on UBLOX NINA B302 too!
    Congratulations to all!


    1 Attachment

    • Sem título.png
  • How can i do make direct access to GPIO P0.30 ?
    I want to make it to blink a led in my ESPRUINO BLOG with NINA B302

  • D30.toggle() should do the trick

  • D30 maps to direct io P030 ?
    Nice! I will do that this night

  • hI, d30 IS not mapped to P030.

    Who is mapped to P030 is D2

    Wich files has this map to me to follow ?

  • Should be. Haven't tested all, just the LEDs and button available on the 52840 dongle, and those were working:

      'BTN1' : { 'pin' : 'D38' }, # the button is at P1.06
      'LED1' : { 'pin' : 'D6' },  # green LED
      'LED2' : { 'pin' : 'D8' },   # RGB LED / red   P0.08
      'LED3' : { 'pin' : 'D41' },  # RGB LED / green P1.09
      'LED4' : { 'pin' : 'D12' },  # RGB LED / blue  P0.12
    

    All pins should be there. P0.00 as D0 and so on. P1.00 is D32 and so on.
    The pins are just defined by the board.py I uploaded in the previous post: http://forum.espruino.com/comments/14905­935/ the line pins = pinutils.generate_pins(0,47) # 48 General Purpose I/O Pins.

  • Akos, if i send my personal MAP, can you compile to me ?

    Or, if you give instructions to compile i can do here...i had done 832 year ago!

    Thanks!

  • Just follow the build instructions :)
    Provisioning was kind of messy on windows with WSL, but otherwise it's not really difficult.
    Or send me the board file, if you can't get it working.

  • :)

    The main is change

    devices = {
    'BTN1' : { 'pin' : 'D38' }, # the button is at P1.06
    'LED1' : { 'pin' : 'D6' }, # green LED
    'LED2' : { 'pin' : 'D8' }, # RGB LED / red P0.08
    'LED3' : { 'pin' : 'D41' }, # RGB LED / green P1.09
    'LED4' : { 'pin' : 'D12' }, # RGB LED / blue P0.12
    'RX_PIN_NUMBER' : { 'pin' : 'D13'},
    'TX_PIN_NUMBER' : { 'pin' : 'D15'},
    };

    Right ?

    I will want to map
    GPIO_1 to GPIO_52 names to the NINA B302

    For example,
    GPIO_1 will be the physical pin P0.13
    GPIO_2 will be the physical pin P0.14
    and soon
    How can i define one of those..
    What is D38, D6, etc ?
    For example, is D0 mapped as P0.0, D1 mapped as P0.1 ?


    1 Attachment

    • Sem título.png
  • I have a new build, fixes:

    • Button and the 4 LEDs are negated
    • Only accessible pins are available from Espruino (for example there is no D3, because P0.03 is not routed on the dongle)

    Board file two hex files are attached: 2v04.105 is built from the same commit as the previous one, 2v04.121 is from the latest master. Bluetooth and USB serial works, haven't done much testing...

    @tcpipchip Don't exactly remember what made it working, IIRC make everything "right"...
    Right now P0.00 is D0, P0.01 is D1 ... P0.31 is D31. P1.00 is D32, P1.01 is D33 and so on.

    You can do that from JS (or wrap it in an object, if you'd like to):

    GPIO_1 = D13
    GPIO_2 = D14
    

    Or - since the dongle build file defines the LEDs, button, and two pins for serial, you might want to create your own board file, and the pin naming could be done like the NodeMCU pin aliases: Add an extra file that defines aliases: Something like Nina.GPIO_1 is an alias for D13.

    @Gordon I have one last (hahaha) question: The nRF52840 has pins on P0 and P1. right now P1.00 maps to D32, that's kind of annoying (thoughts in my brain: do I add 31 or 32 or wat?). Tried to mess with the board file and build_pininfo.py, and I could make a mess and create for example an E9 pin, but didn't work.
    Can we map P1.00 to (for example) E0, P1.01 to E1, and so on?
    The button and an LED is on P1 right now, and those do work, just don't like the pin names this way :)


    3 Attachments

  • Working on my dongle! Thank you!

    >process.env
    ={
      VERSION: "2v04.121",
      GIT_COMMIT: "572d768e",
      BOARD: "NRF52840DONGLE",
      FLASH: 1048576, RAM: 262144,
      SERIAL: "321d5edb-78df5aa8",
      CONSOLE: "Bluetooth",
      MODULES: "Flash,Storage,hea" ... "etworkJS,neopixel",
      EXPTR: 536885656 }
    > 
    
  • Ready, can you compile ?

    #!/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.
    # ----------------------------------------­----------------------------------------­--------
    
    import pinutils;
    
    info = {
     'name' : "nRF52840 U-BLOX NINA B302",
     'link' :  [ "https://www.nordicsemi.com/Software-and­-Tools/Development-Kits/nRF52840-Dongle"­ ],
     'espruino_page_link' : 'nRF52840_B302',
      # This is the PCA10059
     'default_console' : "EV_SERIAL1",
     'default_console_tx' : "D45",
     'default_console_rx' : "D29",
     'default_console_baudrate' : "9600",
     'variables' : 12500, # 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_nrf52840_dongle.hex',
     'build' : {
       'optimizeflags' : '-Os',
       'libraries' : [
         'BLUETOOTH',
         'NET',
         'GRAPHICS',
         'NFC',
         'NEOPIXEL'
       ],
       'makefile' : [
         'DEFINES += -DCONFIG_GPIO_AS_PINRESET', # Allow the reset pin to work
         'DEFINES += -DBOARD_PCA10059',
         'DEFINES += -DNRF_USB=1 -DUSB',
         'NRF_SDK15=1'
       ]
     }
    };
    
    
    chip = {
      'part' : "NRF52840",
      'family' : "NRF52",
      'package' : "QFN48",
      'ram' : 256,
      'flash' : 1024,
      'speed' : 64,
      'usart' : 2,
      'spi' : 3,
      'i2c' : 2,
      'adc' : 1,
      'dac' : 0,
      'saved_code' : {
        'address' : ((246 - 10) * 4096), # Bootloader takes pages 248-255, FS takes 246-247
        'page_size' : 4096,
        'pages' : 10,
        'flash_available' : 1024 - ((31 + 8 + 2 + 10)*4) # Softdevice uses 31 pages of flash, bootloader 8, FS 2, code 10. Each page is 4 kb.
      },
    };
    
    devices = {
      'GPIO_1'  :           { 'pin' : 'D13' }, 
      'GPIO_2'  :           { 'pin' : 'D14' }, 
      'GPIO_3'  :           { 'pin' : 'D15' }, 
      'GPIO_4'  :           { 'pin' : 'D16' }, 
      'GPIO_5'  :           { 'pin' : 'D24' }, 
      'GPIO_7'  :           { 'pin' : 'D25' },
      'GPIO_8'  :           { 'pin' : 'D32' },
      'GPIO_16' :           { 'pin' : 'D3'  }, 
      'GPIO_17' :           { 'pin' : 'D28' }, 
      'GPIO_18' :           { 'pin' : 'D2'  }, 
      'GPIO_20' :           { 'pin' : 'D31' }, 
      'GPIO_21' :           { 'pin' : 'D44' }, 
      'GPIO_22' :           { 'pin' : 'D45' }, 
      'GPIO_23' :           { 'pin' : 'D29' },
      'GPIO_24' :           { 'pin' : 'D30' },
      'GPIO_25' :           { 'pin' : 'D4'  },  
      'GPIO_27' :           { 'pin' : 'D5'  },  
      'GPIO_28' :           { 'pin' : 'D9'  },  
      'GPIO_29' :           { 'pin' : 'D10' },  
      'GPIO_32' :           { 'pin' : 'D11' },  
      'GPIO_33' :           { 'pin' : 'D41' },  
      'GPIO_34' :           { 'pin' : 'D40' }, 
      'GPIO_35' :           { 'pin' : 'D33' },
      'GPIO_36' :           { 'pin' : 'D34' },
      'GPIO_37' :           { 'pin' : 'D35' },  
      'GPIO_38' :           { 'pin' : 'D42' },  
      'GPIO_39' :           { 'pin' : 'D43' },  
      'GPIO_40' :           { 'pin' : 'D47' },  
      'GPIO_41' :           { 'pin' : 'D46' },  
      'GPIO_42' :           { 'pin' : 'D26' },  
      'GPIO_43' :           { 'pin' : 'D6'  },  
      'GPIO_44' :           { 'pin' : 'D27' },  
      'GPIO_45' :           { 'pin' : 'D7'  },  
      'GPIO_46' :           { 'pin' : 'D12' },  
      'GPIO_47' :           { 'pin' : 'D23' },  
      'GPIO_48' :           { 'pin' : 'D21' },  
      'GPIO_49' :           { 'pin' : 'D22' },  
      'GPIO_50' :           { 'pin' : 'D20' },  
      'GPIO_51' :           { 'pin' : 'D17' },  
      'GPIO_52' :           { 'pin' : 'D19' }
    };
    
    # left-right, or top-bottom order
    board = {
      'left' : [ 'VDD', 'VDD', 'RESET', 'VDD','5V','GND','GND','','','D3','D4','­D28','D29','D30','D31'],
      'right' : [
         'D27', 'D26', 'D2', 'GND', 'D25','D24','D23', 'D22','D20','D19','',
         'D18','D17','D16','D15','D14','D13','D12­','D11','',
         'D10','D9','D8','D7','D6','D5','D21','D1­','D0'],
      '_notes' : {
        'D13' : "Serial console RX",
        'D15' : "Serial console TX"
      }
    };
    board["_css"] = """
    [#board](http://forum.espruino.com/searc­h/?q=%23board) {
      width: 528px;
      height: 800px;
      top: 0px;
      left : 200px;
      background-image: url(img/NRF528DK.jpg);
    }
    [#boardcontainer](http://forum.espruino.­com/search/?q=%23boardcontainer) {
      height: 900px;
    }
    
    [#left](http://forum.espruino.com/search­/?q=%23left) {
        top: 219px;
        right: 466px;
    }
    [#right](http://forum.espruino.com/searc­h/?q=%23right) {
        top: 150px;
        left: 466px;
    }
    
    .leftpin { height: 17px; }
    .rightpin { height: 17px; }
    """;
    
    def get_pins():
      pins = pinutils.generate_pins(0,47) # 48 General Purpose I/O Pins.
      pinutils.findpin(pins, "PD0", True)["functions"]["XL1"]=0;
      pinutils.findpin(pins, "PD1", True)["functions"]["XL2"]=0;
      # pinutils.findpin(pins, "PD5", True)["functions"]["RTS"]=0;
      # pinutils.findpin(pins, "PD6", True)["functions"]["TXD"]=0;
      # pinutils.findpin(pins, "PD7", True)["functions"]["CTS"]=0;
      # pinutils.findpin(pins, "PD8", True)["functions"]["RXD"]=0;
      # pinutils.findpin(pins, "PD9", True)["functions"]["NFC1"]=0;
      # pinutils.findpin(pins, "PD10", True)["functions"]["NFC2"]=0;
      pinutils.findpin(pins, "PD2", True)["functions"]["ADC1_IN0"]=0;
      pinutils.findpin(pins, "PD3", True)["functions"]["ADC1_IN1"]=0;
      pinutils.findpin(pins, "PD4", True)["functions"]["ADC1_IN2"]=0;
      pinutils.findpin(pins, "PD5", True)["functions"]["ADC1_IN3"]=0;
      pinutils.findpin(pins, "PD28", True)["functions"]["ADC1_IN4"]=0;
      pinutils.findpin(pins, "PD29", True)["functions"]["ADC1_IN5"]=0;
      pinutils.findpin(pins, "PD30", True)["functions"]["ADC1_IN6"]=0;
      pinutils.findpin(pins, "PD31", True)["functions"]["ADC1_IN7"]=0;
      # Make buttons and LEDs negated
      pinutils.findpin(pins, "PD13", True)["functions"]["RXD"]=0;
      pinutils.findpin(pins, "PD14", True)["functions"]["NEGATED"]=0;
      pinutils.findpin(pins, "PD15", True)["functions"]["TXD"]=0;
      pinutils.findpin(pins, "PD16", True)["functions"]["NEGATED"]=0;
      pinutils.findpin(pins, "PD11", True)["functions"]["NEGATED"]=0;
      pinutils.findpin(pins, "PD12", True)["functions"]["NEGATED"]=0;
      pinutils.findpin(pins, "PD24", True)["functions"]["NEGATED"]=0;
      pinutils.findpin(pins, "PD25", True)["functions"]["NEGATED"]=0;
      # TODO: SW2 is also connected to P0.19, P0.21, P0.23, and P0.25. This is done to simplify PCB routing. These
      #       GPIOs should not be used and should be left as input with no pull or be disconnected by firmware.
    
      # everything is non-5v tolerant
      for pin in pins:
        pin["functions"]["3.3"]=0;
      [#The](http://forum.espruino.com/search/­?q=%23The) boot/reset button will function as a reset button in normal operation. Pin reset on PD21 needs to be enabled on the nRF52832 device for this to work.
      return pins
    
    
  • Wed 2019.10.02

    As @AkosLukacs suggested in #86, 'Just follow the build instructions' as two builds have been provided in #88

    The following is a good starting point, see the AkosLukacs entry which is #8 in the entire thread, when expanded. The step-by-step instructions are what I am following to perform the exact task you wish to accomplish:

    http://forum.espruino.com/comments/14873­740/

  • Without NFC, because I didn't apply the NFC patches, and build fails with NFC.
    You had one typo int your board file at the penultimate line: Should start with # sign to make that line a comment.
    And totally untested, compiled on the train :)

    But yeah, @Robin is right, try to get it building on your computer, so you can tweak the board file.


    2 Attachments

  • Ok, I think you're after two things that are incompatible (I could be wrong though :).

    Basically when you access a pin in Espruino, Espruino gets the hardware pin number and port from gen/jspininfo.c.

    Normally, without PIN_NAMES_DIRECT, you can have a bunch of different name/number pins that access the same port. So E0 could map to pin number 32, eg. E0 -> P1.0.

    But since you want to skip pins out as well, you use PIN_NAMES_DIRECT, which uses the pin number supplied in the pinInfo file, so a pin number 32 must always stay 32.

    The other thing you could do is mess around with jshardware.c to make it look at the port bit of pinInfo, but I think that's pretty nasty and would require a bunch of changes.

  • Lucas
    I compiled with parameters but i getting a 800K hex file! Strange!
    Can you compile there ?

  • The ~800k file is the ".app_hex", but there should be a bigger ".hex" file too.

  • then really something is wrong during my compile...

  • @Gordon Saving code to the dongle doesn't work , but works on the nRF52840DK.
    Tested save() and "Write To Flash" (from the IDE), neither works on nRF52840 dongle, but both work on the DK. Tried two builds on both: 2v04.33 and 2v04.121 (current latest), same behaviour.
    I know neither is an official board, but any idea?

    The DK:

    >setInterval('LED2.toggle()', 333);
    =1
    >save()
    =undefined
    Compacting Flash...
    Calculating Size...
    Writing..
    Compressed 200000 bytes to 6277
    // And works just fine
    

    The dongle:

    >setInterval('LED2.toggle()', 333);
    =1
    >save()
    =undefined
    Compacting Flash...
    Calculating Size...
    // hangs there, and disconnects after a couple of seconds.
    // nothing saved to flash, works just fine after power cycling...
    

    Edit: thanks for the previous reply, of course I want to do something totally not supported with the pins :)

  • Is it actually the same chip, or is it one with less flash memory?

    You could try require("Storage").eraseAll() and see if it helps?

  • nevermind, fix is in my next post :)

  • Same thing on my dongle. :(

    >save()
    =undefined
    Compacting Flash...
    Calculating Size...
    Disconnected
    
    >process.memory()
    ={ free: 12476, usage: 24, total: 12500, history: 7,
      gc: 0, gctime: 20.05004882812, "stackEndAddress": 537092912, flash_start: 0, "flash_binary_end": 478792,
      "flash_code_start": 966656, flash_length: 1048576 }
    
    >require("Storage").getFree()
    =40960
    > 
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Nordic "nRF52840 Dongle" Support

Posted by Avatar for Stev @Stev

Actions