You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 5, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+13-9Lines changed: 13 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,15 @@
1
-
# Configuring STM32 to work with float and double (converting values to char type) under FreeRTOS.
1
+
# Configuring STM32 to work with float and double (converting values to char type) under FreeRTOS use printf, sprintf, snprintf.
2
2
3
3
If you use standard tools for converting float and double to char type such as printf, sprintf, snprintf, then when you run these conversions under FreeRTOS and using the GNU Arm Embedded Toolchain (https://developer.arm.com/tools-and-software/ open-source-software / developer-tools / gnu-toolchain / gnu-rm) the microcontroller hangs and a Hard Fault error occurs.
4
4
According to research on this topic http://www.nadler.com/embedded/newlibAndFreeRTOS.html, this error is associated with incorrect operation of dynamic memory allocation (malloc / malloc_r).
1. Remove the heap_4.c file from the \ Middlewares \ Third_Party \ FreeRTOS \ Source \ portable \ MemMang \ directory of your project
8
-
2. Copy the heap_useNewlib.c file from the given repository (src) to the above directory;
9
-
3. Open the FreeRTOS configuration file (FreeRTOSConfig.h) and add an additional define to the section;
9
+
1. Remove the ```heap_4.c``` file from the ```\Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\``` directory of your project
10
+
2. Copy the ```heap_useNewlib_ST.c``` file from the given repository (src) to the above directory(src);
11
+
3. Comment or delete define function ```caddr_t _sbrk(int incr)``` in file ```Core\Src\syscalls.c```
12
+
4. Open the FreeRTOS configuration file (```FreeRTOSConfig.h```) and add an additional define to the section;
10
13
```
11
14
/* USER CODE BEGIN Defines */
12
15
/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */
@@ -21,7 +24,7 @@ This completes the setup. Compilation and operation of the printf, sprintf, snpr
21
24
22
25
### Do not forget that when you re-generate the project in STM32CubeMX, the procedure will need to be repeated!
23
26
24
-
p.s. The version of the heap_useNewlib.c file provided in this repository is slightly different from the original (http://www.nadler.com/embedded/newlibAndFreeRTOS.html) in terms of fixing compilation errors. It was tested on the following versions of the STM32F103C8T6 and STM32F401CCU6 microcontrollers under Windows 10 and Ubuntu 19.10
27
+
p.s. The version of the ```heap_useNewlib_ST.c``` file provided in this repository is slightly different from the original (https://github.com/DRNadler/FreeRTOS_helpers) in terms of fixing compilation errors. It was tested on the following versions of the STM32F401CCU6 microcontrollers under Windows 10 and Ubuntu 20.04
25
28
26
29
27
30
# Настройка STM32 для работы с float и double (преобразования значений к типу char) под FreeRTOS.
@@ -31,9 +34,10 @@ p.s. The version of the heap_useNewlib.c file provided in this repository is sli
31
34
Согласно исследованиям этой темы http://www.nadler.com/embedded/newlibAndFreeRTOS.html данная ошибка связанна с некорректной работой динамического выделения памяти (malloc/malloc_r).
32
35
33
36
Как это все правиться:
34
-
1. Удалите из директори \Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\ вашего проекта файл heap_4.c;
35
-
2. Скопируйте в вышеуказанную директорию файл heap_useNewlib.c из данного репозитария (src);
36
-
3. Откройте конфигурационный файл FreeRTOS (FreeRTOSConfig.h) и добавьте в секцию дополнительный define;
37
+
1. Удалите из директори `````\Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\``` вашего проекта файл ```heap_4.c```;
38
+
2. Скопируйте в вышеуказанную директорию файл ```heap_useNewlib.c``` из данного репозитария (src);
39
+
3. Закоментируйте или удалите функцию ```caddr_t _sbrk(int incr)``` в файле ```Core\Src\syscalls.c```
40
+
4. Откройте конфигурационный файл FreeRTOS (FreeRTOSConfig.h) и добавьте в секцию дополнительный define;
37
41
```
38
42
/* USER CODE BEGIN Defines */
39
43
/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */
@@ -49,4 +53,4 @@ p.s. The version of the heap_useNewlib.c file provided in this repository is sli
49
53
50
54
### Не забывайте, что при пере генерации проекта в STM32CubeMX процедуру необходимо будет повторить!
51
55
52
-
p.s. Версия файла heap_useNewlib.c приведенного в данном репозитарии немного отличается от исходной (http://www.nadler.com/embedded/newlibAndFreeRTOS.html) в части исправления ошибок компиляции. Проверялось на следующих версиях микроконтроллеров STM32F103C8T6 и STM32F401CCU6 под Windows 10 и Ubuntu 19.10
56
+
p.s. Версия файла ```heap_useNewlib.c``` приведенного в данном репозитарии немного отличается от исходной (https://github.com/DRNadler/FreeRTOS_helpers) в части исправления ошибок компиляции. Проверялось на следующих версиях микроконтроллеров STM32F401CCU6 под Windows 10 и Ubuntu 20.04
0 commit comments