例如,请参阅此代码,了解适用于BlueZ的BCM43xx蓝牙驱动程序:
int bcm43xx_init(int fd, int def_speed, int speed, struct termios *ti,
const char *bdaddr)
{
char chip_name[20];
char fw_path[PATH_MAX];
printf("bcm43xx_init\n");
if (bcm43xx_reset(fd))
return -1;
if (bcm43xx_read_local_name(fd, chip_name, sizeof(chip_name)))
return -1;
if (bcm43xx_locate_patch(FIRMWARE_DIR, chip_name, fw_path)) {
fprintf(stderr, "Patch not found, continue anyway\n");
} else {
if (bcm43xx_set_speed(fd, ti, speed))
return -1;
if (bcm43xx_load_firmware(fd, fw_path))
return -1;
/* Controller speed has been reset to def speed */
if (set_speed(fd, ti, def_speed) < 0) {
perror("Can't set host baud rate");
return -1;
}
if (bcm43xx_reset(fd))
return -1;
}
if (bdaddr)
bcm43xx_set_bdaddr(fd, bdaddr);
if (bcm43xx_set_speed(fd, ti, speed))
return -1;
return 0;
}
在此功能的中间,它在文件系统上查找文件,并通过调用bcm43xx_load_firmware将其加载到芯片。为什么每次都需要这样做?
提前致谢。
答案 0 :(得分:0)
它只加载一个补丁文件(不是整个固件),它存储在bcm43xx芯片的RAM中。在对bcm43xx芯片进行电源循环后,RAM自然需要重新加载。