Skip to content

.pioenvs caching breaks strange behavior on 2nd run #664

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

Closed
nargetdev opened this issue May 19, 2016 · 4 comments
Closed

.pioenvs caching breaks strange behavior on 2nd run #664

nargetdev opened this issue May 19, 2016 · 4 comments
Assignees
Milestone

Comments

@nargetdev
Copy link

nargetdev commented May 19, 2016


Description of problem

The first time I run $ pio run my project builds just fine and generates appropriate things in .pioenvs folder. The second time I $ pio run new things will be generated in .pioenvs which cause many compile errors.

Specifically, on the second run, it appears to be pulling in an entirely unrelated library (one built for a different platform entirely).

This is easy enough to cope with as follows: $rm -rf .pioenvs && pio run
effectively causing every run to be the "first" run and allowing me to work as normal.

Anybody else seen this?

Configuration

Operating system: OS X

PlatformIO Version (platformio --version): PlatformIO, version 2.9.1

Steps to Reproduce

  1. Import Arduino project with board Due (using Arduino libraries folder)
  2. run $pio run
  3. run $pio run again

Actual Results

.pioenvs populates with "grbl" library on second run

Expected Results

.pioenvs stays the same after first being generated

If problems with PlatformIO Build System:

The content of platformio.ini:

[env:due]
platform=atmelsam
framework=arduino
board=due

[platformio]
src_dir=.
lib_dir=~/Documents/Arduino/Libraries

Source file to reproduce issue:

#include <Arduino.h>

 // Simple demo of three threads
// LED blink thread, print thread, and idle loop
#include <FreeRTOS_ARM.h>
// Redefine AVR Flash string macro as nop for ARM
#undef F
#define F(str) str

const uint8_t LED_PIN = 13;

volatile uint8_t count = 0;

// handle for blink task
TaskHandle_t blink;

//------------------------------------------------------------------------------
// high priority for blinking LED
static void vLEDFlashTask(void *pvParameters) {
  pinMode(LED_PIN, OUTPUT);

  // Flash led every 200 ms.
  for (;;) {
    // Turn LED on.
    digitalWrite(LED_PIN, HIGH);

    // Sleep for 50 milliseconds.
    vTaskDelay((50L * configTICK_RATE_HZ) / 1000L);

    // Turn LED off.
    digitalWrite(LED_PIN, LOW);

    // Sleep for 150 milliseconds.
    vTaskDelay((150L * configTICK_RATE_HZ) / 1000L);
  }
}
//------------------------------------------------------------------------------
static void vPrintTask(void *pvParameters) {
  while (1) {
    // Sleep for one second.
    vTaskDelay(configTICK_RATE_HZ);

    // Print count for previous second.
    Serial.print(F("Count: "));
    Serial.print(count);

    // Print unused stack for threads.
    Serial.print(F(", Unused Stack: "));
    Serial.print(uxTaskGetStackHighWaterMark(blink));
    Serial.print(' ');
    Serial.print(uxTaskGetStackHighWaterMark(0));
    Serial.print(' ');
    Serial.println(uxTaskGetStackHighWaterMark(xTaskGetIdleTaskHandle()));

    // Zero count.
    // count = 0;
  }
}
//------------------------------------------------------------------------------
void setup() {
  Serial.begin(9600);
  // wait for Leonardo
  while(!Serial) {}

  // create blink task
  xTaskCreate(vLEDFlashTask,
    "Task1",
    configMINIMAL_STACK_SIZE + 50,
    NULL,
    tskIDLE_PRIORITY + 2,
    &blink);

  // create print task
  xTaskCreate(vPrintTask,
    "Task2",
    configMINIMAL_STACK_SIZE + 100,
    NULL,
    tskIDLE_PRIORITY + 1,
    NULL);

  // start FreeRTOS
  vTaskStartScheduler();

  // should never return
  Serial.println(F("Die"));
  while(1);
}
//------------------------------------------------------------------------------
// WARNING idle loop has a very small stack (configMINIMAL_STACK_SIZE)
// loop must never block
void loop() {
  while(1) {
    // must insure increment is atomic
    // in case of context switch for print
    noInterrupts();
    count++;
    interrupts();
  }
}

Additional info

@nargetdev
Copy link
Author

nargetdev commented May 19, 2016

Hello, I have an appropriate workaround for the time being. This could be scripted easily and does not break Arduino compatibility.

Firstly:
Remove lib_dir=~/Documents/Arduino/Libraries from platformio.ini

The script:
Regex search for includes of the following pattern.. #include <FreeRTOS_ARM.h>
Find those folders in ~/Documents/Arduino/Libraries and copy them to lib ONLY INCLUDING src subdir.

Shall I script this, and add the appropriate option in the Atom IDE "import Arduino IDE project" module?

@ivankravets
Copy link
Member

@valeros please add these 3 libs to PlatformIO Library Registry https://github.com/greiman/FreeRTOS-Arduino/tree/master/libraries

@valeros valeros added this to the 2.9.2 milestone May 24, 2016
@valeros
Copy link
Member

valeros commented May 25, 2016

@ivankravets
Copy link
Member

Please reopen if you still need a help

ivankravets added a commit that referenced this issue Jun 2, 2016
* develop:
  Version bump to 2.9.2 (issues #641, #645, #648, #652, #664, #665, #666, #671, #674)
  Fix issue with ARM mbed framework when abstract class breaks compile for LPC1768 // Resolve #666
  Fix issue with ARM mbed framework and multiple definition errors   on FRDM-KL46Z board // Resolve #641
  List embedded boards in docs
  Fix multiple definition in mbed framework when using abstract class // Issue #641, #666
  Add "stlink" as the default uploader for STM32 Discovery boards // Resolve #665
  Implement grep serial ports for Windows
  Remove unused imports
  Minor improvements
  Fix PyLint's "misplaced-comparison-constant"
  Use $PROGNAME instead static name when looking for the firmware
  Update title of the article
  Add new articles
  Link Community Forums FAQ with Docs FAQ
  Grep for "/dev/cu.*" on OS X
  Skip grep search for serial ports on Windows machines
  Improve firmware uploading to Arduino Leonardo based boards
  Add MinGW to the PATH

# Conflicts:
#	docs/index.rst
#	docs/platforms/creating_board.rst
#	docs/projectconf.rst
#	docs/userguide/platforms/cmd_install.rst
#	platformio/__init__.py
#	platformio/builder/scripts/atmelavr.py
#	platformio/builder/scripts/atmelsam.py
#	platformio/builder/scripts/frameworks/mbed.py
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

3 participants