Skip to content

[STM]Add RNG (random number generator) for STM32F4 STM32F7 families #2253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 25, 2016

Conversation

adustm
Copy link
Member

@adustm adustm commented Jul 26, 2016

These functions are to be tested in mbed-os environment.

The test was passed for DISCO_F429ZI and NUCLEO_F746ZG with IAR toolchain.
The compilation passes for DISCO_F429ZI / DISCO_F469NI / DISCO_F746NG / NUCLEO_F410RB / NUCLEO_F429ZI / NUCLEO_F746ZG / NUCLEO_F767ZI

Please note that not every STM32F4 platforms are supporting the RNG feature. Some defines have been added in hal/targets/hal/TARGET_STM/TARGET_STM32F4/entropy_hardware_poll.c to enable the relevant targets.
I did not find any code to test the function, thus I used the one below :

#include "test_env.h"
#include "entropy_poll.h"

#define BUFF_SIZE       500
unsigned char myrndbuff[BUFF_SIZE]={0};
size_t *olen;

int main() {
    int ret = 0;
    int result = false;
    size_t mysize=0;
    olen = &mysize;
    ret = mbedtls_hardware_poll( NULL, myrndbuff, BUFF_SIZE, olen );
    if (ret == 0 ) {
        printf("tls_ret_ok\n");
        printf("%i\n",(int)*olen);
        if (*olen == BUFF_SIZE) {
            printf("size ok\n");
            result = true;
        } else printf("size ko\n");
    } else printf("tls_ret_ko\n");
}

This result was the following :

tls_ret_ok
500
size ok

Another printf inside the code showed that the values seemed to be random (I trust the hardware :) )

@adustm
Copy link
Member Author

adustm commented Jul 26, 2016

@screamerbg @pjbakker
Could you please review and let me know what you think of it ?

/* Get Random byte */
for( i = 0; i < len; i++ ){
rng_get_byte( output + i );
printf("output %i: %i\n",i,(int)*(output+i));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left over debug info?

@sg-
Copy link
Contributor

sg- commented Jul 26, 2016

formatting is a bit funky (see: https://developer.mbed.org/teams/SDK-Development/wiki/mbed-sdk-coding-style) and updated docs coming :)

@adustm
Copy link
Member Author

adustm commented Jul 28, 2016

Hello Sam,
Thank you for the review.
Sorry for the coding style and docs (did you mean the doxygen comments ?), I copied it from the entropy done on the K64F platform ;)
Is it better now ?

@sg-
Copy link
Contributor

sg- commented Aug 3, 2016

/morph test

@mbed-bot
Copy link

mbed-bot commented Aug 3, 2016

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 591

Build failed!

@bridadan
Copy link
Contributor

bridadan commented Aug 3, 2016

Looks like build failures for ARM toolchain for the following targets: NUCLEO_F429ZI , DISCO_F469NI, DISCO_F429ZI, NUCLEO_F410RB:

Building project test_setup_failure (NUCLEO_F410RB, ARM)
Scan: ARM
Scan: test_setup_failure
Compile: main.cpp
Link: test_setup_failure
Error: L6218E: Undefined symbol mbedtls_hardware_poll (referred from entropy.o).
Finished: 0 information, 0 warning and 1 error messages.

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 11, 2016

@adustm Please can you check those failures?

@adustm adustm force-pushed the STM32F4_F7_entropy branch from 825bb11 to 059c5a3 Compare August 18, 2016 15:36
@adustm
Copy link
Member Author

adustm commented Aug 18, 2016

Hello everyone,
I just rebased the branch, merged the targets.json manually, and relaunched the build for the following list of targets : DISCO_F429ZI / DISCO_F469NI / DISCO_F746NG / NUCLEO_F410RB / NUCLEO_F429ZI / NUCLEO_F746ZG / NUCLEO_F767ZI
You are right, there was an issue with the labels for STM32F4 family. I have fixed those labels in the targets.json file.
I looks like those defines (for instance STM32F429xx) where present in my previous environment, and not anymore...

I am using the command : mbed test --compile -t ARM -m NUCLEO_F410RB and it compiles perfectly.

Let me know.
Kind regards
Armelle

@bridadan
Copy link
Contributor

Thanks @adustm!

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 669

Test failed!

@adustm
Copy link
Member Author

adustm commented Aug 19, 2016

Hello, Could you give me the command + result of the morph test, please ? I can't read them

@adustm
Copy link
Member Author

adustm commented Aug 22, 2016

@0xc0170 , @bridadan
is it possible to get details on the failure, please ?

@bridadan
Copy link
Contributor

Hi @adustm, sorry for the delay! There was a failure in the CI that occurred during this test, I will restart it.

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 685

Test failed!

@adustm
Copy link
Member Author

adustm commented Aug 25, 2016

Hello Brian,
I cannot access the result of your morph test.
Could you provide me a copy/paste of the failure now ? Could I have the command line + text of the result, so that I can test it, please ?
Kind regards
Armelle

@screamerbg
Copy link
Contributor

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 710

Test failed!

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 25, 2016

The build 710 is without any failure

@screamerbg
Copy link
Contributor

@0xc0170 any idea why it reports failure?

@sg- sg- merged commit defa61d into ARMmbed:master Aug 25, 2016
@bridadan
Copy link
Contributor

Hi everyone, sorry for the delay on reporting back on this.

For build 710 (that last one), a test box died again which cause the whole thing to fail. I've since reorganized the boards so they are more balanced across the boxes, so that should help with stability.

I can confirm that build 685 looks ok, so the merge to master should be fine 👍

@adustm
Copy link
Member Author

adustm commented Aug 26, 2016

Hello, thanks for the analysis and merge. I will push the entropy for the rest of STM32 products soon.
Cheers
Armelle

@adustm adustm mentioned this pull request Sep 27, 2016
@adustm adustm deleted the STM32F4_F7_entropy branch March 13, 2017 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants