You are reading a single comment by @ColinP and its replies. Click here to read the full conversation.
  • Hello,

    Flow control (or at least the RTS (or CTS?) pin being asserted) seems to be needed before the JLink dongle serial interface will transmit anything. To begin with I only got data from the console but couldn't send it anything and couldn't find the correct incantation to turn off flow control.

    It turns out that the Bluetooth flakiness was caused as both the "nRF toolbox" and "nRF UART v2.0" apps were running on my phone. It looks as though one of them was trying to reconnect in the background. I rebooted my phone to stop any services that were running, or in case the Android BTL stack was upset, and Bluetooth seems reliable now. I have noticed that after closing a connection it stops advertising and hence I cannot reconnect. Not sure if this is intentional or not.

    I'll try the Adafruit board later to see if it now works without a serial connection.

    In the meantime, for anyone interested, my quick hacks to get it working with the Nordic PCA10000 dongle are:

    Install JLink_Linux_V492_i386 and gcc-arm-none-eabi-4_9-2015q1-20150306-li­nux.tar.bz2 and add to PATH

    Change RAM size in boards.py to run with 16k RAM, as copied from MICROBIT.py:

    diff --git a/boards/NRF51822DK.py b/boards/NRF51822DK.py
    index 0ebc85e..a7be363 100644
    --- a/boards/NRF51822DK.py
    +++ b/boards/NRF51822DK.py
    @@ -23,7 +23,7 @@ info = {
      'default_console_tx' : "D9",
      'default_console_rx' : "D11",
      'default_console_baudrate' : "9600",
    - 'variables' : 200, # How many variables are allocated for Espruino to use. RAM will be overflowed if this number is too high and code won't compile.
    + 'variables' : 145, # How many variables are allocated for Espruino to use. RAM will be overflowed if this number is too high and code won't compile.
      'binary_name' : 'espruino_%v_nrf51822.bin',
      'build' : {
       'defines' : [
    @@ -36,13 +36,13 @@ chip = {
       'part' : "NRF51822",
       'family' : "NRF51",
       'package' : "QFN48",
    -  'ram' : 32,
    +  'ram' : 16,
       'flash' : 256,
    

    Hack serial port config to allow HW flow control:

    diff --git a/targets/nrf5x/jshardware.c b/targets/nrf5x/jshardware.c
    index e30afc8..5ae69fa 100644
    --- a/targets/nrf5x/jshardware.c
    +++ b/targets/nrf5x/jshardware.c
    @@ -400,9 +400,9 @@ void jshUSARTSetup(IOEventFlags device, JshUSARTInfo *inf) {
       const app_uart_comm_params_t comm_params = {
           pinInfo[inf->pinRX].pin,
           pinInfo[inf->pinTX].pin,
    -      UART_PIN_DISCONNECTED,
    -      UART_PIN_DISCONNECTED,
    -      APP_UART_FLOW_CONTROL_DISABLED,
    +      8, //UART_PIN_DISCONNECTED,
    +      10, //UART_PIN_DISCONNECTED,
    +      APP_UART_FLOW_CONTROL_ENABLED, //APP_UART_FLOW_CONTROL_DISABLED,
           inf->parity!=0, // TODO: ODD or EVEN parity?
           baud
       };
    

    I created a script to allow easier flashing - save as 'flash.jlink':

    device nrf51822
    speed 1000
    w4 4001e504 1
    loadfile espruino_1v84.70_nrf51822.hex
    r
    g
    q
    

    build and flash using:

    NRF51822DK=1 RELEASE=1 make && JLinkExe flash.jlink
    

    and access the serial console provided by the JLink using (on Linux):

    screen /dev/ttyACM0 9600
    
About

Avatar for ColinP @ColinP started