Avatar for user75013

user75013

Member since Mar 2017 • Last active Sep 2017
  • 3 conversations
  • 6 comments

Most recent activity

    • 2 comments
    • 2,782 views
  • in Porting to new Devices
    Avatar for user75013

    Hi,

    Until now, I was using a PUCKJS device, for which I have added a library for specific hardware support.
    The library is compiled and linked with Espruino.
    I can load the PUCKJS with this new code through Bluetooth with the nRF toolbox and DFU boot loader.
    All work fine, I can invoque functions in the added library.

    Now I’m trying to use the nRF52 development kit board, which is closed to our target design, and which shall be more convenient for finalization purpose.
    I get some problems for loading the code into this board.

    I have to perform loading in 2 ways:
    1) By directly copying the code into the MBED drive
    2) Through Bluetooth, by using the DFU boot loader as for the PUSKJS

    While I was not sure of the correct state of the board after some unsuccessful load attempts, I decided to update the board firmware, as explained on the ARMmbed site (Boards >> Nordic nRF52-DK):

    • download the binary from Nordic
    • perform a boot reset => BOOTLOADER drive is enumerated
    • copy the firmware to the BOOTLOADER drive
    • wait then power off / power on the board => MBED drive is enumerated

    Next I generated the code for the NRF52832DK board. In a first approach, I removed the specific library I added to the project.

    make clean && BOARD=NRF52832DK RELEASE=1 make
    

    This merges the Espruino code with the SoftDevice and generates the espruino_1v91.599_nrf52832.hex file.
    I then copied the .hex file into the MBED drive.
    The drive automatically dismounts and mounts again.
    I then powered off / powered on the board.
    At this stage, I expected to be able to connect the board through the Espruino WEB IDE, but this is not possible : the board is not advertising and not visible as a Bluetooth device.

    Can you help me for this problem ?

    I also tried to generate a DFU bootloader for the NRF52DK.

    make clean && BOOTLOADER=1 BOARD=NRF52832DK RELEASE=1 make
    

    This first generated several errors because some included files were not found.
    I modified the makefile to add the paths to the missing files and retried the make.
    The make failed again but with undefined references :

    targets/nrf5x_dfu/main.o: In function ‘main’:
    main.c:(.text.startup.main+0x26): undefined reference to ‘nrf_bootloader_init’
    main.c:(.text.startup.main+0x36): undefined reference to ‘nrf_bootloader_app_start’
    

    Is there something wrong in the generation process ?

    So I tried to directly use the DFU boot loader provided in the nRF5 DSK
    I first tried nRF5_SDK_11, which provides 'dfu_dual_bank_ble_s132_pca10040.hex' in examples/dfu/bootloader/hex
    I also tried nRF5_SDK_12, which provides 'secure_dfu_secure_dfu_ble_s132_pca10040_debug.hex' in examples/dfu/bootloader_secure/pca10040_debug/hex

    Both files, once loaded (copied into the MBED drive, etc.) make the board visible as DfuTarg in the DFU nRF toolbox.

    I then generated a .zip package for the NRF52DK. For that I had to modify the NRF52832DK.py file by adding the following lines (copied from PUCKJS.py) in the ‘makefile’ section :

    'DFU_PRIVATE_KEY= targets/nrf5x_dfu/dfu_private_key.pem’,
    ‘DFU_SETTINGS=—application-version 0xff —hw-version 52 —sd-req 0x8C’,

    and then make again :

    make clean && DFU_UPDATE_BUILD=1 USE_BOOTLOADER=1 BOARD=NRF52832DK RELEASE=1 make
    

    This generates the 'espruino_1v91.599_nrf52832.zip' package file.
    When I try to load the generated package with the DFU nRF toolbox, it fails.
    With the bootloader from SDK 11, the error is ‘remote DFU data exceeds limit’. Is it due to the fact that it is a dual bank bootloader ?
    With the bootloader from SDK 12, the error is ‘invalid CRC’.

    Thank you for your help for all these problems.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user75013

    Thank you Gordon, you'r right, the problem disappears when I don't call jsvUnLock(parent);
    All works fine now.
    Thank you for your help.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user75013

    Hi,

    I’m currently using a PUCKJS device, for which I have added a library for specific hardware support.
    The library is compiled and linked with Espruino.
    I am able to load the PUCK with this new code, and invoque some functions of this library from JavaScript code running on the Espruino WEB IDE.
    All of that works well, except that I can observe an abnormal memory consumption where all resources should be released.

    Basically, the library contains the following code in the jswrap source:

    /*JSON{
      "type" : "class",
      "class" : "MyContextClass"
    }
    */
    
    /*JSON{
        "type" : "staticmethod",
        "class" : "MYCLASS",
        "name" : "open",
        "generate" : "jswrap_myclass_open",
        "return" : ["JsVar", "A context object or null if any error"]
    }
    */
    JsVar *jswrap_myclass_open(void) {
        JsVar *context = jspNewObject(0, "MyContextClass");
        if (! context) {
            jsExceptionHere(JSET_ERROR, "myclass resource failure");
            return NULL;
        }
        return(context);
    }
    
    /*JSON{
        "type" : "method",
        "class" : "MyContextClass",
        "name" : "close",
        "generate" : "jswrap_myclass_close"
    }
    */
    void jswrap_myclass_close(JsVar *parent) {
        jsvRemoveAllChildren(parent);
        jsvUnLock(parent);
    }
    

    Then, under the WEB IDE, I repeatadly execute the following lines:

    myContext = MYCLASS.open();
    myContext.close();
    process.memory();
    

    At each iteration, the process.memory displays a decreasing value for the "free" field and an increasing value for the "usage" field.

    Is there something missing or wrong in the close function that could explain why resource is consumed ?

    Thank you for your help.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user75013

    After correcting some installation issues, i can now correctly generate the .zip file and download to the PUCKJS device.
    Thank you for your advices.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user75013

    Thank you for your help. I think you're right, the problem is probably due to an installation or provision issue. This may be related to my version of Linux, witch is a bit old and not very stable. I will revue the installation process and check all the dependencies as soon as possible. I'll keep you informed.
    Again thanks a lot for your commitment and the quickness of your answers.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user75013

    Hi,
    I want to add a module to the Espruino system and load it on a Puck.js device. The module is written in C and has to be compiled and linked with Espruino.
    For now, i just try to build Espruino, which i downloaded from GitHub, on a Linux machine (OpenSUSE 12.2). I run:

    make clean;DFU_UPDATE_BUILD=1 BOARD=PUCKJS RELEASE=1 make
    

    Compilation and link seams to be Ok in spite of minor warnings. The .lst .hex and .elf files are properly generated.
    I get an error in the package generation:

    ...
    GEN espruino_1v91.599_puckjs.lst
    GEN espruino_1v91.599_puckjs.hex
    Not merging softdevice or bootloader with application
    # nrfutil  pkg generate --help
    nrfutil pkg generate espruino_1v91.599_puckjs.zip --application espruino_1v91.599_puckjs.hex --application-version 0xff --hw-version 52 --sd-req 0x8C --key-file targets/nrf5x_dfu/dfu_private_key.pem
    Traceback (most recent call last):
      File "/usr/local/bin/nrfutil", line 5, in <module>
        from pkg_resources import load_entry_point
      File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2735, in <module>
        working_set.require(__requires__)
      File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 690, in require
        needed = self.resolve(parse_requirements(requirements))
      File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 588, in resolve
        raise DistributionNotFound(req)
    pkg_resources.DistributionNotFound: protobuf
    make: *** [espruino_1v91.599_puckjs.hex] Erreur 1
    make: *** Attente des tâches non terminées....
    

    Do you have an idea on this problem ? Is there any software component missing ?
    Thank you for your help.

Actions