Optimising compiled code

Asked by GrahamM at 01:39 on 25 Aug 2017.

Hello there! I wonder if there is a guru who could give me some direction or fill in some of the blanks in my knowledge

I have compiled the Arduino 'Blink' sketch and was surprised at the resource it took: 21896 code bytes and 9700 data bytes (optimised for size) or 24288 code bytes and (again) 9700 data bytes (optimised for speed). The target board is the Fubarino-SD which uses a PIC32MX795F512.

For a program that consists of a single line in setup() and four lines in loop() this seems excessive. The sketch does not use any serial or USB ports, nor does it use I2C, etc. The sketch does use a single IO port and periodically toggles it by using delay().

A check in the etx file indicates that a whole raft of code has been included, (apparently) such as support for:

I would like to have better control over what is included by default. The final application of this board does not want to be encumbered by the likes of a task manager or support for non-existent peripherals.

Any suggestions and pointers appreciated!

Thanks, Graham

Sign up or log in for live updates and to post messages.

Since the Fubarino is a USB board you get USB regardless. There's not a lot you can do about that other than other than creating a custom board that disables the USB support completely.

The TaskManager is used for many internal management things.

The PIC32 chip is very complex and there is a lot of configuration and management going on behind the scenes. You have a nice big vector table for interrupts, co-processor management, core timer event system, etc.

If you want more control over what code is included then you want to move away from the Arduino API and use raw C in MPLAB-X. But then you need to understand how the chip works.

Posted 25 Aug 2017, 09:51, 0 votes
Rating: 5

Rating: 0

Yep - the interrupt table is quite big!

The Arduino API does provide some worthwhile advantages for my application so although the complexity of the PIC32 doesn't phase me I think I will stay with the Arduino API for now.

Why I was looking at 'Blink' in such detail is that I am trying to build my overall knowledge of how the PIC32 platform ties everything together. My main application is to use the Fubarino as a multi-address slave device in our test lab. The problem there is that the I2C system (DTWI) library crashes and ultimately the loop() function fails to run correctly. I suspect that the constructor is not called correctly. I have been pulled onto another issue but hope to get back to this later in the week.

    Posted 28 Aug 2017, 01:01, 0 votes

    This site uses cookies to maintain your current login session and improve your browsing experience. By continuing to use this site you agree to the placing of these cookies on your computer or device.

    About cookies | Close this popup