Support for LCD Controller on STM32F429/469

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
User avatar
badi
Posts: 51
Joined: Mon Aug 10, 2015 2:18 pm
Location: Bern, Switzerland

Support for LCD Controller on STM32F429/469

Post by badi » Thu Dec 24, 2015 1:29 pm

Hello

As a quick pre-XMAS hack I implemented the basic LCD support for STM32F429i-Discovery of STM (Branch simple_lcdctrl_support as in the link):
https://github.com/tobbad/micropython/t ... rl_support
To support the LCD controller you have to call make with MICROPY_PY_LCDCTRL=1 command line options (Is this OK?). Ic checked it on STM32F429, but not on STM32F7.

Following are the requirements:
  • - There is a need for SDRAM support: The code is copy paste from the STMs STM32F429-Discovery BSP. placed in stmhal/sdram/src or stmhal/sdram/inc.
    - Support for the ili9341 and the LTDC (LCD_TFT Controller) in the stmhal/lcdctrl/src/inc. The code is copy/modified/paste from the STMs STM32F429-Discovery BSP/components/utilities placed and renamed in/to stmhal/lcdctrl/src or stmhal/lcdctrl/inc
    (Is this OK?). pyb_lcd_ctrl is copy modified paste of lcd.c. I am not positive about the naming of the files, yet. Maybe I will change the filenames. There is a little script (main.py) in the lcdctrl folder which you can copy to the board.
Further I had to add several HAL components to micropython:
  • hal_dma2d.c/h
    hal_ltdc.c/h
    hal_sdram.c/h
    ll_fmc.c/h
These are only included in the build when MICROPY_PY_LCDCTRL==1.

This code still needs some rework and is not yet PR (push request) ready.

During this there came up some questions:
  • - Shall micropython include a generic LCD library (eg. https://code.google.com/p/u8glib/) which handles all the drawing and several LCDs device drivers out of the box? Or shall this all be done in python (No support for HW acceleration as for example DMA for box filling)?
    - What is the best way to configure the sdram (which will pushed to micropython in an own PR). Inject a configuration struct to the init or just keep it like in this hack hard coded? Maye add a possibility to get the configuration struct and modifiy the values before setting them?
I am looking forward to get feedback as there are probably other people thinkng about LCD support for micropython.
badi

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Support for LCD Controller on STM32F429/469

Post by dhylands » Thu Dec 24, 2015 4:18 pm

badi wrote:Hello

As a quick pre-XMAS hack I implemented the basic LCD support for STM32F429i-Discovery of STM (Branch simple_lcdctrl_support as in the link):
https://github.com/tobbad/micropython/t ... rl_support
To support the LCD controller you have to call make with MICROPY_PY_LCDCTRL=1 command line options (Is this OK?). Ic checked it on STM32F429, but not on STM32F7.
I'd be inclined to call it MICROPY_HW_ENABLE_LTDC. I'd also add MICROPY_HW_ENABLE_SDRAM since its entirely plausible to have a board with SDRAM and no LCD.
Following are the requirements:
  • - There is a need for SDRAM support: The code is copy paste from the STMs STM32F429-Discovery BSP. placed in stmhal/sdram/src or stmhal/sdram/inc.
    - Support for the ili9341 and the LTDC (LCD_TFT Controller) in the stmhal/lcdctrl/src/inc. The code is copy/modified/paste from the STMs STM32F429-Discovery BSP/components/utilities placed and renamed in/to stmhal/lcdctrl/src or stmhal/lcdctrl/inc
    (Is this OK?). pyb_lcd_ctrl is copy modified paste of lcd.c. I am not positive about the naming of the files, yet. Maybe I will change the filenames. There is a little script (main.py) in the lcdctrl folder which you can copy to the board.
This is probably best discussed on github.
Further I had to add several HAL components to micropython:
  • hal_dma2d.c/h
    hal_ltdc.c/h
    hal_sdram.c/h
    ll_fmc.c/h
These are only included in the build when MICROPY_PY_LCDCTRL==1.
There are also the HAL config options in stm32f4xx_hal_conf.h (located in the board directories). For files which are optionally included in the build, I think that the option needs to do into mpconfigport.mk
This code still needs some rework and is not yet PR (push request) ready.
It quite acceptable to create RFC (Request for comment) PRs.
During this there came up some questions:
  • - Shall micropython include a generic LCD library (eg. https://code.google.com/p/u8glib/) which handles all the drawing and several LCDs device drivers out of the box? Or shall this all be done in python (No support for HW acceleration as for example DMA for box filling)?
    - What is the best way to configure the sdram (which will pushed to micropython in an own PR). Inject a configuration struct to the init or just keep it like in this hack hard coded? Maye add a possibility to get the configuration struct and modifiy the values before setting them?
I think that having a generic LCD driver in C is desirable, although it should be controlled by its own config option. This would probably be something like MICROPY_ENABLE_U8GLIB. It may make sense to have something like U8GLIB go in the lib directory rather than in stmhal.

Initially have stuff hardcoded seems reasonable, although the LCD parameters themselves should be configable or have a driver so that we support different LCDs (like the 469 one or a F7 Discovery one). Eventually I'd like to see the heap allocator be able to allocate from SDRAM, but until that time it makes sense to hard code things.

I am looking forward to get feedback as there are probably other people thinkng about LCD support for micropython.[/quote]

Post Reply