[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bluetooth-dev] Big endian issues for ARM patch



Hi,

I am using the Axis BT stack on an embedded PowerPC board. I applied
Gordon's ARM patch, becaused he mentioned that he has done some big
endianess fixes.
I did some tests and here are the result, problems and solutions:

1) There is no support for big endian CPU in the HCI driver. So here is
a fast an dirty solution (I know that this issue has been discussed some
time ago):

In hci.c the cmd_pkt stuct should be defined like this:

typedef struct cmd_pkt {
	u32 type:8;
#if (__BYTE_ORDER == __LITTLE_ENDIAN) 
        u32 ocf:10;
        u32 ogf:6;
#else
        u32 ogf:6;
        u32 ocf:10;
#endif
        u32 len:8;
        u8 data[256];
} cmd_pkt;                                                              

The send_cmd funtion should be changed in this way:

s32 
send_cmd(u8 *cmd, u8 len)
{
#if (__BYTE_ORDER == __BIG_ENDIAN) 
        u8 tmp;
        tmp = cmd[1];
        cmd[1] = cmd[2];
        cmd[2] = tmp;
#endif
	D_CMD("send_cmd : cmd_num %d\n", hci_ctrl.hc_buf.cmd_num);
...

Together with Gordon's patch, I had nmo problems running the stack on a
PowerPC CPU.

Any better idea ? 

Gordon, you talked about some big endian fixes. What have you changed ?
Is it possible that you do not see the HCI problem when you are running
the HCI emulator (I did not really look into that code) ?

2) The readline stuff in the btd application is nice, but the readline
lib, that is linked to theapplication is availagle on my small target.
Therefore I added a new define called USE_READLINE

Here are my changes:

//#define USE_READLINE

#ifdef USE_READLINE
#include <readline/readline.h>
#include <readline/history.h>
#endif

...

#ifndef USE_READLINE
void read_history(char *hist_file_name)
{
}

void write_history(char *hist_file_name)
{
}

void add_history(char *command)
{
}

char *readline(char *promt)
{
  char *tmp;
  tmp = malloc(100);
  printf("%s",promt);
  fflush(stdout);
  scanf("%s",tmp);
  return tmp;
}
#endif

if USE_READLINE is defined, the btd application works as before. If it
is not defined some dummy functions emulate the readline functions be
serving a simple readline function.

It would ne nice to get some comments, so that I can send a useful patch
or perhaps Gordon (?) will include it in his patch (..to reduce the
number of patches).

(I will do some tests with the other layers (also in kernel mode) in the
next days. My target kernel is 2.4.0-test3.)

Matthias
-------------------------------------------------
\ Matthias Fuchs                                 \
 \ esd electronic system design Gmbh              \
  \ Vahrenwalder Straße 205                        \
   \ D-30165 Hannover                               \
    \ email: matthias.fuchs@xxxxxxx.com      \
     \ phone: +49-511-37298-0                         \
      \ fax:   +49-511-37298-68                        \
       --------------------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe bluetooth-dev" in
the body of a message to majordomo@xxxxxxx.com