Get more Flash-/RAMusage out of a ATMega32u4?

Go To Last Post
66 posts / 0 new

Pages

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

If this project is never going to be public you can create a custom board for yourself alone.

 

If you are going to make the project public,   I would just stick with a standard board e.g. Leonardo / ProMicro.

Yes,   there is Flash "lost" in the bootloader and Flash used in the USB.

 

Have a serious look at where the Memory is being used.    If you only use digits in a particular font,   you don't need a full set of characters.    Likewise only uppercase.

 

I would not worry too much about f-p unless you can eliminate it altogether.

 

You can save SRAM by storing const strings in PROGMEM.    And using appropriate width of variables and size of arrays.

If you are using Fonts,  I suspect you are using GLCD or TFT.   

 

I bet that you can fit your app in a regular Leonardo with a little thought.

 

David.

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

david.prentice wrote:

 

Yes,   there is Flash "lost" in the bootloader and Flash used in the USB.

 

Have a serious look at where the Memory is being used.    If you only use digits in a particular font,   you don't need a full set of characters.    Likewise only uppercase.

 

You can save SRAM by storing const strings in PROGMEM.    And using appropriate width of variables and size of arrays.

If you are using Fonts,  I suspect you are using GLCD or TFT.   

 

I bet that you can fit your app in a regular Leonardo with a little thought.

 

David.

 

I already said that i dont use a bootloader.

 

Only Uppercase is a good idea. I will get a bit out of it!

 

Also i have already all stringd in PROGMEM, and the width of the variables are already quite small!

 

GLCD or TFT ? What is this? And you still havent tol me what CDC is ;-)

Yes i use Google, but there is no search enginge within Google to search through those many useless results...

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

I had a look at the BMP function for getting the height... Of course it uses pow...

Yes i use Google, but there is no search enginge within Google to search through those many useless results...

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

We have Google.
GLCD is Graphic Liquid Crystal e.g. KS0108 128X64 display
TFT is Thin Film Transisistor e.g. ILI9341 240X320 dsplay (or the screen on your TV)
CDC is Communication Device Class e.g. how your PC implements a Serial Terminal via USB cable.
.
Googling BMP HEIGHT just returns stuff about .BMP format for storing colour graphics images on a PC. This is commonly used for images on a small colour TFT display. It is very wasteful of storage but simple to display pictures from an SD card.
.
Clearly your BMP means something completely different. Google only works if you can search for a suitable phrase.
.
I would always advise using straightforward code that is easy to maintain.
I am surprised that you are having memory problems with an f-p algorithm for a thermistor on a 32kB chip.
It is worth examining where your Flash and SRAM could be reduced.
.
David.

Last Edited: Sat. Jan 19, 2019 - 07:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Tobey wrote:

Is there an easy way to tell what the difference in funtion use is?

 

I don't know my way around all the various GCC options but with the compiler I use (CVAVR) I get a .map file which gives me the location and size of every item...

 

</p>
<p>RAM Allocation [bytes]<br />
Variable                                                                          Address   Size<br />
------------------------------------------------------------------------------------------------<br />
system_status                                                                     0x0300       4<br />
rx_buffer0                                                                        0x0304      32<br />
rx_wr_index0                                                                      0x0324       1<br />
rx_rd_index0                                                                      0x0325       1<br />
rx_counter0                                                                       0x0326       1</p>
<p>EEPROM Allocation [bytes]<br />
Variable                                                                          Address   Size<br />
------------------------------------------------------------------------------------------------<br />
dummy_location                                                                    0x0000       2<br />
head_position                                                                     0x0002      98</p>
<p>Register Allocation<br />
Variable                                                                          Register  Size<br />
------------------------------------------------------------------------------------------------<br />
shift_register                                                                    R2,R3        2<br />
gNumeric                                                                          GPIOR0.0  1bit</p>
<p>FLASH Allocation [words]<br />
Function                                                                          Address   Size<br />
------------------------------------------------------------------------------------------------<br />
pin_change_interrupt_isr1                                                         0x00724     17<br />
timer_1ms_isr                                                                     0x00735    103<br />
usart_rx_isr                                                                      0x0079C     49<br />
usart_tx_isr                                                                      0x007CD     37<br />
getchar                                                                           0x007F2     30<br />
putchar                                                                           0x00810     44<br />
main                                                                              0x0084E   1256<br />
...<br />
_print_G100                                                                       0x02464    462<br />
printf                                                                            0x02632     37<br />
abs                                                                               0x02657     10<br />
strlen                                                                            0x02661     12<br />
strlenf                                                                           0x0266D     13</p>
<p>

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

Last Edited: Sat. Jan 19, 2019 - 09:26 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Google is crap. It was once good. If you search for short words or for like 32u4 you get a lot of useless results. Sadly the forum search is working almost the same.

 

With BMP i meant the BMP280 sensor. So getting rid of all floats is pointless.

 

Im gonna try the 1284 with my designed PCB. Not that i squeezed it onto the 328, and then need another little function that wont fit.

 

128KB Flash leaves space for quite some nice features.

Yes i use Google, but there is no search enginge within Google to search through those many useless results...

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

Tobey wrote:
Google is crap.

Other Search Engines are available.

Tobey wrote:
With BMP i meant the BMP280 sensor. So getting rid of all floats is pointless.

I agree.   Life is easier with f-p.

Tobey wrote:
128KB Flash leaves space for quite some nice features.

That is quite a BIG difference to your original post.

I would always suggest developing on the biggest most convenient platform.   Then final build on the smallest/cheapest target.

 

You have not explained where your memory is being used.

Do you have Fonts, Images,  Graphic Display ?

Are you using a Serial Terminal ?

 

David.

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

Tobey wrote:
With BMP i meant the BMP280 sensor. So getting rid of all floats is pointless.

I just browsed the datasheet for that Barometer chip. Not only does it omit the altitude calculation it also leaves the host micro to read off the compensation parameters and apply all the (fairly horrific) compensation calculations. It looks like Bosch intended the host micro to be a Cortex M3 as a minimum.

 

By switching up the micro you've almost certainly made the right decision.

 

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

The avr-nm utility will show you how much flash is used by each function in an ELF. If looking for the "big ones" I like the --size-sort option so the big ones that are eating all the space float to the top.

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

david.prentice wrote:

You have not explained where your memory is being used.

Do you have Fonts, Images,  Graphic Display ?

Are you using a Serial Terminal ?

 

David.

I have:

- a Nokia display

- a sdcard reader

- a pressureSensor

- a RTC

 

No im not using the Serial. I already optimized the strings to the least, so there is no serial left. I use the display instead.

Yes i use Google, but there is no search enginge within Google to search through those many useless results...

Last Edited: Sun. Jan 20, 2019 - 12:26 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

The avr-nm utility will show you how much flash is used by each function in an ELF. If looking for the "big ones" I like the --size-sort option so the big ones that are eating all the space float to the top.

The output does not tell me much. The top ones arent the biggest ?

Attachment(s): 

Yes i use Google, but there is no search enginge within Google to search through those many useless results...

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

Well, for one thing it is just " T " entries but also if says loop is biggest. Is that not the case then?

 

Also I hadn't realised this was C++ (if it's Arduino I guess I should have realised) so you probably want to add the option for name demangling.

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

I take it the first column is size.

It makes sense - setup, loop, various fonts, realloc, malloc, free, take the lion's share.

 

getPressure is as huge as I expected after reading the datasheet, but, giant interrupt vectors aside, much of the thread was about these three fellows:

 

000000a0 T log
000000a0 T pow
0000004e T __fp_powser

Which together add up to bugger all. If only we had known that back in #34

 

Actually this is one shit-hot fp library. Over in the world of MSP430, using log() adds about 1.5K to your program.

 

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

It's  not quite as cut and dried as that. You don't get the entire log() for 0xa0 bytes. It is sharing some of the FP core functions. The real test would be to write a test programme with/without log() and compare sizes.

 

(Of course you only pay the "shared cost" once then adding things like pow() on top really is little more than the 0xA0 increment)

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

A few days ago my PCBs and the atmega 1284p arrived. It works quite good. Just a little pain that not OC1A is on pin 8 instead of pin 9. So it isnt completely combatible to a ProMini.

It feels so satisfying to see this:

 

Device: atmega1284p

Program:   32550 bytes (24.8% Full)
(.text + .data + .bootloader)

Data:       2231 bytes (13.6% Full)
(.data + .bss + .noinit)

 

Yes i use Google, but there is no search enginge within Google to search through those many useless results...

Pages