Giter Site home page Giter Site logo

Comments (3)

samsoniuk avatar samsoniuk commented on May 22, 2024 1

Thank you for the suggestions!

Well, the information at boot is the start address of each segment, but it appears that there is a mistake here and the data segment is in the wrongly location... it says:

boot0: text@0 data@6900 stack@8192 (1292 bytes free)

Which means that the text segment starts at position 0, the data starts at position 6900 (which is wrong) and the stack starts at position 8192. The free memory is calculated by the stack-heap, which is correct: the stack can down to the heap. Of course, when the stack reaches the heap, the code will probably crash, but it depends of the core that is running. By coincidence, the last variable in the code is the headcheck variable, which is checked all time. Case this variable changes, the code will print an out of memory diagnostic.

Well, I made some changes today and it is now far better:

boot0: text@0+5360 data@5360+1600 stack@8192 (1232 bytes free)

Which means that the text segment starts at position 0 and have 5360 bytes, the data segment starts at 5360 and have 1600 bytes, and the stack segment starts at position 8192 down to the end of data segment, in a way that we have 1232 bytes. Checking the sum of 5360+1600+1240 is exactly 8192!

The same code, but with the HARVARD option in the build will result in:

boot0: text@0+5360 data@8192+1600 stack@16384 (6592 bytes free)

Which means that the text segment starts at position 0 and have 5360 bytes; the data segment starts at 8192 and have 1600 bytes and the stack starts at 16384, all correct, since now we are working with 8KB of ROM and 8KB of RAM. Also, the available memory for stack is 6592 bytes, in a way that 1600+6592 is 8192. Of course, there are some free memory in the ROM memory, but it cannot be used by the stack, as long it is in the instruction bus and the stack requires that the memory is in the data bus.

Interesting is that the text and data sizes are the same, which makes sense, since they are only in different positions.

from darkriscv.

samsoniuk avatar samsoniuk commented on May 22, 2024 1

oh, I forgot the 4 bytes from .sdata... but it is already fixed:

 .bss           0x0000000000001b30        0x0 boot.o
 *(.sdata)
 .sdata         0x0000000000001b30        0x4 main.o
                0x0000000000001b30                heapcheck
                0x0000000000001b34                _edata = .
                0x0000000000002000                PROVIDE (_stack = (ORIGIN (MEM) + LENGTH (MEM)))

boot0: text@0+5360 data@5360+1604 stack@8192 (1228 bytes free)

from darkriscv.

vgegok avatar vgegok commented on May 22, 2024

Great! darkriscv will be more and more perfect!

from darkriscv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.