earlephilhower / arduino-pico

Raspberry Pi Pico Arduino core, for all RP2040 and RP2350 boards
GNU Lesser General Public License v2.1
1.99k stars 412 forks source link

Feature Request - Display resources, Ram and Flash in complier #17

Closed vslinuxdotnet closed 3 years ago

vslinuxdotnet commented 3 years ago

Hello, In some future day is possible to add the free/occupied resources at the end of the compiler console ? Thank you

earlephilhower commented 3 years ago

It's relatively straightforward and a good project for someone looking to jump in and help.

See how it's done in https://github.com/esp8266/Arduino/blob/master/tools/sizes.py .

You'd also need to find total flash size from the UF2 file using some Python like:

with open(uf2file, "rb") as f:
    blk = f.read(512)
    s = 0
    while blk:
        ret = struct.unpack("8i476xi", blk)
        if (ret[2] & 1) == 0:
            s = s + ret[4]
        blk = f.read(512)
    print(s)
vslinuxdotnet commented 3 years ago

OK I make a change in platform.txt in line: recipe.objcopy.uf2.pattern= I replace the cmd "elf2uf2" to the build.py to process some python code in the middle. This is a test with a blink code:

image

Now lets do some code to get it for memory.

earlephilhower commented 3 years ago

Cool! Looking forward to a PR sometime.

I would not print ELF or UF2 file sizes, they're unimportant and not really related to what's in the flash (i.e. ELF has debugging information and UF2 has large overhead for each sector of flash)

vslinuxdotnet commented 3 years ago

Seams that is not need to invented the Wheel, the Arduino have all things need for that change: the compiler.size.cmd=arm-none-eabi-size exists so.... in file boards.txt add/change this lines for flash and ram: rpipico.upload.maximum_size=2097152 rpipico.upload.maximum_data_size=270336

And in file platform.txt add this line in: ## Compute size: recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).*

Works:

image

That's all for today :)

earlephilhower commented 3 years ago

Great, thanks!!!