ARM-software / CMSIS-RTX

RTX5 real time kernel for Arm Cortex-based embedded systems (spin-off from CMSIS_5)
https://arm-software.github.io/CMSIS-RTX/
Apache License 2.0
79 stars 23 forks source link

osKernelInitialize fails because osRtxInfo is full 0xff'ed at startup #33

Closed markand closed 9 months ago

markand commented 9 months ago

Hi,

I'm trying to use CMSIS-RTOS2+RTX5 on a LPC1768. at startup, before the main function is called osKernelInitialize() occurs and fails because the whole global osRtxInfo structure is fully 0xFF'ed.

Breakpoint 1, osKernelInitialize () at C:/Users/davdem/AppData/Local/arm/packs/ARM/CMSIS-RTX/5.8.0/Source\rtx_kernel.c:773
773   osRtxKernelBeforeInit();
p osRtxInfo
$1 = {os_id = 0xffffffff <error: Cannot access memory at address 0xffffffff>, version = 4294967295, kernel = {state = 255 '\377', blocked = 255 '\377', pendSV = 255 '\377', protect = 255 '\377', tick = 4294967295}, tick_irqn = -1, thread = {run = {curr = 0xffffffff, next = 0xffffffff}, ready = {id = 255 '\377', state = 255 '\377', flags = 255 '\377', attr = 255 '\377', name = 0xffffffff <error: Cannot access memory at address 0xffffffff>, thread_list = 0xffffffff}, idle = 0xffffffff, delay_list = 0xffffffff, wait_list = 0xffffffff, terminate_list = 0xffffffff, wdog_list = 0xffffffff, robin = {thread = 0xffffffff, timeout = 4294967295}}, timer = {list = 0xffffffff, thread = 0xffffffff, mq = 0xffffffff, tick = 0xffffffff}, isr_queue = {max = 65535, cnt = 65535, in = 65535, out = 65535, data = 0xffffffff}, post_process = {thread = 0xffffffff, event_flags = 0xffffffff, semaphore = 0xffffffff, memory_pool = 0xffffffff, message = 0xffffffff}, mem = {stack = 0xffffffff, mp_data = 0xffffffff, mq_data = 0xffffffff, common = 0xffffffff}, mpi = {stack = 0xffffffff, thread = 0xffffffff, timer = 0xffffffff, event_flags = 0xffffffff, mutex = 0xffffffff, semaphore = 0xffffffff, memory_pool = 0xffffffff, message_queue = 0xffffffff}}

Then, osKernelInitialize checks that:

  if (osRtxInfo.kernel.state != osRtxKernelInactive) {
    EvrRtxKernelError((int32_t)osError);
    //lint -e{904} "Return statement before end of function" [MISRA Note 1]
    return osError;
  }

And obviously returns error as kernel.state is non-zero. When dumping the RAM, a large part is zero-ed, some arent but only osRtxInfo gets 0xff'ed all along. I've tried relocating this specific symbol in a different region either with no luck.

This is my scatter file:

LR_IROM0 0x00000000 0x80000 {
  ER_IROM0 0x00000000 0x80000 {
    *.o (RESET, +First)
    *(InRoot$$Sections)
    .ANY (+RO)
    .ANY (+XO)
  }

  RW_IRAM1 0x10000000 0x00008000 {
   .ANY (+RW +ZI)
  }

  RW_IRAM2 0x2007C000 0x00008000 {
   .ANY (+RW +ZI)
  }
}

I'm using CMSIS-6, CMSIS-RTOS2, CMSIS-RTX5 (Source variant), ARMCC6 and VSCode extensions.

markand commented 9 months ago

Nevermind, the deprecated LPC1700_DFP pack was not really compatible with CMSIS-toolbox generating faulty scatter file, stack was then broken before starting up.