[Error] Linux: when including a function from BSP Disocvery library

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
ndhuy
Posts: 32
Joined: Mon Nov 04, 2019 8:01 am

[Error] Linux: when including a function from BSP Disocvery library

Post by ndhuy » Mon Feb 24, 2020 10:53 am

Hi everyone,

I am Huy.

Currently, I am working with micropython on Linux. I am trying to build an LED module and an LCD module.
The content of LED and LCD files base on the BSP Discovery library. (https://github.com/STMicroelectronics/S ... -Discovery)

when i write the LED file to turn on the LED, the file is compiled and runnable.
however, when it comes to LCD module as i call BSP_LCD_Init() from stm32l4r9i_discovery_lcd.h. there are errors like below:
Screenshot from 2020-02-23 23-55-50.png

it is weird because while LED is written with the same method as LCD, LED can be compiled and run and LCD cannot.

the makefile of those 2 are below:

Code: Select all

USERMODULES_DIR := $(USERMOD_DIR)

# Add all C files to SRC_USERMOD.
SRC_USERMOD += $(USERMODULES_DIR)/simplefunction.c

CFLAGS_USERMOD += -I$(USERMODULES_DIR)
the code of LED.c

Code: Select all

#include "stm32l4r9i_discovery.h"
#include "stm32l4xx_hal.h"

void LED_init(int led)
{
if (led == 1)
{
BSP_LED_Init(LED1);
}
else
{
BSP_LED_Init(LED2);
}
}
void LED_on(int time)
{
BSP_LED_On(LED1);
HAL_Delay(time*1000);
BSP_LED_Off(LED1);
}

the code of LCD.c

Code: Select all

#include "stm32l4r9i_discovery_lcd.h"

#include "MyLCD.h"

void LCDinit(int color)
{
HAL_Init();

HAL_Delay(50);
BSP_LCD_Init();

uint32_t theColor;

if (color == 1)
{
theColor = 0xFFFF0000;
} else {
theColor = 0xFF00FFFF;
}
BSP_LCD_SetBackColor(theColor);
}
What might be the causes of this issue?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: [Error] Linux: when including a function from BSP Disocvery library

Post by jimmo » Mon Feb 24, 2020 11:12 am

My guess (based on previous experience with these libraries) is that the LCD code makes some assumptions about memory and peripherals that is incompatible with MicroPython.

For example, if it assumes that it can use an area of memory
for a framebuf that MicroPython thinks it can use for the gc heap. Or perhaps it expects to be able to manage the SPI controller or something.

But really the only way to get to the bottom of this is to read the code of the BSP_LCD_SetBackColor(theColor).

Or it might be some simple like you also need to tell it to update the display (i.e. first you draw to it's framebuffer then you tell it to update).

ndhuy
Posts: 32
Joined: Mon Nov 04, 2019 8:01 am

Re: [Error] Linux: when including a function from BSP Disocvery library

Post by ndhuy » Tue Feb 25, 2020 2:33 am

https://drive.google.com/open?id=1XmQFz ... jO5cGB6Jrh

Hi Jimmo,

Sorry the picture cannot be seen. Here is the error.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: [Error] Linux: when including a function from BSP Disocvery library

Post by jimmo » Tue Feb 25, 2020 4:00 am

You need to share that link publicly.

ndhuy
Posts: 32
Joined: Mon Nov 04, 2019 8:01 am

Re: [Error] Linux: when including a function from BSP Disocvery library

Post by ndhuy » Wed Feb 26, 2020 1:45 am

Hi Jimmo,

Thanks for your response. My team figured out the error and solved it already.

On IDE (we used STM32CubeIDE), when we configure the board and the project, there is a file called stm32l4xx_hal_conf.h created by the template stm32l4xx_hal_conf_template.h in Inc of the Hal library. As far as i know, this file is created to include relevant library such as stm32l4xx_hal_dsi.h or stm32l4xx_hal_uart.h

However, there is no such thing on the Linux platform. So the connection between Hal library and BSP library is not established.

After that i also met some errors relating to memory and as you suggest i recheck the code and figure the way to fix that.

Thanks for your response. In my projects from porting STM32L4R9I Discovery to MicroPython, you help me alot.

Post Reply