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

Slim down sketch size #553

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cores/arduino/abi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));

extern "C" void __assert_func(void) __attribute__ ((__noreturn__));

void __assert_func(void) {
while (1)
;
}

void __cxa_pure_virtual(void) {
// We might want to write some diagnostics to uart in this case
Expand Down
1 change: 1 addition & 0 deletions libraries/CurieBLE/src/internal/BLEDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ bool BLEDeviceManager::begin(BLEDevice *device)
{
if (NULL == _local_ble)
{
ble_cfw_init();
_local_ble = device;
bt_le_set_mac_address(_local_bda);

Expand Down
9 changes: 9 additions & 0 deletions libraries/CurieBLE/src/internal/ble_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ static void *ble_client_update_param_event_param;
extern "C" {
#endif

static bool initialized = false;

inline void ble_cfw_init() {
if (!initialized) {
ble_cfw_service_init(BLE_SERVICE_ID, cfw_get_service_queue());
initialized = true;
}
}

static void on_connected(bt_conn_t *conn, uint8_t err)
{
if (ble_client_connect_event_cb)
Expand Down
1 change: 1 addition & 0 deletions libraries/CurieBLE/src/internal/ble_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ typedef void (*ble_client_update_param_event_cb_t)(struct bt_conn *conn,
extern "C" {
#endif

void ble_cfw_init();
void ble_client_init(ble_client_connect_event_cb_t connect_cb, void* connect_param,
ble_client_disconnect_event_cb_t disconnect_cb, void* disconnect_param,
ble_client_update_param_event_cb_t update_param_cb, void* update_param_param);
Expand Down
2 changes: 1 addition & 1 deletion platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -D
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"

## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" "-L{build.variant.path}" -Wl,--whole-archive "-l{build.variant_system_lib}" -Wl,--no-whole-archive -Wl,--start-group "-l{build.variant_system_lib}" -lnsim -lc -lm -lgcc {object_files} "{build.path}/{archive_file}"
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" "-L{build.variant.path}" -Wl,--no-whole-archive -Wl,--start-group -lnsim -lc -lm -lgcc -l{build.variant_system_lib} {object_files} "{build.path}/{archive_file}"

## Save output with debug symbols (.debug.elf file). Uncomment if you wish to use OpenOCD to debug.
recipe.hooks.objcopy.preobjcopy.1.pattern="{runtime.tools.arduino101load.path}/arduino101load" -c -from="{build.path}/{build.project_name}.elf" -to="{build.path}/../arduino101_sketch.debug.elf"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ extern "C" {

void cfw_platform_init(void);
T_QUEUE cfw_get_service_queue(void);
void ble_cfw_service_init(int service_id, T_QUEUE queue);

#ifdef __cplusplus
}
Expand Down
3 changes: 1 addition & 2 deletions system/libarc32_arduino101/framework/src/cfw_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@

/* FIXME: Service manager API */
extern void _cfw_init(void *);
extern void ble_cfw_service_init(int service_id, T_QUEUE queue);

extern void *services;

Expand Down Expand Up @@ -115,7 +114,7 @@ void cfw_platform_init(void)
shared_data->services, shared_data->service_mgr_port_id);
#else
_cfw_init(service_mgr_queue);
ble_cfw_service_init(BLE_SERVICE_ID, service_mgr_queue);
//ble_cfw_service_init(BLE_SERVICE_ID, service_mgr_queue);

/* Initialized shared structure. */
shared_data->ports = port_get_port_table();
Expand Down
Binary file modified variants/arduino_101/libarc32drv_arduino101.a
Binary file not shown.
3 changes: 3 additions & 0 deletions variants/arduino_101/linker_scripts/flash.ld
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ SECTIONS
{
. = ALIGN(4);
__start_heap = .;
end = __start_heap;
_end = end;
__end = end;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not clear on the purpose of these 3 new symbols? can you explain them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the first step to properly support newlib's nano.specs, which unfortunately aren't compiled in the current toolchain. The nano lib doesn't provide all the symbols and the linker would fail with something like

sbrk.c:(.text._sbrk+0x2): undefined reference to `end'

. = . + __HEAP_SIZE_MIN;
__end_heap = ALIGN(__PAGE_SIZE);
} > SRAM
Expand Down