LPC55S69 : use RNG in SVC handler

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LPC55S69 : use RNG in SVC handler

1,403 次查看
EugeneHiihtaja
Senior Contributor I

Hi !

It seems to me I should call RNG_Init and RNG_GetRandomData API from SVC handler.

Can I do this without any problems ?

Or those can block execution for long time and I can miss some interrupts and etc.

Or what are limitations ?

Regards,

Eugene

标签 (1)
0 项奖励
回复
2 回复数

1,341 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Eugene,

I suppose that the RNG(Random Number Generation) is nothing to do with the SVC handler.

This is the SVCall interrupt official definition:

SVCall A supervisor call (SVC) is an exception that is triggered by the SVC
instruction. In an OS environment, applications can use SVC instructions to
access OS kernel functions and device drivers.

The RNG is not related to SVCall.

I think it is okay to use the RNG module in SDK for LPC family:

#define RNG_EXAMPLE_RANDOM_NUMBERS (4)
#define RNG_EXAMPLE_RANDOM_BYTES (16)

    uint32_t number;
    uint32_t data[RNG_EXAMPLE_RANDOM_NUMBERS];
#define RNG_EXAMPLE_RANDOM_NUMBER_BITS (RNG_EXAMPLE_RANDOM_NUMBERS * 8 * sizeof(uint32_t))

 RNG_Init(RNG);

    status = RNG_GetRandomData(RNG, &data, RNG_EXAMPLE_RANDOM_BYTES);

    status = RNG_GetRandomData(RNG, &data, RNG_EXAMPLE_RANDOM_BYTES);

    status = RNG_GetRandomData(RNG, &data, RNG_EXAMPLE_RANDOM_BYTES);

Hope it can help you

BR

XiangJun Rong

0 项奖励
回复

1,341 次查看
EugeneHiihtaja
Senior Contributor I

Hi xiangjun.rong‌ !

Yes, SVC and peripherals are different things. But if you take FreeRTOS for example and run tasks in nonprivileged mode, you should have posibility to access peripherals in nonprivileged mode as well. But it is only 3 user configurable MPU sections.

As practical result only one peripheral address range can be specified there. Other user section occupied wit memory chunks what should be attached to tasks.

But typical task need accesses to few peripherals at list.

Even usage of mbedtls in task context require RNG, HASCRYPT and etc.

As result SVC call need to be designed for access peripheral registers. And SVC handler should be execytes as fast as possible.

And it is always dilemma ho-to split typical device driver where part of it should be called in SVC.

In my case RNG is candidate for SVC type of access, but I'm afraid if usage if it can lock MCU for very long time.

But RNG might be very fast and it is not a problem.

And I try to find out if it really so. Or not ?

Regards,

Eugene

0 项奖励
回复