cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX V1.1.0 + STM32F439 + FreeRTOS + LwIP bugs

malcolm23
Associate III
Posted on April 24, 2014 at 04:50

Greetings all,

I have a couple of problems with STM32CubeMX-V1.1.0 with the following options:

 * STM32F439

 * FreeRTOS

 * LwIP

 

 

The first problem is a bug in the sys_mutex_lock function which is generated as:

    void sys_mutex_lock(sys_mutex_t *mutex)

    {

        sys_arch_sem_wait(*mutex, 0);

    }

It's calling the sys_arch_sem_wait function which has a prototype of:

    u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)

    

As can be seen here; both sys_mutex_lock and sys_arch_sem_wait both expect to receive a 'sys_mutex_t*'; however sys_mutex_lock dereferences the pointer rather than passing it across correctly. The correct implementation of sys_mutex_lock is:

    void sys_mutex_lock(sys_mutex_t *mutex)

    {

        sys_arch_sem_wait(mutex, 0);

    }

    

The second problem is with configuring LwIP to disable DHCP and entering a static IP address in the LWIP Configuration dialog. The IP_ADDRESS value will only accept three digit IP addresses - for example ''010.001.101.099'' (you can't remove the zeros). It then turns around and pastes these values directly into the generated code. So lwip.c ends up with the following:

    void MX_LWIP_Init(void)

    {

      IP_ADDRESS[0] = 010;

      IP_ADDRESS[1] = 001;

      IP_ADDRESS[2] = 101;

      IP_ADDRESS[3] = 099;

Leading zeros in C result in the value being interpreted as OCTAL instead of decimal. This IP address is actually ''8.1.101.<syntax error>'' - a syntax error because 099 is not a legal octal constant. It's not actually possible to enter the value 99 because even if you try pre-convert to OCTAL you find that OCTAL(99) = 143, and trying to enter this in the field results in having no leading zeros so the number is interpreted as decimal 143.

Other than these minor items I'm highly impressed with the ease of the tool to get projects started. Keep up the good work!

- Malcolm

#stm32cubemx-lwip-bug
1 REPLY 1
Bino
Senior
Posted on April 24, 2014 at 15:08

Effectively there is an issue on leading zeros in IP addresses, a fix will be done in a future release, so that to avoid the compilation error, it is necessary to replace the following code:

  IP_ADDRESS[0] = 010;

  IP_ADDRESS[1] = 001;

  IP_ADDRESS[2] = 101;

  IP_ADDRESS[3] = 099;

by this one:

  IP_ADDRESS[0] = 10;

  IP_ADDRESS[1] = 1;

  IP_ADDRESS[2] = 101;

  IP_ADDRESS[3] = 99;

Regarding the sys_mutex_lock function problem , waiting for the fix in a future FW package, you can directly patch the source file here:

C:\Users\<user_id>\STM32Cube\Repository\STM32Cube_FW_F4_V1.1.0\Middlewares\Third_Party\LwIP\system\OS\sys_arch.c file

BR

Eric.a