RISC-V/HiFive memory limitations

Joel Sherrill joel at rtems.org
Mon Jun 19 21:19:33 UTC 2017


Check the value in gdb without loading it on a target.

Gdb hello.exe

p symbol

Since it is a constant, it should be as expected. If it is, you have a code
loading issue.

Is that value by any chance an instruction?

On Jun 19, 2017 4:03 PM, "Denis Obrezkov" <denisobrezkov at gmail.com> wrote:

> 2017-06-19 23:57 GMT+03:00 Hesham Almatary <heshamelmatary at gmail.com>:
>
>> Hi Denis,
>>
>> If you cscope this symbol you'll end up with the following:
>>
>> /**
>>>  * By default, use the minimum stack size requested by this port.
>>>  */
>>> #ifndef CONFIGURE_MINIMUM_TASK_STACK_SIZE
>>>   #define CONFIGURE_MINIMUM_TASK_STACK_SIZE CPU_STACK_MINIMUM_SIZE
>>> #endif
>>>
>>
>> This means if you, from the application (i.e. hello or ticker), didn't
>> define CONFIGURE_MINIMUM_TASK_STACK_SIZE it will be
>> CPU_STACK_MINIMUM_SIZE which is 4KiB for riscv32 CPU
>> (cpukit/score/cpu/riscv32/rtems/score/cpu.h:457)
>>
>>
>> On Mon, Jun 19, 2017 at 10:07 AM, Denis Obrezkov <denisobrezkov at gmail.com>
>> wrote:
>> > Hesham, could you check what is the value of rtems_minimum_stack_size in
>> > your SPIKE executable?
>> >
>> > 2017-06-18 22:10 GMT+03:00 Denis Obrezkov <denisobrezkov at gmail.com>:
>> >>
>> >> Hello all,
>> >>
>> >> I was able to proceed further via setting rtems_minimum_stack_size
>> >> manually to 0x200.
>> >> Now I have another error, my backtrace:
>> >> #0  0x20403728 in _Internal_error
>> >> (core_error=INTERNAL_ERROR_WORKSPACE_ALLOCATION)
>> >>     at
>> >> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/score/src/interr.c:44
>> >> #1  0x2040ec40 in _Workspace_Allocate_or_fatal_error (size=2976696) at
>> >> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/score/src/wkspace.c:163
>> >> #2  0x2040f0e6 in _Freechain_Initialize (freechain=0x80000c3c
>> >> <_RTEMS_tasks_Information+60>, allocator=0x2040ec16
>> >> <_Workspace_Allocate_or_fatal_error>, number_nodes=41343,
>> node_size=72)
>> >>     at
>> >> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/score/src/freechain.c:31
>> >> #3  0x20409346 in _Thread_Initialize_information
>> (information=0x80000c00
>> >> <_RTEMS_tasks_Information>, the_api=OBJECTS_CLASSIC_API, the_class=1,
>> >> maximum=3908149631, is_string=false,
>> >>     maximum_name_length=4) at
>> >> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/score/src/thread.c:68
>> >> #4  0x20401dac in _RTEMS_tasks_Manager_initialization () at
>> >> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/rtems/src/tasks.c:72
>> >> #5  0x204021bc in rtems_initialize_executive () at
>> >> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/sapi/src/exinit.c:95
>> >> #6  0x2040031c in boot_card (cmdline=0x0) at
>> >> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/lib/libbsp/riscv32/hifive1/../../shared/bootcard.c:76
>> >> #7  0xffffcd98 in ?? ()
>> >>
>> >> Is RTEMS trying to allocate 2976696 bytes?
>> >> It seems to me, that .data region is not properly initialized. What do
>> you
>> >> think about this?
>> >>
>> >> 2017-06-18 1:31 GMT+03:00 Denis Obrezkov <denisobrezkov at gmail.com>:
>> >>>
>> >>> 2017-06-17 22:11 GMT+03:00 Denis Obrezkov <denisobrezkov at gmail.com>:
>> >>>>>>
>> >>>>>>
>> >>>>> Can you run RTEMS hello world? Or does printf make that too large?
>> If
>> >>>>> that is
>> >>>>> too large, you need to force the tests to switch to printk(). There
>> is
>> >>>>> some magic
>> >>>>> in testsuites/configure.ac for that.
>> >>>>>
>> >>>>> The low ticker examples (especially the last one) will show
>> configure
>> >>>>> options
>> >>>>> to cut memory use.
>> >>>>>
>> >>>>> But these are hacks on individual tests. If there is a simulator
>> which
>> >>>>> has interrupts,
>> >>>>> I would be testing on it since you will be battling the architecture
>> >>>>> not a RAM limit.
>> >>>>> Your project is the port not to put RTEMS into a tiny memory space.
>> :)
>> >>>>>
>> >>>>> --joel
>> >>>>>
>> >>>>>>
>> >>>>>> --
>> >>>>>> Regards, Denis Obrezkov
>> >>>>>
>> >>>>>
>> >>>> I was able to run the low ticker example further than in my earlier
>> >>>> attempts.
>> >>>>
>> >>>> But now I have a problem with it:
>> >>>> #0  memset (m=0xb98a0641, c=0, n=102) at
>> >>>> ../../../../../gcc-7.1.0/newlib/libc/string/memset.c:62
>> >>>> #1  0x20403168 in _Heap_Initialize (heap=0xb98a0641,
>> >>>> heap_area_begin_ptr=0x80002456, heap_area_size=7082, page_size=8)
>> >>>>     at
>> >>>> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/score/src/heap.c:230
>> >>>> #2  0x20400954 in RTEMS_Malloc_Initialize (areas=0x80003f78,
>> >>>> area_count=1, extend=0x0)
>> >>>>     at
>> >>>> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/libcsupport/src/malloc_initialize.c:40
>> >>>> #3  0x20400378 in bsp_work_area_initialize_default
>> >>>> (area_begin=0x80000e10, area_size=12784) at
>> >>>> ../../../../../.././hifive1/lib/include/bsp/bootcard.h:158
>> >>>> #4  0x204003c0 in bsp_work_area_initialize () at
>> >>>> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/lib/libbsp/riscv32/hifive1/../../shared/
>> bspgetworkarea.c:61
>> >>>> #5  0x204021bc in rtems_initialize_executive () at
>> >>>> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/sapi/src/exinit.c:95
>> >>>> #6  0x2040031c in boot_card (cmdline=0x0) at
>> >>>> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/lib/libbsp/riscv32/hifive1/../../shared/bootcard.c:76
>> >>>> #7  0x20400064 in _end_clear_bss () at
>> >>>> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/lib/libbsp/riscv32/hifive1/start/start.S:116
>> >>>>
>> >>>> I want to figure out, why it wants to use memset on these addresses,
>> >>>> because 0x80004000 is the maximum available address.
>> >>>>
>> >>>>
>> >>>> --
>> >>>> Regards, Denis Obrezkov
>> >>>
>> >>>
>> >>> I was able to proceed further after adding
>> >>> #define CONFIGURE_UNIFIED_WORK_AREAS
>> >>> to init.c of low_ticker example.
>> >>> Now I get an error:
>> >>> #0  0x2040d940 in _Chain_Initialize_node (the_node=0x80003ec0) at
>> >>> ../../cpukit/../../../hifive1/lib/include/rtems/score/chainimpl.h:127
>> >>> #1  0x2040da82 in _Chain_Iterator_initialize (the_chain=0x80000320
>> >>> <_User_extensions_List>, the_registry=0x8000032c
>> <_User_extensions_List+12>,
>> >>> the_iterator=0x80003ec0,
>> >>>     direction=CHAIN_ITERATOR_FORWARD) at
>> >>> ../../cpukit/../../../hifive1/lib/include/rtems/score/chaini
>> mpl.h:1049
>> >>> #2  0x2040de90 in _User_extensions_Iterate (arg=0x80003f18,
>> >>> visitor=0x2040dd48 <_User_extensions_Fatal_visitor>,
>> >>> direction=CHAIN_ITERATOR_FORWARD)
>> >>>     at
>> >>> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/score/src/userextiterate.c:174
>> >>> #3  0x204036c4 in _User_extensions_Fatal (source=INTERNAL_ERROR_CORE,
>> >>> error=4) at
>> >>> ../../cpukit/../../../hifive1/lib/include/rtems/score/userex
>> timpl.h:307
>> >>> #4  0x204036e8 in _Terminate (the_source=INTERNAL_ERROR_CORE,
>> >>> the_error=4) at
>> >>> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/score/src/interr.c:35
>> >>> #5  0x20403730 in _Internal_error
>> >>> (core_error=INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL)
>> >>>     at
>> >>> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/score/src/interr.c:44
>> >>> #6  0x20403824 in _ISR_Handler_initialization () at
>> >>> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/score/src/isr.c:51
>> >>> #7  0x20402170 in rtems_initialize_data_structures () at
>> >>> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/sapi/src/exinit.c:82
>> >>> #8  0x204021bc in rtems_initialize_executive () at
>> >>> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/../../cpukit/sapi/src/exinit.c:95
>> >>> #9  0x2040031c in boot_card (cmdline=0x0) at
>> >>> /home/reprofy/Projects/riscv/rtems/development/rtems/kernel/
>> rtems-riscv/c/src/lib/libbsp/riscv32/hifive1/../../shared/bootcard.c:76
>> >>> #10 0xffffcd98 in ?? ()
>> >>>
>> >>> And I found out that rtems_minimum_stack_size variable is 0xab817bb3.
>> >>> And I don't know why - in the low ticker example it is set to 512.
>> >>>
>> >>> --
>> >>> Regards, Denis Obrezkov
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >> Regards, Denis Obrezkov
>> >
>> >
>> >
>> >
>> > --
>> > Regards, Denis Obrezkov
>>
>>
>>
>> --
>> Hesham
>>
>
> Yes, I have configured it in application.
> Anyway, the number 0xab817bb3 is not for 4 KiB.
>
> --
> Regards, Denis Obrezkov
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20170619/05757b44/attachment-0002.html>


More information about the devel mailing list