Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12667 Discussions

Nios V - BSP generation produces incorrect ALT_CPU_MTIME_OFFSET value in system.h

KennyJoosen
Novice
516 Views

I'm in the process of migrating a Nios II/f processor to a Nios V/g processor. Quartus Pro 23.3 is being used.

In our setup we use an external timer block for the sys_clk_timer. For the timestamp_timer we use none. No OS is being used.

When using a sleep (alt_busy_sleep of the HAL) command in the code, it leads to an exception causing the application to halt.

I tracked it down to the following:

 

When generating the BSP, the system.h file contains the following define (which indicates that the timer_sw_agent is not connected, and that it correct):

 

 

#define ALT_CPU_MTIME_OFFSET 0xffffffff

 

 

The alt_busy_sleep method in alt_busy_sleep.c of the BSP checks on if MTIME_SW_AGENT_CONNECTED is defined (it should not be defined, since we want to go into the else statement!). This is defined on the following condition:

 

 

// Determine if timer_sw_agent interface is connected in HW
#ifdef ALT_CPU_MTIME_OFFSET
    #if ALT_CPU_MTIME_OFFSET != 0xffffffffffffffff
        #define MTIME_SW_AGENT_CONNECTED
    #endif
#endif

 

 

Since the ALT_CPU_MTIME_OFFSET is defined as 32-bit and the check is done with 64-bit, it seems that the width of ALT_CPU_MTIME_OFFSET or the if condition is incorrect?

How should I fix this?

0 Kudos
1 Solution
aikeu
Employee
331 Views

Hi KennyJoosen,



I have file an internal request regarding the issue last week. Estimated that the changes will take some time for the next release.



Thanks.

Regards,

Aik Eu


View solution in original post

0 Kudos
5 Replies
aikeu
Employee
437 Views

Hi KennyJoosen,


If purposely not define define MTIME_SW_AGENT_CONNECTED without the if else condition, will the issue persist?


Thanks.

Regards,

Aik Eu


0 Kudos
KennyJoosen
Novice
426 Views

The define is part of the generated Intel BSP sources. So with every generation, all changes done in these sources are gone. Since the entire functionality happens in these BSP sources, it is not possible to undefine MTIME_SW_AGENT_CONNECTED...

Current workaround is to replace below define with 64-bit value (0xffffffffffffffff) in system.h after every BSP generation...

#define ALT_CPU_MTIME_OFFSET 0xffffffff

There is no option to be set so the BSP generation defines it differently?

0 Kudos
aikeu
Employee
389 Views

Hi KennyJoosen,


Unfortunately there is no option to make the changes permanent in the BSP at the moment. I think I will file a case internally to discuss about the matter.


Thanks.

Regards,

Aik Eu


0 Kudos
aikeu
Employee
332 Views

Hi KennyJoosen,



I have file an internal request regarding the issue last week. Estimated that the changes will take some time for the next release.



Thanks.

Regards,

Aik Eu


0 Kudos
aikeu
Employee
258 Views

Hi KennyJoosen,


I will close the case if there is no further question.


Thanks.

Regards,

Aik Eu


0 Kudos
Reply