• Sun 2021.09.19

    Repeatable on both native WebIDE and web based espruino\ide
    Repeatable on either editor upload or direct console entry



    I have worked two days on attempting to get neopixels to run on a Nordic nRF52840 Dongle based on the work that @AkosLukacs did two years ago.

    http://forum.espruino.com/conversations/323658/?offset=100

    post #123   Nordic "nRF52840 Dongle" Support

    As can be seen from the console output, the first two lines will upload and execute fine. As the third linerequire("neopixel") starts to upload, the WebIDE locks.



    Board Green LED is D6 - For neopixel also tried D2, D13, D29, D31

    digitalWrite(D6,0);
    pinMode(D2,"output");
    require("neopixel").write(D2, [11,11,0]);
    
    >process.env
    ={
      VERSION: "2v06.6",
      GIT_COMMIT: "db576d70",
      BOARD: "NRF52840DONGLE",
    
    "BAUD_RATE":"115200"
    



    Note the require statement is commented out - 4th line of L5

    [success] Connected to COM10
    >>> Connected to COM10
    Found a prompt... great!
    Splitting for reset(), delay 250
    SET chrome.storage.sync = {"AUTO_SAVE_CODE":true,"BAUD_RATE":"115200","BLOCKLY_EXTENSIONS":"|bluetooth|robot|","BLOCKLY_LANGUAGE":"en","BLOCKLY_TO_JS":false,"BOARD_JSON_URL":"http://www.espruino.com/json","CODE":"digitalWrite(D6,0);\n\npinMode(D2,\"output\");\n//require(\"neopixel\").write(D2, [11,11,0]);\n","COMPILATION":true,"COMPILATION_URL":"https://www.espruino.com/service/compiler","DISABLE_CODE_HINTS":false,"ENABLE_Testing":false,"ENV_ON_CONNECT":true,"FONT_SIZE":12,"MINIFICATION_DeadCode":true,"MINIFICATION_LEVEL":"","MINIFICATION_Literal":true,"MINIFICATION_Mangle":true,"MINIFICATION_Unreachable":true,"MINIFICATION_Unused":true,"MODULE_AS_FUNCTION":false,"MODULE_EXTENSIONS":".min.js|.js","MODULE_MINIFICATION_LEVEL":"","MODULE_PROXY_ENABLED":false,"MODULE_PROXY_PORT":"","MODULE_PROXY_URL":"","MODULE_URL":"https://www.espruino.com/modules","OFFLINE_DATA":"","OFFLINE_DATA_DOWNLOAD":"","OFFLINE_DATA_UPLOAD":"","OFFLINE_ENABLED":false,"RESET_BEFORE_SEND":true,"SAVE_ON_SEND":0,"SERIAL_AUDIO":"0","SERIAL_TCPIP":"","SERIAL_THROTTLE_SEND":false,"SET_TIME_ON_WRITE":false,"SHOW_CODE_LINK_ICON":false,"SHOW_WEBCAM_ICON":0,"STORE_LINE_NUMBERS":true,"Sound_Error":"","Sound_Info":"","Sound_Success":"","Sound_Warning":"","Speak_Error":false,"Speak_Info":false,"Speak_Success":false,"Speak_Warning":false,"UI_MODE":"Normal","WEBCAM_CONSTRAINTS":0,"projectEntry":"ECDBE226B08643DC748E4DFA98647B9D:EspruinonRF52840"}
    Config.BAUD_RATE => 115200
    Found a prompt... great!
    Splitting for reset(), delay 250
    Found a prompt... great!
    Splitting for reset(), delay 250
    

    Code executes as it should and board responds to commands entered from the console.


    Locks - note the un-commented require - 4th of L2 - so it is this line

    >>> Connected to COM10
    SET chrome.storage.sync = {"AUTO_SAVE_CODE":true,"BAUD_RATE":"115200","BLOCKLY_EXTENSIONS":"|bluetooth|robot|","BLOCKLY_LANGUAGE":"en","BLOCKLY_TO_JS":false,"BOARD_JSON_URL":"http://www.espruino.com/json","CODE":"digitalWrite(D6,0);\n\npinMode(D2,\"output\");\nrequire(\"neopixel\").write(D2, [11,11,0]);\n","COMPILATION":true,"COMPILATION_URL":"https://www.espruino.com/service/compiler","DISABLE_CODE_HINTS":false,"ENABLE_Testing":false,"ENV_ON_CONNECT":true,"FONT_SIZE":12,"MINIFICATION_DeadCode":true,"MINIFICATION_LEVEL":"","MINIFICATION_Literal":true,"MINIFICATION_Mangle":true,"MINIFICATION_Unreachable":true,"MINIFICATION_Unused":true,"MODULE_AS_FUNCTION":false,"MODULE_EXTENSIONS":".min.js|.js","MODULE_MINIFICATION_LEVEL":"","MODULE_PROXY_ENABLED":false,"MODULE_PROXY_PORT":"","MODULE_PROXY_URL":"","MODULE_URL":"https://www.espruino.com/modules","OFFLINE_DATA":"","OFFLINE_DATA_DOWNLOAD":"","OFFLINE_DATA_UPLOAD":"","OFFLINE_ENABLED":false,"RESET_BEFORE_SEND":true,"SAVE_ON_SEND":0,"SERIAL_AUDIO":"0","SERIAL_TCPIP":"","SERIAL_THROTTLE_SEND":false,"SET_TIME_ON_WRITE":false,"SHOW_CODE_LINK_ICON":false,"SHOW_WEBCAM_ICON":0,"STORE_LINE_NUMBERS":true,"Sound_Error":"","Sound_Info":"","Sound_Success":"","Sound_Warning":"","Speak_Error":false,"Speak_Info":false,"Speak_Success":false,"Speak_Warning":false,"UI_MODE":"Normal","WEBCAM_CONSTRAINTS":0,"projectEntry":"ECDBE226B08643DC748E4DFA98647B9D:EspruinonRF52840"}
    Found a prompt... great!
    Splitting for reset(), delay 250
    


    At this point, powering down is the only option.

    Also toyed with minification and Esprima settings

  • Note the same for the online WebIDE

    https://www.espruino.com/ide/

    Web IDE version 0.75.10

    >>> Receiving...
    Got "< << {\"VERSION\":\"2v06.6\",\"GIT_COMMIT\":\"db576d70\",\"BOARD\":\"NRF52840DONGLE\",\"FLASH\":1048576,\"STORAGE\":40960,\"RAM\":262144,\"SERIAL\":\"2325de65-c6b872ca\",\"CONSOLE\":\"USB\",\"MODULES\":\"Flash,Storage,heatshrink,net,dgram,http,NetworkJS,neopixel\",\"EXPTR\":536885592} >> >\r\n>"
    >>> 
    [notify_info] Found NRF52840DONGLE, 2v06.6
    Loading https://www.espruino.com/json/NRF52840DONGLE.json
    ERROR: getURL("https://www.espruino.com/json/NRF52840DONGLE.json") error : HTTP 404
    Board JSON loaded
    Firmware >1.43 supports faster writes over USB
    Set Slow Write = false
    Device found {"portName":"webserial:1091:498b"}
    [success] Connected to Web Serial, webserial:1091:498b
    >>> Connected to Web Serial, webserial:1091:498b
    >>> Minifying
    >>> Minification complete
    Found a prompt... great!
    Splitting for reset(), delay 250
    
    
    Connection Failed.
    
    Disconnect callback... {"port":"Web Serial","portName":"webserial:1091:498b"}
    WARNING: [notify_warn] Disconnected from Web Serial, webserial:1091:498b
    >>> Disconnected from Web Serial, webserial:1091:498b
    >>> Connecting...
    Set Slow Write = true
    Serial> Pre-paired Web Serial device already found
    >>> Connecting to serial port
    Serial> ERROR: InvalidStateError: Failed to execute 'open' on 'SerialPort': The port is already open.
    ERROR: [notify_error] Connection Failed.
    >>> Connection Failed.
    

    At this point, powering down is the only option.



    Trying to block copy into L-Hand console side, only first char 'r' shows and console then locks

    require("neopixel").write(D2, [11,11,0]);
    


     2v06.6 (c) 2019 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    >
    >r
    


  • There have been some updates for using neopixel on nrf52840 since that hex files where shared.

    https://github.com/espruino/Espruino/blob/a4a38ec17d354d951642a123f768875ee7005a0e/boards/NRF52840DK.py#L43

  • Sun 2021.09.19

    Thank you for the response @MaBe

    That specific line was added for the Developer Kit version.

    neopixels on the nRF52840   WaveShare DK
    post #123 Nordic "nRF52840 Dongle" Support

    However, from post #129

    http://forum.espruino.com/comments/15376706/

    that change was part of the 2V06.1 DK build for WaveShare board.

    I have the latest 2V06.6 Nordic Dongle build, (post #1) not that one for the DK

  • Also, it is puzzling what the pin values should be.

    From

    https://github.com/espruino/Espruino/blob/master/boards/NRF52840DK.py

     'DEFINES += -DNEOPIXEL_SCK_PIN=22 -DNEOPIXEL_LRCK_PIN=23', # nRF52840 needs LRCK pin defined for neopixel
    

    and

    https://espruino.microcosm.app/api/v1/files/9c0363019e9793499afe9f0fc5182af61ed1f622.py

    From:

    Discontinous pin numbers (for nRF52840 dongle)
    'Basically if all the pins are there then Espruino just works out the offset in pinInfo based on the number after D.'

    I've been able to use digitalWrite() to confirm these four outputs that do toggle:

    D2  :: 0.02
    D29 :: 0.29
    D31 :: 0.31
    
    D13 :: 0.13
    

    What should the designation be for pins such as 1.10 thru 1.16 ?

    Can anyone provide a pin reference for one specific pin that does work on the Nordic Dongle using neopixels please.

  • Check this for details about NRF52 pin names

    http://forum.espruino.com/conversations/363461/#comment16023461

  • At this point, powering down is the only option.

    The dongle is documented here https://infocenter.nordicsemi.com/topic/ug_nrf52840_dongle/UG/nrf52840_Dongle/intro.html?cp=4_0_5 and there is also link to download schematics. Not sure if it helps but I know that some pins (more than just one) are tied to reset pin so the module can reset itself to bootloader (led is glowing) by setting pin. Maybe that's what happened to you and it is waiting in bootloader?

    EDIT:
    pins 25,23,21,19 are tied to reset => -DNEOPIXEL_LRCK_PIN=23 in board file is not a good idea with the dongle.


    1 Attachment

    • Capture.JPG
  • Yes, most likely that's the problem. The dongle ties a bunch of pins together to make routing easier.

  • Wed 2021.09.22

    re: post #6   'Check this for details about NRF52 pin names'

    Thank you @MaBe for that snippet as it shall come in handy.

    I am a bit curious how one gets from the Nordic board silkscreen values:

    https://infocenter.nordicsemi.com/topic/ug_nrf52840_dongle/UG/nrf52840_Dongle/Images/nRF52840_dongle_front.svg

    to the output that your JS snippet provides.

    I've located the jspin.c file along with the specific nrf_gpio.h but just haven't stumbled across the method that is used to determine the offsets for the above image. I'm sure I'll eventually locate the source, but in the mean time your JS snippet should provide the needed reference.

    • first I though you struggle with pin names, because the dongle is using PN.M

    • next that the used firmware is missing the additional pins

    • than fanoush mentioned that D23 is a bad choice

    • than posted a full circuit to figure out two pins that are not used, eg P1.03 and P1.05

    P1.03 : D35, P1.05 : D37

    replace the old pin values with those two, like this

     'DEFINES += -DNEOPIXEL_SCK_PIN=35-DNEOPIXEL_LRCK_PIN=37',
    

    make and flash the new firmware and try again.

  • What should the designation be for pins such as 1.10 thru 1.16 ?

    1. prefix is +32, 1.10=D42
  • I had the same issue on a different nrf52840 board http://forum.espruino.com/conversations/354468/ not sure if this would help but this sounds like what I experienced before

  • In this case, http://forum.espruino.com/comments/15562682/ and building the hex file with this board def works for me

    Edit: just saw that fanoush mentioned it's not a good idea. I guess you can just pick any pin that's free (for the dongle, maybe one that's on a pad underneath so you don't accidentally use it?)

  • I guess you can just pick any pin that's free (for the dongle, maybe one that's on a pad underneath so you don't accidentally use it?)

    I never used neopixels so don't know what -DNEOPIXEL_LRCK_PIN=23 does and what this LRCK pin is used for. It is not good idea if it outputs low - that will reset the dongle. Was thinking you really use it for something and connect it to the leds - so not sure what "don't accidentally use it" means :-)

  • The neopixels require fast pulses, and the usual way firmware for microcontrollers do it is to ride on I2S (instead of bitbanging gpio).

    I2S usually need both SCK and LRCK defined, but the nRF52832 didn't need the LRCK pin defined. However after some testing (and a trip to the nordic forums) it seems it is indeed required.

    What I meant by not accidentally using it is that since with nRF52 you can assign devices their pins, if you put LRCK it on an exposed pin, you might accidentally connect it to your circuit and have a really awful time debugging :P

  • thanks, got it, so LRCK goes nowhere but must be used to enable i2s and some clock is produced there. Then it is indeed not a good idea to connect this to reset pin :-)

    So there are couple of pins not connected at all on 52840 dongle, one is P0.16 on the picture posted above.

    just tried D16 on dongle clone (E104-BT5040U) and writing 1 or 0 does nothing, reading gives true by default and false when configured as D16.mode("input_pulldown"), so I guess the pin is floating. D23.write(0) reboots to bootloader indeed

  • Fri 2021.09.24

    reply post #11

    'make and flash the new firmware and try again'

    Hi @MaBe thank you for that instruction.

    I'm not sure it has been understood, but I made my attempts using the pre-built solutions from post #123 'Nordic "nRF52840 Dongle" Support' thread that I referenced in post #1 and post #4

    Although a bit pre-mature, your steps and instruction command will come in handy when I get to the build.

  • Fri 2021.09.24

    reply to post #12

    'prefix is +32, 1.10=D42'

    Thank you @fanoush as I know you got what I was after.

    I feel like a real Dolt as your simple reponse makes it all clear now, as going back over the Nordic images and using MaBe's JS snippet, I understand where the thinking was incorrect.

    I now realize that I kept looking at the Dongle pin references and as they were all below 20, I somehow convinced myself that we were working with base 10. Just couldn't grasp what I perceived was needed an offset and increment, which just wouldn't work.

    As Spock in Star Trek would respond to an inbound tranmission;

       'Captain, . . . a simple binary code! . . .'

    How I missed the obvious really surprises me, as your example clears it all up. Thank you.

  • Sat 2021.09.25

    Temporary halt while attempting to resolve a build issue:

    Firmware build for PICO fails - make: *** [lib/startup_stm32f401xx.o] Error 127

  • Sat 2021.09.25

    While builds for the PICO and WIFI are problematic, and Make is running, I made an attampt at the nRF52840DK to see if progress could be made outside the original board list.

    Made progress there after successful install of SDK15, but a new error surfaced: make: *** [espruino_2v08.220_nrf52840.elf] Error 1


    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/atomic/nrf_atomic.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/atomic_flags/nrf_atflags.oCC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/ble_link_ctx_manager/ble_link_ctx_manager.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/util/app_error_handler_gcc.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/peer_manager/pm_mutex.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/common/ble_advdata.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/common/ble_conn_params.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/common/ble_srv_common.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/common/ble_conn_state.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/ble_services/ble_nus/ble_nus.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/peer_manager/peer_manager.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/peer_manager/peer_id.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/peer_manager/peer_database.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/peer_manager/peer_data_storage.oCC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/peer_manager/pm_buffer.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/peer_manager/id_manager.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/peer_manager/security_manager.o
    targetlibs/nrf5x_15/components/ble/peer_manager/pm_buffer.c: In function 'pm_buffer_block_acquire':
    targetlibs/nrf5x_15/components/ble/peer_manager/pm_buffer.c:104:46: warning: comparison of integer expressions of different signedness: 'int' and 'uint32_t' {aka 'long unsigned int'} [-Wsign-compare]
                 if ((i - first_locked_mutex + 1) == n_blocks)
                                                  ^~
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/peer_manager/security_dispatcher.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/peer_manager/gatt_cache_manager.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/ble/peer_manager/gatts_cache_manager.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/timer/app_timer.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/fds/fds.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/queue/nrf_queue.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/util/app_util_platform.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/util/sdk_mapped_flags.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/util/app_error.o
    targetlibs/nrf5x_15/components/libraries/fds/fds.c: In function 'write_execute':
    targetlibs/nrf5x_15/components/libraries/fds/fds.c:1237:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
                 if (!record_find_by_desc(&desc, &page))
                    ^
    targetlibs/nrf5x_15/components/libraries/fds/fds.c:1245:9: note: here
             case FDS_OP_WRITE_HEADER_BEGIN:
             ^~~~
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/util/nrf_assert.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/softdevice/common/nrf_sdh.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/softdevice/common/nrf_sdh_ble.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/softdevice/common/nrf_sdh_soc.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/experimental_section_vars/nrf_section_iter.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/fstorage/nrf_fstorage.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/fstorage/nrf_fstorage_sd.oCC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/atomic_fifo/nrf_atfifo.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/strerror/nrf_strerror.o
    CC /mnt/c/Users/robin/Espruino/targetlibs/nrf5x_15/components/libraries/balloc/nrf_balloc.o
    LD espruino_2v08.220_nrf52840.elf
    src/jslex.o: file not recognized: file format not recognized
    collect2: error: ld returned 1 exit status
    make/targets/ARM.make:2: recipe for target 'espruino_2v08.220_nrf52840.elf' failed
    make: *** [espruino_2v08.220_nrf52840.elf] Error 1
    rgc@DESKTOP-R7T0VUC:/mnt/c/Users/robin/Espruino$
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

WebIDE locks up while loading require("neopixel") on Nordic nRF52840 Dongle

Posted by Avatar for Robin @Robin

Actions