-
Notifications
You must be signed in to change notification settings - Fork 3k
Update devices to have minimum 2K RAM and heap, also added test #5285
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
Conversation
Build : FAILUREBuild number : 22 |
Looks good. Are the numbers 'random' or did you pick them based on something? |
Build : FAILUREBuild number : 70 |
👍 Documented anywhere? should be ? |
The latest build shows devices that fail this test
Any other feedback for this test and requirement? Please review! |
@c1728p9 @bulislaw @0xc0170 NUCLEO_F070RB - ARM: pass
NUCLEO_F070RB - IAR: fail
|
Maybe we should require 1k on heap? |
We see some failures with IAR, updaring IAR to use dynamic heap for this upcoming minor release will resolve this.
I am wondering if a device with 16k does not have 4k RAM left, if it is a target that should be supported? What others think? @jeromecoutant Where is all RAM for NUCLEO_F070RB that GCC fails this test? |
Hi |
If #5386 is a real bug and we will get at least 1kB of heap back then most of memory problems with basic tests on devices with small RAM will disappear |
7432bb9
to
e6faa68
Compare
I rebased this PR and added some comments to the PR to indicate the purpose of this test.
I tried to pick numbers that were on the higher end on most tests. These numbers aren't based on any hard requirement or anything though. If they need to be increased or decreased its not a problem. |
/morph build |
1 similar comment
/morph build |
Build : FAILUREBuild number : 400 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved by @bulislaw
/morph build |
Build : FAILUREBuild number : 467 |
Failures are for few targets, only IAR toolchain. I am wondering if updating to IAR 8.x,dynamic heap resolves this to get some space back? From the log, these are offending boards:
I checked few, failing to allocate around 1k in readwrite region. |
Hi
What are next steps:
|
@c1728p9 ^^^ |
This may need to wait for a new version of IAR. I can close this for now if you would like, or I can leave this PR up as a reminder. |
@jeromecoutant - Please share the test log. I dont have NUCLEO_F070RB :-( , but have NUCLEO_F072RB. |
Same result with NUCLEO_F072RB, test is failing here :
|
@jeromecoutant Would toy mind providing steps to reproduce? For myself, running the following all succeeded without issues:
|
@cmonr , maybe I was not explicit enough. So I would appreciate to check this regression before merging PR Thx |
Did some additional tests with NUCLEO_F070RB and I can see following problems:
diff --git a/TESTS/mbedmicro-rtos-mbed/heap_and_stack/main.cpp b/TESTS/mbedmicro-rtos-mbed/heap_and_stack/main.cpp
index d4334ad6f..b72daec4a 100644
--- a/TESTS/mbedmicro-rtos-mbed/heap_and_stack/main.cpp
+++ b/TESTS/mbedmicro-rtos-mbed/heap_and_stack/main.cpp
@@ -54,8 +54,70 @@ struct linked_list {
uint8_t data[MALLOC_TEST_SIZE];
};
+#define MEM_LOG
+#ifdef MEM_LOG
+volatile uint32_t isr_variable1_addr = 0;
+volatile uint32_t isr_variable2_addr = 0;
+volatile uint32_t isr_variable3_addr = 0;
+void fun()
+{
+ uint8_t isr_variable1 = 1;
+ uint8_t isr_variable2 = 2;
+ uint8_t isr_variable3 = 3;
+ isr_variable1_addr = (uint32_t)&isr_variable1;
+ isr_variable2_addr = (uint32_t)&isr_variable2;
+ isr_variable3_addr = (uint32_t)&isr_variable3;
+
+}
+
+void test_log()
+{
+ mbed_rtos_storage_thread_t *thread = (mbed_rtos_storage_thread_t *) osThreadGetId();
+
+ uint32_t psp = __get_PSP();
+ uint8_t *stack_mem = (uint8_t *) thread->stack_mem;
+ uint32_t stack_size = thread->stack_size;
+ uint8_t main_stack_variable1 = 3;
+ uint8_t main_stack_variable2 = 2;
+ uint8_t main_stack_variable3 = 3;
+
+ utest_printf("mbed_main_stack_size: %X\r\n", stack_size);
+ utest_printf("%X: mbed_main_stack_start\r\n", (uint32_t)stack_mem);
+ utest_printf("%X: psp\r\n", psp);
+ utest_printf("%X: main_stack_variable1_addr\r\n", (uint32_t)&main_stack_variable1);
+ utest_printf("%X: main_stack_variable2_addr\r\n", (uint32_t)&main_stack_variable2);
+ utest_printf("%X: main_stack_variable3_addr\r\n", (uint32_t)&main_stack_variable3);
+ utest_printf("%X: mbed_main_stack_end\r\n", (uint32_t)stack_mem + stack_size);
+
+ utest_printf("mbed_heap_size: %X\r\n", mbed_heap_size);
+ utest_printf("%X: mbed_heap_start\r\n", (uint32_t)mbed_heap_start);
+ uint8_t *heap_variable1_addr = (uint8_t*)malloc(1);
+ utest_printf("%X: heap_variable1_addr\r\n", (uint32_t)heap_variable1_addr);
+ uint8_t *heap_variable2_addr = (uint8_t*)malloc(1);
+ utest_printf("%X: heap_variable2_addr\r\n", (uint32_t)heap_variable2_addr);
+ uint8_t *heap_variable3_addr = (uint8_t*)malloc(1);
+ utest_printf("%X: heap_variable3_addr\r\n", (uint32_t)heap_variable3_addr);
+ utest_printf("%X: mbed_heap_end\r\n", (uint32_t)mbed_heap_start + mbed_heap_size);
+ free(heap_variable1_addr);
+ free(heap_variable2_addr);
+ free(heap_variable3_addr);
+
+ utest_printf("mbed_stack_isr_size: %X\r\n", mbed_stack_isr_size);
+ utest_printf("%X: mbed_stack_isr_start\r\n", mbed_stack_isr_start);
+
+ Timeout t;
+ t.attach_us(fun, 1);
+ while (isr_variable3_addr == 0);
+ utest_printf("%X: isr_variable1_addr\r\n", isr_variable1_addr);
+ utest_printf("%X: isr_variable2_addr\r\n", isr_variable2_addr);
+ utest_printf("%X: isr_variable3_addr\r\n", isr_variable3_addr);
+ uint32_t msp = __get_MSP();
+ utest_printf("%X: msp\r\n", msp);
+ utest_printf("%X: mbed_stack_isr_end\r\n", (uint32_t)mbed_stack_isr_start + mbed_stack_isr_size);
+
+
+}
+#endif
/* TODO: add memory layout test.
*
* The test was skipped for now since not all devices seems to comply with Mbed OS memory.
@@ -234,6 +296,9 @@ void test_heap_allocation_free(void)
// Test cases
Case cases[] = {
+#ifdef MEM_LOG
+ Case("test_log", test_log),
+#endif
Case("Test heap in range", test_heap_in_range),
Case("Test main stack in range", test_main_stack_in_range),
Case("Test isr stack in range", test_isr_stack_in_range),
Results:
|
Just a comment about tested fix: it is maybe now far from the original PR... "Add a minimum requirements HAL test" |
HEAP memory should be 4K aligned for GCC newlib, with ISR stack at the end of RAM memory we loose 3K of RAM memory. This fix is for device with <16K RAM to use RAM entirely.
56004bd
to
37bfc9e
Compare
Fixed @jeromecoutant - Fix is not just for STM targets, but for all devices with low RAM/ROM memories hence will like to keep it in same PR as it is related and will help in tracking specific targets fixed for this requirement. Also commits are different, and I will update the header as well. |
Hi |
After last fix
|
/morph build |
Build : SUCCESSBuild number : 3323 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2958 |
Test : SUCCESSBuild number : 3133 |
Update the linker scripts (memory map) of targets to have atleast 2K free ram and 2K free heap.
Add a test to ensure the same, this test should be the first test that fails due to running out of ram or heap.