ArduinoBT --> SET CONTROL MUX 1, cannot upload

Hello !

Trying to enable multiple bluetooth connections, I tried to enable the multplexing in the WT11 (bluetooth) chip.

Now I am screwed ! I can't upload anymore sketches to the board

--> the classical error below raises each time I try to upload something !

avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

I still can connect to the board with Bluetooth. I can also connect with the terminal, but it seems the board does not answer !

program loaded:

/*

#include <EEPROM.h>
#include <stdlib.h>
#include <string.h>
#include <avr/sleep.h>

#define LED_PIN 13
#define WAKE_PIN 2
#define RESET 7


void setup(){
  pinMode(LED_PIN,OUTPUT);
  pinMode(WAKE_PIN, INPUT);
  Serial.begin(115200);
  
  
  // Reset the bluetooth interface
  //digitalWrite(RESET, HIGH);
  //delay(10);
  //digitalWrite(RESET, LOW);
  //delay(2000);
  //configure the bluetooth module
  //Serial.println(SET BT PAGEMODE 3 2000 1);
  //Serial.println(SET BT NAME BTSWITCH);
  //Serial.println(SET BT ROLE 0 f 7d00);
  //Serial.println("SET CONTROL ECHO 0");
  //Serial.println(SET BT AUTH * 12345);
  Serial.println("SET CONTROL MUX 0");
  //Serial.println(SET CONTROL ESCAPE - 00 1);
}


static int ledState = 0;
char buffer[50];
char c;
int waitTime;
  
void loop(){
     
  // If there is something to read in the serial
  if(Serial.available() > 0){
      c = Serial.read();
      Serial.print("Received ");
      Serial.println(c);
      processData();
} 
  if(ledState){
      digitalWrite(LED_PIN,HIGH);
    }else{
      digitalWrite(LED_PIN,LOW);
    } 
}

void processData(){
  switch(c){
    case 'i':
    {
      const char cmd[] = {'S','E', 'T', ' ','C','O','N','T','R','O','L', ' ','M','U','X', ' ','0'};
      sendMuxCommand(cmd, '0xFF');
      sendMuxCommand(cmd, '0x00');
      break;
    }
    case 'n':
    {
      const char cmd[] = {'S','E', 'T', ' ','B','T',' ','N','A','M','E', ' ','T','E','S','T'};
      sendMuxCommand(cmd, '0xFF');
      sendMuxCommand(cmd, '0x00');
      break;
    }
    case 'e':
    {
      break;
    }
    case 'f':
    {
      break;
    }
    default:
    {
      break;
    }
  }
}

void sendMuxCommand(const char cmd[], unsigned char link){
  int cmdLen;
  for(cmdLen =0; cmd[cmdLen] != 0x00; cmdLen++){
    if(cmdLen > 100){
      cmdLen = 0;
      break;
    }
  
  }
  //Serial.print("sof ");
  Serial.print((unsigned char) 0xBF); //Start of Frame
  //Serial.print("link ");
  Serial.print((unsigned char) link); //Link id ( 0x00-0x08 pour les connecs (data), control = 0xFF)
  //Serial.print("frameflag ");
  Serial.print((unsigned char) 0x00); //Frame flags
  //Serial.print("length ");
  Serial.print((unsigned char) cmdLen); // Data length
  
  int i;
  for(i=0;i<cmdLen;i++){
    Serial.print((unsigned char) cmd[i]); // data
  }
  //Serial.println("");
  //Serial.print("nLink ");
  Serial.print((unsigned char) (link^0xFF)); //nLink
}

any Help would be appreciated ....

PS. I don't have any cable to upload my sketches, only Bluetooth connection ...
Should I buy a AVR ISP mkII programmer ?

So, MikeT

do you think your comment from my previous post (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1253009727) is still valid in that case ?

Hi nomis,

your sketch should not cause any problem! Its really not that easy to crash your Arduino Smiley

To upload a new sketch, you have to press and release the reset button at the right time (see http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1247005623/3#1).

When the Arduino is reset, it run the bootloader instead of your code.

MikeT

Because I am trying hard to reset it at the perfect time ... but keeps telling me the same not in sync ...

Note that I have been uploading sketches without problems for a few weeks before messing with the 2 ArduinoBT I have here (one of them was partially broken, the new electronic component is being shipped now ...). I was able to have one working out of the 2 ... now both are unresponding .. doh

Thanks !

I'm completely oblivious when it comes to the Bluetooth version of the Arduino, but I've got that error plenty of times. It sounds like you're trying to upload with the wrong board selected.

But if you need to push a reset button, just click the upload button, then push the reset button. (Keep in mind, the first time compiling when I first open the IDE, it takes longer than other times. So compile first before uploading.) Once you push the upload button, you have I believe about 3 seconds to reset the board.

BUT
I did read in a previous post (I'm sorry I can't find it:X) about a person who was trying to change the speed of the bluetooth connection through some files, and ended up with the same error. He had to use the AVR-whatever they're called programmers to correct the speed. (I'm sure there's an easier way, considering you can use one Arduino to bootload another.)

I hope some of this helps, and when you do fix it, please do explain so if anyone else has the same problem, they can refer here! :smiley:

Best of luck!

Hello !

Unfortunately I have selected the correct board (ArduinoBT).
I have tried many times to upload it at the exact right timing ... without any success .

From my understanding, I set multiplexing mode on on the WT-11 chip, so now the WT11 chips wraps all the incoming and outgoing data in frames. I guess this (frame wrapping) must avoid to send the right commands to the Arduino microprocessor, avoiding it to upload a new sketch. [As the command sent by the Arduino IDE will be wrapped in frames when arriving in the microprocessor]

The post you mentionned is here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1249753712/2#2

Therefore I believe that by using a cable (AVRISP mkII) to uplaod my new sketch. In this new sketch, during the setup phase, I will try to put the command SET CONTROL MUX 0 to disable the multiplexing ...
Not sure this will work though as the WT-11 should receive this command as hex and not as ASCII chars. Will also try to send the line BF FF 00 11 53 45 54 20 43 4f 4e 54 52 4f 4c 20 4d 55 58 20 30 00 which is SET CONTROL MUX 0 in hex. I hope one of those should work.
If it does not work, I will still have one more solution to try which is to make a parallel port to program WT-11 Bluetooth module directly. So I could "reset" the firmware ... see Arduino Playground - BTWT11Interface

Will see ... anyway I'll post my findings here !

But thanks for the help, and if anyone else has a hint/tips ...

So ....

Received my AVRISP mkII cable today ....

I was able to upload once a new sketch through the AVR program ... but the Bluetooth was still not responding ... and no command from the new sketch to the Bluegiga module were taken into account (such as SET BT NAME BLA). So I could not turn OFF The multiplexing that way ...

So I tried to burn the bootloader on the card hoping it would help ....
It did not work and now when I try to upload anything on the card through AVR studio,
I got this: error

 OK
Reading FLASH input file.. OK
Setting mode and device parameters.. OK!
[color=#ff0000]Entering programming mode.. FAILED![/color]
Leaving programming mode.. OK!

And the card does not reset when I press the reset button manually ....

Pfffff ... it is gonna kill me !

Hi nomis,

you have to use a sketch which sends the MUX DISABLE command. I made one as an example, but I haven't tried it:

/* Arduino BT: disable the MUX mode of the WT11 chip 2009-09-21 MikeT
*/

int LED = 13; // select the pin for the LED
int RESET = 7; // BT module uses pin 7 for reset

// "SET CONTROL MUX 0" in MUX mode framing format
byte disableMuxMode[] = {0xBF, 0xFF, 0x00, 0x11, 0x53, 0x45, 0x54, 0x20, 0x43, 0x4f, 0x4e, 0x54, 0x52, 0x4f, 0x4c, 0x20, 0x4d, 0x55, 0x58, 0x20, 0x30, 0x00};

void resetBTModule(void)
{
digitalWrite(RESET, HIGH);
delay(10);
digitalWrite(RESET, LOW);
delay(2000);
}

void setup()
{
pinMode(LED, OUTPUT); // declare the LED and BT RESET pins as output
pinMode(RESET, OUTPUT);
Serial.begin(115200);

// reset the Bluetooth module to activate the command mode
resetBTModule();
Serial.flush();

// send the command
for(int i = 0; i < sizeof(disableMuxMode); i++)
{
Serial.print(disableMuxMode*);*

  • }*
    }
    void loop()
    {
    }
    [/quote]
    Please have a look at the SET CONTROL BIND command to avoid such lockout situations. You can set a command which is activated when a rising/falling edge is detected on a WT-11 GPIO pin.
    You can for example use the following command to set up such a command:
    > SET CONTROL BIND 0 20 RISE SET CONTROL MUX 0
    This is activated by GPIO5 which is pin 9 on SV2, see also the original Arduino-BT schematic.
    Up to eight commands can be used (0 to 7).

  • MikeT*

Hello MikeT !

Thanks a lot for your answer ! That will probably help me for the next time that happens ! [I really messed up with this card ... don't think I can revive it ... fuse problems when trying to upload the bootloader ..]

I'll disable the mux mode each time in the setup and will enable it through a command in the loop ... this way I won't mess up again ! As well as adding a BIND command, just in case.

Anyway, I am still trying to use multiplexing mode of the WT11 module with Arduino ... did you by chance already used it and would have a "simple" example sketch. [maybe we can continue this discussion in this thread --> http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1252420773 ]
It's sad there are not much documentation on this part of the ArduinoBT, because even if it is a bit complicated it is a very interesting and useful part.

Thnaks again !

Simon