Skip to content
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

[GCC_CR] non-RTOS build code doesn't reach to the main() function #2581

Closed
toyowata opened this issue Aug 30, 2016 · 1 comment
Closed

[GCC_CR] non-RTOS build code doesn't reach to the main() function #2581

toyowata opened this issue Aug 30, 2016 · 1 comment

Comments

@toyowata
Copy link
Contributor

An exported project to LPCXpresso IDE (GCC_CR build) doesn't reach to the main() function for baremetal (non-RTOS) build.
Automate test result of the LPC1768 is below:

Test summary:
+---------+---------+-----------+-------------+---------------------------------------+--------------------+---------------+-------+
| Result  | Target  | Toolchain | Test ID     | Test Description                      | Elapsed Time (sec) | Timeout (sec) | Loops |
+---------+---------+-----------+-------------+---------------------------------------+--------------------+---------------+-------+
| TIMEOUT | LPC1768 | GCC_CR    | DTCT_1      | Simple detect test                    |       20.07        |       10      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | EXAMPLE_1   | /dev/null                             |       20.07        |       10      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_10     | Hello World                           |       20.07        |       10      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_11     | Ticker Int                            |       40.33        |       20      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_12     | C++                                   |       20.08        |       10      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_16     | RTC                                   |       30.25        |       15      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_2      | stdio                                 |       40.34        |       20      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_22     | Semihost                              |       20.14        |       10      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_23     | Ticker Int us                         |       30.25        |       15      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_24     | Timeout Int us                        |       30.25        |       15      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_25     | Time us                               |       30.23        |       15      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_26     | Integer constant division             |       20.08        |       10      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_34     | Ticker Two callbacks                  |       30.22        |       15      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_37     | Serial NC RX                          |        20.1        |       10      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_38     | Serial NC TX                          |       20.12        |       10      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_A1     | Basic                                 |       20.07        |       10      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_A18    | Interrupt vector relocation           |       20.09        |       10      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_A2     | Semihost file system                  |       20.12        |       10      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_A21    | Call function before main (mbed_main) |       20.13        |       10      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_A9     | Serial Echo at 115200                 |       20.09        |       10      |  0/1  |
| TIMEOUT | LPC1768 | GCC_CR    | MBED_BUSOUT | BusOut                                |       30.21        |       15      |  0/1  |
| OK      | LPC1768 | GCC_CR    | RTOS_1      | Basic thread                          |       12.69        |       15      |  1/1  |
| OK      | LPC1768 | GCC_CR    | RTOS_2      | Mutex resource lock                   |       12.84        |       20      |  1/1  |
| OK      | LPC1768 | GCC_CR    | RTOS_3      | Semaphore resource lock               |        9.81        |       20      |  1/1  |
| OK      | LPC1768 | GCC_CR    | RTOS_4      | Signals messaging                     |        7.78        |       20      |  1/1  |
| OK      | LPC1768 | GCC_CR    | RTOS_5      | Queue messaging                       |        3.7         |       20      |  1/1  |
| OK      | LPC1768 | GCC_CR    | RTOS_6      | Mail messaging                        |        3.71        |       20      |  1/1  |
| OK      | LPC1768 | GCC_CR    | RTOS_7      | Timer                                 |       12.62        |       15      |  1/1  |
| OK      | LPC1768 | GCC_CR    | RTOS_8      | ISR (Queue)                           |        7.81        |       20      |  1/1  |
+---------+---------+-----------+-------------+---------------------------------------+--------------------+---------------+-------+
Result: 8 OK / 21 TIMEOUT

Completed in 732.83 sec

This was because the software_init_hook() function was defined here with strong (non-weak) symbol by this change.

43e595a

Original code in the reset vector startup code for GCC_CR is below:

extern "C" void software_init_hook(void) __attribute__((weak));

AFTER_VECTORS void ResetISR(void) {

// snip

    SystemInit();
    if (software_init_hook) // give control to the RTOS
        software_init_hook(); // this will also call __libc_init_array
    else {
        __libc_init_array();
        main();
    }
    while (1) {;}
}

The software_init_hook symbol is now defined as strong rather than weak, therefore if (software_init_hook) statement is always true even an mbed-rtos library is not linked. i.e. baremetal project.

I tried to use a software_init_hook_rtos symbol instead which is weakly defined in retarget.cpp, but this was strongly linked into the ResetISR startup code because they were in the same static library. See: http://stackoverflow.com/questions/23079997/override-weak-symbols-in-static-library

When I use pre_main symbol which is weakly defined in other static library (mbed-rtos) and it works as expected. I will make PR once my local test has been completed.

@toyowata
Copy link
Contributor Author

#2582 merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant