Function to return kernel size

General discussion about anything related to Ultibo.
Posts: 1324
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Function to return kernel size

Postby mark » Tue Aug 07, 2018 11:07 pm

Is there an ultibo function that returns the kernel size (reflective of the size of kernel7.img?) I'd like to report it in a web status page. Thanks, Mark.
User avatar
Site Admin
Posts: 2150
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Function to return kernel size

Postby Ultibo » Tue Aug 07, 2018 11:45 pm

mark wrote:Is there an ultibo function that returns the kernel size (reflective of the size of kernel7.img?)

There is no specific function available but it is very easy to calculate based on information already known to the kernel.

Near the top of the GlobalConfig unit you will find variables that reference the "Kernel Image sections" and describe the start and end of code, initialized data and uninitialized data, you can also see in the WebStatus unit how to use these variables to get the start and end addresses of each section.

If you just want to know the size of the kernel7.img file (without looking at the file itself) then subtracting _text_start from _edata will give a very close match (the difference is just the size of the kernel trailer which does not get loaded info memory).

Remember of course that the kernel image does not include the BSS (unitialized data) section because it is all zeroes so there is no point including it in the file, if you want to know the total size of the kernel including the BSS then subtracting _text_start from _bss_end will tell you that.

Note that this only tells you the raw loaded size, there are other structures created during boot like the page tables, initial stack, initial heap etc that consume memory but are not part of the image size as such, most of those are also available as GlobalConfig values as well. | Make something amazing

Return to “Discussion”

Who is online

Users browsing this forum: No registered users and 0 guests