Undefined reference to `rpc_fncall_sync', uVisor

19 Aug 2016

Hi,

When I try to use the RPC API in uvisor, i'm getting this error while building my project:

[ERROR] c:/program files (x86)/gnu tools arm embedded/5.3 2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld.exe: Warning: alignment 1 of symbol `__uvisor_ps' in ./mbed-os/features/FEATURE_UVISOR/targets/TARGET_UVISOR_SUPPORTED/TARGET_MAX32550/TARGET_DEBUG/TARGET_M3\libconfiguration_maxim_m3_mq55.a(uvisor-output.o) is smaller than 4 in ./mbed-os/features/FEATURE_UVISOR/targets/TARGET_UVISOR_SUPPORTED/TARGET_MAX32550/TARGET_DEBUG/TARGET_M3\libconfiguration_maxim_m3_mq55.a(disabled.o)
./.build/MAX32550/GCC_ARM/source/box.o: In function `_sgw_sync_print_secret(unsigned long)':
C:\Users\abderrahman.sensaoui\Documents\Code\mbedclitest\toto/.\source/box.cpp:33: undefined reference to `rpc_fncall_sync'
collect2.exe: error: ld returned 1 exit status

my objectif is to make 2 boxes communicate securely using the RPC. here my code :

box1.cpp :

 /* ... */
static void Thread_1(const void *);
void print_secret(void);

/* Secure box configuration */
UVISOR_BOX_NAMESPACE(NULL);                   /* We won't specify a box namespace for this example. */
UVISOR_BOX_HEAPSIZE(4096);                    /* Heap size for the secure box */
UVISOR_BOX_MAIN(Thread_1,    /* Main thread for the secure box */
                osPriorityNormal,             /* Priority of the secure box's main thread */
                1024);                        /* Stack size for the secure box's main thread */
UVISOR_BOX_CONFIG(box1,              /* Name of the secure box */
                  Thread_1_acls,       /* ACLs list for the secure box */
                  1024,                       /* Stack size for the secure box */
                  Contextbox);  /* Private static memory for the secure box. */

UVISOR_BOX_RPC_GATEWAY_SYNC(box1, print_secret_sync, print_secret, void, void);

void print_secret(void)
{
  printf("Test print : %d \r\n", uvisor_ctx->nb++);
}

/* Main thread for the secure box */
static void Thread_1(const void *)
{
 
  uvisor_ctx->nb = 0;
  while (1) {
   
    uvisor_ctx->nb++;
    Thread::wait(1000);
  }
}

box1.h :

UVISOR_EXTERN void (*print_secret_sync)(void);

and box2.cpp

/* ... */
static void Thread_2(const void *);
/* Secure box configuration */
UVISOR_BOX_NAMESPACE(NULL);                   /* We won't specify a box namespace for this example. */
UVISOR_BOX_HEAPSIZE(4096);                    /* Heap size for the secure box */
UVISOR_BOX_MAIN(Thread_2,    /* Main thread for the secure box */
                osPriorityNormal,             /* Priority of the secure box's main thread */
                1024);                        /* Stack size for the secure box's main thread */
UVISOR_BOX_CONFIG(box2,              /* Name of the secure box */
                  Thread_2_acls,       /* ACLs list for the secure box */
                  1024,                       /* Stack size for the secure box */
                  Contextbox2);  /* Private static memory for the secure box. */


/* Main thread for the secure box */
static void Thread_2(const void *)
{
  DigitalOut led2(LED2);

  while (1) {
      led2 = !led2;
      print_secret_sync();
      Thread::wait(1000);
  }
}

Thank you for your help.

23 Aug 2016

When I try and compile the basic blinky uVisor code I am met with an undefined reference to __wrap_calloc_r. Did you come across this error at some point?

There seem to be a fair amount of problems getting this thing to build.

24 Aug 2016

No, I didn't encounter this error, uVisor seems to work fine on my board except for the RPC API, and I think it's because they still haven't publish yet the source file "rpc.c".

I think _wrap_calloc_c is in an extern library(newlib) provided by the GCC ARM toolchain. I can't say more, but maybe it will help you. make sure you are using GCC_ARM toolchain, for now uVisor is only compatible with this toolchain.

24 Aug 2016

Seems to be a bug in the mbed-cli tools. I posted an issue on the uVisor github page. Apparently the `new` mbed command will pull down the latest commit rather than the latest release. Of course, using the latest revision of code can be prone to bugs - which is what I am running into.

I mention this here in case this is related to the problem you are observing. See my post here: https://github.com/ARMmbed/uvisor/issues/312

30 Aug 2016

I, too, ran into this problem and a quick search reveals that rpc_fncall_sync is not defined anywhere in the uVisor source tree, even on branches other than master. https://github.com/ARMmbed/uvisor/search?utf8=%E2%9C%93&q=rpc_fncall_sync

That function, and the rest of RPC, has been implemented in a PR that is not yet mature enough to be merged into mainline. https://github.com/ARMmbed/uvisor/pull/308/files#diff-3f50a22652fa8f9c6be2d63b98ca9e66R128

31 Aug 2016

Thank you, I've seen that the source file rpc.c was missing.

Have you tried the last version of uVisor, I don't know which board you are using, but if you are using K64F you won't have any problem. if you are using another one, can you tell how you set up the page heap SECTION in the linker script? especially the alignment, I did this (as shown in vmpu_armv7m.c) but it's not working :

/* ... */

__uvisor_bss_end = .; 
    } > RAM


      /* Heap space for the page allocator */
    .page_heap (NOLOAD) :
    {
      . = ALIGN(32);
      __uvisor_page_start = .;
      KEEP(*(.keep.uvisor.page_heap))
      . = ALIGN((1 << LOG2CEIL(LENGTH(RAM)) / 8));
      __uvisor_page_end = .;
    } > RAM

/* ... */

I don't know why but I feel like the (1 << LOG2CEIL(LENGTH(RAM))/8) = 0 which is wrong, it must be > 0 when LENGHT(RAM) > 0 !!!!

01 Sep 2016

Now it's a little better, (1 << LOG2CEIL(LENGTH(RAM))/8) > 0 but even tho I'm having another error :

@"HALT_ERROR(./core/system/src/mpu/vmpu_armv7m_mpu.c#178): inferred ACL's (0x003F) don't match exptected ACL's (0x0037)\n" This occurs during the :

/* Unlock the upper SRAM subregion only. */
    vmpu_mpu_set_static_acl(
        1,
        (uint32_t) __uvisor_config.sram_start,
        total_size,
        UVISOR_TACLDEF_DATA | UVISOR_TACL_UEXECUTE | UVISOR_TACL_SUBREGIONS(subregions_disable_mask)
    );

exactly in line 177 in vmpu_armv7m_mpu.c

Do you have any Idea about it?