UART Mode Input Problem

Hacking multi-tool. Get one for $30, including worldwide shipping.

UART Mode Input Problem

Postby derpeter » Tue Jun 21, 2011 1:59 pm

Hi

We are trying to use the buspirat with a Kindle3. We can see the output of the Kindle and the characters are returned by the kindle but 'enter' and 'space' are not working.

We assume that the correct echo and the fact that we can read the output proving that the serial settings are correct. We tested two bus pirates and tried it on a linux pc and a mac with two kindles.

We used macro (1) and it works fine i.E. with an fonera router.

The only difference between the kindle and the fonera are the different voltages. The kindle uses 1,8V which is supplied by the kindle it self. We also tried a 1,8V power supply.

The settings are of buspirate and minicom are 115200 8N1 with not flow controle

Bus pirate is a 3a with Firmware v5.10 (r559) and Bootloader v4.1

mfg derpeter
derpeter
Newbie
Newbie
 
Posts: 8
Joined: Tue Jun 21, 2011 1:42 pm

Re: UART Mode Input Problem

Postby adamoutler » Wed Jun 22, 2011 10:27 am

The only thing you see on the output is what is sent over the TX line on the kindle and received by the RX line on the bus pirate. If the return key is not sent by kindle, then the return key will not be seen by bus pirate.

I made a program for the Arduino mega for communications with my phone.... If you have an Arduino, this may do the trick.... It will show you every charactor being sent in hex. then the line as it was intended to be read. you can switch modes with the "`" key.

Code: Select all
/*
Arduino Serial Connector
  Copyright 2011 Adam Outler

  Licensed under the I Dont Give a Fuck License, Version 1.0 (the "License");
  you may not use this file except in compliance with the License.
 
  3. Send me an email if you find this helpful
  If you're wondering where number 1 and 2 is, I don't give a fuck.
 
  -Adam Outler  adamoutler, gmail.com
 
/*
HEXOUTPUT displays a line of hex output then
a line of normal text- activated by "`"
BAUD will be the computer's baud rate and the
inital baud rate set for all devices
*/
boolean HEXOUTPUT=true;
unsigned long BAUD=115200;


//begin sketch
String MESSAGE[4]; //Hexoutput messages dumped into this string array
unsigned long SerialPrintTimer[4]={0,0,0,0}; //Serial timers off
int inByte;//byte received from serials 1,2,3

void setup() {
  Serial.begin(BAUD); //Initialize Computer baud
  setSerialBaudRate(BAUD); //Initialize Serials 1,2,3 baud
  Serial.print("Communications established");
}

/*
Loop will check if Serial(computer) has anything to
say to the Serial1(device), and then says it.  It
will also print all values from Serial1, Serial2,
and Serial3 to Serial(computer)
If HEXOUTPUT formatting is requested by pressing the
"`" key, it will display output in hex format, then
output a line of human readable text
*/
void loop() {
  if ( HEXOUTPUT ) { // if hex output is requested then use this
    hexOutputHandling();
  } else { //Serial1,Serial2, Serial3>Computer in byte format
    standardOutputHandling();
  }
  serialInputHandler();//send to Serial1 and handle special keys
  checkForUntruncatedSerial(); //timer to print serial lines in std output
}



/*
serialInputHandler reads keys comming from computer
makes decisions based on key numbers
sends output to Serial1
*/
void serialInputHandler() {
  if (Serial.available()) { //User has commanded input
    int IncommingSerial=Serial.read(); //read input to var
    //turn on/off HEXOUTPUT with the "`" key
    if (IncommingSerial == 96 ) displayMenu();
    Serial1.print(IncommingSerial, BYTE); //Send var to Serial1
  } 
}

void displayMenu(){
  Serial.println("");
  Serial.println("Main Menu");
  Serial.println("--------------------");
  Serial.println("--HEX OUTPUT--");
  Serial.println("`-toggle hex output"); //96
  Serial.println("--BAUD RATE--");
  Serial.println("a-115200");//97
  Serial.println("b-57600");//98
  Serial.println("c-38400");//99
  Serial.println("d-28800");//100
  Serial.println("e-19200");//101
  Serial.println("f-14400");//102
  Serial.println("g-9600");//103
  Serial.println("h-4800");//104
  Serial.println("i-2400");//105
  Serial.println("j-1200");//106
  Serial.println("k-300");//107
  Serial.print("Select one, press enter");
  int inkey;
  Serial.flush();
  while (inkey != 13 ){
    inkey=-1;
    if (Serial.available()) inkey=Serial.read();
    switch (inkey) {
      case 96: //`
        HEXOUTPUT=(!HEXOUTPUT);
        displayBlatentChangeMessage("HEX Output toggled");
        break;
      case 97: //a
        setSerialBaudRate(115200);
        displayBlatentChangeMessage("Baud 115200");
        break;
      case 98: //b
        setSerialBaudRate(57600);
        displayBlatentChangeMessage("Baud 57600");
        break;
      case 99: //c
        setSerialBaudRate(38400);
        displayBlatentChangeMessage("Baud 38400");
        break;
      case 100: //d
        setSerialBaudRate(28800);
        displayBlatentChangeMessage("Baud 28800");
        break;
      case 101: //e
        setSerialBaudRate(19200);
        displayBlatentChangeMessage("Baud 19200");
        break;
      case 102: //f
        setSerialBaudRate(14400);
        displayBlatentChangeMessage("Baud 14400");
        break;
      case 103: //g
        setSerialBaudRate(9600);
        displayBlatentChangeMessage("Baud 9600");
        break;
      case 104: //h
        setSerialBaudRate(4800);
        displayBlatentChangeMessage("Baud 4800");
        break;
      case 105: //i
        setSerialBaudRate(2400);
        displayBlatentChangeMessage("Baud 2400");
        break;
      case 106: //j
        setSerialBaudRate(1200);
        displayBlatentChangeMessage("Baud 1200");
        break;
      case 107: //k
        setSerialBaudRate(300);
        displayBlatentChangeMessage("Baud 300");
        break;
      case 13: //l
        return;
        break;
    }
  }
}


void displayBlatentChangeMessage(String Message){
  for (int i = 0; i < 40; i++){
    Serial.println(Message); 
  }
}

/*
checkForUntruncatedSerial reads timers put on
each serial line and if it has been greater then
the time allowed for a 0x13, then it will print the line
*/
void checkForUntruncatedSerial() {
  double time=millis();
  for ( int i = 1; i <= 3; i++){
     if ( SerialPrintTimer[i] != 0 && SerialPrintTimer[i] < time ){
       displayNormal(i);
     }
 
  }
}
 
void setSerialBaudRate(unsigned long baud){
  if ( baud == 0.00 ) baud=BAUD;
  Serial1.begin(baud);
  Serial2.begin(baud);
  Serial3.begin(baud);
}


/*
standardOutputHandling reads from Serial1
Serial2, and serial3 then outputs to computer
*/
void standardOutputHandling(){
  if (Serial1.available()) Serial.print(Serial1.read(), BYTE);
  if (Serial2.available()) Serial.print(Serial2.read(), BYTE);
  if (Serial3.available()) Serial.print(Serial3.read(), BYTE);
}


/*
hexOutputHandling reads from Serial1, Serial2,
and Serial3 then sends to displayHex function
for processing. The output is stored in an
array and displayed on 0x13, or after timer
has elapsed
*/
void hexOutputHandling(){
  if (Serial1.available()) {
    inByte = Serial1.read();
    displayHex(1); //Serial1>displayHexfunction>Computer
  }
  if (Serial2.available()) {
    inByte = Serial2.read();
    displayHex(2);//Serial2>displayHexfunction>Computer
  }
  if (Serial3.available()) {
    inByte = Serial3.read();
    displayHex(3);//Serial3>displayHexfunction>Computer
  }
}


/*
displayNormal is called at the end of a line of hexoutput
or when serialPrintTimer has elapsed. It displays the
byte format output and the serial line which originated
the transaction
*/
void displayNormal( int SerialID ){
  Serial.println("");
  Serial.print(" SERIAL");
  Serial.print(SerialID);
  Serial.println(": " + MESSAGE[SerialID]);//Serial1:Message
  MESSAGE[SerialID]="";//clear message
   SerialPrintTimer[SerialID]=0;//reset print timer
  }


/*
displayHex formats the hexoutput and the final message
which is displayed when char 13 is received or the timer
has elapsed
*/
void displayHex(int SerialID){

      SerialPrintTimer[SerialID]=millis()+ 1000;//set timer for display
      if ( inByte >= 19 ) MESSAGE[SerialID] = MESSAGE[SerialID] + " " + (char)inByte; //dump char into string
      Serial.print("|");
      Serial.print(inByte, HEX); //print character
      if ( inByte == 13 ){ displayNormal( SerialID ); }//line ending dump string onto screen
}


example:

Code: Select all
+k�́Co., Ltd. 2006-2010
-----------------------------------------------------------

+n1stVPN       2688
+nPgsPerBlk    64
+n1stVPN       3008
+nPgsPerBlk    64
PBL found bootable SBL: Partition(4).

Main Menu
--------------------
--HEX OUTPUT--
`-toggle hex output
--BAUD RATE--
a-115200
b-57600
c-38400
d-28800
e-19200
f-14400
g-9600
h-4800
i-2400
j-1200
k-300
Select one, press enterHEX Output toggled
HEX Output toggled
HEX Output toggled
........

|D6|D1|C9|BD|B9|A5|8D|CD|81|43|6F|2E|2C|20|4C|74|64|2E|20|32|30|30|36|2D|32|30|31|30|A|D
SERIAL1:  � � � ֽ � � � � ́ C o . ,   L t d .   2 0 0 6 - 2 0 1 0
|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|A|D
SERIAL1:  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|A|D
SERIAL1:
|2B|6E|31|73|74|56|50|4E|20|20|20|20|20|20|20|32|36|38|38|20|A|D
SERIAL1:  + n 1 s t V P N               2 6 8 8 
|2B|6E|50|67|73|50|65|72|42|6C|6B|20|20|20|20|36|34|20|A|D
SERIAL1:  + n P g s P e r B l k         6 4 
|2B|6E|31|73|74|56|50|4E|20|20|20|20|20|20|20|33|30|30|38|20|A|D
SERIAL1:  + n 1 s t V P N               3 0 0 8 
|2B|6E|50|67|73|50|65|72|42|6C|6B|20|20|20|20|36|34|20|A|D
SERIAL1:  + n P g s P e r B l k         6 4 
|50|42|4C|20|66|6F|75|6E|64|20|62|6F|6F|74|61|62|6C|65|20|53|42|4C|3A|20|50|61|72|74|69|74|69|6F|6E|28|34|29|2E|A|D
SERIAL1:  P B L   f o u n d   b o o t a b l e   S B L :   P a r t i t i o n ( 4 ) .
|AB|8D|D1|C9|BD|B9|A5|8D|CD|81|43|6F|2E|2C|20|4C|74|64|2E|20|32|30|30|36|2D|32|30|31|30|A|D
SERIAL1:  � � � � ѽ � � � � ́ C o . ,   L t d .   2 0 0 6 - 2 0 1 0
|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|2D|A|D
SERIAL1:  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|A|D
adamoutler
Jr. Member
Jr. Member
 
Posts: 56
Joined: Sat Jun 11, 2011 1:46 pm

Re: UART Mode Input Problem

Postby derpeter » Wed Jun 22, 2011 11:21 am

adamoutler wrote:The only thing you see on the output is what is sent over the TX line on the kindle and received by the RX line on the bus pirate. If the return key is not sent by kindle, then the return key will not be seen by bus pirate.


I'm not sure if i get you right. But at least space results in number of blanks. When you say "received by the RX line" didn't that mean that the kindle has received the input?

At least i found some posts on the interweb that people used the bus pirat with the kindle so in generell it should work.

Thanks for the arduino code i'm sure i can borrow one from a frind.
derpeter
Newbie
Newbie
 
Posts: 8
Joined: Tue Jun 21, 2011 1:42 pm

Re: UART Mode Input Problem

Postby ian » Mon Jun 27, 2011 2:58 am

Hi derpeter,

When you say enter and space are not working, from where to where? You press enter in the PC terminal and it does not register on the Kindle? Or you send enter from kindle and it does display in the PC terminal?

If it is PC->Kindle problem, check out the terminal emulation and line feed settings in your terminal program. Maybe it wants a specific type.

What terminal apps have you tried? I use teraterm on windows, but I don't like it very much :)

How is your Bus Pirate output configured? Normal outputs would be 3.3volts and could damage the kindle at 1.8volts.

Checking the datasheet for the PIC on the Bus Pirate, it has a 0.6Vmax low and a 2.5volt min high. It will probably work out of that range, but it could also be an issue with strange characters too.
User avatar
ian
Crew
Crew
 
Posts: 10531
Joined: Mon Jul 06, 2009 6:14 am

Re: UART Mode Input Problem

Postby derpeter » Thu Jun 30, 2011 4:04 pm

ian wrote:Hi derpeter,

When you say enter and space are not working, from where to where? You press enter in the PC terminal and it does not register on the Kindle?



Correkt

ian wrote:Or you send enter from kindle and it does display in the PC terminal?

No the input from the kindle keyboard is not passed to the terminal
ian wrote:What terminal apps have you tried? I use teraterm on windows, but I don't like it very much :)

I tried minicom and screen running in a bash terminal
ian wrote:How is your Bus Pirate output configured? Normal outputs would be 3.3volts and could damage the kindle at 1.8volts.

UART mode
115200
8, NONE
1
Idel 1
Open Drain

As far as i understand you can supply a voltage in opendrain mode that is used for the signal pegel when you pull up the pull up resistor.

ian wrote:Checking the datasheet for the PIC on the Bus Pirate, it has a 0.6Vmax low and a 2.5volt min high. It will probably work out of that range, but it could also be an issue with strange characters too.


1,8V should be in the range. And there are reports from people who used the buspirate with the kindle so i think it should work.
derpeter
Newbie
Newbie
 
Posts: 8
Joined: Tue Jun 21, 2011 1:42 pm

Re: UART Mode Input Problem

Postby ian » Fri Jul 01, 2011 2:46 am

UART mode
115200
8, NONE
1
Idel 1
Open Drain

As far as i understand you can supply a voltage in opendrain mode that is used for the signal pegel when you pull up the pull up resistor.



Thanks for the update. How do you have the pullup resistors connected and enabled? Could you please post the full terminal output from the Bus Pirate showing the config steps and your test.

Here's the docs on the on-board pullups:
http://dangerousprototypes.com/docs/Pra ... _resistors
User avatar
ian
Crew
Crew
 
Posts: 10531
Joined: Mon Jul 06, 2009 6:14 am

Re: UART Mode Input Problem

Postby derpeter » Fri Jul 01, 2011 12:37 pm

HI Ian thanks for you support

The 1,8v pin from from the kindle is connected to Vpu on the Bus Pirate here is the console output

Code: Select all
HiZ> m3
Set serial port speed: (bps)
1. 300
2. 1200
3. 2400
4. 4800
5. 9600
6. 19200
7. 38400
8. 57600
9. 115200
10. BRG raw value

(1)> 9
Data bits and parity:
1. 8, NONE *default
2. 8, EVEN
3. 8, ODD
4. 9, NONE
(1)>
Stop bits:
1. 1 *default
2. 2
(1)>
Receive polarity:
1. Idle 1 *default
2. Idle 0
(1)>
Select output type:
1. Open drain (H=Hi-Z, L=GND)
2. Normal (H=3.3V, L=GND)

(1)>
Ready
UART> P
Pull-up resistors ON
UART> (1)
UART bridge
Reset to exit
Are you sure? y
[ linux boot up jibberjabber]


characters entered into the minicom terminal are echoed (if i disconnect the kindle no characters are echoed).

hitting "enter" results in courser back to the start of the line but no newline.
backspace act like left arrow key in the terminal.

thanks again for your time

derpeter
derpeter
Newbie
Newbie
 
Posts: 8
Joined: Tue Jun 21, 2011 1:42 pm

Re: UART Mode Input Problem

Postby ian » Fri Jul 01, 2011 12:40 pm

can you please do a 'v' command just in case, to make sure the pullups are in good order. Vpu should read 1.8.

If it is not the voltage levels failing, my next thought is terminal emulation. Maybe the new line is not set correctly in your terminal (/r/n or something), or the terminal emulation (VT-102 is a good starting point) is off.
User avatar
ian
Crew
Crew
 
Posts: 10531
Joined: Mon Jul 06, 2009 6:14 am

Re: UART Mode Input Problem

Postby derpeter » Fri Jul 01, 2011 1:02 pm

Code: Select all
1.(BR)  2.(RD)  3.(OR)  4.(YW)  5.(GN)  6.(BL)  7.(PU)  8.(GR)  9.(WT)  0.(Blk)
GND     3.3V    5.0V    ADC     VPU     AUX     -       TxD     -       RxD
P       P       P       I       I       I       I       I       I       I
GND     0.00V   0.00V   0.00V   1.75V   L       H       H       H       H


A not correct set newline was one of thought too so tried the buspirate with the serial interface of a fonera router where it works like it suppose to work. Do you think this is a good test ?

I will try to build a better connector to the kindle this weekend because the one I build has a not that good connection. (I used a much better one from a friend by the first tests).

as I wrote we used a mac and a linux pc which means totally different terminals I cant image that both are working in exactly the same wrong way but i will give that a tray.

Just to be cross this out, if i can read the output does that mean the voltage level is correct? or is the level only concerning the tx part?
derpeter
Newbie
Newbie
 
Posts: 8
Joined: Tue Jun 21, 2011 1:42 pm

Re: UART Mode Input Problem

Postby ian » Fri Jul 01, 2011 1:21 pm

The levels look right, but the only one that really matters ifs the TX from BP to kindle.

Most terminals send 0x0a and 0x0d to do a new line. If the Kindle sends only one, there is the chance the it only goes back to the new line instead of starting a new one. I'm not totally sure. I've never seen the kindle tutorials, if you link them I'll read through and see what I can pick up.
User avatar
ian
Crew
Crew
 
Posts: 10531
Joined: Mon Jul 06, 2009 6:14 am

Re: UART Mode Input Problem

Postby derpeter » Fri Jul 01, 2011 5:14 pm

Ididn't find a real tutorial but here are some hardware infos
http://www.electricstuff.co.uk/kindlehack.html
here are some additional informations and a report from "yifanlu" who uses the bus pirate
http://www.mobileread.mobi/forums/showthread.php?t=99177&page=2
i tried to reach him via email but know answer up to know.
derpeter
Newbie
Newbie
 
Posts: 8
Joined: Tue Jun 21, 2011 1:42 pm

Re: UART Mode Input Problem

Postby ian » Sat Jul 02, 2011 3:29 am

The guy who hacked it used a level translator, and mentioned that the 1.8V supply couldn't power the logic chip @2mA. I bet the pullups use that much when it both RX and TX are 0.

First of all the 1.8V were not able to supply my level shifter (74AVC4T245 which requires about 2mA@1.8V).
This I solved by using the 3.3V Volt from my usb to serial adapter to generate the 1.8V (using Zener diode and a resistor).


If it's not the terminal emulation or line feed, then the voltage levels are probably the hang up. Funny things happen at undefined voltage levels. Do you have access to these parts to make a level shifter?
User avatar
ian
Crew
Crew
 
Posts: 10531
Joined: Mon Jul 06, 2009 6:14 am

Re: UART Mode Input Problem

Postby derpeter » Sat Jul 02, 2011 3:45 am

ian wrote:If it's not the terminal emulation or line feed, then the voltage levels are probably the hang up. Funny things happen at undefined voltage levels. Do you have access to these parts to make a level shifter?


I tryed now ansi mode and vt102

I can get one on monday but we tried a lab power supply which provides 1,8V. I actually start to think that it is still a problem with the connector.
derpeter
Newbie
Newbie
 
Posts: 8
Joined: Tue Jun 21, 2011 1:42 pm

Re: UART Mode Input Problem

Postby ian » Wed Jul 06, 2011 11:16 am

Thanks, please keep me updated. I'm interested to find the culprit, and know how well the PIC works in the undefined range. I can help out with a voltage buffer if you need a way to test.
User avatar
ian
Crew
Crew
 
Posts: 10531
Joined: Mon Jul 06, 2009 6:14 am

Re: UART Mode Input Problem

Postby derpeter » Wed Jul 06, 2011 2:03 pm

Of course :-). I'm thinking about sending it in for repair and start hacking on the repaired one when its back so it can take some time until i can post updates.
derpeter
Newbie
Newbie
 
Posts: 8
Joined: Tue Jun 21, 2011 1:42 pm


Return to Bus Pirate Support