Warning or Error when Program is bigger than X bytes?

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi there,

We are using the Mega1281, using the first 88kbytes for program memory, the next 32kbytes for FPGA configuration and the last 8kbytes for the bootloader.

How can I configure the makefile to stop compilation or gve me an error when the program memory (.text section?) is bigger than 88kbytes?

Thanks
Jacques

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can't do it in an easy way, you would need to mess with the linker script.

You can consider a post-compilation checking tool similar to what I concocted.

Note, that there is the .data initialisers above .text, which needs to fit to your allocated space, too.

JW

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can't access Jan's link (server not responding?) so I don't know what his checker is doing but simplistically, if you run avr-size after the build:

AVR Memory Usage
----------------
Device: atmega16

Program:     178 bytes (1.1% Full)
Program:   17178 bytes (104.8% Full)

then you just need a bit of script to check if there are more than 2 characters between '(' and '.' on the line containing "Program:" then set the errorlevel.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
I can't access Jan's link (server not responding?)

Hummm... It seems good from my side, pings from all over the world are working...
clawson wrote:
so I don't know what his checker is doing

I've mentioned it already here, you surely remember that thread.

clawson wrote:
but simplistically, if you run avr-size after the build:

AVR Memory Usage
----------------
Device: atmega16

Program:     178 bytes (1.1% Full)
Program:   17178 bytes (104.8% Full)

then you just need a bit of script to check if there are more than 2 characters between '(' and '.' on the line containing "Program:" then set the errorlevel.

The issue here is, that the OP wants to check against a lower level than the total FLASH amount. It is doable also through parsing avr-size's output, sure.

JW

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Adding a section to the link will give a section overlap warning when the code runs into it:

LDFLAGS+=--section-start=.mysection=0x16000

Don't know if the section needs to really exist in the source, I've only tried it when something has actually been declared in it e.g.

__attribute__ ((section ("mysection"))) const char mydata[256]={1,2,3...}