ZakKemble / avr-gcc-build

https://blog.zakkemble.net/avr-gcc-builds/
51 stars 10 forks source link

The avr-size.exe is not suit for avr mcu #3

Closed wanggaoteng closed 1 year ago

wanggaoteng commented 1 year ago

I download the .zip file below: image and unzip it, the path of avr-size.exe is: avr-gcc-12.1.0-x64-windows\bin look at the help of avr-size.exe: image It lacks the --mcu and --mlist-devices as the following picture shows: image

ZakKemble commented 1 year ago

avr-size does not need to know the MCU to show you the memory usage (omit the --mcu arg). If you want to get the usage as a percentage then the new correct way is to use avr-objdump with the -Pmem-usage argument: avr-objdump -Pmem-usage myproject.elf which will output something like:

myproject.elf:     file format elf32-avr
AVR Memory Usage
----------------
Device: attiny402

Program:    1934 bytes (47.2% Full)
(.text + .data + .bootloader)

Data:         16 bytes (6.2% Full)
(.data + .bss + .noinit)

This is because the MCU and available memory sizes are now embedded into the .elf file. See here - https://web.archive.org/web/20211026214736/https://www.avrfreaks.net/forum/where-does-avr-size-get-data-supported-devices

wanggaoteng commented 1 year ago

avr-size does not need to know the MCU to show you the memory usage (omit the --mcu arg). If you want to get the usage as a percentage then the new correct way is to use avr-objdump with the -Pmem-usage argument: avr-objdump -Pmem-usage myproject.elf which will output something like:

myproject.elf:     file format elf32-avr
AVR Memory Usage
----------------
Device: attiny402

Program:    1934 bytes (47.2% Full)
(.text + .data + .bootloader)

Data:         16 bytes (6.2% Full)
(.data + .bss + .noinit)

This is because the MCU and available memory sizes are now embedded into the .elf file. See here - https://web.archive.org/web/20211026214736/https://www.avrfreaks.net/forum/where-does-avr-size-get-data-supported-devices

I see, thank you for reply. Best regards.

atoomnetmarc commented 1 year ago

Thanks!

I used your help to write a post-build event for Microchip Studio to get Memory Usage back: $(ToolchainDir)/avr-objdump -Pmem-usage "$(OutputDirectory)/$(OutputFileName)$(OutputFileExtension)"