Skip to content

Commit

Permalink
boards/linum-stm32h753bi: Fix LVGL video memory allocation
Browse files Browse the repository at this point in the history
Previously, the LVGL example had a workaround in lv_nuttx_fbdev.c to prevent
video memory invasion. This fix properly addresses the issue by:

- Reducing total SDRAM size from 8MB to 6MB
- Moving LTDC base address to 0xC0600000
- Reserving dedicated space for video memory outside NuttX heap

This ensures proper memory separation between video buffer and system heap.

Signed-off-by: Jorge Guzman <[email protected]>
  • Loading branch information
JorgeGzm committed Jan 28, 2025
1 parent abcbb1e commit af7a4d2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Board information
=================

This board was release by Witte Tenology in 2023 and developed based on
STM32H753BI microcontroller. The board has 2 expansion connectors used by the LCD display with
STM32H753BI microcontroller. The board has 2 expansion connectors used by the LCD display with
touchscreen and another for access to other peripherals of microcontroller.

The board features:
Expand All @@ -38,7 +38,7 @@ The board features:
- 2 On-board CAN-FD Transceiver

Expansion connector 1 features:
- 1 Display RBG 888
- 1 Display RBG 565
- 1 Capacitive Touchscreen sensor

Expansion connector 2 features.
Expand All @@ -61,7 +61,7 @@ The LINUM-STM32H753BI has 3 software controllable LEDs.
======= =====
LED_R PG2
LED_G PG3
LED_B PB2
LED_B PB2
======= =====

UART/USART
Expand All @@ -76,7 +76,7 @@ USART1
USART1 PINS
====== =====
TX PB14
RX PB15
RX PB15
====== =====

The LINUM-STM32H753BI board has two on-board RS-232 transceiver connected to USART2 and USART3.
Expand Down Expand Up @@ -114,9 +114,9 @@ The LINUM-STM32H753BI board has two on-board RS-485 transceiver connected to USA
====== =====
TXD PC6
RXD PC7
DE PG12
DE PG12
====== =====

SDMMC
======

Expand All @@ -137,7 +137,7 @@ The LINUM-STM32H753BI has one SDCard slot connected as below:
=============== =====
SDCARD_DETECTED PG7
SDCARD_PWR_EN PD7
=============== =====
=============== =====

ETHERNET
========
Expand Down Expand Up @@ -170,15 +170,15 @@ The LINUM-STM32H753BI board has two on-board CAN-FD transceiver connected to FDC
====== =====
TXD PH13
RXD PH14
STD PI2
STD PI2
====== =====

====== =====
FDCAN2 PINS
====== =====
TXD PB13
RXD PB12
STD PE3
STD PE3
====== =====

USB
Expand Down Expand Up @@ -212,7 +212,7 @@ The NOR memory used is the W25Q128JV with 16MB
CLK PF10
NCS PG6
======= =====

I2C3
============
The LINUM-STM32H753BI connects the EEPROM memory and the touchscreen sensor to I2C3.
Expand Down Expand Up @@ -244,7 +244,7 @@ The touchscreen sensor used is the FT5X06.
I2C4
=======
The I2C4 is available for general use on the expansion connector.

====== =====
I2C4 PINS
====== =====
Expand Down Expand Up @@ -356,7 +356,7 @@ The LINUM-STM32H753BI has a buzzer without internal oscillator connected to PB7
========= =====
GPIO PINS
========= =====
BUZZER PB7
BUZZER PB7
========= =====

==============
Expand Down Expand Up @@ -541,7 +541,7 @@ Transmiting a file to PC::

# Using zmodem to receive a file from target
my_pc/temp$ rz > /dev/ttyACM0 < /dev/ttyACM0
Receiving: nuttx_logo.txt
Receiving: nuttx_logo.txt
Bytes received: 1942/ 1942 BPS:124544

Transfer complete
Expand Down Expand Up @@ -672,7 +672,7 @@ In your pc you will be able connect to target using telnet and access their shel
nsh> exit
Connection closed by foreign host.
$

Testing wget to download file from server::

# PC: Creating a http server and sharing local folder.
Expand All @@ -682,7 +682,7 @@ Testing wget to download file from server::
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
10.42.0.2 - - [28/Apr/2024 16:14:39] "GET /nuttx_logo.txt HTTP/1.0" 200 -

# Using wget on target
# Using wget on target
nsh> mount -t tmpfs /tmp
nsh> cd /tmp
nsh> pwd
Expand All @@ -707,7 +707,7 @@ Enable the USB Mass Storage with the command **msconn**::
After that check if your PC recognized the usb driver::

$ sudo dmesg | tail
[sudo] password for jaga:
[sudo] password for jaga:
[27219.361934] usbcore: registered new interface driver uas
[27220.378231] scsi 0:0:0:0: Direct-Access NuttX Mass Storage 0101 PQ: 0 ANSI: 2
[27220.378646] sd 0:0:0:0: Attached scsi generic sg0 type 0
Expand Down Expand Up @@ -817,7 +817,7 @@ Configures the board to use the SPI4 and enables RFID driver with MFRC522::
lvgl
----

Configures the board to use display of 7 inch with lvgl example. The touch screen functionality is implemented using
Configures the board to use display of 7 inch with lvgl example. The touch screen functionality is implemented using
the FT5X06 capacitive touch controller connected to I2C3 interface, with interrupt handling configured on pin PH9 for touch event detection.

To verify if the touch controller is functioning correctly, use the **tc** command.::
Expand Down Expand Up @@ -886,17 +886,12 @@ To verify if the display is functioning correctly, use the **fb** command. You s
5: (465,270) ( 94, 60)
Test finished

Once the **fd** command work, run the lvgl exemple. ::
Once the **fd** command work, run the lvgl examples. ::

nsh> lvgldemo
nsh> lvgldemo benchmark

**WARNING:** This example at the moment is not working correctly yet and have a bug fix to be done.
In the lvgl file **./apps/graphics/lvgl/lvgl/src/drivers/nuttx/lv_nuttx_fbdev.c**
search the function **lv_nuttx_fbdev_set_file** and modify line 156 as follows::

dsc->mem_off_screen = malloc(data_size);
to
dsc->mem_off_screen = (void*)0xC0000000;
**WARNING:** For this example, the total SDRAM size was reduced from 8M to 6M and the LTDC base address was moved to address 0xC0600000 to avoid video memory invasion since the SDRAM was mapped to use the nuttx heap. If using the example with 2 layers, the reserved value will need to be doubled.

tone
----
Expand Down
13 changes: 8 additions & 5 deletions boards/arm/stm32h7/linum-stm32h753bi/configs/lvgl/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ CONFIG_INPUT_FT5X06=y
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBM=y
CONFIG_LINE_MAX=64
CONFIG_LV_USE_CLIB_MALLOC=y
CONFIG_LV_USE_CLIB_SPRINTF=y
CONFIG_LV_USE_CLIB_STRING=y
CONFIG_LV_FONT_MONTSERRAT_24=y
CONFIG_LV_MEM_SIZE_KILOBYTES=128
CONFIG_LV_USE_DEMO_BENCHMARK=y
CONFIG_LV_USE_DEMO_WIDGETS=y
CONFIG_LV_USE_NUTTX=y
CONFIG_LV_USE_NUTTX_TOUCHSCREEN=y
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_USE_SYSMON=y
CONFIG_MM_REGIONS=5
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
Expand All @@ -69,13 +71,14 @@ CONFIG_START_YEAR=2011
CONFIG_STM32H7_FMC=y
CONFIG_STM32H7_I2C3=y
CONFIG_STM32H7_LTDC=y
CONFIG_STM32H7_LTDC_FB_BASE=0xC0000000
CONFIG_STM32H7_LTDC_FB_SIZE=1228800
CONFIG_STM32H7_LTDC_FB_BASE=0xC0600000
CONFIG_STM32H7_LTDC_FB_SIZE=2097152
CONFIG_STM32H7_PWR=y
CONFIG_STM32H7_RTC=y
CONFIG_STM32H7_USART1=y
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_TESTING_RAMTEST=y
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USEC_PER_TICK=1000
CONFIG_VIDEO_FB=y
11 changes: 10 additions & 1 deletion boards/arm/stm32h7/linum-stm32h753bi/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,16 @@
# endif
#endif

#define BOARD_SDRAM1_SIZE (8*1024*1024)
/* BOARD_SDRAM1_SIZE - With ltdc enabled, we reserve the last 2M
* of SDRAM for use with the LTDC framebuffer. If using double buffering,
* this value will need to be doubled.
*/

#ifdef CONFIG_STM32H7_LTDC
# define BOARD_SDRAM1_SIZE (6*1024*1024)
#else
# define BOARD_SDRAM1_SIZE (8*1024*1024)
#endif

/* BOARD_FMC_SDCR1 - Initial value for SDRAM control registers for SDRAM
* bank 1. Note bank 2 isn't used!
Expand Down

0 comments on commit af7a4d2

Please sign in to comment.