benblazak / ergodox-firmware

firmware for the ergoDOX keyboard
Other
596 stars 295 forks source link

Keyboard doesnt boots after tried to flashing with another firmware #95

Open Thanatermesis opened 1 year ago

Thanatermesis commented 1 year ago

I wanted to create this bug report especially to have some information on internet about this issue.

Today I was wondering how my ergodox will work with another firmware (qmk) so I tried to use it, what can happen? I will only need to reflash my older firmware on which I have a very good keymap...

Thats what I did, and it worked, I have put back this original firmware, my leds flashed as my own customization and my keys worked perfectly.... then when I rep-plugged the keyboard, nothing worked, no startup leds, no keys, nothing... wtf? I was scared

So I tried to re-program it, replug it, reprogram, no way... the only way is: by flashing the qmk firmware, and then this one again, this works correctly... until you re-plug the keyboard

Is this normal? I mean, the chip is not meant to be entirely rewrited when flashing? what could have changed that does that now ? this is a bit weird...

So now im forced to use the qmk firmware (this will require me a lot of time to convert my special keymap) or to... create a script that does a double flashing everytime my ergodox is disconnected lol

Well, any idea of why this is happening is welcome, anybody has seen this problem before? I can of course do more tests with my strange keyboard state if you want to

Notes: yes i tried to use the "reset" and the "eprom reset" keys from the qmk firmware, even if im not sure what exactly they does thinking

benblazak commented 1 year ago

bug confirmed on one of my boards. this is really weird.

Thanatermesis commented 1 year ago

it is, the only difference the keyboard is meant to have is an entirely different, rewrited contents, isnt? im not expert on it but i cannot get how this bug happens, the hardware is the same of course

benblazak commented 1 year ago

i don't understand it yet either -- and i may not have time to figure it out, but i've been looking at it a bit today.

if you unplug the TRRS jack, and then unplug -> replug the USB, it will work, though it blinks an error (i'm still trying to remember what that means lol, it's been a while). if you then plug in the TRRS cable (quickly, maybe not too quickly) both sides will work.

not really a workaround, but interesting.

benblazak commented 1 year ago

not sure if i should have spent so long working on this today lol, but i got it!

two ways to fix

first way

it's this for loop that's keeping the function from returning.

of course if you're using macros (i can't remember if i ever got them to work) this isn't the solution you want lol.

second way

#include <EEPROM.h>

void setup() {
  // initialize the LED pin as an output.
  pinMode(11, OUTPUT);

  for (int i = 0 ; i < EEPROM.length() ; i++) {
    EEPROM.write(i, 0xff);
  }

  // turn the LED on when we're done
  digitalWrite(11, HIGH);
}

void loop() {
  /** Empty loop. **/
}

for whatever reason, initializing all eeprom bytes to 0x00 doesn't seem to work. definitely a bug, but not one i'm going to try and fix right now (lots to do).

thanks for catching this.