You can find the video presentation here: http://youtu.be/VhVjCnF-Y0M
Ron Ravid and Grégoire Sage cover the Overlay technique and how to load parts of code from resources.
Day 2 - Video 4
2. What's an overlay ?
In a general computing sense, overlaying means
"replacement of a block of stored instructions or
data with another."
Overlaying is a programming method that allows
programs to be larger than the computer's main
memory.
http://www.wikiwand.com/en/Overlay
Overlays technique 2
4. Our Build Proc es s
1.Generate an initial LD script
2.First build of the app
3.Calculate the size of the overlay sections
4.Generate final LD script
5.Second build of the app
6.Extract overlays sections from the elf to
external resource file
7.Trim elf file to remove overlays section
8.Very final build
Overlays technique 4
5. Generate the initial LD s c ript
Overlay configuration
Selecting files (from sources or libraries) for every
overlay section
Overlays technique 5
1 / 8
7. F irs t build of the app
Overlays technique 7
pebble build
The overlays sections are mapped at a
default hard-coded position
2 / 8
8. Calc ulate the overlay s ec tion
s ize
arm-none-eabi-readelf -S build/pebble-app.elf
Maximum overlay section size = 0x1D00
Overlays technique 8
3 / 8
9. Generate final LD s c ript
Maximum overlay Size of main app section size
= 0x1D00 + 0x2600
Overlays technique 9
4 / 8
10. Generate final LD s c ript
Overlay Table
Overlays technique 10
4 / 8
11. S ec ond build of the app
Overlays technique 11
pebble build
Every section will be mapped in its correct
position thanks to the final LD script
5 / 8
12. E xtrac t overlays from elf
Extract the compiled code in the overlay
sections to one unique resource binary
file.
Overlays technique 12
6 / 8
13. T hird and final build of the app
Overlays technique 13
pebble build
Pack the previously generated binary
resource in the app
7 / 8
14. Trim the elf file
Remove the extracted overlay compiled
code from the elf file to reduce its size
(optional)
Overlays technique 14
8 / 8
16. How to load an overlay ?
Overlays technique 16
17. How to load an overlay ?
Overlays technique 17
18. Pos s ible applic ations
If your app can be divided in
independant parts,
more parts can be added.
Example:
Heap Usage for App <Pebblets>: Total Size <3632B> Used <2928B> Still allocated <40B>
Only 700 bytes remaining...
Any application that not all of its
parts are active simultaneously
Overlays technique 18
19. Adjus ting c ode for overlay
● Change any string array from form of c ons t c har* days [] to
c ons t c har days [][12] (one-two bytes bigger than length of your
longest string.)
● If you use GPath, move your GPath data to external file with setup
function
● menu_layer_set_callbacks. Instead of defining
'MenuLayerCallbacks menu_callbacks' and giving it to that
function as parameter, put it directly inside the 3rd parameter of
menu_layer_set_callbacks like:
(MenuL ayerC allbac ks ){ .get_num_rows = get_num_rows ,
.draw_row = draw_row, .s elec t_c lic k = s elec t_c lic k });
● vibes_enqueue_custom_pattern. Move your custom pattern to
external non-overlay file.
Overlays technique 19
21. Try it
Some apps in the appstore :
- F inally (12 watchfaces in one)
- PPOSDemo (concept for a point of sale
demo) with source code, & detailed readme
- Pebble Demos (all the SDK demos +
compass in one app) with source code
* check the links to source code on GitHub
Overlays technique 21