Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mbed-os-example-client size with UBLOX_EVK_ODIN_W2 is massive #3598

Closed
JanneKiiskila opened this issue Jan 17, 2017 · 14 comments
Closed

mbed-os-example-client size with UBLOX_EVK_ODIN_W2 is massive #3598

JanneKiiskila opened this issue Jan 17, 2017 · 14 comments

Comments

@JanneKiiskila
Copy link
Contributor

Note: This is just a template, so feel free to use/remove the unnecessary things

Description

  • Type: Bug
  • Related issue: #abc
  • Priority: Major

Bug

Target
UBLOX_EVK_ODIN_W2

Toolchain:
GCC_ARM

Toolchain version:
0.9.10

mbed-cli version:
(mbed --version)

meed-os sha:
(git log -n1 --oneline)
5.3.3

DAPLink version:

Expected behavior

mbed-os-example-client binary size should match approximately what it is for the rest of the boards, somewhere from 250 to 500 kB.

Actual behavior

The binary is huge, it 1.1 megabytes.

Steps to reproduce

git clone mbed-os-example-client
generate security.h from portal (connect.mbed.com)
./build_all.sh
check binary sizes

@JanneKiiskila
Copy link
Contributor Author

JanneKiiskila commented Jan 17, 2017

 404456 Jan 17 14:32 f439zi-GCC_ARM-6lowpan.bin*
 278752 Jan 17 14:31 f439zi-GCC_ARM-eth-v4.bin*
 435392 Jan 17 14:33 f439zi-GCC_ARM-Thread.bin*
 395132 Jan 17 14:32 k64f-GCC_ARM-6lowpan.bin*
 271516 Jan 17 14:29 k64f-GCC_ARM-eth-v4.bin*
 274212 Jan 17 14:30 k64f-GCC_ARM-eth-v6.bin*
 426228 Jan 17 14:33 k64f-GCC_ARM-Thread.bin*
 237876 Jan 17 14:31 k64f-GCC_ARM-wifi-v4.bin*
1147488 Jan 17 14:31 ublox-odin-GCC_ARM-wifi-v4.bin*

@JanneKiiskila
Copy link
Contributor Author

What is really strange is that if you look at the mbed-os-example-client-map.csv, total flash is 464853 -> so the size should not be even remotely close to 1 megabyte? What's the linker doing in the end?

@JanneKiiskila
Copy link
Contributor Author

JanneKiiskila commented Jan 17, 2017

mbed compile -m UBLOX_EVK_ODIN_W2 -t GCC_ARM -c
Link: mbed-os-example-client
Elf2Bin: mbed-os-example-client
+-----------------------------+--------+-------+-------+
| Module                      |  .text | .data |  .bss |
+-----------------------------+--------+-------+-------+
| Fill                        |    662 |    15 |    86 |
| Misc                        | 286923 |  2653 | 18052 |
| drivers                     |   1255 |     0 |     0 |
| events                      |     64 |     0 |     0 |
| events/equeue               |   1226 |     0 |    61 |
| features/FEATURE_COMMON_PAL |  16651 |    93 |  8345 |
| features/FEATURE_LWIP       |  34802 |    87 | 46801 |
| features/mbedtls            |  90261 |    55 |  8755 |
| features/netsocket          |   5046 |    85 |    60 |
| hal                         |    672 |     0 |     8 |
| platform                    |   1390 |     4 |   313 |
| rtos                        |    757 |     4 |     4 |
| rtos/rtx                    |   7851 |    20 |  6871 |
| targets/TARGET_STM          |  14143 |     4 |   784 |
| Subtotals                   | 461703 |  3020 | 90140 |
+-----------------------------+--------+-------+-------+
Allocated Heap: unknown
Allocated Stack: unknown
Total Static RAM memory (data + bss): 93160 bytes
Total RAM memory (data + bss + heap + stack): 93160 bytes
Total Flash memory (text + data + misc): 464723 bytes

@JanneKiiskila
Copy link
Contributor Author

JanneKiiskila commented Jan 17, 2017

K64F with ESP8266 as reference:

Elf2Bin: mbed-os-example-client
+-----------------------------+--------+-------+-------+
| Module                      |  .text | .data |  .bss |
+-----------------------------+--------+-------+-------+
| Fill                        |    453 |    14 |  2297 |
| Misc                        | 117785 |  2521 |  1427 |
| drivers                     |   1659 |     0 |     0 |
| features/FEATURE_COMMON_PAL |  16651 |    89 |  8345 |
| features/mbedtls            |  73371 |    51 |  8755 |
| features/netsocket          |   4082 |    85 |     0 |
| features/storage            |     42 |     0 |   184 |
| hal                         |    580 |     0 |     8 |
| platform                    |   1424 |    20 |   297 |
| rtos                        |    757 |     4 |     4 |
| rtos/rtx                    |   7221 |    20 |  6871 |
| targets/TARGET_Freescale    |   9787 |    12 |   872 |
| Subtotals                   | 233812 |  2816 | 29060 |
+-----------------------------+--------+-------+-------+
Allocated Heap: 65540 bytes
Allocated Stack: unknown
Total Static RAM memory (data + bss): 31876 bytes
Total RAM memory (data + bss + heap + stack): 97416 bytes
Total Flash memory (text + data + misc): 237668 bytes

237876 Jan 17 15:36 mbed-os-example-client.bin*

The image size very closely matches what elf2bin reports.

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 17, 2017

cc @andreaslarssonublox

@JanneKiiskila
Copy link
Contributor Author

JanneKiiskila commented Jan 18, 2017

Issue also exists with mbed-os-example-wifi, so it's not to do with mbed-os-example-client.

For K64F


Elf2Bin: mbed-os-example-wifi
+--------------------------+-------+-------+-------+
| Module                   | .text | .data |  .bss |
+--------------------------+-------+-------+-------+
| Fill                     |   143 |     3 |  2221 |
| Misc                     | 55025 |  2480 |   512 |
| drivers                  |   835 |     0 |     0 |
| features/netsocket       |  3635 |    85 |     0 |
| features/storage         |    42 |     0 |   184 |
| hal                      |   432 |     0 |     8 |
| platform                 |  1230 |     4 |   269 |
| rtos                     |   213 |     4 |     4 |
| rtos/rtx                 |  6649 |    20 |  6870 |
| targets/TARGET_Freescale |  8552 |    12 |   228 |
| Subtotals                | 76756 |  2608 | 10296 |
+--------------------------+-------+-------+-------+
Allocated Heap: 65536 bytes
Allocated Stack: unknown
Total Static RAM memory (data + bss): 12904 bytes
Total RAM memory (data + bss + heap + stack): 78440 bytes
Total Flash memory (text + data + misc): 80404 bytes

80056 Jan 18 09:55 mbed-os-example-wifi.bin*

UBLOX;

Elf2Bin: mbed-os-example-wifi
+-----------------------+--------+-------+-------+
| Module                |  .text | .data |  .bss |
+-----------------------+--------+-------+-------+
| Fill                  |    387 |     8 |    71 |
| Misc                  | 219824 |  2580 | 17165 |
| drivers               |   1068 |     0 |     0 |
| events                |     64 |     0 |     0 |
| events/equeue         |   1226 |     0 |    61 |
| features/FEATURE_LWIP |  34782 |    87 | 46796 |
| features/mbedtls      |  20313 |     0 |  8748 |
| features/netsocket    |   4800 |    85 |    60 |
| hal                   |    490 |     0 |     8 |
| platform              |   1196 |     4 |   269 |
| rtos                  |    213 |     4 |     4 |
| rtos/rtx              |   7279 |    20 |  6870 |
| targets/TARGET_STM    |  13729 |     4 |   844 |
| Subtotals             | 305371 |  2792 | 80896 |
+-----------------------+--------+-------+-------+
Allocated Heap: unknown
Allocated Stack: unknown
Total Static RAM memory (data + bss): 83688 bytes
Total RAM memory (data + bss + heap + stack): 83688 bytes
Total Flash memory (text + data + misc): 308163 bytes

990268 Jan 18 09:56 mbed-os-example-wifi.bin*

So, should be around 308 kb but it is 990 kb. So, we actually have 2 issues:
#1 - why can the K64F version be only 80 kb, but UBLOX would be some 308 kb?
#2 - UBLOX should be 308 kb, but it ends up being >900 kb.

@JanneKiiskila
Copy link
Contributor Author

JanneKiiskila commented Jan 18, 2017

Kudos to @teetak01 for actually spotting that this is an issue. I just did some more digging on this and filed this bug.

@andreaslarssonublox
Copy link

andreaslarssonublox commented Jan 18, 2017

The u-blox ODIN-W2 Wi-Fi driver takes approximately 1M of flash since the driver contains patch files for Wi-Fi(682k) and Bluetooth in addition to the stacks.
The patch file can be found in the generated map file:
.firmware 0xa6966(682342) cb_fw_owl35x.o

This is defined as:
static const cb_uint8 attribute((section (".firmware"))) fw[] = { .... }

When building the wifi test (included in mbed test suite) with ARM and IAR toolchains the numbers look OK:
| wifi | UBLOX_EVK_ODIN_W2 | ARM | 84004 | 0 | 0 | 84004 | 1038251 |
| wifi | UBLOX_EVK_ODIN_W2 | IAR | 83645 | 24576 | 49152 | 157373 | 984678 |
while GCC_ARM is wrong:
| wifi | UBLOX_EVK_ODIN_W2 | GCC_ARM | 84020 | 0 | 0 | 84020 | 316971 |

Don't know why the elf2bin is presenting the wrong numbers.

@theotherjimmy
Copy link
Contributor

@JanneKiiskila @andreaslarssonublox It sounds like this is a bug with memap.py. @MarceloSalazar Any thoughts on what could be causing this?

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 27, 2017

@JanneKiiskila @andreaslarssonublox It sounds like this is a bug with memap.py. @MarceloSalazar Any thoughts on what could be causing this?

@MarceloSalazar Any update?

@MarceloSalazar
Copy link

I'm sorry, didn't have chance to look into this yet...

@MarceloSalazar
Copy link

The patch file is indeed defined in the '.firmware' section, however this is not part of the GNU GCC standard sections, and hence why it's discarded.
https://gcc.gnu.org/onlinedocs/gccint/Sections.html

The problem doesn't happen when using the ARM or IAR compilers, because of the nature of the memory map files (this falls in the RO area).

@andreaslarssonublox would it be possible to rename .firmware to .text?

@andreaslarssonublox
Copy link

Thanks for finding it @MarceloSalazar. We will fix it in the next release of the driver.

@MarceloSalazar
Copy link

Built Wifi example with UBLOX_EVK_ODIN_W2 and mbed OS SHA: 5d0ce3c

Total Flash memory (text + data + misc): 998507 bytes

Issue considered fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants