Mbed Build Error - RTOS 'osKernelGetTickCount'


#1

Hi All,

Been stumped on this error; when I try to build a project requiring RTOS on mbed for disco_f769ni I get the following errors:

C:\Users\DesktopX6\.platformio\packages\framework-mbed\rtos\Kernel.cpp: In function 'uint64_t     rtos::Kernel::get_ms_count()':
C:\Users\DesktopX6\.platformio\packages\framework-mbed\rtos\Kernel.cpp:37:16: error: 'osKernelGetTickCount' was not declared in this scope
if (sizeof osKernelGetTickCount() == sizeof(uint64_t)) {
^~~~~~~~~~~~~~~~~~~~

rtx_kernal.c where osKernelGetTickCount() is defined can be found in “.platformio\packages\framework-mbed\rtos\TARGET_CORTEX\rtx5\RTX\Source” so I’m not sure where to go with it.

Easiest way to recreate this is to select disco_f769ni from the board menu with mbed as the framework and copy the following example from mbed mbed-os-tcp-server-example

Worth noting that this same issue occurs when trying to do anything even as simple as run a second thread (like you would expect if you can’t find the basis of the RTOS!). Have tried this on two PC’s both running VSCode (1.21.1) with platform IO (0.9.3/3.5.3a8) as clean installs so that should hopefully rule that out.

Anyone got any suggestions?

Thanks


#2

Might be also worth noting i get the same issue with PlatformIO-IDE for atom…

Compiling .pioenvs\disco_f769ni\libde1\rtos\TARGET_CORTEX\mbed_rtx_handlers.o
C:\Users\sssss\.platformio\packages\framework-mbed\rtos\Kernel.cpp: In function 'uint64_t rtos::Kernel::get_ms_count()':
C:\Users\sssss\.platformio\packages\framework-mbed\rtos\Kernel.cpp:37:16: error: 'osKernelGetTickCount' was not declared in this scope

if (sizeof osKernelGetTickCount() == sizeof(uint64_t)) {
^~~~~~~~~~~~~~~~~~~~
*** [.pioenvs\disco_f769ni\libde1\rtos\Kernel.o] Error 1
 [ERROR] Took 18.38 seconds

#3

Similar issue here. I am working with STM32F103C8T board. Build is OK with standard mbed-framework, but fails with this error when I switch to any version of mbed-dev.

framework-mbed/rtos/Kernel.cpp:37:16: error: 'osKernelGet

TickCount' was not declared in this scope

#4

Glad its not just me!

Could it be possible that as I’ve only recently installed PlatformIO that it’s downloaded the most recent version of mbed? Though I would have thought there is some sort of version control/unit tests to ensure compatibility.


#5

Not sure that it’s anything to do with the version of framework-mbed as I have tried different versions. What I am trying to do is reduce code to fit my project into 64K of an STM32F103C8. I found that lib_ignore of mbed functions does not have any effect, so I am trying to work with mbed-dev - here is part of my platformio.ini:
[env:genericSTM32F103C8]
platform = https://github.com/platformio/platform-ststm32.git
board = bluepill_f103c8
framework = mbed
; build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT
lib_deps =
mbed-dev
lib_ignore = mbed-rtos, mbed-LWIP, mbed-events, mbed-fs, mbed-net, mbed-netsocket, mbed-rpc, mbed-dsp, mbed-USBHost, mbed-USBDevice

Building this generates lots of 'bad instruction' errors, similar to: -
.piolibdeps/mbed-dev_ID2491/cmsis/TARGET_CORTEX_M/TOOLCHAIN_IAR/cmain.S: Assembler messages:
.piolibdeps/mbed-dev_ID2491/cmsis/TARGET_CORTEX_M/TOOLCHAIN_IAR/cmain.S:28: Error: junk at e
nd of line, first unrecognized character is `-'
.piolibdeps/mbed-dev_ID2491/cmsis/TARGET_CORTEX_M/TOOLCHAIN_IAR/cmain.S:29: Error: bad instr
uction `module ?cmain,C-level initialization.'

.piolibdeps/mbed-dev_ID2491/cmsis/TARGET_CORTEX_M/TOOLCHAIN_IAR/cmain.S:33: Error: bad instr
uction `section SHT$$PREINIT_ARRAY:CONST:NOROOT(2)'

#6

Anyone got any ideas?

Opened an issue on [GitHub] for it (https://github.com/platformio/builder-framework-mbed/issues/8)

Clean default install of either Atom or VS code with platformIO installed. Disco_F769ni board with the mbed framework. This is completely default with no changes.


#7

Hi @GeorgeStephens!
Please take a look at mbed framework configuration page.
So your platformio.ini should look like this:

[env:disco_f769ni]
platform = ststm32
board = disco_f769ni
framework = mbed
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT

Hi @nicbkw!
PlatformIO won’t add any libraries that you don’t use in your project, so there is no sense in ignoring all those libraries. Adding mbed-dev also won’t work, since mbed is a framework that requires additional build logic. Have you tried to compile your project with the online mbed compiler? How much RAM do you need to reduce?


Trouble with LORA and PingPong demo
#8

Hi @valeros - thanks for the response. I tried mbed and saw that the lib_ignore option did not reduce my code size. I thought that using mbed-dev would work. I understand that using DPIO_FRAMEWORK_MBED_RTOS_PRESENT switches in and out the RTOS library. Are there any complier options I could use to reduce my code size? The project is designed to have an STM32 handle sensors and then link to an 8266 for web server functions. Currently, I am monitoring GPS vis serial, debug via serial and accelerometer & magnetometer (LSM303). Codesize is already over 50kB :

#include "mbed.h"
#include <LSM303.h>
#include <BufferedSerial.h>

static void feedGPS(unsigned long ms);
static int isdigit(char c);

DigitalOut led(PB_12);

Serial gpsSerial(NC, PB_11, 9600);
Serial dbgSerial(PA_2, PA_3, 115200);

// The IMU sensor object
LSM303 lsm;
int heading;
// used as millisecond timer
Timer t;
// variables used to parse GPS
int gpsptr;
char gpschar, gps[128], timestr[16], latstr[16], lonstr[16];

int main() {
  printf("GPS test start!\r\n");
  lsm.setup();

  while(1){
    feedGPS(1000);
    heading = lsm.getTiltHeading();
    printf("heading=%d\r\n", heading);
    printf("Lat: %s, Lng: %s %s\r\n", latstr, lonstr, timestr);
  }
}

//delay loop to parse GPS

static void feedGPS(unsigned long ms) {
  t.start();
  int begin = t.read_ms();
  do{
    if (gpsSerial.readable()) {
      gpschar = gpsSerial.getc();
      if (gpschar == '$')
        gpsptr = 0;
      else if (gpschar == '\r') {
        if (!strncmp(gps, "GPGGA", 5)) {
          memset(timestr, 0, sizeof(timestr));
          memset(latstr, 0, sizeof(latstr));
          memset(lonstr, 0, sizeof(lonstr));
          strncpy(timestr, &gps[6], 6);
          if (isdigit(gps[16])) {
            strncpy(latstr, (const char *)&gps[16], 10);
            latstr[10] = gps[27];
            strncpy(lonstr, (const char *)&gps[29], 11);
            lonstr[11] = gps[41];
          }
        }
      }
      else
        gps[gpsptr++] = gpschar;
    }
  }
  while((t.read_ms() - begin) < ms);
}

static int isdigit(char c) {
  if (c - '0' > -1 and c - '0' < 10)
    return 1;
  else
    return 0;
}

#9

You can try to use a special version of standard libraries called newlib-nano. To enable it you need to add a special linker flag to the file with default configuration for your board, it’s located here:
c:\Users\YOUR_USER\.platformio\packages\framework-mbed\platformio\variants\BLUEPILL_F103C8\BLUEPILL_F103C8.json (Windows)
/home/YOUR_USER/.platformio/packages/framework-mbed/platformio/variants/BLUEPILL_F103C8/BLUEPILL_F103C8.json (Linux)
Navigate to the section build_flags and add "--specs=nano.specs to the ld section:

"ld": [
    "-mcpu=cortex-m3", 
    "-mthumb", 
    "-Wl,--gc-sections", 
    "-Wl,--wrap,main", 
    "-Wl,--wrap,_malloc_r", 
    "-Wl,--wrap,_free_r", 
    "-Wl,--wrap,_realloc_r", 
    "-Wl,--wrap,_memalign_r", 
    "-Wl,--wrap,_calloc_r", 
    "-Wl,--wrap,exit", 
    "-Wl,--wrap,atexit", 
    "-Wl,-n",
    "--specs=nano.specs"
]

But these changes will be overwritten with next release of the mbed framework.


Saving SRAM on mbed
#10

Ok - added the line as suggested to the json file.
My platformi.io file looks like this:
[env:genericSTM32F103C8]
platform = https://github.com/platformio/platform-ststm32.git
board = bluepill_f103c8
framework = mbed
; build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT
; lib_deps =
; lib_ignore = mbed-rtos, mbed-LWIP, mbed-events, mbed-fs, mbed-net, mbed-netsocket, mbed-rpc, mbed-dsp, mbed-USBHost, mbed-USBDevice
upload_protocol = stlink
upload_port = /dev/cu.usbmodemFD13423
I now see this error:
/Users/nicbkw/.platformio/packages/framework-mbed/rtos/Thread.cpp:368:24: error: ‘Kernel’ ha
s not been declared
Why am I seeing an RTOS error when I am not uaing the RTOS library?
Thanks


#11

Could you provide the entire build log?