Hi,
I’m a beginner using mbed OS and Embedded programing in general, i want to become familiar with mbed OS and uvisor and my aim is to use the LCD screen to print or not the secret in the secured box.
so when i juste use mbed-library with uvisor disabled, everything works perfectly. But when i try to enable uvisor library, my program stops working. I’ve tried implementing a simple example using mbed OS+uvisor and it works well. I hope you can help me, thank you in advance.
Here is my code :
main.cpp:
#include "mbed-drivers/mbed.h"
#include "minar/minar.h"
#include "core-util/FunctionPointer.h"
#include "uvisor-lib/uvisor-lib.h"
#include "lcd.h"
#include "main.h"
#include "btn.h"
/* messages on LCD */
char uvisorhello[] = " *** uvisor-Hello ***";
using mbed::util::FunctionPointer0;
/* Create ACLs for main box. */
MAIN_ACL(g_main_acl);
/* Enable uVisor. */
UVISOR_SET_MODE_ACL(UVISOR_ENABLED, g_main_acl);
DigitalOut led(MAIN_LED);
DigitalOut red_led(RED_LED);
void toggle_led()
{
led = !led;
}
void init_periph()
{
/* Init LCD */
init_LCD();
/* Configure the pushbutton. */
btn_init();
}
void main_prog()
{
toggle_led();
}
void app_start(int, char**){
init_periph();
lcd_print(uvisorhello);
minar::Scheduler::postCallback(toggle_led).period(minar::milliseconds(1500));
}
main.h:
void lcd_print(char *str);
void lcd_clear();
void toggle_led();
#define LED_ON true
#define LED_OFF false
#define MAIN_LED LED1
#define RED_LED LED2
#define MAIN_BTN USER_BUTTON
#define MAIN_BTN_PD PullDown
#define MAIN_ACL(acl_list_name) \
static const UvisorBoxAclItem acl_list_name[] = { \
{TIM2, sizeof(*TIM2), UVISOR_TACLDEF_PERIPH}, \
{TIM5, sizeof(*TIM5), UVISOR_TACLDEF_PERIPH}, \
{GPIOA, sizeof(*GPIOA), UVISOR_TACLDEF_PERIPH}, \
{GPIOG, sizeof(*GPIOG), UVISOR_TACLDEF_PERIPH}, \
{GPIOC, sizeof(*GPIOC), UVISOR_TACLDEF_PERIPH}, \
{GPIOD, sizeof(*GPIOD), UVISOR_TACLDEF_PERIPH}, \
{GPIOF, sizeof(*GPIOF), UVISOR_TACLDEF_PERIPH}, \
{SPI5, sizeof(*SPI5), UVISOR_TACLDEF_PERIPH}, \
/* FIXME: Secure RCC/EXTI/SYSCFG/FLASH */ \
{RCC, sizeof(*RCC), UVISOR_TACLDEF_PERIPH}, \
{EXTI, sizeof(*EXTI), UVISOR_TACLDEF_PERIPH}, \
{SYSCFG, sizeof(*SYSCFG), UVISOR_TACLDEF_PERIPH}, \
{FLASH, sizeof(*FLASH), UVISOR_TACLDEF_PERIPH}, \
{PWR, sizeof(*PWR), UVISOR_TACLDEF_PERIPH}, \
{(void *) 0x42470000, 0x1000, UVISOR_TACLDEF_PERIPH}, \
}
lcd.cpp :
#include "lcd.h"
/* Font size structure */
TM_FONT_SIZE_t FontSize;
void init_LCD()
{
/* Init LCD */
TM_LCD_Init();
/* Fill LCD with color */
//TM_LCD_Fill(0x4321);
}
void lcd_print(char *str)
{
/* Verify if the bottom of the screen is reached*/
if(TM_LCD_GetCurrentY()>TM_LCD_GetHeight()) lcd_clear();
/* Put string to LCD */
TM_LCD_Puts(str);
}
void lcd_clear()
{
TM_LCD_SetXY(0,0);
TM_LCD_Fill(0xFFFF);
}
lcd.h :
#include "lib/stm32fxxx_hal.h"
#include "lib/tm_stm32_disco.h"
#include "lib/tm_stm32_delay.h"
#include "lib/tm_stm32_lcd.h"
#include "main.h"
void init_LCD();
void lcd_print(char *str);
void lcd_clear();