Quantcast
Viewing all articles
Browse latest Browse all 293

Propeller C - Propeller Activity Board - Execute code from SD

Hello. I have heard that you can execute code on the PAB from an SD card, but after hours of scouring the internet from general ideas to very specific ideas, I have turned up with nothing. In one of the learning tutorials, the sd data one I believe, it mentions doing this later, but I never could find it. I also found that you could take byte code and cast it to a function pointer which I attempted to do here.
  sd_mount(DO, CLK, DI, CS);  FILE* fp = fopen("run.bin", "r");
  int size = 0;
  char c;
  while(fread(c, 1, 1, fp) != 0) {
    size++;
  }    
  fclose(fp);
  
  char code[size];
  
  fp = fopen("run.bin", "r");
  for(int i = 0; i < size; i++) {
    fread(c, 1, 1, fp);
    code[i] = c;
  }
  
  fclose(fp);
  
  ((void*)code)();
but failed to compile for obvious reasons. So now I ask for help from you, people of the forums. Please help me execute code from the sd card in the board.
Thank you.

Viewing all articles
Browse latest Browse all 293

Trending Articles