cancel
Showing results for 
Search instead for 
Did you mean: 

Code generated with errors

SPrak.4
Associate II

I use STM32 Nucleo f429zi. I tried to replicate the application on the following link, and followed all the steps. I use USART3 with pins PD8 and PD9 (the manual says these pins are connected to ST-Link)

https://www.youtube.com/watch?v=grgNXdkmzzQ

I use STM Cube IDE. On STM Cude IDE -> there is Debug option to flash the code on Board. However, when I try to Debug - there are errors generated in the app_x-cube-ai.c file.

void MX_X_CUBE_AI_Process(void)
{
    aiValidationProcess();
    /* USER CODE BEGIN 1 */
	int nb_run = 20;
    int res;
 
    /* Example of definition of the buffers to store the tensor input/output */
    /*  type is dependent of the expected format                             */
    AI_ALIGNED(4)
    static ai_i8 in_data[AI_IMAGECLASSIFICATION_IN_1_SIZE_BYTES];
 
    AI_ALIGNED(4)
    static ai_i8 out_data[AI_IMAGECLASSIFICATION_OUT_1_SIZE_BYTES];
 
    /* Retrieve format/type of the first input tensor - index 0 */
    const ai_buffer_format fmt_ = AI_BUFFER_FORMAT(&ai_input[0]);   // ai_input undeclared
    const uint32_t type_ = AI_BUFFER_FMT_GET_TYPE(fmt_);
 
    /* Prepare parameters for float to Qmn conversion */
    const ai_i16 N_ = AI_BUFFER_FMT_GET_FBITS(fmt_);
    const ai_float scale_ = (0x1U << N_);
    const ai_i16 M_ =  AI_BUFFER_FMT_GET_BITS(fmt_)
                       - AI_BUFFER_FMT_GET_SIGN(fmt_) - N_;
    const ai_float max_ = (ai_float)(0x1U << M_);
 
    /* Perform nb_rub inferences (batch = 1) */
    while (--nb_run) {
 
        /* ---------------------------------------- */
        /* Data generation and Pre-Process          */
        /* ---------------------------------------- */
        /* - fill the input buffer with random data */
        for (ai_size i=0;  i < AI_IMAGECLASSIFICATION_IN_1_SIZE; i++ ) {
 
            /* Generate random data in the range [-1, 1] */
            ai_float val = 2.0f * (ai_float)rand() / (ai_float)RAND_MAX - 1.0f;   // RAND_MAX undeclared
 
            /* Convert the data if necessary */
            if (type_ == AI_BUFFER_FMT_TYPE_FLOAT) {
                ((ai_float *)in_data)[i] = val;
            } else { /* AI_BUFFER_FMT_TYPE_Q */
                /* Scale the values in the range [-2^M, 2^M] */
                val *= max_;
                /* Convert float to Qmn format */
                const ai_i32 tmp_ = AI_ROUND(val * scale_, ai_i32);  // expected expression before ai_132
                in_data[i] =  AI_CLAMP(tmp_, -128, 127, ai_i8);  // expected expression before ai_i8
            }
        }
 
        /* Perform the inference */
        res = aiRun(in_data, out_data);
        if (res) {
            // ...
            return;
        }
 
        /* Post-Process - process the output buffer */
        // ...
    }
    /* USER CODE END 1 */
}

Eventhough I got these error. I tried to validate on target, just to see what happens. I selected COM PORT 3 (COM 3 and COM 4 were the available options) with baud rate 115200. I got error "No board connected or invalid firware or restart board". I tried with COM port 4, but got the same error.

Could someone please help me out and let me know as to what is going wrong here.

Thanks in advance

20 REPLIES 20

I tried the same. Selected the correct baud rate, com port and other configuration as you mentioned. Still validation on target shows the same error.

While using putty, i see no output received on the com port

and I suppose you closed the putty before launching the validation on the target on the PC (on windows only one application can access a com port at the same time)


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

and I suppose you closed the putty before launching the validation on the target on the PC (on windows only one application can access a com port at the same time)


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

and I suppose you closed the putty before launching the validation on the target on the PC (on windows only one application can access a com port at the same time)


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

yes i closed putty before launching the validation. and opened the port only after I received the error message stating "No board found".

I received the message Program Stopped - UART_WaitOnFlagUntilTimeout on debugger console of the IDE

Yes I opened the putty connected only after launching the validation on the target. The received the error message "no board". And only then I opened the putty connection -> ofcourse there will not be any message transmitted there

SPrak.4
Associate II

Yes I did. Still the same error.

But the program got flashed on the board, I could debug the program. However, Validate on Target is not able to identify the board. Once the program has been flashed to the board, should I terminate the execution and then select "Validate on target" or should the IDE be still running the program ?

fauvarque.daniel
ST Employee

I guess the code on the target is not correct.

The main should look like that:

int main(void)

{

 /* USER CODE BEGIN 1 */

 /* USER CODE END 1 */

 /* MCU Configuration--------------------------------------------------------*/

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

 HAL_Init();

 /* USER CODE BEGIN Init */

 /* USER CODE END Init */

 /* Configure the system clock */

 SystemClock_Config();

 /* USER CODE BEGIN SysInit */

 /* USER CODE END SysInit */

 /* Initialize all configured peripherals */

 MX_GPIO_Init();

 MX_CRC_Init();

 MX_X_CUBE_AI_Init();

 /* USER CODE BEGIN 2 */

 /* USER CODE END 2 */

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

 {

   /* USER CODE END WHILE */

 MX_X_CUBE_AI_Process();

   /* USER CODE BEGIN 3 */

 }

 /* USER CODE END 3 */

}

And app_x-cube-ai.c like that

void MX_X_CUBE_AI_Init(void)

{

 MX_UARTx_Init();

 aiValidationInit();

 /* USER CODE BEGIN 0 */

 /* USER CODE END 0 */

}

void MX_X_CUBE_AI_Process(void)

{

   aiValidationProcess();

 /* USER CODE BEGIN 1 */

 /* USER CODE END 1 */

}

with some extra code below to manage multiple networks.

What version of X-Cube-AI are you using ?


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
SPrak.4
Associate II

Am using X-Cube-AI version 4.0.0.

The code I previosuly posted was generated wrong, as I tried application template and validation consecutively. However, based on your advice I regenerated all the files. No my code looks like what you have posted.

I would like to bring it to your point that: the code got compiled with no errors and flashed on board. However validation on target says "no board found"

SPrak.4
Associate II

The log I received on "Validation on Target"

Flashing project 

Build is Done 

Starting AI validation on target with random data... 

Neural Network Tools for STM32 v1.0.0 (AI tools v4.0.0) 

Automatic build and run succeed 

-- Importing model 

-- Importing model - done (elapsed time 0.506s) 

-- Building X86 C-model 

-- Building X86 C-model - done (elapsed time 7.360s) 

-- Setting inputs (and outputs) data 

Using random input, shape=(10, 270) 

-- Running STM32 C-model 

ON-DEVICE STM32 execution ("aimodel", COM4, 115200).. 

LOAD ERROR: STM32 - no connected board(s)or invalid firmware or the board should be re-started