2.5k views
in System Integration by
Hello everybody,

i made my own project in the STM32 System Workbench and tried there to integrate the Embedded Wizard generated code. I use the STM32F469i-Discovery Board with a FreeRTOS. I know that the settings of my system are right, because when i initialize the display by my own and display some strings, it works fine. The problem is, when i integrate the task for the embedded wizard,  the system runs into a undefined state. This is happening, when the task is trying to initialize the display.
Here is my code:

int main(void)
{
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART6_UART_Init();

  /* Testing the Display without Embedded Wizard 2 */
  BSP_EEPROM_Init();
  BSP_QSPI_Init();
  BSP_SDRAM_Init();
  BSP_LCD_Init();
  BSP_LCD_LayerDefaultInit(0, 0xC0000000);
  BSP_LCD_SelectLayer(0);
  BSP_LCD_DisplayOn();
  BSP_LCD_Clear(LCD_COLOR_WHITE);
  BSP_LCD_SetBackColor(LCD_COLOR_BLACK);
  BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
  BSP_LCD_SetFont(myfont);

  /* configure LED */
  EwBspConfigLed();

    /* initialize serial interface for debugging and connect xprintf module */
    EwBspConfigSerial();
    xdev_out(EwBspPutCharacter);

  /* Create the thread(s) */
  /* definition and creation of defaultTask */
  osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
  defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);

  /* definition and creation of TaskEmbWiz */
  osThreadDef(TaskEmbWiz, StartTaskEmbWiz, osPriorityIdle, 0, 1280);
  TaskEmbWizHandle = osThreadCreate(osThread(TaskEmbWiz), NULL);

  /* Start scheduler */
  osKernelStart();
  
    while (1) {

    }
}

/* StartTaskEmbWiz function */
void StartTaskEmbWiz(void const * argument) {
    CoreRoot rootObject;
    XViewport* viewport;
    XEnum cmd = CoreKeyCodeNoKey;

    int touched = 0;
    XPoint touchPos;

    /* initialize display */
    EwPrint("Initialize Display...                        ");
    EwBspConfigDisplay( FRAME_BUFFER_WIDTH, FRAME_BUFFER_HEIGHT,
            FRAME_BUFFER_ADDR);
    EwPrint("[OK]\n");

    /* initialize touchscreen */
    EwPrint("Initialize Touch Driver...                   ");
    EwBspConfigTouch( FRAME_BUFFER_WIDTH, FRAME_BUFFER_HEIGHT);
    EwPrint("[OK]\n");

    /* initialize tlsf memory manager */
    /* please note, that the first part of SDRAM is reserved for framebuffer */
    EwPrint("Initialize Memory Manager...                 ");
    MemPool = tlsf_create_with_pool( MEMORY_POOL_ADDR, MEMORY_POOL_SIZE);
    EwPrint("[OK]\n");
    EwPrint("MemoryPool at address 0x%08X size 0x%08X\n", MEMORY_POOL_ADDR,
            MEMORY_POOL_SIZE);

    /* initialize the Graphics Engine and Runtime Environment */
    EwPrint("Initialize Graphics Engine...                ");
    if (!EwInitGraphicsEngine(0))
        return;
    EwPrint("[OK]\n");

    /* create the applications root object ... */
    EwPrint("Create Embedded Wizard Root Object...        ");
    rootObject = (CoreRoot) EwNewObjectIndirect(EwApplicationClass, 0);
    EwLockObject(rootObject);
    CoreRoot__Initialize(rootObject, EwScreenSize);
    EwPrint("[OK]\n");

    /* create Embedded Wizard viewport object to provide uniform access to the framebuffer */
    EwPrint("Create Embedded Wizard Viewport...           ");
    viewport = EwInitViewport(EwScreenSize,
            EwNewRect(0, 0, FRAME_BUFFER_WIDTH, FRAME_BUFFER_HEIGHT), 0, 255,
            FRAME_BUFFER_ADDR, DOUBLE_BUFFER_ADDR, 0, 0);
    EwPrint("[OK]\n");

    /* Initialize your device driver(s) that provide data for your GUI */
    DeviceDriver_Initialize();

    /* start the Embedded Wizard main loop and process all user inputs, timers and signals */
    while (cmd != CoreKeyCodePower) {
        int timers = 0;
        int signals = 0;
        int events = 0;
        int devices = 0;

        /* process data of your device driver(s) and update the GUI
         application by setting properties or by triggering events */
        devices = DeviceDriver_ProcessData();

        /* receive keyboard inputs */
        cmd = GetKeyCommand();

        if (cmd != CoreKeyCodeNoKey) {
            /* feed the application with a 'press' and 'release' event */
            events |= CoreRoot__DriveKeyboardHitting(rootObject, cmd, 0, 1);
            events |= CoreRoot__DriveKeyboardHitting(rootObject, cmd, 0, 0);
        }

        /* receive touch inputs and provide the application with them */
        if (EwBspGetTouchPosition(&touchPos)) {
            /* begin of touch cycle */
            if (touched == 0)
                CoreRoot__DriveCursorHitting(rootObject, 1, 0, touchPos);

            /* movement during touch cycle */
            else if (touched == 1)
                CoreRoot__DriveCursorMovement(rootObject, touchPos);

            touched = 1;
            events = 1;
        }
        /* end of touch cycle */
        else if (touched == 1) {
            CoreRoot__DriveCursorHitting(rootObject, 0, 0, touchPos);
            touched = 0;
            events = 1;
        }

        /* process expired timers */
        timers = EwProcessTimers();

        /* process the pending signals */
        signals = EwProcessSignals();

        /* refresh the screen, if something has changed and draw its content */
        if (devices || timers || signals || events) {
            EmbWiz_Update( viewport, rootObject );

            /* after each processed message start the garbage collection */
            EwReclaimMemory();

            /* print current memory statistic to serial interface - uncomment if needed */
            //  EwPrintProfilerStatistic( 0 );
        }
        /* otherwise sleep/suspend the UI application until a certain event occurs or a timer expires... */
        else
            EwBspWaitForSystemEvent(EwNextTimerExpiration());
    }

    /* Deinitialize your device driver(s) */
    DeviceDriver_Deinitialize();

    /* finished -> release unused resources and memory */
    EwPrint("Shutting down application...                 ");
    EwDoneViewport(viewport);
    EwUnlockObject(rootObject);
    EwReclaimMemory();

    /* ... and deinitialize the Graphics Engine */
    EwDoneGraphicsEngine();

    EwPrint("[OK]\n");

    tlsf_destroy(MemPool);
//    // Aktivate to Test the Display without Embedded Wizard
//    // dont forget to comment the code above
//    for(;;){
//          BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"Hello World", CENTER_MODE);
//
//          for(int r=1;r<120;r+=1){
//
//        BSP_LCD_SetTextColor(0xff000000+r*1398);
//          BSP_LCD_DrawCircle(120, 160, r);
//          HAL_Delay(5);
//          }
//          HAL_Delay(100);
//          BSP_LCD_Clear(LCD_COLOR_BLACK);
//          osDelay(1000);
//    }
}

I don't know where there is the Problem. I only know, if the embedded wizard starts the EwBspConfigDisplay routine, the system runs into a undefined state. Maybe someone can help me :)

thanks anyway.

Greetz Torben

3 Answers

0 votes
by
Hi,

have you seen, that within the provided Build Environment for STM32F469 you can also set the compiler flag to use the FreeRTOS operating system. Just change the following define within the makefile from 0 to 1:

FREE_RTOS                     = 0
# REMARK: Set the macro FREE_RTOS to 1 to build an Embedded Wizard project
# based on FreeRTOS.

Maybe this helps to find the difference between your implementation and the provided (working) Embedded Wizard GUI + FreeRTOS example.

Best regards,

Manfred
by
Hello Manfred,

i did set a compiler flag in my IDE Settings and i checked all the files. if there is the FREE_RTOS active. Do you have any other suggestion? Because i really don't know why this is not working!
by
Hello Torben,

are you able to compile and execute successfully one of the provided examples using FreeRTOS? Does this run on your target?

This can serve as a foundation for your development.

Maybe the problem is caused related to the system/display intitialization that is already done when EwBspConfigDisplay() is called.

Is it possible to start with the provided template and integrate step by step your software?

Best regards,

Manfred.
by

The thing itself is, that i try to get a working example with the STM32 System Workbench and there is no working example from embedded wizard. I can compile my project without problems and can integrate step by step to my software. But when i go throw the EwBspConfigDisplay() the software crashs. 

I also think, that the problem is the initialization befor the EwBspConfigDisplay() is called. It would be really nice, if you can check my setting:

Thank you.

Best regards,
Torben

by
Hi Manfred,

I came upon this thread, as I have no clue where to find the configuration to enable FreeRTOS. I am using the toolchain of the stmIDE working with the STM32F429-Disco. Can you please elaborate where in the Build Environment Folder I can change it?

Kind regards,

Xiu
by
Hi Xiu,

this is a very old thread.... maybe it is better to open a new discussion, where you describe the issue that you have.

Meanwhile FreeRTOS is enabled by default.

In principle, you can switch on/off the usage of FreeRTOS within the makefile.

Best regards,

Manfred.
0 votes
by
Hello,

thanks Manfred for the good advices. Now i achieved my goal to create a  working template in STM32 System Workbench for the Evaluationboard STM32F469i-Discovery. It works for both use cases FreeRTOS or in the main loop. Here you can download the Code:

https://www.dropbox.com/s/nm3n683th1nfh1u/Template.zip?dl=0

Please read the README.txt, there is a instruction how to do this. And if you are using the UART you have to devide the BAUD by an factor 3, don't know why this is happing.
by
Thanks for sharing the good news!
0 votes
by
Hello,

my template is working with any example provided by Embedded Wizard, now i want to add my own code. It works only if i set the ScreenOrientation to normal and the Screensize to <800,480>. But my Application has a vertical orientated display, so i set the Screen Orientation to Rotated_90 and the Screensize to <480,800>. I set the compiler switch EW_SURFACE_ROTATION = 90, but i get the following error:

Create Embedded Wizard Root Object...        [FATAL ERROR in ewextbmp_RGB565_RGBA8888.c:207] The rotation of the bitmap resource 'Home_button' doesn't correspond to the configuration the Graphics Engine has been built for. Please verify whether the attribute 'ScreenOrientation' in your Embedded Wizard project does correctly conform the value of the define 'EW_SURFACE_ROTATION' used during the build process (e.g. within your MAKE file, etc.). You can also try to clean/rebuild your project.System halted! [HardFault_Handler]

It also works with my application, when i set the ScreenOrientation to normal and the Screensize to <800,480>, this is only happing when a changed this parameters. But when i use the flashing batch from embedded wizard the code is programmed and working an the system without problems, irrelevant with setting i choose. So i think the problem is again in the IDE settings and i am missing anything.
by
Hello,

beside the compiler flag (EW_SURFACE_ROTATION=90) you need to choose the appropriate library (e.g. libewgfx-m4-r90-gcc.a for GCC, or libewgfx-m4-r90-keil for KEIL or libewgfx-m4-r90-iar for IAR).

Best regards,

Manfred.
by
that solved my problem :) Thank you very much!

Best regards,

Torben

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...