{"action":"opened","issue":{"url":"https://api.github.com/repos/platformio/platformio/issues/651","repository_url":"https://api.github.com/repos/platformio/platformio","labels_url":"https://api.github.com/repos/platformio/platformio/issues/651/labels{/name}","comments_url":"https://api.github.com/repos/platformio/platformio/issues/651/comments","events_url":"https://api.github.com/repos/platformio/platformio/issues/651/events","html_url":"https://github.com/platformio/platformio/issues/651","id":153619730,"number":651,"title":"Large Arduino Micro project built with PIO crashes, works when built with Arduino IDE","user":{"login":"digitalstreamio","id":19243925,"avatar_url":"https://avatars.githubusercontent.com/u/19243925?v=3","gravatar_id":"","url":"https://api.github.com/users/digitalstreamio","html_url":"https://github.com/digitalstreamio","followers_url":"https://api.github.com/users/digitalstreamio/followers","following_url":"https://api.github.com/users/digitalstreamio/following{/other_user}","gists_url":"https://api.github.com/users/digitalstreamio/gists{/gist_id}","starred_url":"https://api.github.com/users/digitalstreamio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/digitalstreamio/subscriptions","organizations_url":"https://api.github.com/users/digitalstreamio/orgs","repos_url":"https://api.github.com/users/digitalstreamio/repos","events_url":"https://api.github.com/users/digitalstreamio/events{/privacy}","received_events_url":"https://api.github.com/users/digitalstreamio/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-07T21:52:49Z","updated_at":"2016-05-07T21:52:49Z","closed_at":null,"body":"# Configuration:\r\n\r\nBoard: RedBearLabs Blend Micro board (Arduino Micro + NRF8001) \r\nPlatformIO Version: 2.9.1\r\nOperating System: Fedora 23\r\nFramework: Arduino\r\nLibraries: BLEPeripheral\r\n\r\n# Issue: \r\n\r\nWhen the program is built with pio and uploaded to the board, it crashes when accessing Serial. Same source code built with Arduino IDE works fine.\r\n\r\n# Workaround\r\n\r\nThe only way to work around the linker issue below was to embed BLEPeripheral library directly in the project/src (not project/lib) directory instead of referencing it in platformio.ini. This way the build process skips part of the static library linking step which seems to produce firmware that crashes on arduino micro.\r\n\r\n# Details:\r\n\r\nThe issue seems to be related to the way firmware is linked. \r\n\r\n* pio compiled object files linked using pio generated command (outcome: firmware crashes)\r\n\r\n/home/user/.platformio/packages/toolchain-atmelavr/bin/avr-g++ -o .pioenvs/blendmicro8/firmware.elf -Os -mmcu=atmega32u4 -Wl,--gc-sections,--relax .pioenvs/blendmicro8/src/main.o -L/home/sebby/.platformio/packages/ldscripts -L.pioenvs/blendmicro8 -Wl,--start-group .pioenvs/blendmicro8/libFrameworkArduinoVariant.a .pioenvs/blendmicro8/libFrameworkArduino.a -lm .pioenvs/blendmicro8/libSPI.a .pioenvs/blendmicro8/libBLEPeripheral_ID259.a -Wl,--end-group\r\n\r\n* pio compiled object files linked using Arduino IDE method (outcome: firmware no longer crashes)\r\n\r\n/home/user/.platformio/packages/toolchain-atmelavr/bin/avr-g++ -w -Os -Wl,--gc-sections -mmcu=atmega32u4  -o .pioenvs/blendmicro8/firmware.elf \".pioenvs/blendmicro8/SPI/SPI.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEAttribute.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEBondStore.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLECentral.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLECharacteristic.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEConstantCharacteristic.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEDescriptor.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEDevice.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEFixedLengthCharacteristic.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEHID.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEHIDPeripheral.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEHIDReportMapCharacteristic.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEHIDReportReferenceDescriptor.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEKeyboard.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLELocalAttribute.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEMouse.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEMultimedia.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEPeripheral.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEProgmemConstantCharacteristic.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLERemoteAttribute.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLERemoteCharacteristic.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLERemoteService.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEService.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLESystemControl.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLETypedCharacteristics.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEUtil.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/BLEUuid.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/EddystoneBeacon.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/iBeacon.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/nRF51822.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/nRF8001.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/utility/aci_queue.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/utility/acilib.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/utility/hal_aci_tl.o\" \".pioenvs/blendmicro8/BLEPeripheral_ID259/utility/lib_aci.o\" \".pioenvs/blendmicro8/src/main.o\" \".pioenvs/blendmicro8/libFrameworkArduino.a\" \"-L.pioenvs/blendmicro8\" -lm\r\n\r\n# Source Code:\r\n\r\n* platformio.ini\r\n\r\n[env:blendmicro8]\r\nplatform = atmelavr\r\nframework = arduino\r\nboard = blendmicro8\r\nlib_install = 259\r\nbuild_flags = -DARDUINO_BLEND_MICRO_8MHZ\r\n\r\n* main.cpp\r\n\r\n\r\n[main.cpp.txt](https://github.com/platformio/platformio/files/253631/main.cpp.txt)\r\n\r\n\r\n\r\n"}}