Hi,
I am trying to get the CC256xEM to work with a Freescale MPC5125 (ppc, big endian), kernel 2.6.35 and bluez 4.84
The first hurdle was that the oscillator in the schematics was not actually mounted. So I provided a 32.768 KHz slow clock, and the module now starts. This is confirmed by seeing that HCI_RTS goes low according to http://processors.wiki.ti.com/index.php/CC256x_Testing_Guide#Required_Voltage_Rail_and_Signal_Sequence
Copied bluetooth_init_cc2564B_1.0_BT_Spec_4.0.bts to /lib/firmware
Made a symlink to get the name correct:
#ln -sf bluetooth_init_cc2564B_1.0_BT_Spec_4.0.bts TIInit_6.7.16.bts
Changed the timeout in hciattach_ti.c according to http://e2e.ti.com/support/wireless_connectivity/f/660/t/375766.aspx?pi310978=2
I then tried the hciattach, and got the following output.
-----------------------------------------------------------------------------------------------------------------------------------------------------
# strace /usr/sbin/hciattach ttyPSC3 texas
execve("/usr/sbin/hciattach", ["/usr/sbin/hciattach", "ttyPSC3", "texas"], [/* 12 vars */]) = 0
brk(0) = 0x2033c000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4801e000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/var/run/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=3214, ...}) = 0
mmap(NULL, 3214, PROT_READ, MAP_PRIVATE, 3, 0) = 0x4801f000
close(3) = 0
open("/usr/lib/libbluetooth.so.3", O_RDONLY) = 3
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0\0c|\0\0\0004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=100172, ...}) = 0
mmap(0x2007c000, 165800, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2007c000
mprotect(0x20093000, 65536, PROT_NONE) = 0
mmap(0x200a3000, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x200a3000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0\1\355\204\0\0\0004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1392996, ...}) = 0
mmap(0x1ff06000, 1463216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x1ff06000
mprotect(0x20054000, 65536, PROT_NONE) = 0
mmap(0x20064000, 20480, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14e000) = 0x20064000
mmap(0x20069000, 9136, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x20069000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x48020000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x48021000
mprotect(0x20064000, 4096, PROT_READ) = 0
munmap(0x4801f000, 3214) = 0
rt_sigaction(SIGALRM, {0x200b8a24, [], SA_NOCLDSTOP}, NULL, 8) = 0
alarm(10) = 0
open("/dev/ttyPSC3", O_RDWR|O_NOCTTY) = 3
ioctl(3, TCFLSH, 0x2) = 0
ioctl(3, TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0
ioctl(3, TCSETS, {B115200 -opost -isig -icanon -echo ...}) = 0
ioctl(3, TCSETS, {B115200 -opost -isig -icanon -echo ...}) = 0
ioctl(3, TCFLSH, 0x2) = 0
write(3, "\1\1\20\0", 4) = 4
read(3, "\4", 1) = 1
read(3, "\16\f", 2) = 2
read(3, "\1\1\20\0\6\0\0\6\r\0\220\33", 12) = 12
write(2, "Found a Texas Instruments' chip!"..., 33Found a Texas Instruments' chip!
) = 33
write(2, "Firmware file : /lib/firmware/TI"..., 48Firmware file : /lib/firmware/TIInit_6.7.16.bts
) = 48
brk(0) = 0x2033c000
brk(0x2035d000) = 0x2035d000
open("/lib/firmware/TIInit_6.7.16.bts", O_RDONLY) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=7093, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4801f000
read(4, "BTSB\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 4096
write(2, "/lib/firmware/TIInit_6.7.16.bts "..., 61/lib/firmware/TIInit_6.7.16.bts not a legal TI firmware file
) = 61
close(4) = 0
munmap(0x4801f000, 4096) = 0
write(2, "Warning: cannot find BTS file: /"..., 63Warning: cannot find BTS file: /lib/firmware/TIInit_6.7.16.bts
) = 6
-----------------------------------------------------------------------------------------------------------------------------------------------------
After inspection of the tools/hciattach_ti.c I saw that use of the "#define FILE_HEADER_MAGIC 0x42535442" was not endian safe. So I changed the define to big endian and now the hciattach command recognizes the file but fails since the use of all structs seem to be implemented without regarding that the endian may be big endian, not little.
I also checked at kernel.org and the code in hciattach_ti.c seems to have the same problem even on the master branch on the bluez git.
So my question is, does there exist a tool to change endianness of the firmware file or some other solution to use the service packs on big endian machines with bluez.
The change in the hciattach_ti.c to correct for endianness is some work, which I can manage, but I do not want to do it if there exists a solution already.
Regards
Jonas