요점
esp32c3의 spi모드가 2-->3으로 변경되어야하므로, esp32c3의 prebuild이미지는 사용할수가 없음.
uart hci는 사용하지않고 spi로만 사용함.-->vhci 모드라고 함.
블루투스는 표준규칙을 잘 따르는듯 한데 wifi는 약간 야매느낌이다.
wifi는 esp32에서 다 해주고. 뭔가 별도의 내부프로토콜로 esp32로의 통신을 중계해주는 구라 network interface 인듯함. 그래서 쓰는법도 좀 다른듯하고 해서 찬찬히 연구해볼필요있음.
순서.
1. esp-hosted의 리눅스 드라이버 빌드
esp-hosted/host/linux/host_driver/esp32/spi/esp_spi.c 아래와 같이 수정.
//esp_board.mode = SPI_MODE_2;
esp_board.mode = SPI_MODE_3;
//esp_board.max_speed_hz = spi_clk_mhz * NUMBER_1M;
esp_board.max_speed_hz = 5 * NUMBER_1M;
esp-hosted/host/linux/host_driver/esp32/spi/esp_spi.h 핀번호 변경 ev1 값이므로 ssonic은 다른 번호겠지.
//#define HANDSHAKE_PIN 111 //evm
#define HANDSHAKE_PIN 105 // ssonic gpiog15
#define SPI_IRQ gpio_to_irq(HANDSHAKE_PIN)
//#define SPI_DATA_READY_PIN 55 // evm
#define SPI_DATA_READY_PIN 77 // ssonic gpiob9
#define SPI_DATA_READY_IRQ gpio_to_irq(SPI_DATA_READY_PIN)
esp-hosted/host/linux/host_driver/esp32/main.c delay있는 두줄 추가.
#define HOST_GPIO_PIN_INVALID -1
static int resetpin = HOST_GPIO_PIN_INVALID;
static int delay = 0;
module_param(resetpin, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
MODULE_PARM_DESC(resetpin, "Host's GPIO pin number which is connected to ESP32's EN to reset ESP32 device");
module_param(delay, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
source /home/happycpu/work/Developer-Package/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
export KERNEL=/home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1
make target=spi ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE KERNEL=$KERNEL resetpin=3
make target=spi ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE KERNEL=$KERNEL resetpin=3
#resetpin은 컴파일할데 인자로 리셋핀을 지정하는 방법임. 지정하지않을경우, 기본3으로 정의됨.gpio번호임. 다른거라면 다른번호로 지정해야함.
happycpu@happycpubox:~/work/testproj/esp-hosted/host/linux/host_driver/esp32$ source /home/happycpu/work/Developer-Package/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
happycpu@happycpubox:~/work/testproj/esp-hosted/host/linux/host_driver/esp32$ export KERNEL=/home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1
happycpu@happycpubox:~/work/testproj/esp-hosted/host/linux/host_driver/esp32$ make target=spi ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE KERNEL=$KERNEL resetpin=3
rm -rf *.o sdio/*.o spi/*.o *.ko
make ARCH=arm CROSS_COMPILE=arm-ostl-linux-gnueabi- -C /home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1 M=/home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32 clean
make[1]: 디렉터리 '/home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1' 들어감
CLEAN /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/Module.symvers
make[1]: 디렉터리 '/home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1' 나감
make ARCH=arm CROSS_COMPILE=arm-ostl-linux-gnueabi- -C /home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1 M=/home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32 modules
make[1]: 디렉터리 '/home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1' 들어감
CC [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/esp_bt.o
CC [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/main.o
CC [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/spi/esp_spi.o
CC [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/esp_serial.o
CC [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/esp_rb.o
LD [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/esp32_spi.o
MODPOST /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/Module.symvers
CC [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/esp32_spi.mod.o
LD [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/esp32_spi.ko
make[1]: 디렉터리 '/home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1' 나감
happycpu@happycpubox:~/work/testproj/esp-hosted/host/linux/host_driver/esp32$
happycpu@happycpubox:~/work/testproj/esp-hosted/host/linux/host_driver/esp32$ export KERNEL=/home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1
happycpu@happycpubox:~/work/testproj/esp-hosted/host/linux/host_driver/esp32$ make target=spi ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE KERNEL=$KERNEL resetpin=3
rm -rf *.o sdio/*.o spi/*.o *.ko
make ARCH=arm CROSS_COMPILE=arm-ostl-linux-gnueabi- -C /home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1 M=/home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32 clean
make[1]: 디렉터리 '/home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1' 들어감
CLEAN /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/Module.symvers
make[1]: 디렉터리 '/home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1' 나감
make ARCH=arm CROSS_COMPILE=arm-ostl-linux-gnueabi- -C /home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1 M=/home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32 modules
make[1]: 디렉터리 '/home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1' 들어감
CC [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/esp_bt.o
CC [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/main.o
CC [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/spi/esp_spi.o
CC [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/esp_serial.o
CC [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/esp_rb.o
LD [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/esp32_spi.o
MODPOST /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/Module.symvers
CC [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/esp32_spi.mod.o
LD [M] /home/happycpu/work/testproj/esp-hosted/host/linux/host_driver/esp32/esp32_spi.ko
make[1]: 디렉터리 '/home/happycpu/work/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61.ev1' 나감
happycpu@happycpubox:~/work/testproj/esp-hosted/host/linux/host_driver/esp32$
출력파일은
happycpu@happycpubox:~/work/testproj/esp-hosted/host/linux/host_driver/esp32$ ls
LICENSE Module.symvers esp32_spi.ko esp32_spi.mod.c esp32_spi.o esp_bt.c esp_bt_api.h esp_rb.c esp_rb.o esp_serial.h main.c modules.order spi
Makefile esp.h esp32_spi.mod esp32_spi.mod.o esp_api.h esp_bt.o esp_if.h esp_rb.h esp_serial.c esp_serial.o main.o sdio
happycpu@happycpubox:~/work/testproj/esp-hosted/host/linux/host_driver/esp32$
LICENSE Module.symvers esp32_spi.ko esp32_spi.mod.c esp32_spi.o esp_bt.c esp_bt_api.h esp_rb.c esp_rb.o esp_serial.h main.c modules.order spi
Makefile esp.h esp32_spi.mod esp32_spi.mod.o esp_api.h esp_bt.o esp_if.h esp_rb.h esp_serial.c esp_serial.o main.o sdio
happycpu@happycpubox:~/work/testproj/esp-hosted/host/linux/host_driver/esp32$
scp로 넘겨서 사용. 향후 드라이버는 커널에 합치고, 아래 dev파일은 rootfs에 미리 만들어놓는다. 그래서 부팅하면서 자연스럽게 드라이버까지 올라가도록
rmmod esp32_spi &> /dev/null
insmod esp32_spi.ko resetpin=3
mknod /dev/esps0 c 221 0
chmod 666 /dev/esps0
insmod esp32_spi.ko resetpin=3
mknod /dev/esps0 c 221 0
chmod 666 /dev/esps0
2. esp-hosted의 esp32c3용 driver수정.
esp-hosted/esp/esp_driver/network_adapter/main/spi_slave_api.c 수정 SPI_MODE_3 으로..
/* Configuration for the SPI slave interface */
spi_slave_interface_config_t slvcfg={
//.mode=SPI_MODE_2,
.mode=SPI_MODE_3,
.spics_io_num=GPIO_CS,
.queue_size=SPI_QUEUE_SIZE,
.flags=0,
.post_setup_cb=spi_post_setup_cb,
.post_trans_cb=spi_post_trans_cb
};
3. esp-hosted의 test용 app 빌드
파이썬이 아닌 c언어 app으로 드라이버를 제어하는 유틸 및 api사용법, api라이브러리 사용법등이 이곳에 있음.
샘플 test.out 파일을 컴파일한다. (그걸로 ap scan 등등을 드라이버로 시킬수있다)
esp-hosted/esp-hosted/host/linux/host_control/c_support
Makefile 수정
첫쩨줄의 gcc를 주석처리함.
#CC = gcc
CROSS_COMPILE :=
컴파일
happycpu@happycpubox:~/work/esp-hosted/esp-hosted/host/linux/host_control/c_support$ make
arm-ostl-linux-gnueabi-gcc -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/home/happycpu/work/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi -C -Wall -I/home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/../../../host_common/include/ -I/home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/../../../../common//protobuf-c/ -I/home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/../../../../common//include/ /home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/../../../../common//protobuf-c/protobuf-c/protobuf-c.c /home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/platform_wrapper.c /home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/../../../../common//esp_hosted_config.pb-c.c /home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/../../../host_common/transport_pserial.c /home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/../../../host_common/commands.c test_api.c test.c -o test.out
happycpu@happycpubox:~/work/esp-hosted/esp-hosted/host/linux/host_control/c_support$ ls
Makefile platform_wrapper.c stress.c test.c test.out test_api.c test_api.h test_config.h
arm-ostl-linux-gnueabi-gcc -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/home/happycpu/work/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi -C -Wall -I/home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/../../../host_common/include/ -I/home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/../../../../common//protobuf-c/ -I/home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/../../../../common//include/ /home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/../../../../common//protobuf-c/protobuf-c/protobuf-c.c /home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/platform_wrapper.c /home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/../../../../common//esp_hosted_config.pb-c.c /home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/../../../host_common/transport_pserial.c /home/happycpu/work/esp-hosted/esp-hosted/host/linux/host_control/c_support/../../../host_common/commands.c test_api.c test.c -o test.out
happycpu@happycpubox:~/work/esp-hosted/esp-hosted/host/linux/host_control/c_support$ ls
Makefile platform_wrapper.c stress.c test.c test.out test_api.c test_api.h test_config.h
scp로 넘겨서 사용.
4. device tree
실컷 유저모드 spi설정 다 해놓고선. 마지막에 다시 disable하는것이 끝.
// stm32mp157c-ev1 board.
&spi1{
pinctrl-names = "default", "sleep";
pinctrl-0 = <&spi1_pins_z_mx>;
pinctrl-1 = <&spi1_sleep_pins_z_mx>;
status = "okay";
cs-gpios = <&gpioz 3 0>;
bus-num = <1>;
num-chipselects = <1>;
#address-cells = <1>;
#size-cells = <0>;
spidev1: spi@1{
status = "okay";
compatible = "spidev";
reg = <0>;
spi-max-frequency = <10000000>;
};
};
&spidev1{
status = "disable";
};
//////////////////////////////////////////
// stm32mp153d-ssonic
&spi2{
pinctrl-names = "default","sleep";
pinctrl-0 = <&spi2_pins_mx>;
pinctrl-1 = <&spi2_sleep_pins_mx>;
status = "okay";
cs-gpios = <&gpiob 25 0>;
// /delete-property/dmas;
// /delete-property/dma-names;
spidev:spidev@0{
compatible = "linux,spidev";
status = "okay";
reg = <0>;
spi-max-frequency = <10000000>;
};
};
&spidev{
status = "disable";
};
5. yocto bluez
버전을 꼭 높은것을 써야 Codedphy를 사용할수있을듯
레시피에 추가한다. bblayer.conf
참, esp32c3용으로 빌드는
idf.py set-target esp32c3
댓글 없음:
댓글 쓰기