Avatar for Chris3006

Chris3006

Member since May 2024 • Last active Jul 2024
  • 1 conversations
  • 8 comments

Most recent activity

  • in Other Boards
    Avatar for Chris3006

    Ahh! I don't know why this happened! So i just reversed it.

    diff --git a/targets/nrf5x/jshardware.c b/targets/nrf5x/jshardware.c
    index ca501bb..ac937f4 100644
    --- a/targets/nrf5x/jshardware.c
    +++ b/targets/nrf5x/jshardware.c
    @@ -54,8 +54,8 @@ USB data receive is broken, although examples+config seem almost identical.
     [#include](https://forum.espruino.com/se­arch/?q=%23include) "bluetooth.h"
     [#include](https://forum.espruino.com/se­arch/?q=%23include) "bluetooth_utils.h"
     [#include](https://forum.espruino.com/se­arch/?q=%23include) "jswrap_bluetooth.h"
    -#else
     [#include](https://forum.espruino.com/se­arch/?q=%23include) "nrf_sdm.h"
    +#else
     [#include](https://forum.espruino.com/se­arch/?q=%23include) "nrf_temp.h"
     void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info) {
     }
    @@ -2493,7 +2493,7 @@ bool jshFlashErasePages(uint32_t addr, uint32_t byteLength) {
       uint8_t sd_enabled = 0;
    -  [#ifndef](https://forum.espruino.com/sea­rch/?q=%23ifndef) BLUETOOTH
    +  [#ifdef](https://forum.espruino.com/sear­ch/?q=%23ifdef) BLUETOOTH
       sd_softdevice_is_enabled(&sd_enabled);
       [#endif](https://forum.espruino.com/sear­ch/?q=%23endif)
       while (byteLength>=4096 && !jspIsInterrupted()) {
    @@ -2662,7 +2662,7 @@ void jshFlashWrite(void * buf, uint32_t addr, uint32_t len) {
       if (jshFlashWriteProtect(addr)) return;
       uint32_t err = 0;
    
  • in Other Boards
    Avatar for Chris3006

    Hi,
    if i do peek32(0x40000000+0x418) i get STATE = running and SRC = RC, so thats not the problem. However if i execute poke32(0x4000B000,1) the setInterval() works so i assume that the RTC0 has not been started.

    So i made your suggested changes:

    diff --git a/targets/nrf5x/jshardware.c b/targets/nrf5x/jshardware.c
    index 879942b..de94214 100644
    --- a/targets/nrf5x/jshardware.c
    +++ b/targets/nrf5x/jshardware.c
    
    @@ -984,7 +987,14 @@ void jshInit() {
     [#else](https://forum.espruino.com/searc­h/?q=%23else) // !BLUETOOTH
       // because the code in bluetooth.c will call jsh_sys_evt_handler for us
       // if we were using bluetooth
    +#ifdef SOFTDEVICE_PRESENT
    +#if NRF_SD_BLE_API_VERSION<5
       softdevice_sys_evt_handler_set(jsh_sys_e­vt_handler);
    +#else
    +  NRF_SDH_SOC_OBSERVER(m_soc_observer, 1, jsh_sys_evt_handler, NULL);
    +#endif
    +#endif
    +NRF_RTC0->TASKS_START = 1;
     [#endif](https://forum.espruino.com/sear­ch/?q=%23endif)
    

    It looks like the PRESCALER configuration works like this. At least the setInterval() calls execute with the right interval.
    For now everything works so far i think. You helped me a lot! Thanks.

    I've attached the complete changes. If anyone needs this too it can be found here.

  • in Other Boards
    Avatar for Chris3006

    I tried a little more and found out that that setIntervaland setTimeout do not work anymore when compiling without bluetooth. The function does not fail with an error and return the correct index, but they never execute the callback function. Could it be that the interrupts are handled differently?

  • in Other Boards
    Avatar for Chris3006

    Now i understand what is happening. So the lines in
    https://github.com/espruino/Espruino/blo­b/52352efac4f8f40976a4d268a0a074ad15251b­29/targets/nrf5x/jshardware.c#L984
    are not needed at all, because there are no events generated.
    I used your suggested changes from #9 and that works so far for writing to flash.
    Thanks again for your help!

  • in Other Boards
    Avatar for Chris3006

    No this unfortunately does not work.
    I get an InternalError: Timeout on jshFlashWrite if i write to a file.
    But if i try to read the same file afterwards, i can obtain the contents of it with no errors.

  • in Other Boards
    Avatar for Chris3006

    Thanks for the detailed explanation!
    The hex file you provided indeed does not run on the NRF52840DK. But i tried your fixes in jshardware.c and they worked. Even tho i got a linker error here (undefined reference to app_ram_base):
    https://github.com/espruino/Espruino/blo­b/edc64ce1ab231c608110797546ffa9d4457454­25/src/jswrap_process.c#L159

    I just added defines to ignore these lines if bluetooth is disabled.

    diff --git a/src/jswrap_process.c b/src/jswrap_process.c
    index b25720f..288fb93 100644
    --- a/src/jswrap_process.c
    +++ b/src/jswrap_process.c
    @@ -156,9 +156,11 @@ JsVar *jswrap_process_env() {
       // Pointer to a list of predefined exports - eventually we'll get rid of the array above
       jsvObjectSetChildAndUnLock(obj, "EXPTR", jsvNewFromInteger((JsVarInt)(size_t)expo­rtPtrs));
     [#ifdef](https://forum.espruino.com/sear­ch/?q=%23ifdef) NRF5X
    +  [#ifdef](https://forum.espruino.com/sear­ch/?q=%23ifdef) BUETOOTH
       extern uint32_t app_ram_base;
       if (app_ram_base)
         jsvObjectSetChildAndUnLock(obj, "APP_RAM_BASE", jsvNewFromInteger((JsVarInt)app_ram_base­));
    +  [#endif](https://forum.espruino.com/sear­ch/?q=%23endif)
     [#endif](https://forum.espruino.com/sear­ch/?q=%23endif)
     [#endif](https://forum.espruino.com/sear­ch/?q=%23endif)
       return obj;
    

    It compiles and runs on the NRF52840DK and is the desired result i was looking for.
    I think removing Softdevice entirely would save a lot more memory but it is not needed for my application.
    Thanks alot!

  • in Other Boards
    Avatar for Chris3006

    First of all thanks for your reply.
    The idea was to compile a minimal binary with only the Espruino core functionality to reduce flash usage. If softdevice is not needed necessarily for this I could try to compile without softdevice entirely.

  • in Other Boards
    Avatar for Chris3006

    Hi,

    i have successfully compiled an Espruino 2V22 binary for the NRF52840-DK using the NRF52840DK.py board definition file.
    However if i try to compile without bluetooth i get the following errors:

    targets/nrf5x/jshardware.c: In function 'jshInit':
    targets/nrf5x/jshardware.c:987:3: error: implicit declaration of function 'softdevice_sys_evt_handler_set' [-Werror=implicit-function-declaration]
      987 |   softdevice_sys_evt_handler_set(jsh_sys_e­vt_handler);
            |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    targets/nrf5x/jshardware.c:1005:5: error: 'ret' undeclared (first use in this function)
     1005 |     ret = app_usbd_power_events_enable();
             |     ^~~
    

    any advice on how to get espruino working on the NRF52840DK without Bluetooth?

Actions