├── APP ├── README.md ├── adc │ ├── c │ │ ├── Makefile │ │ └── user │ │ │ └── main.c │ └── shell │ │ └── adc.sh ├── beep │ ├── README.md │ ├── c │ │ ├── Makefile │ │ ├── includes │ │ │ └── bsp_beep.h │ │ └── sources │ │ │ ├── bsp_beep.c │ │ │ └── main.c │ ├── c_shell │ │ ├── Makefile │ │ ├── bin │ │ │ └── beep_demo │ │ ├── includes │ │ │ └── bsp_beep.h │ │ └── sources │ │ │ ├── bsp_beep.c │ │ │ └── main.c │ └── shell │ │ └── beep.sh ├── file_io │ ├── README.md │ ├── stdio │ │ ├── Makefile │ │ ├── filesystem_test.txt │ │ └── main.c │ └── systemcall │ │ ├── Makefile │ │ └── main.c ├── hello_c │ ├── Makefile │ ├── README.md │ └── hello.c ├── hello_crosscompile │ ├── Makefile │ ├── README.md │ └── hello.c ├── hello_sh │ ├── README.md │ └── hello_world.sh ├── input │ ├── README.md │ ├── c │ │ ├── Makefile │ │ └── sources │ │ │ └── main.c │ └── shell │ │ └── input.sh ├── led │ ├── README.md │ ├── sys_class_gpio_export │ │ ├── README.md │ │ ├── c_systemcall │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── includes │ │ │ │ └── bsp_led.h │ │ │ └── sources │ │ │ │ ├── bsp_led.c │ │ │ │ └── main.c │ │ └── shell │ │ │ └── led.sh │ └── sys_class_leds │ │ ├── README.md │ │ ├── c_shell │ │ ├── Makefile │ │ └── sources │ │ │ └── main.c │ │ ├── c_stdio │ │ ├── Makefile │ │ └── sources │ │ │ └── main.c │ │ ├── c_systemcall │ │ ├── Makefile │ │ └── sources │ │ │ └── main.c │ │ └── shell │ │ └── led.sh ├── makefile_step │ ├── README.md │ ├── step0 │ │ ├── Makefile │ │ ├── Makefile_PHONY │ │ └── test.txt │ ├── step1 │ │ ├── Makefile │ │ ├── hello_func.c │ │ ├── hello_func.h │ │ ├── hello_main │ │ └── hello_main.c │ ├── step2 │ │ ├── Makefile │ │ ├── hello_func.c │ │ ├── hello_func.h │ │ ├── hello_main │ │ └── hello_main.c │ ├── step3 │ │ ├── Makefile │ │ ├── Makefile_test │ │ ├── hello_func.c │ │ ├── hello_func.h │ │ ├── hello_main │ │ └── hello_main.c │ ├── step4 │ │ ├── Makefile │ │ ├── hello_func.c │ │ ├── hello_func.h │ │ └── hello_main.c │ └── step5 │ │ ├── Makefile │ │ ├── includes │ │ └── hello_func.h │ │ └── sources │ │ ├── hello_func.c │ │ ├── hello_main.c │ │ └── test.c ├── mpu6050 │ ├── Makefile │ └── user │ │ └── main.c ├── music │ ├── c │ │ ├── Makefile │ │ └── user │ │ │ └── main.c │ └── shell │ │ ├── music.mp3 │ │ └── music_player.sh ├── nfs_config │ ├── README.md │ └── exports ├── uart │ ├── c │ │ ├── .vscode │ │ │ └── settings.json │ │ ├── Makefile │ │ ├── bin │ │ │ └── uart_demo │ │ ├── inc │ │ │ └── bsp_uart.h │ │ ├── src │ │ │ └── bsp_uart.c │ │ └── user │ │ │ └── main.c │ ├── c_simple │ │ ├── Makefile │ │ └── user │ │ │ └── main.c │ └── shell │ │ └── uart.sh └── video │ ├── c │ ├── Makefile │ └── user │ │ └── main.c │ └── shell │ ├── Angry_Birds.avi │ ├── video_player.sh │ └── 将该视频文件放在家目录下.txt ├── README.md ├── VERSION ├── build.sh ├── configs ├── boot.scripts │ ├── emmc_boot.txt │ ├── nand_boot.txt │ └── sd_boot.txt └── defconfig.mk ├── docs ├── 野火_EBF6ULL S1 Pro 底板_V1.0_原理图.pdf └── 野火_EBF6ULL S1 核心板V1.0_原理图.pdf ├── filesystems ├── base_fs │ └── core-image-base-imx6ull14x14evk.tar.bz2 ├── debian10 │ └── sources.list ├── debian9 │ └── sources.list ├── readme.md └── ubuntu_core │ ├── ubuntu16.04 │ ├── resolv.conf │ └── sources.list │ └── ubuntu18.04 │ ├── resolv.conf │ └── sources.list ├── output ├── dtbs │ ├── imx6ull-14x14-evk-btwifi.dtb │ ├── imx6ull-14x14-evk-emmc-43.dtb │ ├── imx6ull-14x14-evk-emmc-cam-dht11.dtb │ ├── imx6ull-14x14-evk-emmc-hdmi.dtb │ ├── imx6ull-14x14-evk-emmc-wifi.dtb │ ├── imx6ull-14x14-evk-emmc.dtb │ ├── imx6ull-14x14-evk-gpmi-weim-43.dtb │ ├── imx6ull-14x14-evk-gpmi-weim-cam-dht11.dtb │ ├── imx6ull-14x14-evk-gpmi-weim-hdmi.dtb │ ├── imx6ull-14x14-evk-gpmi-weim-wifi.dtb │ └── imx6ull-14x14-evk.dtb ├── kernel │ └── zImage └── uboot │ ├── boot.scr │ └── u-boot.imx ├── packages └── x11vnc │ ├── readme.txt │ └── x11vnc-0.9.13.tar.gz └── scripts ├── building_env_check.sh ├── building_fs_func.sh ├── building_kernel_func.sh ├── building_sdcard_img.sh ├── building_uboot_func.sh └── func_echo.sh /APP/README.md: -------------------------------------------------------------------------------- 1 | # 配套书籍第二部分的代码 2 | 这部分包含各种基础外设的C和Shell演示代码 -------------------------------------------------------------------------------- /APP/adc/c/Makefile: -------------------------------------------------------------------------------- 1 | #生成可执行文件的名称 2 | Target = adc_demo 3 | ARCH = ARM 4 | #编译器CC 5 | #根据传入的参数ARCH,确定使用的编译器 6 | #默认使用arm-gcc编译器 7 | ifeq ($(ARCH), ARM) 8 | CC = arm-linux-gnueabi-gcc 9 | else 10 | CC = gcc 11 | endif 12 | #存放中间文件的路径 13 | build_dir = objs 14 | #存放源文件的文件夹 15 | src_dir = src user 16 | #存放头文件的文件夹 17 | inc_dir = inc 18 | #存放可执行文件的文件夹 19 | exe_dir = bin 20 | #源文件 21 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 22 | #目标文件(*.o) 23 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 24 | #头文件 25 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 26 | #编译参数 27 | #指定头文件的路径 28 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 29 | #链接过程 30 | #开发板上无法使用动态库,因此使用静态链接的方式 31 | $(exe_dir)/$(Target) : $(objects) 32 | $(CC) $^ -o $@ --static 33 | #编译工程 34 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 35 | $(build_dir)/%.o : src/%.c | Build_DIR 36 | $(CC) -c $(CFLAGS) $^ -o $@ 37 | #编译user文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : user/%.c | Build_DIR 39 | $(CC) -c $(CFLAGS) $^ -o $@ 40 | #以下为伪目标,调用方式:make 伪目标 41 | #clean:用于Clean Project 42 | #check:用于检查某个变量的值 43 | .PHONY:clean check 44 | #命令前带“-”,表示出错之后,继续执行后面的命令 45 | clean: 46 | -rm -rf objs 47 | -rm -rf bin 48 | 49 | #命令前带“@”,表示不在终端上输出执行的命令 50 | check: 51 | @echo $(CFLAGS) 52 | #创建一个新目录objs,用于存放过程文件 53 | Build_DIR: 54 | @mkdir -p $(build_dir) 55 | @mkdir -p $(exe_dir) 56 | 57 | -------------------------------------------------------------------------------- /APP/adc/c/user/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | char cmdout[100]; 6 | 7 | int main(void) 8 | { 9 | unsigned int ADC_ConvertedValue = 0; 10 | float ADC_ConvertedValueLocal = 0; //保存转换得到的电压值 11 | FILE *fp; 12 | printf("This is the adc demo\n"); 13 | while(1) 14 | { 15 | fp = popen("cat /sys/bus/iio/devices/iio\\:device0/in_voltage3_raw", "r"); 16 | if(fp == NULL) 17 | printf("Fail to open\n"); 18 | 19 | fgets(cmdout, 100, fp); 20 | pclose(fp); 21 | ADC_ConvertedValue = atoi(cmdout); 22 | /*输出原始转换结果*/ 23 | printf("The Conversion Value: %d\r\n", ADC_ConvertedValue); 24 | 25 | ADC_ConvertedValueLocal = ((float)ADC_ConvertedValue)/4095.0f*3.3f; 26 | /*将结果转换为电压值并通过串口输出*/ 27 | printf("The current AD value = %f V \r\n",ADC_ConvertedValueLocal); 28 | 29 | sleep(1); 30 | } 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /APP/adc/shell/adc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | range=4095 3 | max_vol=3.3 4 | 5 | 6 | 7 | while true 8 | do 9 | echo "Press Ctrl+C for quit" 10 | Conversion_Value=$(cat /sys/bus/iio/devices/iio\:device0/in_voltage3_raw) 11 | echo The Conversion Value is : $Conversion_Value 12 | vol=$(echo "scale=4;$Conversion_Value*$max_vol/$range" | bc) 13 | echo The current AD value = $vol V 14 | sleep 1s 15 | done 16 | -------------------------------------------------------------------------------- /APP/beep/README.md: -------------------------------------------------------------------------------- 1 | # 蜂鸣器示例 2 | 3 | 蜂鸣器示例,开发板默认的出厂镜像蜂鸣器可以使用GPIO子系统驱动进行控制。 4 | 5 | 各个目录的演示说明如下: 6 | 1. c:使用系统调用的文件操作方式控制蜂鸣器 7 | 2. c_shell:使用C代码执行shell命令的控制方式,这是比较傻的方式,只是作为参考 8 | 3. shell:使用shell命令控制蜂鸣器 9 | 10 | 由于主机的Ubuntu系统通常没有GPIO设备,所以这些示例不能在主机上运行。 11 | 在配套的ARM开发板可以运行 12 | 13 | ## c范例说明 14 | 使用系统open、read、write、close、ioctl等底层函数控制蜂鸣器设备。 15 | 16 | ### 编译 17 | 18 | 19 | 编译的输出目录为`build_xxx/beep_demo`文件 20 | 切换至Makefile所在目录,使用如下命令编译: 21 | ARM平台编译指令: 22 | ``` bash 23 | make ARCH=arm 24 | ``` 25 | 26 | ### 运行 27 | Ubuntu主机通常没有GPIO设备,本实验不支持在主机上运行。 28 | 编译后在ARM终端上使用如下命令运行: 29 | ``` bash 30 | #在ARM终端对应的目录下运行 31 | ./build_arm/beep_demo 32 | ``` 33 | 34 | -------- 35 | 36 | 37 | ## c_shell范例 38 | 使用系统system系统调用的方式执行命令行。 39 | 40 | 41 | ### 编译和运行 42 | 本示例的编译和运行与c的相同,切换至相应目录以同样的方式操作即可 43 | 44 | ------- 45 | 46 | ## shell范例 47 | 使用echo等脚本控制GPIO设备。 48 | 49 | 50 | ### 运行 51 | Ubuntu主机通常没有GPIO设备,本实验不支持在主机上运行。 52 | 53 | 脚本本身可能没有可执行权限,需要添加权限后再运行,使用如下命令: 54 | ```bash 55 | #在ARM终端对应的脚本目录下执行如下命令 56 | #添加可执行权限 57 | chmod u+x beep.sh 58 | #运行 59 | ./beep.sh 60 | ``` 61 | -------------------------------------------------------------------------------- /APP/beep/c/Makefile: -------------------------------------------------------------------------------- 1 | 2 | #生成可执行文件的名称 3 | Target = beep_demo 4 | ARCH ?= x86 5 | #编译器CC 6 | #根据传入的参数ARCH,确定使用的编译器 7 | #默认使用gcc编译器 8 | #make ARCH=arm 时使用ARM-GCC编译器 9 | ifeq ($(ARCH), x86) 10 | CC = gcc 11 | else 12 | CC = arm-linux-gnueabihf-gcc 13 | endif 14 | #存放中间文件的路径 15 | build_dir = build_$(ARCH) 16 | #存放源文件的文件夹 17 | src_dir = sources 18 | #存放头文件的文件夹 19 | inc_dir = includes . 20 | 21 | #源文件 22 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 23 | #目标文件(*.o) 24 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 25 | #头文件 26 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 27 | #编译参数 28 | #指定头文件的路径 29 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 30 | 31 | #链接过程 32 | #开发板上无法使用动态库,因此使用静态链接的方式 33 | $(build_dir)/$(Target) : $(objects) | create_build 34 | $(CC) $^ -o $@ 35 | 36 | #编译工程 37 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : $(src_dir)/%.c $(includes) | create_build 39 | $(CC) -c $(CFLAGS) $< -o $@ 40 | 41 | 42 | #以下为伪目标,调用方式:make 伪目标 43 | #clean:用于Clean Project 44 | #check:用于检查某个变量的值 45 | .PHONY:clean cleanall check create_build 46 | #按架构删除 47 | clean: 48 | rm -rf $(build_dir) 49 | 50 | #全部删除 51 | cleanall: 52 | rm -rf build_x86 build_arm 53 | 54 | #命令前带“@”,表示不在终端上输出执行的命令 55 | #这个目标主要是用来调试Makefile时输出一些内容 56 | check: 57 | @echo $(CFLAGS) 58 | @echo $(CURDIR) 59 | @echo $(src_dir) 60 | @echo $(sources) 61 | @echo $(objects) 62 | 63 | #创建一个新目录create,用于存放过程文件 64 | create_build: 65 | @mkdir -p $(build_dir) 66 | 67 | -------------------------------------------------------------------------------- /APP/beep/c/includes/bsp_beep.h: -------------------------------------------------------------------------------- 1 | #ifndef _BSP_BEEP_H_ 2 | #define _BSP_BEEP_H_ 3 | 4 | 5 | //蜂鸣器的GPIO引脚号 6 | //imx6的计算方式,GPIOn_IOx = (n-1)*32 + x 7 | //如GPIO1_IO19 = (1-1)*32 + 19 = 19 8 | #define BEEP_GPIO_INDEX "19" 9 | 10 | /** 11 | * @brief 初始化蜂鸣器gpio相关 12 | * @return 13 | * @arg 0,正常 14 | * @arg 1,export文件打开错误 15 | * @arg 2,direction文件打开错误 16 | */ 17 | extern int beep_init(void); 18 | 19 | /** 20 | * @brief 关闭蜂鸣器gpio的export输出 21 | * @return 0正常,非0,value文件打开错误 22 | */ 23 | extern int beep_deinit(void); 24 | 25 | /** 26 | * @brief 蜂鸣器响 27 | * @return 0正常,非0,value文件打开错误 28 | */ 29 | extern int beep_on(void); 30 | 31 | /** 32 | * @brief 关闭蜂鸣器gpio的export输出 33 | * @return 0正常,非0,unexport文件打开错误 34 | */ 35 | extern int beep_off(void); 36 | 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /APP/beep/c/sources/bsp_beep.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "includes/bsp_beep.h" 6 | 7 | 8 | int beep_init(void) 9 | { 10 | int fd; 11 | //index config 12 | fd = open("/sys/class/gpio/export", O_WRONLY); 13 | if(fd < 0) 14 | return 1 ; 15 | 16 | write(fd, BEEP_GPIO_INDEX, strlen(BEEP_GPIO_INDEX)); 17 | close(fd); 18 | 19 | //direction config 20 | fd = open("/sys/class/gpio/gpio" BEEP_GPIO_INDEX "/direction", O_WRONLY); 21 | if(fd < 0) 22 | return 2; 23 | 24 | write(fd, "out", strlen("out")); 25 | close(fd); 26 | 27 | return 0; 28 | } 29 | 30 | int beep_deinit(void) 31 | { 32 | int fd; 33 | fd = open("/sys/class/gpio/unexport", O_WRONLY); 34 | if(fd < 0) 35 | return 1; 36 | 37 | write(fd, BEEP_GPIO_INDEX, strlen(BEEP_GPIO_INDEX)); 38 | close(fd); 39 | 40 | return 0; 41 | } 42 | 43 | 44 | int beep_on(void) 45 | { 46 | int fd; 47 | 48 | fd = open("/sys/class/gpio/gpio" BEEP_GPIO_INDEX "/value", O_WRONLY); 49 | if(fd < 0) 50 | return 1; 51 | 52 | write(fd, "1", 1); 53 | close(fd); 54 | 55 | return 0; 56 | } 57 | 58 | int beep_off(void) 59 | { 60 | int fd; 61 | 62 | fd = open("/sys/class/gpio/gpio" BEEP_GPIO_INDEX "/value", O_WRONLY); 63 | if(fd < 0) 64 | return 1; 65 | 66 | write(fd, "0", 1); 67 | close(fd); 68 | 69 | return 0; 70 | } 71 | 72 | 73 | -------------------------------------------------------------------------------- /APP/beep/c/sources/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "includes/bsp_beep.h" 4 | 5 | /** 6 | * @brief 主函数 7 | * @param 无 8 | * @retval 无 9 | */ 10 | int main(int argc, char *argv[]) 11 | { 12 | char buf[10]; 13 | int res; 14 | printf("This is the beep demo\n"); 15 | 16 | res = beep_init(); 17 | if(res){ 18 | printf("beep init error,code = %d",res); 19 | return 0; 20 | } 21 | 22 | while(1){ 23 | printf("Please input the value : 0--off 1--on q--exit\n"); 24 | scanf("%10s", buf); 25 | 26 | switch (buf[0]){ 27 | case '0': 28 | beep_off(); 29 | break; 30 | 31 | case '1': 32 | beep_on(); 33 | break; 34 | 35 | case 'q': 36 | beep_deinit(); 37 | printf("Exit\n"); 38 | return 0; 39 | 40 | default: 41 | break; 42 | } 43 | } 44 | } 45 | 46 | 47 | -------------------------------------------------------------------------------- /APP/beep/c_shell/Makefile: -------------------------------------------------------------------------------- 1 | 2 | #生成可执行文件的名称 3 | Target = beep_demo 4 | ARCH ?= x86 5 | #编译器CC 6 | #根据传入的参数ARCH,确定使用的编译器 7 | #默认使用gcc编译器 8 | #make ARCH=arm 时使用ARM-GCC编译器 9 | ifeq ($(ARCH), x86) 10 | CC = gcc 11 | else 12 | CC = arm-linux-gnueabihf-gcc 13 | endif 14 | #存放中间文件的路径 15 | build_dir = build_$(ARCH) 16 | #存放源文件的文件夹 17 | src_dir = sources 18 | #存放头文件的文件夹 19 | inc_dir = includes . 20 | 21 | #源文件 22 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 23 | #目标文件(*.o) 24 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 25 | #头文件 26 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 27 | #编译参数 28 | #指定头文件的路径 29 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 30 | 31 | #链接过程 32 | #开发板上无法使用动态库,因此使用静态链接的方式 33 | $(build_dir)/$(Target) : $(objects) | create_build 34 | $(CC) $^ -o $@ 35 | 36 | #编译工程 37 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : $(src_dir)/%.c $(includes) | create_build 39 | $(CC) -c $(CFLAGS) $< -o $@ 40 | 41 | 42 | #以下为伪目标,调用方式:make 伪目标 43 | #clean:用于Clean Project 44 | #check:用于检查某个变量的值 45 | .PHONY:clean cleanall check create_build 46 | #按架构删除 47 | clean: 48 | rm -rf $(build_dir) 49 | 50 | #全部删除 51 | cleanall: 52 | rm -rf build_x86 build_arm 53 | 54 | #命令前带“@”,表示不在终端上输出执行的命令 55 | #这个目标主要是用来调试Makefile时输出一些内容 56 | check: 57 | @echo $(CFLAGS) 58 | @echo $(CURDIR) 59 | @echo $(src_dir) 60 | @echo $(sources) 61 | @echo $(objects) 62 | 63 | #创建一个新目录create,用于存放过程文件 64 | create_build: 65 | @mkdir -p $(build_dir) 66 | 67 | -------------------------------------------------------------------------------- /APP/beep/c_shell/bin/beep_demo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/APP/beep/c_shell/bin/beep_demo -------------------------------------------------------------------------------- /APP/beep/c_shell/includes/bsp_beep.h: -------------------------------------------------------------------------------- 1 | #ifndef _BSP_BEEP_H_ 2 | #define _BSP_BEEP_H_ 3 | 4 | 5 | //蜂鸣器的GPIO引脚号 6 | //imx6的计算方式,GPIOn_IOx = (n-1)*32 + x 7 | //如GPIO1_IO19 = (1-1)*32 + 19 = 19 8 | #define BEEP_GPIO_INDEX "19" 9 | 10 | /** 11 | * @brief 初始化蜂鸣器gpio相关 12 | */ 13 | extern void beep_init(void); 14 | 15 | /** 16 | * @brief 关闭蜂鸣器gpio的export输出 17 | */ 18 | extern void beep_deinit(void); 19 | 20 | extern void beep_on(void); 21 | extern void beep_off(void); 22 | 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /APP/beep/c_shell/sources/bsp_beep.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "bsp_beep.h" 3 | 4 | void beep_init(void) 5 | { 6 | system("echo " BEEP_GPIO_INDEX " > /sys/class/gpio/export"); 7 | system("echo 'out' > /sys/class/gpio/gpio" BEEP_GPIO_INDEX "/direction"); 8 | } 9 | 10 | void beep_deinit(void) 11 | { 12 | system("echo " BEEP_GPIO_INDEX " > /sys/class/gpio/unexport"); 13 | 14 | } 15 | 16 | 17 | void beep_on(void) 18 | { 19 | system("echo 1 > /sys/class/gpio/gpio" BEEP_GPIO_INDEX "/value"); 20 | } 21 | 22 | void beep_off(void) 23 | { 24 | system("echo 0 > /sys/class/gpio/gpio" BEEP_GPIO_INDEX "/value"); 25 | } 26 | 27 | -------------------------------------------------------------------------------- /APP/beep/c_shell/sources/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "includes/bsp_beep.h" 5 | 6 | /** 7 | * @brief 主函数 8 | * @param 无 9 | * @retval 无 10 | */ 11 | int main(int argc, char *argv[]) 12 | { 13 | char buf[10]; 14 | printf("This is the beep demo\n"); 15 | 16 | beep_init(); 17 | 18 | while(1){ 19 | printf("Please input the value : 0--off 1--on q--exit\n"); 20 | scanf("%10s", buf); 21 | 22 | switch (buf[0]){ 23 | case '0': 24 | beep_off(); 25 | break; 26 | 27 | case '1': 28 | beep_on(); 29 | break; 30 | 31 | case 'q': 32 | beep_deinit(); 33 | printf("Exit\n"); 34 | return 0; 35 | 36 | default: 37 | break; 38 | } 39 | } 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /APP/beep/shell/beep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "=================BEEP test, Press q to exit=================" 4 | #蜂鸣器对应的引脚编号 5 | index=19 6 | #系统是否导出了相应的gpio文件夹 7 | if [ ! -e /sys/class/gpio/gpio$index ] 8 | then 9 | echo "init hardware" > /tmp/beep 10 | 11 | echo $index > /sys/class/gpio/export 12 | echo 'out' > /sys/class/gpio/gpio$index/direction 13 | fi 14 | while true 15 | do 16 | echo "Please Input the value : 0--off 1--on q--exit" 17 | #读取端口的输入电平,为1时,蜂鸣器响 18 | read value 19 | case $value in 20 | 0) echo $value > /sys/class/gpio/gpio$index/value 21 | ;; 22 | 1) echo $value > /sys/class/gpio/gpio$index/value 23 | ;; 24 | q) echo "quit" 25 | exit 0 26 | ;; 27 | *) echo "Incorrect format input" 28 | ;; 29 | esac 30 | done 31 | -------------------------------------------------------------------------------- /APP/file_io/README.md: -------------------------------------------------------------------------------- 1 | # 文件IO操作 2 | 本目录主要包含`stdio`和`systemcall`文件操作的范例。 3 | 4 | 5 | ## stdio:标准C库方式 6 | 使用C库的fopen、fread、fwrite、fclose、fioctl等库函数。 7 | 这种方式通常用于访问存储器的文件或终端输入输出。 8 | 9 | ### 编译 10 | 编译的输出目录为`build_xxx/file_demo`文件 11 | 切换至Makefile所在目录,使用如下命令编译: 12 | ``` bash 13 | #x86架构 14 | make 15 | ``` 16 | 17 | ARM平台编译指令: 18 | ``` bash 19 | #arm架构 20 | make ARCH=arm 21 | ``` 22 | 23 | ### 运行 24 | 25 | 编译后使用如下命令运行: 26 | ``` bash 27 | #x86 28 | ./build_x86/file_demo 29 | #ARM 30 | ./build_arm/file_demo 31 | ``` 32 | ------- 33 | 34 | 35 | ## systemcall:系统调用方式 36 | 使用系统open、read、write、close、ioctl等底层函数。 37 | 这种方式通常用于访问设备驱动程序。 38 | 39 | ### 编译和运行 40 | 本示例的编译和运行与stdio的相同,切换至相应目录以同样的方式操作即可 41 | 42 | 43 | -------------------------------------------------------------------------------- /APP/file_io/stdio/Makefile: -------------------------------------------------------------------------------- 1 | 2 | #生成可执行文件的名称 3 | Target = file_demo 4 | ARCH ?= x86 5 | #编译器CC 6 | #根据传入的参数ARCH,确定使用的编译器 7 | #默认使用gcc编译器 8 | #make ARCH=arm 时使用ARM-GCC编译器 9 | ifeq ($(ARCH), x86) 10 | CC = gcc 11 | else 12 | CC = arm-linux-gnueabihf-gcc 13 | endif 14 | #存放中间文件的路径 15 | build_dir = build_$(ARCH) 16 | #存放源文件的文件夹 17 | src_dir = . 18 | #存放头文件的文件夹 19 | inc_dir = includes . 20 | 21 | #源文件 22 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 23 | #目标文件(*.o) 24 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 25 | #头文件 26 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 27 | #编译参数 28 | #指定头文件的路径 29 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 30 | 31 | #链接过程 32 | #开发板上无法使用动态库,因此使用静态链接的方式 33 | $(build_dir)/$(Target) : $(objects) | create_build 34 | $(CC) $^ -o $@ 35 | 36 | #编译工程 37 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : $(src_dir)/%.c $(includes) | create_build 39 | $(CC) -c $(CFLAGS) $< -o $@ 40 | 41 | 42 | #以下为伪目标,调用方式:make 伪目标 43 | #clean:用于Clean Project 44 | #check:用于检查某个变量的值 45 | .PHONY:clean cleanall check create_build 46 | #按架构删除 47 | clean: 48 | rm -rf $(build_dir) 49 | 50 | #全部删除 51 | cleanall: 52 | rm -rf build_x86 build_arm 53 | 54 | #命令前带“@”,表示不在终端上输出执行的命令 55 | #这个目标主要是用来调试Makefile时输出一些内容 56 | check: 57 | @echo $(CFLAGS) 58 | @echo $(CURDIR) 59 | @echo $(src_dir) 60 | @echo $(sources) 61 | @echo $(objects) 62 | 63 | #创建一个新目录create,用于存放过程文件 64 | create_build: 65 | @mkdir -p $(build_dir) 66 | 67 | -------------------------------------------------------------------------------- /APP/file_io/stdio/filesystem_test.txt: -------------------------------------------------------------------------------- 1 | filesystem_test:Hello World! 2 | Embedfire 3 | -------------------------------------------------------------------------------- /APP/file_io/stdio/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************** 3 | * @file main.c 4 | * @author fire 5 | * @version V1.0 6 | * @date 2019-xx-xx 7 | * @brief 文件系统测试代码(使用系统调用) 8 | ****************************************************************** 9 | * @attention 10 | * 11 | * 实验平台: 12 | * 论坛 :http://www.firebbs.cn 13 | * 淘宝 :http://firestm32.taobao.com 14 | * 15 | ****************************************************************** 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | //要写入的字符串 22 | const char buf[] = "filesystem_test:Hello World!\n"; 23 | //文件描述符 24 | FILE *fp; 25 | char str[100]; 26 | 27 | 28 | int main(void) 29 | { 30 | //创建一个文件 31 | fp = fopen("filesystem_test.txt", "w+"); 32 | //正常返回文件指针 33 | //异常返回NULL 34 | if(NULL == fp){ 35 | printf("Fail to Open File\n"); 36 | return 0; 37 | } 38 | //将buf的内容写入文件 39 | //每次写入1个字节,总长度由strlen给出 40 | fwrite(buf, 1, strlen(buf), fp); 41 | 42 | //写入Embedfire 43 | //每次写入1个字节,总长度由strlen给出 44 | fwrite("Embedfire\n", 1, strlen("Embedfire\n"),fp); 45 | 46 | //把缓冲区的数据立即写入文件 47 | fflush(fp); 48 | 49 | //此时的文件位置指针位于文件的结尾处,使用fseek函数使文件指针回到文件头 50 | fseek(fp, 0, SEEK_SET); 51 | 52 | //从文件中读取内容到str中 53 | //每次读取100个字节,读取1次 54 | fread(str, 100, 1, fp); 55 | 56 | printf("File content:\n%s \n", str); 57 | 58 | fclose(fp); 59 | 60 | return 0; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /APP/file_io/systemcall/Makefile: -------------------------------------------------------------------------------- 1 | 2 | #生成可执行文件的名称 3 | Target = file_demo 4 | ARCH ?= x86 5 | #编译器CC 6 | #根据传入的参数ARCH,确定使用的编译器 7 | #默认使用gcc编译器 8 | #make ARCH=arm 时使用ARM-GCC编译器 9 | ifeq ($(ARCH), x86) 10 | CC = gcc 11 | else 12 | CC = arm-linux-gnueabihf-gcc 13 | endif 14 | #存放中间文件的路径 15 | build_dir = build_$(ARCH) 16 | #存放源文件的文件夹 17 | src_dir = . 18 | #存放头文件的文件夹 19 | inc_dir = includes . 20 | 21 | #源文件 22 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 23 | #目标文件(*.o) 24 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 25 | #头文件 26 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 27 | #编译参数 28 | #指定头文件的路径 29 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 30 | 31 | #链接过程 32 | #开发板上无法使用动态库,因此使用静态链接的方式 33 | $(build_dir)/$(Target) : $(objects) | create_build 34 | $(CC) $^ -o $@ 35 | 36 | #编译工程 37 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : $(src_dir)/%.c $(includes) | create_build 39 | $(CC) -c $(CFLAGS) $< -o $@ 40 | 41 | 42 | #以下为伪目标,调用方式:make 伪目标 43 | #clean:用于Clean Project 44 | #check:用于检查某个变量的值 45 | .PHONY:clean cleanall check create_build 46 | #按架构删除 47 | clean: 48 | rm -rf $(build_dir) 49 | 50 | #全部删除 51 | cleanall: 52 | rm -rf build_x86 build_arm 53 | 54 | #命令前带“@”,表示不在终端上输出执行的命令 55 | #这个目标主要是用来调试Makefile时输出一些内容 56 | check: 57 | @echo $(CFLAGS) 58 | @echo $(CURDIR) 59 | @echo $(src_dir) 60 | @echo $(sources) 61 | @echo $(objects) 62 | 63 | #创建一个新目录create,用于存放过程文件 64 | create_build: 65 | @mkdir -p $(build_dir) 66 | 67 | -------------------------------------------------------------------------------- /APP/file_io/systemcall/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************** 3 | * @file main.c 4 | * @author fire 5 | * @version V1.0 6 | * @date 2019-xx-xx 7 | * @brief 文件系统测试代码(使用系统调用) 8 | ****************************************************************** 9 | * @attention 10 | * 11 | * 实验平台: 12 | * 论坛 :http://www.firebbs.cn 13 | * 淘宝 :http://firestm32.taobao.com 14 | * 15 | ****************************************************************** 16 | */ 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | //文件描述符 24 | int fd; 25 | char str[100]; 26 | 27 | 28 | int main(void) 29 | { 30 | //创建一个文件 31 | fd = open("testscript.sh", O_RDWR|O_CREAT|O_TRUNC, S_IRWXU); 32 | //文件描述符fd为非负整数 33 | if(fd < 0){ 34 | printf("Fail to Open File\n"); 35 | return 0; 36 | } 37 | //写入字符串pwd 38 | write(fd, "pwd\n", strlen("pwd\n")); 39 | 40 | //写入字符串ls 41 | write(fd, "ls\n", strlen("ls\n")); 42 | 43 | //此时的文件指针位于文件的结尾处,使用lseek函数使文件指针回到文件头 44 | lseek(fd, 0, SEEK_SET); 45 | 46 | //从文件中读取100个字节的内容到str中,该函数会返回实际读到的字节数 47 | read(fd, str, 100); 48 | 49 | printf("File content:\n%s \n", str); 50 | 51 | close(fd); 52 | 53 | return 0; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /APP/hello_c/Makefile: -------------------------------------------------------------------------------- 1 | #生成的可执行文件名 2 | 3 | hello:hello.o 4 | gcc -o hello hello.o 5 | 6 | #生成规则 7 | hello.o:hello.c 8 | gcc -c hello.c -o hello.o 9 | 10 | #伪目标 11 | .PHONY:clean 12 | clean: 13 | rm -f *.o hello -------------------------------------------------------------------------------- /APP/hello_c/README.md: -------------------------------------------------------------------------------- 1 | # 使用C语言编写Hello world程序 2 | 本目录主要包含使用C语言编写的输入Hello world的程序。 3 | 4 | ## 使用make编译 5 | 切换至Makefile所在目录。 6 | 使用如下命令编译: 7 | ``` bash 8 | make 9 | ``` 10 | 11 | ## 直接使用编译器编译 12 | 切换至hello.c所在目录。 13 | 使用如下命令编译: 14 | ``` bash 15 | gcc -o hello hello.c 16 | ``` 17 | 18 | 19 | 20 | ## 运行 21 | 22 | 编译后使用如下命令运行: 23 | ``` bash 24 | ./hello 25 | ``` 26 | 27 | -------------------------------------------------------------------------------- /APP/hello_c/hello.c: -------------------------------------------------------------------------------- 1 | /* $begin hello */ 2 | #include 3 | 4 | int main() 5 | { 6 | printf("hello, world! This is a C program.\n"); 7 | for(int i=0;i<10;i++ ){ 8 | printf("output i=%d\n",i); 9 | } 10 | 11 | return 0; 12 | } 13 | /* $end hello */ 14 | 15 | -------------------------------------------------------------------------------- /APP/hello_crosscompile/Makefile: -------------------------------------------------------------------------------- 1 | #生成的可执行文件名 2 | 3 | hello:hello.o 4 | arm-linux-gnueabihf-gcc -o hello hello.o 5 | hello.o:hello.c 6 | arm-linux-gnueabihf-gcc -c hello.c -o hello.o 7 | 8 | #伪目标 9 | .PHONY:clean 10 | clean: 11 | rm -f *.o hello 12 | -------------------------------------------------------------------------------- /APP/hello_crosscompile/README.md: -------------------------------------------------------------------------------- 1 | # 使用C语言编写Hello world程序 2 | 本目录主要包含使用C语言编写的输入Hello world的程序。 3 | 4 | ## 使用make编译 5 | 切换至Makefile所在目录。 6 | 使用如下命令编译: 7 | ``` bash 8 | make 9 | ``` 10 | 11 | ## 直接使用编译器编译 12 | 切换至hello.c所在目录。 13 | 使用如下命令编译: 14 | ``` bash 15 | arm-linux-gnueabihf-gcc -o hello hello.c 16 | ``` 17 | 18 | 19 | 20 | ## 运行 21 | 22 | 编译后`在开发板的终端上,切换至共享目录`,使用如下命令运行: 23 | `以下命令在开发板的终端上运行` 24 | `以下命令在开发板的终端上运行` 25 | ``` bash 26 | #切换至程序所在目录运行 27 | ./hello 28 | ``` 29 | 30 | -------------------------------------------------------------------------------- /APP/hello_crosscompile/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | printf("hello, world! This is a C program.\n"); 6 | for(int i = 0; i < 10; i++){ 7 | printf("output i = %d\n", i ); 8 | } 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /APP/hello_sh/README.md: -------------------------------------------------------------------------------- 1 | # 使用脚本输入hello world 2 | 使用脚本在终端输出hello world,方便测试 3 | 4 | # 运行 5 | 6 | 切换至hello_world.sh文件所在路径。 7 | 8 | 使用如下命令运行程序: 9 | ``` bash 10 | ./hello_world.sh 11 | ``` -------------------------------------------------------------------------------- /APP/hello_sh/hello_world.sh: -------------------------------------------------------------------------------- 1 | echo "helloworld,this is a script test!" 2 | -------------------------------------------------------------------------------- /APP/input/README.md: -------------------------------------------------------------------------------- 1 | # 输入检测示例 2 | 3 | 输入检测示例,开发板默认的出厂镜像按键可以使用input子系统驱动进行控制。 4 | 5 | 各个目录的演示说明如下: 6 | 1. c:使用系统调用的文件操作方式控制蜂鸣器 7 | 2. shell:使用shell命令控制蜂鸣器 8 | 9 | 由于主机的Ubuntu系统通常没有GPIO设备,所以这些示例不能在主机上运行。 10 | 在配套的ARM开发板可以运行 11 | 12 | ## c范例说明 13 | 使用系统open、read、write、close、ioctl等底层函数读取输入设备事件。 14 | 15 | ### 编译 16 | 17 | 18 | 编译的输出目录为`build_xxx/input_demo`文件 19 | 切换至Makefile所在目录,使用如下命令编译: 20 | 21 | x86平台编译指令: 22 | ```bash 23 | #注意编译前要把代码中的设备路径修改成主机上的设备 24 | make 25 | ``` 26 | 27 | ARM平台编译指令: 28 | ``` bash 29 | make ARCH=arm 30 | ``` 31 | 32 | ### 运行 33 | 34 | 程序默认使用开发板中的KEY按键进行输入测试,运行时可使用参数指定要测试的输入设备路径。 35 | 36 | 可使用evtest查看系统中存储的输入设备: 37 | 38 | ```bash 39 | sudo evtest 40 | #以下为示例输出 41 | #No device specified, trying to scan all of /dev/input/event* 42 | #Available devices: 43 | #/dev/input/event0: Power Button 44 | #/dev/input/event1: Sleep Button 45 | #/dev/input/event2: AT Translated Set 2 keyboard 46 | #/dev/input/event3: Video Bus 47 | #/dev/input/event4: ImExPS/2 Generic Explorer Mouse 48 | #/dev/input/event5: VirtualBox USB Tablet 49 | #/dev/input/event6: VirtualBox mouse integration 50 | 51 | #示例中的“VirtualBox mouse integration”为鼠标设备,它的路径为“/dev/input/event6”, 52 | #把“/dev/input/event6”作为本程序的输入参数运行即可,运行后移动鼠标即会有输出。 53 | 54 | #如: sudo ./build_x86/input_demo /dev/input/event6 55 | ``` 56 | 57 | 编译后在Ubuntu上使用如下命令运行: 58 | ``` bash 59 | #在Ubuntu对应的目录下运行 60 | #要使用sudo运行! 61 | #要使用sudo运行! 62 | 63 | #命令要根据要测试的设备修改,如前面示例中的/dev/input/event6 64 | sudo ./build_x86/input_demo 要测试的设备路径 65 | ``` 66 | 67 | 程序默认使用开发板中的KEY按键进行输入测试,运行时也可使用参数指定要测试的输入设备路径。 68 | 编译后在ARM终端上使用如下命令运行: 69 | ``` bash 70 | #在ARM终端对应的目录下运行 71 | #默认使用KEY按键测试 72 | ./build_arm/input_demo 73 | #运行后按开发板上的按键后会有输出 74 | 75 | #也可以使用参数指定设备事件路径 76 | ./build_arm/input_demo [要测试的事件设备路径] 77 | #使用相应的设备进行输入 78 | ``` 79 | 80 | -------- 81 | 82 | 83 | ## shell范例 84 | 直接调用evtest工具检测输入设备 85 | 86 | ### 运行 87 | 88 | 脚本本身可能没有可执行权限,需要添加权限后再运行,使用如下命令: 89 | ```bash 90 | #在ARM终端对应的脚本目录下执行如下命令 91 | #添加可执行权限 92 | chmod u+x beep.sh 93 | #运行 94 | ./input.sh 95 | ``` 96 | -------------------------------------------------------------------------------- /APP/input/c/Makefile: -------------------------------------------------------------------------------- 1 | 2 | #生成可执行文件的名称 3 | Target = input_demo 4 | ARCH ?= x86 5 | #编译器CC 6 | #根据传入的参数ARCH,确定使用的编译器 7 | #默认使用gcc编译器 8 | #make ARCH=arm 时使用ARM-GCC编译器 9 | ifeq ($(ARCH), x86) 10 | CC = gcc 11 | else 12 | CC = arm-linux-gnueabihf-gcc 13 | endif 14 | #存放中间文件的路径 15 | build_dir = build_$(ARCH) 16 | #存放源文件的文件夹 17 | src_dir = sources 18 | #存放头文件的文件夹 19 | inc_dir = includes . 20 | 21 | #源文件 22 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 23 | #目标文件(*.o) 24 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 25 | #头文件 26 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 27 | #编译参数 28 | #指定头文件的路径 29 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 30 | 31 | #链接过程 32 | #开发板上无法使用动态库,因此使用静态链接的方式 33 | $(build_dir)/$(Target) : $(objects) | create_build 34 | $(CC) $^ -o $@ 35 | 36 | #编译工程 37 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : $(src_dir)/%.c $(includes) | create_build 39 | $(CC) -c $(CFLAGS) $< -o $@ 40 | 41 | 42 | #以下为伪目标,调用方式:make 伪目标 43 | #clean:用于Clean Project 44 | #check:用于检查某个变量的值 45 | .PHONY:clean cleanall check create_build 46 | #按架构删除 47 | clean: 48 | rm -rf $(build_dir) 49 | 50 | #全部删除 51 | cleanall: 52 | rm -rf build_x86 build_arm 53 | 54 | #命令前带“@”,表示不在终端上输出执行的命令 55 | #这个目标主要是用来调试Makefile时输出一些内容 56 | check: 57 | @echo $(CFLAGS) 58 | @echo $(CURDIR) 59 | @echo $(src_dir) 60 | @echo $(sources) 61 | @echo $(objects) 62 | 63 | #创建一个新目录create,用于存放过程文件 64 | create_build: 65 | @mkdir -p $(build_dir) 66 | 67 | -------------------------------------------------------------------------------- /APP/input/c/sources/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | //开发板上的KEY按键,请根据实际情况修改 12 | const char default_path[] = "/dev/input/by-path/platform-gpio-keys-event"; 13 | 14 | //开发板上的ON_OFF按键,请根据实际情况修改 15 | //const char default_path[] = "/dev/input/by-path/platform-20cc000.snvs:snvs-powerkey-event"; 16 | 17 | 18 | int main(int argc, char *argv[]) 19 | { 20 | int fd; 21 | struct input_event event; 22 | char *path; 23 | 24 | printf("This is a input device demo.\n"); 25 | 26 | //若无输入参数则使用默认事件设备 27 | if(argc > 1) 28 | path = argv[1]; 29 | else 30 | path = (char *)default_path; 31 | 32 | fd = open(path, O_RDONLY); 33 | if(fd < 0){ 34 | printf("Fail to open device:%s.\n" 35 | "Please confirm the path or you have permission to do this.\n", path); 36 | exit(1); 37 | } 38 | 39 | printf("Test device: %s.\nWaiting for input...\n", path); 40 | 41 | while(1){ 42 | if(read(fd, &event, sizeof(event)) == sizeof(event)){ 43 | 44 | //EV_SYN是事件分隔标志,不打印 45 | if(event.type != EV_SYN) 46 | printf("Event: time %ld.%ld, type %d, code %d,value %d\n", 47 | event.time.tv_sec,event.time.tv_usec, 48 | event.type, 49 | event.code, 50 | event.value); 51 | } 52 | } 53 | close(fd); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /APP/input/shell/input.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | evtest 4 | -------------------------------------------------------------------------------- /APP/led/README.md: -------------------------------------------------------------------------------- 1 | # LED点灯示例 2 | 初次学习时,请使用`sys_class_leds`目录下的示例进行学习。 3 | 因为默认情况下`sys_class_gpio_export`目录下的示例是不能正常运行的。 -------------------------------------------------------------------------------- /APP/led/sys_class_gpio_export/README.md: -------------------------------------------------------------------------------- 1 | # LED点灯示例 2 | LED示例,硬件相关的示例依赖于设备树。 3 | 在应用层点亮LED灯有`/sys/class/gpio_export`和`/sys/class/leds`两种方式, 4 | 受设备树的影响,本开发板默认**只能**使用`/sys/class/leds`控制板上RGB和心跳灯。 5 | 默认情况下,使用`/sys/class/gpio_export`**无法**对板载LED灯进行控制。 6 | 7 | 本目录下的示例使用`/sys/class/gpio_export`的LED设备,默认不能正常运行,在以后学习了替换设备树可更换LED灯的控制方式。 8 | 9 | 各个目录的演示说明如下: 10 | 1. c_systemcall:使用系统调用的文件操作方式点灯 11 | 2. shell:使用shell命令点灯 12 | 13 | 由于主机的Ubuntu系统没有LED设备,所以这些示例不能在主机上运行。 14 | 在配套的ARM开发板可以运行 15 | 16 | ## c_systemcall范例说明 17 | 使用系统open、read、write、close、ioctl等底层函数控制LED设备。 18 | 19 | ### 编译 20 | 21 | 22 | 编译的输出目录为`build_xxx/file_demo`文件 23 | 切换至Makefile所在目录,使用如下命令编译: 24 | ARM平台编译指令: 25 | ``` bash 26 | make ARCH=arm 27 | ``` 28 | 29 | ### 运行 30 | Ubuntu主机通常没有LED设备,本实验不支持在主机上运行。 31 | 编译后在ARM终端上使用如下命令运行: 32 | ``` bash 33 | #在ARM终端对应的目录下运行 34 | ./build_arm/led_demo 35 | ``` 36 | 37 | 38 | ------- 39 | 40 | ## shell范例 41 | 使用echo等脚本控制LED设备。 42 | 43 | 44 | ## 运行 45 | Ubuntu主机通常没有LED设备,本实验不支持在主机上运行。 46 | 47 | 脚本本身可能没有可执行权限,需要添加权限后再运行,使用如下命令: 48 | ```bash 49 | #在ARM终端对应的脚本目录下执行如下命令 50 | #添加可执行权限 51 | chmod u+x led.sh 52 | #运行 53 | ./led.sh 54 | ``` 55 | -------------------------------------------------------------------------------- /APP/led/sys_class_gpio_export/c_systemcall/Makefile: -------------------------------------------------------------------------------- 1 | 2 | #生成可执行文件的名称 3 | Target = led_demo 4 | ARCH ?= x86 5 | #编译器CC 6 | #根据传入的参数ARCH,确定使用的编译器 7 | #默认使用gcc编译器 8 | #make ARCH=arm 时使用ARM-GCC编译器 9 | ifeq ($(ARCH), x86) 10 | CC = gcc 11 | else 12 | CC = arm-linux-gnueabihf-gcc 13 | endif 14 | #存放中间文件的路径 15 | build_dir = build_$(ARCH) 16 | #存放源文件的文件夹 17 | src_dir = sources 18 | #存放头文件的文件夹 19 | inc_dir = includes 20 | 21 | #源文件 22 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 23 | #目标文件(*.o) 24 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 25 | #头文件 26 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 27 | #编译参数 28 | #指定头文件的路径 29 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 30 | 31 | #链接过程 32 | #开发板上无法使用动态库,因此使用静态链接的方式 33 | $(build_dir)/$(Target) : $(objects) | create_build 34 | $(CC) $^ -o $@ 35 | 36 | #编译工程 37 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : $(src_dir)/%.c $(includes) | create_build 39 | $(CC) -c $(CFLAGS) $< -o $@ 40 | 41 | 42 | #以下为伪目标,调用方式:make 伪目标 43 | #clean:用于Clean Project 44 | #check:用于检查某个变量的值 45 | .PHONY:clean cleanall check create_build 46 | #按架构删除 47 | clean: 48 | rm -rf $(build_dir) 49 | 50 | #全部删除 51 | cleanall: 52 | rm -rf build_x86 build_arm 53 | 54 | #命令前带“@”,表示不在终端上输出执行的命令 55 | #这个目标主要是用来调试Makefile时输出一些内容 56 | check: 57 | @echo $(CFLAGS) 58 | @echo $(CURDIR) 59 | @echo $(src_dir) 60 | @echo $(sources) 61 | @echo $(objects) 62 | 63 | #创建一个新目录create,用于存放过程文件 64 | create_build: 65 | @mkdir -p $(build_dir) 66 | 67 | -------------------------------------------------------------------------------- /APP/led/sys_class_gpio_export/c_systemcall/README.md: -------------------------------------------------------------------------------- 1 | # Readme.md 2 | ## 文件夹说明 3 | ### user
4 | + main.c:主函数 5 | ### src
6 | + bsp_led.c:LED灯相关的函数定义:
7 | + LED_GPIO_Config:用于初始化LED的GPIO引脚。GPIO4对应的是红灯;GPIO116对应的是绿灯;GPIO115对应的是蓝灯
8 | + LED_GPIO_DeInit:复位LED灯相应的GPIO端口 9 | ### inc
10 | + bsp_led.h:LED灯相关的函数声明,以及宏定义
11 | ### objs
12 | + 在编译过程中生成,用来存放编译过程中生成的目标文件(*.o)
13 | ### Makefile 14 | + 本例中使用的Makefile文件 15 | ### ***run.sh*** 16 | + 脚本文件,用来编译该工程 17 | ### ***led_demo*** 18 | + 编译生成的可执行文件,可以直接在板子上运行。 19 | 20 | 21 | 22 | ## 使用方法 23 | 1. 编译工程
24 | + **先切换到当前工程Makefile所在的目录**,再运行脚本run.sh,具体代码如下:
25 | ./run.sh 26 | 2. 执行程序
27 | + 通过以下命令,将可执行文件led_demo放到共享文件夹中(此处使用的是nfs共享文件的方式,其他方式请百度)
28 | #***代表共享目录的路径,例如,我配置的是家目录的workdir文件夹,则应该是~/workdir
29 | cp led_demo *** 30 | + 确保板子已经挂载上了nfs文件系统,切换到挂载的目录,执行以下命令
31 | ./led_demo
32 | 3. 若操作无误的话,我们可以看到板子的LED灯,轮流显示 “红绿蓝黄紫青白” 的颜色 33 | --- 34 | # 补充说明 35 | 若想要执行Clean Project的操作,可以使用以下命令:./run.sh clc -------------------------------------------------------------------------------- /APP/led/sys_class_gpio_export/c_systemcall/includes/bsp_led.h: -------------------------------------------------------------------------------- 1 | #ifndef _BSP_LED_H_ 2 | #define _BSP_LED_H_ 3 | //system函数的头文件 4 | #include 5 | /** 控制LED灯亮灭的宏, 6 | * LED低电平亮,设置ON=0,OFF=1 7 | * 若LED高电平亮,把宏设置成ON=1 ,OFF=0 即可 8 | */ 9 | #define ON 0 10 | #define OFF 1 11 | /* 带参宏,可以像内联函数一样使用 */ 12 | #define LED1(a) if (a) \ 13 | system("echo 1 >/sys/class/gpio/gpio4/value");\ 14 | else \ 15 | system("echo 0 >/sys/class/gpio/gpio4/value"); 16 | 17 | #define LED2(a) if (a) \ 18 | system("echo 1 >/sys/class/gpio/gpio116/value");\ 19 | else \ 20 | system("echo 0 >/sys/class/gpio/gpio116/value"); 21 | 22 | #define LED3(a) if (a) \ 23 | system("echo 1 >/sys/class/gpio/gpio115/value");\ 24 | else \ 25 | system("echo 0 >/sys/class/gpio/gpio115/value"); 26 | 27 | /* 基本混色,后面高级用法使用PWM可混出全彩颜色,且效果更好 */ 28 | 29 | //红 30 | #define LED_RED \ 31 | LED1(ON);\ 32 | LED2(OFF);\ 33 | LED3(OFF) 34 | 35 | //绿 36 | #define LED_GREEN \ 37 | LED1(OFF);\ 38 | LED2(ON);\ 39 | LED3(OFF) 40 | 41 | //蓝 42 | #define LED_BLUE \ 43 | LED1(OFF);\ 44 | LED2(OFF);\ 45 | LED3(ON) 46 | 47 | 48 | //黄(红+绿) 49 | #define LED_YELLOW \ 50 | LED1(ON);\ 51 | LED2(ON);\ 52 | LED3(OFF) 53 | 54 | //紫(红+蓝) 55 | #define LED_PURPLE \ 56 | LED1(ON);\ 57 | LED2(OFF);\ 58 | LED3(ON) 59 | 60 | //青(绿+蓝) 61 | #define LED_CYAN \ 62 | LED1(OFF);\ 63 | LED2(ON);\ 64 | LED3(ON) 65 | 66 | //白(红+绿+蓝) 67 | #define LED_WHITE \ 68 | LED1(ON);\ 69 | LED2(ON);\ 70 | LED3(ON) 71 | 72 | //黑(全部关闭) 73 | #define LED_RGBOFF \ 74 | LED1(OFF);\ 75 | LED2(OFF);\ 76 | LED3(OFF) 77 | 78 | extern void LED_GPIO_Config(void); 79 | extern void LED_GPIO_DeInit(void); 80 | #endif /* _BSP_LED_H_ */ 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /APP/led/sys_class_gpio_export/c_systemcall/sources/bsp_led.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "bsp_led.h" 4 | 5 | /** 6 | * @brief GPIO初始化函数 7 | * @param 无 8 | * @retval 无 9 | */ 10 | 11 | void LED_GPIO_Config(void) 12 | { 13 | //Init GPIO for Red 14 | system("echo 4 > /sys/class/gpio/export"); 15 | system("echo 'out' > /sys/class/gpio/gpio4/direction"); 16 | LED1(OFF); 17 | //Init GPIO for Green 18 | system("echo 116 > /sys/class/gpio/export"); 19 | system("echo 'out' > /sys/class/gpio/gpio116/direction"); 20 | LED2(OFF); 21 | //Init GPIO for Blue 22 | system("echo 115 > /sys/class/gpio/export"); 23 | system("echo 'out' > /sys/class/gpio/gpio115/direction"); 24 | LED3(OFF); 25 | } 26 | 27 | /** 28 | * @brief GPIO复位函数 29 | * @param 无 30 | * @retval 无 31 | */ 32 | 33 | void LED_GPIO_DeInit(void) 34 | { 35 | system("echo 4 > /sys/class/gpio/unexport"); 36 | 37 | system("echo 116 > /sys/class/gpio/unexport"); 38 | 39 | system("echo 115 > /sys/class/gpio/unexport"); 40 | } -------------------------------------------------------------------------------- /APP/led/sys_class_gpio_export/c_systemcall/sources/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "bsp_led.h" 3 | #include 4 | 5 | /** 6 | * @brief 延时函数 7 | * @param 无 8 | * @retval 无 9 | */ 10 | void Delay() 11 | { 12 | sleep(1); 13 | } 14 | /** 15 | * @brief 主函数 16 | * @param 无 17 | * @retval 无 18 | */ 19 | int main(int argc, char *argv[]) 20 | { 21 | printf("This is the led demo\n"); 22 | LED_GPIO_Config(); 23 | 24 | while(1){ 25 | /*轮流显示 红绿蓝黄紫青白 颜色*/ 26 | LED_RED; 27 | Delay(); 28 | 29 | LED_GREEN; 30 | Delay(); 31 | 32 | LED_BLUE; 33 | Delay(); 34 | 35 | LED_YELLOW; 36 | Delay(); 37 | 38 | LED_PURPLE; 39 | Delay(); 40 | 41 | LED_CYAN; 42 | Delay(); 43 | 44 | LED_WHITE 45 | Delay(); 46 | 47 | LED_RGBOFF; 48 | Delay(); 49 | } 50 | 51 | LED_GPIO_DeInit(); 52 | return 0; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /APP/led/sys_class_gpio_export/shell/led.sh: -------------------------------------------------------------------------------- 1 | #RGB灯脚本 2 | #此脚本使用/bin/sh来解释执行 3 | 4 | #!/bin/bash 5 | 6 | while true 7 | do 8 | echo "=================LED test,Press q to exit=================" 9 | echo "Please Input the RGB index : 4/116/115(4--R 116--G 115--B)" 10 | #等待输入灯的编号 11 | read index 12 | #输入有效性检测 13 | case $index in 14 | 4) 15 | ;; 16 | 115) 17 | ;; 18 | 116) 19 | ;; 20 | q) echo "quit" 21 | exit 0 22 | ;; 23 | *) echo "Incorrect format input" 24 | continue 25 | ;; 26 | esac 27 | 28 | while true 29 | do 30 | echo "Please Input the value : 0-on 1-off" 31 | #输入LED的值 32 | read value 33 | #输入有效性检测 34 | case $value in 35 | 0) break 36 | ;; 37 | 1) break 38 | ;; 39 | q) echo "quit" 40 | exit 0 41 | ;; 42 | *) echo "Incorrect format input" 43 | continue 44 | ;; 45 | esac 46 | done 47 | 48 | #是否初始化LED灯 49 | if [ ! -e /tmp/led$index ] 50 | then 51 | echo "init led hardware" > /tmp/led$index 52 | #初始化相应的GPIO口 53 | echo $index > /sys/class/gpio/export 54 | #设置GPIO口的方法,由于是用于点亮RGB灯,因此设置为输出模式 55 | echo 'out' > /sys/class/gpio/gpio$index/direction 56 | fi 57 | 58 | #控制LED灯的亮灭。 59 | echo $value > /sys/class/gpio/gpio$index/value 60 | done 61 | -------------------------------------------------------------------------------- /APP/led/sys_class_leds/README.md: -------------------------------------------------------------------------------- 1 | # LED点灯示例 2 | 3 | LED示例,硬件相关的示例依赖于设备树。 4 | 在应用层点亮LED灯有`/sys/class/gpio_export`和`/sys/class/leds`两种方式, 5 | 受设备树的影响,本开发板默认**只能**使用`/sys/class/leds`示例控制板上RGB和心跳灯。 6 | 默认情况下,使用`/sys/class/gpio_export`示例**无法**对板载LED灯进行控制。 7 | 8 | 本目录下的示例使用`/sys/class/leds`的LED设备,默认可以正常运行,使用可确认通过查看是否存在相应的设备文件确认。 9 | 10 | 各个目录的演示说明如下: 11 | 1. c_shell:使用C代码执行shell命令的控制方式,这是比较傻的方式,只是作为参考 12 | 2. c_stdio:使用C标准库文件操作方式点灯 13 | 3. c_systemcall:使用系统调用的文件操作方式点灯 14 | 4. shell:使用shell命令点灯 15 | 16 | 由于主机的Ubuntu系统没有LED设备,所以这些示例不能在主机上运行。 17 | 在配套的ARM开发板可以运行 18 | 19 | ## c_stdio范例说明 20 | 使用库函数fopen、fread、fwrite、fclose、fflush控制led设备。 21 | 22 | ### 编译 23 | 24 | 25 | 编译的输出目录为`build_xxx/led_demo`文件 26 | 切换至Makefile所在目录,使用如下命令编译: 27 | ARM平台编译指令: 28 | ``` bash 29 | make ARCH=arm 30 | ``` 31 | 32 | ### 运行 33 | Ubuntu主机通常没有LED设备,本实验不支持在主机上运行。 34 | 编译后在ARM终端上使用如下命令运行: 35 | ``` bash 36 | #在ARM终端对应的目录下运行 37 | ./build_arm/led_demo 38 | ``` 39 | 40 | 41 | ------- 42 | 43 | 44 | ## c_systemcall范例 45 | 使用系统open、read、write、close、ioctl等底层函数控制LED设备。 46 | 47 | 48 | ### 编译和运行 49 | 本示例的编译和运行与stdio的相同,切换至相应目录以同样的方式操作即可 50 | 51 | ------- 52 | 53 | 54 | ## c_shell范例 55 | 使用系统system系统调用的方式执行命令行。 56 | 57 | 58 | ### 编译和运行 59 | 本示例的编译和运行与stdio的相同,切换至相应目录以同样的方式操作即可 60 | 61 | ------- 62 | 63 | ## shell范例 64 | 使用echo等脚本控制LED设备。 65 | 66 | 67 | ### 运行 68 | Ubuntu主机通常没有LED设备,本实验不支持在主机上运行。 69 | 70 | 脚本本身可能没有可执行权限,需要添加权限后再运行,使用如下命令: 71 | ```bash 72 | #在ARM终端对应的脚本目录下执行如下命令 73 | #添加可执行权限 74 | chmod u+x led.sh 75 | #运行 76 | ./led.sh 77 | ``` 78 | -------------------------------------------------------------------------------- /APP/led/sys_class_leds/c_shell/Makefile: -------------------------------------------------------------------------------- 1 | 2 | #生成可执行文件的名称 3 | Target = led_demo 4 | ARCH ?= x86 5 | #编译器CC 6 | #根据传入的参数ARCH,确定使用的编译器 7 | #默认使用gcc编译器 8 | #make ARCH=arm 时使用ARM-GCC编译器 9 | ifeq ($(ARCH), x86) 10 | CC = gcc 11 | else 12 | CC = arm-linux-gnueabihf-gcc 13 | endif 14 | #存放中间文件的路径 15 | build_dir = build_$(ARCH) 16 | #存放源文件的文件夹 17 | src_dir = sources 18 | #存放头文件的文件夹 19 | inc_dir = includes . 20 | 21 | #源文件 22 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 23 | #目标文件(*.o) 24 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 25 | #头文件 26 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 27 | #编译参数 28 | #指定头文件的路径 29 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 30 | 31 | #链接过程 32 | #开发板上无法使用动态库,因此使用静态链接的方式 33 | $(build_dir)/$(Target) : $(objects) | create_build 34 | $(CC) $^ -o $@ 35 | 36 | #编译工程 37 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : $(src_dir)/%.c $(includes) | create_build 39 | $(CC) -c $(CFLAGS) $< -o $@ 40 | 41 | 42 | #以下为伪目标,调用方式:make 伪目标 43 | #clean:用于Clean Project 44 | #check:用于检查某个变量的值 45 | .PHONY:clean cleanall check create_build 46 | #按架构删除 47 | clean: 48 | rm -rf $(build_dir) 49 | 50 | #全部删除 51 | cleanall: 52 | rm -rf build_x86 build_arm 53 | 54 | #命令前带“@”,表示不在终端上输出执行的命令 55 | #这个目标主要是用来调试Makefile时输出一些内容 56 | check: 57 | @echo $(CFLAGS) 58 | @echo $(CURDIR) 59 | @echo $(src_dir) 60 | @echo $(sources) 61 | @echo $(objects) 62 | 63 | #创建一个新目录create,用于存放过程文件 64 | create_build: 65 | @mkdir -p $(build_dir) 66 | 67 | -------------------------------------------------------------------------------- /APP/led/sys_class_leds/c_shell/sources/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | //通过system执行shell命令 7 | //ARM 开发板LED设备的路径 8 | #define RLED_ON system("echo 255 > /sys/class/leds/red/brightness"); 9 | #define RLED_OFF system("echo 0 > /sys/class/leds/red/brightness"); 10 | #define GLED_ON system("echo 255 > /sys/class/leds/green/brightness"); 11 | #define GLED_OFF system("echo 0 > /sys/class/leds/green/brightness"); 12 | #define BLED_ON system("echo 255 > /sys/class/leds/blue/brightness"); 13 | #define BLED_OFF system("echo 0 > /sys/class/leds/blue/brightness"); 14 | 15 | //通过system执行shell命令 16 | //Ubuntu主机LED设备的路径,具体请根据自己的主机LED设备修改 17 | // #define RLED_ON system("echo 255 > /sys/class/leds/input2::capslock/brightness"); 18 | // #define RLED_OFF system("echo 0 > /sys/class/leds/input2::capslock/brightness"); 19 | // #define GLED_ON system("echo 255 > /sys/class/leds/input2::numlock/brightness"); 20 | // #define GLED_OFF system("echo 0 > /sys/class/leds/input2::numlock/brightness"); 21 | // #define BLED_ON system("echo 255 > /sys/class/leds/input2::scrolllock/brightness"); 22 | // #define BLED_OFF system("echo 0 > /sys/class/leds/input2::scrolllock/brightness"); 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | while(1){ 27 | printf("This is the led demo.\n"); 28 | RLED_ON; 29 | sleep(1); 30 | RLED_OFF 31 | 32 | GLED_ON 33 | sleep(1); 34 | GLED_OFF 35 | 36 | BLED_ON 37 | sleep(1); 38 | BLED_OFF 39 | } 40 | } -------------------------------------------------------------------------------- /APP/led/sys_class_leds/c_stdio/Makefile: -------------------------------------------------------------------------------- 1 | 2 | #生成可执行文件的名称 3 | Target = led_demo 4 | ARCH ?= x86 5 | #编译器CC 6 | #根据传入的参数ARCH,确定使用的编译器 7 | #默认使用gcc编译器 8 | #make ARCH=arm 时使用ARM-GCC编译器 9 | ifeq ($(ARCH), x86) 10 | CC = gcc 11 | else 12 | CC = arm-linux-gnueabihf-gcc 13 | endif 14 | #存放中间文件的路径 15 | build_dir = build_$(ARCH) 16 | #存放源文件的文件夹 17 | src_dir = sources 18 | #存放头文件的文件夹 19 | inc_dir = includes . 20 | 21 | #源文件 22 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 23 | #目标文件(*.o) 24 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 25 | #头文件 26 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 27 | #编译参数 28 | #指定头文件的路径 29 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 30 | 31 | #链接过程 32 | #开发板上无法使用动态库,因此使用静态链接的方式 33 | $(build_dir)/$(Target) : $(objects) | create_build 34 | $(CC) $^ -o $@ 35 | 36 | #编译工程 37 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : $(src_dir)/%.c $(includes) | create_build 39 | $(CC) -c $(CFLAGS) $< -o $@ 40 | 41 | 42 | #以下为伪目标,调用方式:make 伪目标 43 | #clean:用于Clean Project 44 | #check:用于检查某个变量的值 45 | .PHONY:clean cleanall check create_build 46 | #按架构删除 47 | clean: 48 | rm -rf $(build_dir) 49 | 50 | #全部删除 51 | cleanall: 52 | rm -rf build_x86 build_arm 53 | 54 | #命令前带“@”,表示不在终端上输出执行的命令 55 | #这个目标主要是用来调试Makefile时输出一些内容 56 | check: 57 | @echo $(CFLAGS) 58 | @echo $(CURDIR) 59 | @echo $(src_dir) 60 | @echo $(sources) 61 | @echo $(objects) 62 | 63 | #创建一个新目录create,用于存放过程文件 64 | create_build: 65 | @mkdir -p $(build_dir) 66 | 67 | -------------------------------------------------------------------------------- /APP/led/sys_class_leds/c_stdio/sources/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | //ARM 开发板LED设备的路径 6 | #define RLED_DEV_PATH "/sys/class/leds/red/brightness" 7 | #define GLED_DEV_PATH "/sys/class/leds/green/brightness" 8 | #define BLED_DEV_PATH "/sys/class/leds/blue/brightness" 9 | 10 | //Ubuntu主机LED设备的路径,具体请根据自己的主机LED设备修改 11 | // #define RLED_DEV_PATH "/sys/class/leds/input2::capslock/brightness" 12 | // #define GLED_DEV_PATH "/sys/class/leds/input2::numlock/brightness" 13 | // #define BLED_DEV_PATH "/sys/class/leds/input2::scrolllock/brightness" 14 | 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | FILE *r_fd, *g_fd, *b_fd; 19 | 20 | printf("This is the led demo\n"); 21 | //获取红灯的设备文件描述符 22 | r_fd = fopen(RLED_DEV_PATH, "w"); 23 | if(r_fd < 0){ 24 | printf("Fail to Open %s device\n", RLED_DEV_PATH); 25 | exit(1); 26 | } 27 | 28 | //获取绿灯的设备文件描述符 29 | g_fd = fopen(GLED_DEV_PATH, "w"); 30 | if(g_fd < 0){ 31 | printf("Fail to Open %s device\n", GLED_DEV_PATH); 32 | exit(1); 33 | } 34 | 35 | //获取蓝灯的设备文件描述符 36 | b_fd = fopen(BLED_DEV_PATH, "w"); 37 | if(b_fd < 0){ 38 | printf("Fail to Open %s device\n", BLED_DEV_PATH); 39 | exit(1); 40 | } 41 | 42 | while(1){ 43 | //红灯亮 44 | fwrite("255",3,1,r_fd); 45 | fflush(r_fd); 46 | //延时1s 47 | sleep(1); 48 | //红灯灭 49 | fwrite("0",1,1,r_fd); 50 | fflush(r_fd); 51 | 52 | //绿灯亮 53 | fwrite("255",3,1,g_fd); 54 | fflush(g_fd); 55 | //延时1s 56 | sleep(1); 57 | //绿灯灭 58 | fwrite("0",1,1,g_fd); 59 | fflush(g_fd); 60 | 61 | //蓝灯亮 62 | fwrite("255",3,1,b_fd); 63 | fflush(b_fd); 64 | //延时1s 65 | sleep(1); 66 | //蓝灯亮 67 | fwrite("0",1,1,b_fd); 68 | fflush(b_fd); 69 | } 70 | } -------------------------------------------------------------------------------- /APP/led/sys_class_leds/c_systemcall/Makefile: -------------------------------------------------------------------------------- 1 | 2 | #生成可执行文件的名称 3 | Target = led_demo 4 | ARCH ?= x86 5 | #编译器CC 6 | #根据传入的参数ARCH,确定使用的编译器 7 | #默认使用gcc编译器 8 | #make ARCH=arm 时使用ARM-GCC编译器 9 | ifeq ($(ARCH), x86) 10 | CC = gcc 11 | else 12 | CC = arm-linux-gnueabihf-gcc 13 | endif 14 | #存放中间文件的路径 15 | build_dir = build_$(ARCH) 16 | #存放源文件的文件夹 17 | src_dir = sources 18 | #存放头文件的文件夹 19 | inc_dir = includes . 20 | 21 | #源文件 22 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 23 | #目标文件(*.o) 24 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 25 | #头文件 26 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 27 | #编译参数 28 | #指定头文件的路径 29 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 30 | 31 | #链接过程 32 | #开发板上无法使用动态库,因此使用静态链接的方式 33 | $(build_dir)/$(Target) : $(objects) | create_build 34 | $(CC) $^ -o $@ 35 | 36 | #编译工程 37 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : $(src_dir)/%.c $(includes) | create_build 39 | $(CC) -c $(CFLAGS) $< -o $@ 40 | 41 | 42 | #以下为伪目标,调用方式:make 伪目标 43 | #clean:用于Clean Project 44 | #check:用于检查某个变量的值 45 | .PHONY:clean cleanall check create_build 46 | #按架构删除 47 | clean: 48 | rm -rf $(build_dir) 49 | 50 | #全部删除 51 | cleanall: 52 | rm -rf build_x86 build_arm 53 | 54 | #命令前带“@”,表示不在终端上输出执行的命令 55 | #这个目标主要是用来调试Makefile时输出一些内容 56 | check: 57 | @echo $(CFLAGS) 58 | @echo $(CURDIR) 59 | @echo $(src_dir) 60 | @echo $(sources) 61 | @echo $(objects) 62 | 63 | #创建一个新目录create,用于存放过程文件 64 | create_build: 65 | @mkdir -p $(build_dir) 66 | 67 | -------------------------------------------------------------------------------- /APP/led/sys_class_leds/c_systemcall/sources/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | //ARM 开发板LED设备的路径 9 | #define RLED_DEV_PATH "/sys/class/leds/red/brightness" 10 | #define GLED_DEV_PATH "/sys/class/leds/green/brightness" 11 | #define BLED_DEV_PATH "/sys/class/leds/blue/brightness" 12 | 13 | //Ubuntu主机LED设备的路径,具体请根据自己的主机LED设备修改 14 | // #define RLED_DEV_PATH "/sys/class/leds/input2::capslock/brightness" 15 | // #define GLED_DEV_PATH "/sys/class/leds/input2::numlock/brightness" 16 | // #define BLED_DEV_PATH "/sys/class/leds/input2::scrolllock/brightness" 17 | 18 | 19 | int main(int argc, char *argv[]) 20 | { 21 | int res = 0; 22 | int r_fd, g_fd, b_fd; 23 | 24 | printf("This is the led demo\n"); 25 | //获取红灯的设备文件描述符 26 | r_fd = open(RLED_DEV_PATH, O_WRONLY); 27 | if(r_fd < 0){ 28 | printf("Fail to Open %s device\n", RLED_DEV_PATH); 29 | exit(1); 30 | } 31 | //获取绿灯的设备文件描述符 32 | g_fd = open(GLED_DEV_PATH, O_WRONLY); 33 | if(g_fd < 0){ 34 | printf("Fail to Open %s device\n", GLED_DEV_PATH); 35 | exit(1); 36 | } 37 | //获取蓝灯的设备文件描述符 38 | b_fd = open(BLED_DEV_PATH, O_WRONLY); 39 | if(b_fd < 0){ 40 | printf("Fail to Open %s device\n", BLED_DEV_PATH); 41 | exit(1); 42 | } 43 | 44 | while(1){ 45 | //红灯亮 46 | write(r_fd, "255", 3); 47 | //延时1s 48 | sleep(1); 49 | //红灯灭 50 | write(r_fd, "0", 1); 51 | 52 | //绿灯亮 53 | write(g_fd, "255", 3); 54 | //延时1s 55 | sleep(1); 56 | //绿灯灭 57 | write(g_fd, "0", 1); 58 | 59 | //蓝灯亮 60 | write(b_fd, "255", 3); 61 | //延时1s 62 | sleep(1); 63 | //蓝灯亮 64 | write(b_fd, "0", 1); 65 | } 66 | } -------------------------------------------------------------------------------- /APP/led/sys_class_leds/shell/led.sh: -------------------------------------------------------------------------------- 1 | #RGB灯脚本 2 | #此脚本使用/bin/bash来解释执行 3 | 4 | #!/bin/bash 5 | 6 | function led1(){ 7 | echo $1 > /sys/class/leds/red/brightness 8 | } 9 | 10 | function led2(){ 11 | echo $1 > /sys/class/leds/green/brightness 12 | } 13 | 14 | function led3(){ 15 | echo $1 > /sys/class/leds/blue/brightness 16 | } 17 | 18 | 19 | function led_red(){ 20 | led1 255 21 | led2 0 22 | led3 0 23 | } 24 | 25 | function led_green(){ 26 | led1 0 27 | led2 255 28 | led3 0 29 | } 30 | 31 | function led_blue(){ 32 | led1 0 33 | led2 0 34 | led3 255 35 | } 36 | 37 | keep_alive () { 38 | while : ; do 39 | sleep 1 40 | echo "led_demo is running. Press Ctrl+C to exit!" 41 | done 42 | } 43 | keep_alive & 44 | while true 45 | do 46 | led_red 47 | sleep 1 48 | led_green 49 | sleep 1 50 | led_blue 51 | sleep 1 52 | done 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /APP/makefile_step/README.md: -------------------------------------------------------------------------------- 1 | # Makefile步步为营 2 | 本目录主要包含Makefile一步步递进学习的示例代码 3 | 4 | 5 | ## step0:Makefile小实验 6 | 进行Makefile小实验,体验Makefile的功能。 7 | 目录中的`Makefile`是不严谨的编写方式。 8 | 目录中的`Makefile_PHONY`是严谨的编写方式。 9 | 10 | ### make实验 11 | 12 | 切换至step0目录下,即Makefile所在的同级目录,使用如下命令实验: 13 | ``` bash 14 | #在主机上Makefile所在的目录执行如下命令 15 | #查看当前目录的内容 16 | ls 17 | #执行make命令,make会在当前目录下搜索“Makefile”或“makefile”,并执行 18 | make 19 | #可看到make命令后的输出,它执行了Makefile中编写的命令 20 | #查看执行make命令后的目录内容,多了test.txt文件 21 | ls 22 | #执行Makefile的targetd目标,并查看,少了test.txt文件 23 | make targetd 24 | ls 25 | #执行Makefile的targetb目标,并查看,又生成了test.txt文件 26 | make targetb 27 | ls 28 | #执行Makefile的targetc目标 29 | make targetc 30 | ``` 31 | 32 | make使用` -f `参数可以指定使用其它文件。 33 | 34 | ``` bash 35 | #通过-f选项指定make使用的Makefile文件 36 | make -f Makefile_PHONY 37 | #本示例中其它操作与Makefile功能相同 38 | 39 | ``` 40 | 41 | ------- 42 | 43 | 44 | ## step1:使用Makefile编译程序 45 | 使用Makefile编译Hello示例程序。 46 | 47 | ### 编译 48 | 编译的输出为`hello_main`文件 49 | 切换至step1目录下,即Makefile所在的同级目录,使用如下命令编译: 50 | ``` bash 51 | #后编译 52 | make 53 | ``` 54 | 55 | ### 运行 56 | 57 | 编译后使用如下命令运行: 58 | ``` bash 59 | ./hello_main 60 | ``` 61 | 62 | ---------- 63 | 64 | ## step2:使用Makefile默认编译规则 65 | 使用Makefile编译Hello示例程序,Makefile中使用o文件依赖 66 | 67 | ### 编译及运行 68 | 本实验编译及运行操作与step1相同,切换至step2目录操作即可。 69 | 70 | ---------- 71 | 72 | ## step3:使用变量 73 | 使用Makefile编译Hello示例程序,Makefile中使用变量 74 | 75 | ### 编译及运行 76 | 本实验编译及运行操作与step1相同,切换至step3目录操作即可。 77 | 78 | ### Makefile_test实验 79 | Makefile_test文件用于变量赋值实验测试,可执行如下命令实验: 80 | 81 | ```bash 82 | make -f Makefile 83 | #实验输出为Makefile中各个变量的值 84 | ``` 85 | 86 | ---------- 87 | 88 | 89 | ## step4:使用变量及分支 90 | 使用Makefile编译Hello示例程序,Makefile中使用变量定义最终目标,并使用分支支持不同的架构 91 | 92 | ### x86架构编译及运行 93 | 切换至step4目录下,即Makefile所在的同级目录,使用如下命令编译: 94 | ``` bash 95 | #先清理,否则可能因为*.o文件架构不同而出错 96 | make clean 97 | #后编译 98 | make 99 | ``` 100 | 101 | 编译后使用如下命令运行: 102 | ``` bash 103 | ./hello_main 104 | ``` 105 | 106 | ### ARM架构编译及运行 107 | 切换至step4目录下,即Makefile所在的同级目录,使用如下命令编译: 108 | ``` bash 109 | #先清理,否则可能因为*.o文件架构不同而出错 110 | make clean 111 | #后编译 112 | make ARCH=arm 113 | ``` 114 | 115 | 编译后使用如下命令运行: 116 | ``` bash 117 | ./hello_main 118 | ``` 119 | 120 | ------- 121 | 122 | ## step5:使用函数 123 | 使用Makefile编译Hello示例程序,Makefile中使用函数,并支持层级目录。 124 | 125 | ### x86架构编译及运行 126 | 切换至step5目录下,即Makefile所在的同级目录,使用如下命令编译: 127 | ``` bash 128 | make 129 | ``` 130 | 编译的输出目录为`bulid_x86` 131 | 132 | 编译后使用如下命令运行: 133 | ``` bash 134 | .bulid_x86/hello_main 135 | ``` 136 | 137 | ### ARM架构编译及运行 138 | 切换至step5目录下,即Makefile所在的同级目录,使用如下命令编译: 139 | ``` bash 140 | make ARCH=arm 141 | ``` 142 | 编译的输出目录为`bulid_arm` 143 | 144 | 编译后使用如下命令运行: 145 | ``` bash 146 | .bulid_arm/hello_main 147 | ``` 148 | ### 清理文件 149 | 若要清理文件,也要指定架构 150 | 151 | 1. 清理x86的编译输出,默认架构为x86,直接make clean即可: 152 | ```bash 153 | make clean 154 | ``` 155 | 156 | 2. 清理arm的编译输出,需要使用ARCH=arm指定: 157 | ```bash 158 | make clean ARCH=arm 159 | ``` 160 | 161 | 3. 清理所有的编译输出,可以直接使用cleanall目标: 162 | ```bash 163 | make cleanall 164 | ``` 165 | 166 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /APP/makefile_step/step0/Makefile: -------------------------------------------------------------------------------- 1 | #Makefile格式 2 | #目标:依赖的文件或其它目标 3 | #Tab 命令1 4 | #Tab 命令2 5 | 6 | #第一个目标,是最终目标及make的默认目标 7 | #目标a,依赖于目标targetc和targetb 8 | #目标要执行的shell命令 ls -lh,列出目录下的内容 9 | targeta: targetc targetb 10 | ls -lh 11 | 12 | #目标b,无依赖 13 | #目标要执行的shell命令,使用touch创建test.txt文件 14 | targetb: 15 | touch test.txt 16 | 17 | #目标c,无依赖 18 | #目标要执行的shell命令,pwd显示当前路径 19 | targetc: 20 | pwd 21 | 22 | #目标d,无依赖 23 | #由于abc目标都不依赖于目标d,所以直接make时目标d不会被执行 24 | #可以使用make targetd命令执行 25 | targetd: 26 | rm -f test.txt 27 | 28 | 29 | -------------------------------------------------------------------------------- /APP/makefile_step/step0/Makefile_PHONY: -------------------------------------------------------------------------------- 1 | #Makefile格式 2 | #目标:依赖的文件或其它目标 3 | #Tab 命令1 4 | #Tab 命令2 5 | 6 | #第一个目标,是最终目标及make的默认目标 7 | #目标a,依赖于目标targetc和targetb 8 | #目标要执行的shell命令 ls -lh,列出目录下的内容 9 | .PHONY:targeta 10 | targeta: targetc targetb 11 | ls -lh 12 | 13 | #目标b,无依赖 14 | #目标要执行的shell命令,使用touch创建test.txt文件 15 | .PHONY:targetb 16 | targetb: 17 | touch test.txt 18 | 19 | #目标c,无依赖 20 | #目标要执行的shell命令,pwd显示当前路径 21 | .PHONY:targetc 22 | targetc: 23 | pwd 24 | 25 | #目标d,无依赖 26 | #由于abc目标都不依赖于目标d,所以直接make时目标d不会被执行 27 | #可以使用make targetd命令执行 28 | .PHONY:targetd 29 | targetd: 30 | rm -f test.txt 31 | 32 | 33 | -------------------------------------------------------------------------------- /APP/makefile_step/step0/test.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/APP/makefile_step/step0/test.txt -------------------------------------------------------------------------------- /APP/makefile_step/step1/Makefile: -------------------------------------------------------------------------------- 1 | #Makefile格式 2 | #目标:依赖 3 | #Tab 命令1 4 | #Tab 命令2 5 | 6 | #默认目标 7 | #hello_main依赖于hello_main.c和hello_func.c文件 8 | hello_main: hello_main.c hello_func.c 9 | gcc -o hello_main hello_main.c hello_func.c -I . 10 | 11 | 12 | #clean伪目标,用来删除编译生成的文件 13 | .PHONY:clean 14 | clean: 15 | rm -f *.o hello_main -------------------------------------------------------------------------------- /APP/makefile_step/step1/hello_func.c: -------------------------------------------------------------------------------- 1 | /* $begin hello_func */ 2 | #include 3 | #include "hello_func.h" 4 | 5 | void hello_func(void) 6 | { 7 | printf("hello, world! This is a C program.\n"); 8 | for(int i=0;i<10;i++ ){ 9 | printf("output i=%d\n",i); 10 | } 11 | } 12 | /* $end hello_func */ 13 | 14 | -------------------------------------------------------------------------------- /APP/makefile_step/step1/hello_func.h: -------------------------------------------------------------------------------- 1 | /* $begin hello_func_h */ 2 | 3 | void hello_func(void); 4 | /* $end hello_func_h */ 5 | 6 | -------------------------------------------------------------------------------- /APP/makefile_step/step1/hello_main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/APP/makefile_step/step1/hello_main -------------------------------------------------------------------------------- /APP/makefile_step/step1/hello_main.c: -------------------------------------------------------------------------------- 1 | /* $begin hello_main */ 2 | #include "hello_func.h" 3 | 4 | int main() 5 | { 6 | hello_func(); 7 | return 0; 8 | } 9 | /* $end hello_main */ 10 | 11 | -------------------------------------------------------------------------------- /APP/makefile_step/step2/Makefile: -------------------------------------------------------------------------------- 1 | #Makefile格式 2 | #目标文件:依赖的文件 3 | #Tab 命令1 4 | #Tab 命令2 5 | hello_main: hello_main.o hello_func.o 6 | gcc -o hello_main hello_main.o hello_func.o 7 | 8 | #以下是make的默认规则,下面两行可以不写 9 | #hello_main.o: hello_main.c 10 | # gcc -c hello_main.c 11 | 12 | #以下是make的默认规则,下面两行可以不写 13 | #hello_func.o: hello_func.c 14 | # gcc -c hello_func.c 15 | 16 | 17 | #伪目标 18 | .PHONY: clean 19 | clean: 20 | rm -f *.o hello_main -------------------------------------------------------------------------------- /APP/makefile_step/step2/hello_func.c: -------------------------------------------------------------------------------- 1 | /* $begin hello_func */ 2 | #include 3 | #include "hello_func.h" 4 | 5 | void hello_func(void) 6 | { 7 | printf("hello, world! This is a C program.\n"); 8 | for(int i=0;i<10;i++ ){ 9 | printf("output i=%d\n",i); 10 | } 11 | } 12 | /* $end hello_func */ 13 | 14 | -------------------------------------------------------------------------------- /APP/makefile_step/step2/hello_func.h: -------------------------------------------------------------------------------- 1 | /* $begin hello_func_h */ 2 | 3 | void hello_func(void); 4 | /* $end hello_func_h */ 5 | 6 | -------------------------------------------------------------------------------- /APP/makefile_step/step2/hello_main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/APP/makefile_step/step2/hello_main -------------------------------------------------------------------------------- /APP/makefile_step/step2/hello_main.c: -------------------------------------------------------------------------------- 1 | /* $begin hello_main */ 2 | #include "hello_func.h" 3 | 4 | int main() 5 | { 6 | hello_func(); 7 | return 0; 8 | } 9 | /* $end hello_main */ 10 | 11 | -------------------------------------------------------------------------------- /APP/makefile_step/step3/Makefile: -------------------------------------------------------------------------------- 1 | #Makefile格式 2 | #目标文件:依赖的文件 3 | #Tab 命令1 4 | #Tab 命令2 5 | 6 | #定义变量 7 | CC = gcc 8 | CFLAGS = -I. 9 | DEPS = hello_func.h 10 | 11 | 12 | #目标文件 13 | hello_main: hello_main.o hello_func.o 14 | $(CC) -o hello_main hello_main.o hello_func.o 15 | 16 | #*.o文件的生成规则 17 | %.o: %.c $(DEPS) 18 | $(CC) -c -o $@ $< $(CFLAGS) 19 | 20 | #伪目标 21 | .PHONY: clean 22 | clean: 23 | rm -f *.o hello_main -------------------------------------------------------------------------------- /APP/makefile_step/step3/Makefile_test: -------------------------------------------------------------------------------- 1 | VAR_A = FILEA 2 | VAR_B = $(VAR_A) 3 | VAR_C := $(VAR_A) 4 | VAR_A += FILEB 5 | VAR_D ?= FILED 6 | .PHONY:check 7 | check: 8 | @echo "VAR_A:"$(VAR_A) 9 | @echo "VAR_B:"$(VAR_B) 10 | @echo "VAR_C:"$(VAR_C) 11 | @echo "VAR_D:"$(VAR_D) 12 | -------------------------------------------------------------------------------- /APP/makefile_step/step3/hello_func.c: -------------------------------------------------------------------------------- 1 | /* $begin hello_func */ 2 | #include 3 | #include "hello_func.h" 4 | 5 | void hello_func(void) 6 | { 7 | printf("hello, world! This is a C program.\n"); 8 | for(int i=0;i<10;i++ ){ 9 | printf("output i=%d\n",i); 10 | } 11 | } 12 | /* $end hello_func */ 13 | 14 | -------------------------------------------------------------------------------- /APP/makefile_step/step3/hello_func.h: -------------------------------------------------------------------------------- 1 | /* $begin hello_func_h */ 2 | 3 | void hello_func(void); 4 | /* $end hello_func_h */ 5 | 6 | -------------------------------------------------------------------------------- /APP/makefile_step/step3/hello_main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/APP/makefile_step/step3/hello_main -------------------------------------------------------------------------------- /APP/makefile_step/step3/hello_main.c: -------------------------------------------------------------------------------- 1 | /* $begin hello_main */ 2 | #include "hello_func.h" 3 | 4 | int main() 5 | { 6 | hello_func(); 7 | return 0; 8 | } 9 | /* $end hello_main */ 10 | 11 | -------------------------------------------------------------------------------- /APP/makefile_step/step4/Makefile: -------------------------------------------------------------------------------- 1 | #Makefile格式 2 | #目标文件:依赖的文件 3 | #Tab 命令1 4 | #Tab 命令2 5 | 6 | #定义变量 7 | #ARCH默认为x86,使用gcc编译器, 8 | #否则使用ARM编译器 9 | ARCH ?= x86 10 | TARGET = hello_main 11 | CFLAGS = -I. 12 | DEPS = hello_func.h 13 | OBJS = hello_main.o hello_func.o 14 | 15 | 16 | #根据输入的ARCH变量来选择编译器 17 | #ARCH=x86,使用gcc 18 | #ARCH=arm,使用arm-gcc 19 | ifeq ($(ARCH),x86) 20 | CC = gcc 21 | else 22 | CC = arm-linux-gnueabihf-gcc 23 | endif 24 | 25 | #目标文件 26 | $(TARGET): $(OBJS) 27 | $(CC) -o $@ $^ $(CFLAGS) 28 | 29 | #*.o文件的生成规则 30 | %.o: %.c $(DEPS) 31 | $(CC) -c -o $@ $< $(CFLAGS) 32 | 33 | #伪目标 34 | .PHONY: clean 35 | clean: 36 | rm -f *.o hello_main -------------------------------------------------------------------------------- /APP/makefile_step/step4/hello_func.c: -------------------------------------------------------------------------------- 1 | /* $begin hello_func */ 2 | #include 3 | #include "hello_func.h" 4 | 5 | void hello_func(void) 6 | { 7 | printf("hello, world! This is a C program.\n"); 8 | for(int i=0;i<10;i++ ){ 9 | printf("output i=%d\n",i); 10 | } 11 | } 12 | /* $end hello_func */ 13 | 14 | -------------------------------------------------------------------------------- /APP/makefile_step/step4/hello_func.h: -------------------------------------------------------------------------------- 1 | /* $begin hello_func_h */ 2 | 3 | void hello_func(void); 4 | /* $end hello_func_h */ 5 | 6 | -------------------------------------------------------------------------------- /APP/makefile_step/step4/hello_main.c: -------------------------------------------------------------------------------- 1 | /* $begin hello_main */ 2 | #include "hello_func.h" 3 | 4 | int main() 5 | { 6 | hello_func(); 7 | return 0; 8 | } 9 | /* $end hello_main */ 10 | 11 | -------------------------------------------------------------------------------- /APP/makefile_step/step5/Makefile: -------------------------------------------------------------------------------- 1 | #Makefile格式 2 | #目标文件:依赖的文件 3 | #Tab 命令1 4 | #Tab 命令2 5 | 6 | #定义变量 7 | #ARCH默认为x86,使用gcc编译器, 8 | #否则使用arm编译器 9 | ARCH ?= x86 10 | TARGET = hello_main 11 | 12 | 13 | #存放中间文件的路径 14 | BUILD_DIR = build_$(ARCH) 15 | #存放源文件的文件夹 16 | SRC_DIR = sources 17 | #存放头文件的文件夹 18 | INC_DIR = includes . 19 | 20 | #源文件 21 | SRCS = $(wildcard $(SRC_DIR)/*.c) 22 | #目标文件(*.o) 23 | OBJS = $(patsubst %.c, $(BUILD_DIR)/%.o, $(notdir $(SRCS))) 24 | #头文件 25 | DEPS = $(wildcard $(INC_DIR)/*.h) 26 | 27 | #指定头文件的路径 28 | CFLAGS = $(patsubst %, -I%, $(INC_DIR)) 29 | 30 | #根据输入的ARCH变量来选择编译器 31 | #ARCH=x86,使用gcc 32 | #ARCH=arm,使用arm-gcc 33 | ifeq ($(ARCH),x86) 34 | CC = gcc 35 | else 36 | CC = arm-linux-gnueabihf-gcc 37 | endif 38 | 39 | #目标文件 40 | $(BUILD_DIR)/$(TARGET): $(OBJS) 41 | $(CC) -o $@ $^ $(CFLAGS) 42 | 43 | #*.o文件的生成规则 44 | $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c $(DEPS) 45 | #创建一个编译目录,用于存放过程文件 46 | #命令前带“@”,表示不在终端上输出 47 | @mkdir -p $(BUILD_DIR) 48 | $(CC) -c -o $@ $< $(CFLAGS) 49 | 50 | #伪目标 51 | .PHONY: clean cleanall 52 | #按架构删除 53 | clean: 54 | rm -rf $(BUILD_DIR) 55 | 56 | #全部删除 57 | cleanall: 58 | rm -rf build_x86 build_arm 59 | 60 | 61 | -------------------------------------------------------------------------------- /APP/makefile_step/step5/includes/hello_func.h: -------------------------------------------------------------------------------- 1 | /* $begin hello_func_h */ 2 | 3 | void hello_func(void); 4 | /* $end hello_func_h */ 5 | 6 | -------------------------------------------------------------------------------- /APP/makefile_step/step5/sources/hello_func.c: -------------------------------------------------------------------------------- 1 | /* $begin hello_func */ 2 | #include 3 | #include "hello_func.h" 4 | 5 | void hello_func(void) 6 | { 7 | printf("hello, world! This is a C program.\n"); 8 | for(int i=0;i<10;i++ ) 9 | { 10 | printf("output i=%d\n",i); 11 | } 12 | } 13 | /* $end hello_func */ 14 | 15 | -------------------------------------------------------------------------------- /APP/makefile_step/step5/sources/hello_main.c: -------------------------------------------------------------------------------- 1 | /* $begin hello_main */ 2 | #include "hello_func.h" 3 | 4 | int main() 5 | { 6 | hello_func(); 7 | return 0; 8 | } 9 | /* $end hello_main */ 10 | 11 | -------------------------------------------------------------------------------- /APP/makefile_step/step5/sources/test.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/APP/makefile_step/step5/sources/test.c -------------------------------------------------------------------------------- /APP/mpu6050/Makefile: -------------------------------------------------------------------------------- 1 | #生成可执行文件的名称 2 | Target = mpu_demo 3 | ARCH = ARM 4 | #编译器CC 5 | #根据传入的参数ARCH,确定使用的编译器 6 | #默认使用arm-gcc编译器 7 | ifeq ($(ARCH), ARM) 8 | CC = arm-linux-gnueabi-gcc 9 | else 10 | CC = gcc 11 | endif 12 | #存放中间文件的路径 13 | build_dir = objs 14 | #存放源文件的文件夹 15 | src_dir = src user 16 | #存放头文件的文件夹 17 | inc_dir = inc 18 | #存放可执行文件的文件夹 19 | exe_dir = bin 20 | #源文件 21 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 22 | #目标文件(*.o) 23 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 24 | #头文件 25 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 26 | #编译参数 27 | #指定头文件的路径 28 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 29 | #链接过程 30 | #开发板上无法使用动态库,因此使用静态链接的方式 31 | $(exe_dir)/$(Target) : $(objects) 32 | $(CC) $^ -o $@ --static 33 | #编译工程 34 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 35 | $(build_dir)/%.o : src/%.c | Build_DIR 36 | $(CC) -c $(CFLAGS) $^ -o $@ 37 | #编译user文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : user/%.c | Build_DIR 39 | $(CC) -c $(CFLAGS) $^ -o $@ 40 | #以下为伪目标,调用方式:make 伪目标 41 | #clean:用于Clean Project 42 | #check:用于检查某个变量的值 43 | .PHONY:clean check 44 | #命令前带“-”,表示出错之后,继续执行后面的命令 45 | clean: 46 | -rm -rf objs 47 | -rm -rf bin 48 | 49 | #命令前带“@”,表示不在终端上输出执行的命令 50 | check: 51 | @echo $(CFLAGS) 52 | #创建一个新目录objs,用于存放过程文件 53 | Build_DIR: 54 | @mkdir -p $(build_dir) 55 | @mkdir -p $(exe_dir) 56 | -------------------------------------------------------------------------------- /APP/mpu6050/user/main.c: -------------------------------------------------------------------------------- 1 | 2 | /************************************************************/ 3 | //文件名:mpu6050.c 4 | //功能:测试linux下iic读写mpu6050程序 5 | //使用说明: (1) 6 | // (2) 7 | // (3) 8 | // (4) 9 | //作者:pengjie 10 | //日期:2019-07-03 11 | 12 | /************************************************************/ 13 | //包含头文件 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | //宏定义 25 | #define SMPLRT_DIV 0x19 26 | #define CONFIG 0x1A 27 | #define GYRO_CONFIG 0x1B 28 | #define ACCEL_CONFIG 0x1C 29 | #define ACCEL_XOUT_H 0x3B 30 | #define ACCEL_XOUT_L 0x3C 31 | #define ACCEL_YOUT_H 0x3D 32 | #define ACCEL_YOUT_L 0x3E 33 | #define ACCEL_ZOUT_H 0x3F 34 | #define ACCEL_ZOUT_L 0x40 35 | #define TEMP_OUT_H 0x41 36 | #define TEMP_OUT_L 0x42 37 | #define GYRO_XOUT_H 0x43 38 | #define GYRO_XOUT_L 0x44 39 | #define GYRO_YOUT_H 0x45 40 | #define GYRO_YOUT_L 0x46 41 | #define GYRO_ZOUT_H 0x47 42 | #define GYRO_ZOUT_L 0x48 43 | #define PWR_MGMT_1 0x6B 44 | #define WHO_AM_I 0x75 45 | #define SlaveAddress 0xD0 46 | #define Address 0x68 //MPU6050地址 47 | #define I2C_RETRIES 0x0701 48 | #define I2C_TIMEOUT 0x0702 49 | #define I2C_SLAVE 0x0703 //IIC从器件的地址设置 50 | #define I2C_BUS_MODE 0x0780 51 | 52 | typedef unsigned char uint8; 53 | int fd = -1; 54 | 55 | //函数声明 56 | static uint8 MPU6050_Init(void); 57 | static uint8 i2c_write(int fd, uint8 reg, uint8 val); 58 | static uint8 i2c_read(int fd, uint8 reg, uint8 * val); 59 | static uint8 printarray(uint8 Array[], uint8 Num); 60 | 61 | //MPU6050初始化 62 | static uint8 MPU6050_Init(void) 63 | { 64 | fd = open("/dev/i2c-0", O_RDWR); // open file and enable read and write 65 | 66 | if (fd < 0) 67 | { 68 | perror("Can't open /dev/MPU6050 \n"); // open i2c dev file fail 69 | exit(1); 70 | } 71 | 72 | printf("open /dev/i2c-0 success !\n"); // open i2c dev file succes 73 | 74 | if (ioctl(fd, I2C_SLAVE, Address) < 0) 75 | { //set i2c address 76 | printf("fail to set i2c device slave address!\n"); 77 | close(fd); 78 | return - 1; 79 | } 80 | 81 | printf("set slave address to 0x%x success!\n", Address); 82 | i2c_write(fd, PWR_MGMT_1, 0X00); 83 | i2c_write(fd, SMPLRT_DIV, 0X07); 84 | i2c_write(fd, CONFIG, 0X06); 85 | i2c_write(fd, ACCEL_CONFIG, 0X01); 86 | return (1); 87 | } 88 | 89 | //MPU6050 wirte byte 90 | static uint8 i2c_write(int fd, uint8 reg, uint8 val) 91 | { 92 | int retries; 93 | uint8 data[2]; 94 | 95 | data[0] = reg; 96 | data[1] = val; 97 | 98 | for (retries = 5; retries; retries--) 99 | { 100 | if (write(fd, data, 2) == 2) 101 | { 102 | return 0; 103 | 104 | } 105 | 106 | usleep(1000 * 10); 107 | } 108 | 109 | return - 1; 110 | } 111 | 112 | //MPU6050 read byte 113 | static uint8 i2c_read(int fd, uint8 reg, uint8 * val) 114 | { 115 | int retries; 116 | 117 | for (retries = 5; retries; retries--) 118 | { 119 | if (write(fd, ®, 1) == 1) 120 | { 121 | if (read(fd, val, 1) == 1) 122 | { 123 | return 0; 124 | } 125 | 126 | } 127 | 128 | } 129 | 130 | return - 1; 131 | } 132 | 133 | //get data 134 | short GetData(unsigned char REG_Address) 135 | { 136 | char H, L; 137 | 138 | i2c_read(fd, REG_Address, &H); 139 | usleep(1000); 140 | i2c_read(fd, REG_Address + 1, &L); 141 | return (H << 8) +L; 142 | } 143 | 144 | // main 145 | int main(int argc, char * argv[]) 146 | { 147 | MPU6050_Init(); 148 | usleep(1000 * 100); 149 | 150 | while (1) 151 | { 152 | //printf("\033[2J"); 153 | usleep(1000 * 200); 154 | printf("ACCE_X:%6d\n ", GetData(ACCEL_XOUT_H)); 155 | usleep(1000 * 200); 156 | printf("ACCE_Y:%6d\n ", GetData(ACCEL_YOUT_H)); 157 | usleep(1000 * 200); 158 | printf("ACCE_Z:%6d\n ", GetData(ACCEL_ZOUT_H)); 159 | usleep(1000 * 200); 160 | printf("GYRO_X:%6d\n ", GetData(GYRO_XOUT_H)); 161 | usleep(1000 * 200); 162 | printf("GYRO_Y:%6d\n ", GetData(GYRO_YOUT_H)); 163 | usleep(1000 * 200); 164 | printf("GYRO_Z:%6d\n\n ", GetData(GYRO_ZOUT_H)); 165 | sleep(1); 166 | } 167 | 168 | close(fd); 169 | } 170 | -------------------------------------------------------------------------------- /APP/music/c/Makefile: -------------------------------------------------------------------------------- 1 | #生成可执行文件的名称 2 | Target = music_demo 3 | ARCH = ARM 4 | #编译器CC 5 | #根据传入的参数ARCH,确定使用的编译器 6 | #默认使用arm-gcc编译器 7 | ifeq ($(ARCH), ARM) 8 | CC = arm-linux-gnueabi-gcc 9 | else 10 | CC = gcc 11 | endif 12 | #存放中间文件的路径 13 | build_dir = objs 14 | #存放源文件的文件夹 15 | src_dir = src user 16 | #存放头文件的文件夹 17 | inc_dir = inc 18 | #存放可执行文件的文件夹 19 | exe_dir = bin 20 | #源文件 21 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 22 | #目标文件(*.o) 23 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 24 | #头文件 25 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 26 | #编译参数 27 | #指定头文件的路径 28 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 29 | #链接过程 30 | #开发板上无法使用动态库,因此使用静态链接的方式 31 | $(exe_dir)/$(Target) : $(objects) 32 | $(CC) $^ -o $@ --static 33 | #编译工程 34 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 35 | $(build_dir)/%.o : src/%.c | Build_DIR 36 | $(CC) -c $(CFLAGS) $^ -o $@ 37 | #编译user文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : user/%.c | Build_DIR 39 | $(CC) -c $(CFLAGS) $^ -o $@ 40 | #以下为伪目标,调用方式:make 伪目标 41 | #clean:用于Clean Project 42 | #check:用于检查某个变量的值 43 | .PHONY:clean check 44 | #命令前带“-”,表示出错之后,继续执行后面的命令 45 | clean: 46 | -rm -rf objs 47 | -rm -rf bin 48 | 49 | #命令前带“@”,表示不在终端上输出执行的命令 50 | check: 51 | @echo $(CFLAGS) 52 | #创建一个新目录objs,用于存放过程文件 53 | Build_DIR: 54 | @mkdir -p $(build_dir) 55 | @mkdir -p $(exe_dir) 56 | -------------------------------------------------------------------------------- /APP/music/c/user/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | //音乐文件列表,大小需要根据SD卡的内容调整 6 | char music_ls[1000]; 7 | //命令 8 | char cmdstr[100]; 9 | 10 | int main(void) 11 | { 12 | //文件指针,用于接收管道数据 13 | FILE *fp; 14 | printf("This is the music demo\n"); 15 | //挂载SD卡 16 | //system("mount /dev/mmcblk0 /media"); 17 | //使用popen函数接收find的执行结果, 18 | //第二个参数‘r’表示从标准输出读取数据 19 | //xargs用于删除执行结果的换行符 20 | fp = popen("find /run -name *.mp3 | xargs", "r"); 21 | if(fp == NULL) 22 | printf("fail to open\n"); 23 | //读取文件内容,这里能够读取到命令的执行结果 24 | fgets(music_ls, 1000, fp); 25 | //关闭文件 26 | pclose(fp); 27 | //执行播放命令 28 | sprintf(cmdstr,"gplay-1.0 %s", music_ls); 29 | system(cmdstr); 30 | //取消SD卡的挂载 31 | system("umount /media"); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /APP/music/shell/music.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/APP/music/shell/music.mp3 -------------------------------------------------------------------------------- /APP/music/shell/music_player.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export GPLAY=gplay-1.0 3 | 4 | if [ `pwd | awk -F "/" '{print $NF}'` == "all_test" ];then 5 | res_path=$(dirname $(pwd)) 6 | else 7 | res_path=$(pwd) 8 | fi 9 | 10 | $GPLAY --repeat $res_path/resource/music.mp3 11 | -------------------------------------------------------------------------------- /APP/nfs_config/README.md: -------------------------------------------------------------------------------- 1 | # NFS文件系统配置说明 2 | 3 | 4 | ## 主机配置 5 | 6 | 1. 安装NFS服务 7 | Ubuntu系统默认没有安装NFS服务,需要使用如下命令安装NFS服务端软件: 8 | 9 | ```bash 10 | sudo apt-get install nfs-kernel-server 11 | ``` 12 | 13 | 2. 查看用户和组id 14 | 先运行命令id查看主机的用户uid和gid,方便后面使用id进行配置 15 | ``` bash 16 | embedfire@dev:~$ id 17 | uid=998(embedfire) gid=998(embedfire) 组=998(embedfire) 18 | ``` 19 | 本示例中embedfire的用户uid为998,组gid为998。 20 | 21 | 3. 修改 /etc/exports 文件的内容, 22 | 在文件末尾添加如下配置语句: 23 | 24 | ``` config 25 | /home/embedfire/workdir 192.168.0.0/24(rw,sync,anonuid=998,anongid=998,no_subtree_check) 26 | 27 | ``` 28 | 29 | 该配置说明如下: 30 | - /home/embedfire/workdir:要用于NFS文件系统共享的主机目录 31 | - 192.168.0.0/24:配置谁可以访问,此处配置IP为 192.168.0.* 的主机均可以访问该目录,即局域网上的所有主机,若局域网是其它网段,请参考此处的配置,不要用星号,如192.168.1.* 的局域网请配置为 192.168.1.0/24 32 | - rw: 表示客户机的权限,r为可读,w为可写,具体的权限还受文件系统的rwx及用户身份影响 33 | - sync:资料同步写入到内存与硬盘中 34 | - anonuid=998:将客户机上的用户映射成指定的本地用户ID的用户,此处998是 35 | - anongid=998: 将客户机上的用户映射成属于指定的本地用户组ID 36 | - no_subtree_check:不检查子目录权限,默认配置,不写会提示警告 37 | 38 | 39 | 4. 共享需要确保目录存在。 40 | 创建共享目录可使用如下命令: 41 | 42 | ```bash 43 | #创建共享目录,前面示例中共享的是/home/embedfire/workdir 44 | mkdir /home/embedfire/workdir 45 | ``` 46 | 47 | 5. 更新exports配置。 48 | 49 | 修改完/etc/exports文件并保存后,可使用exportfs命令更新配置: 50 | ```bash 51 | sudo exportfs -arv 52 | ``` 53 | 54 | 该命令的参数说明如下: 55 | * -a:全部mount或umount文件/etc/exports中的内容。 56 | * -r:重新mount文件/etc/exports中的共享内容。 57 | * -u:umount目录。 58 | * -v:在exportfs的时候,将详细的信息输出到屏幕上。 59 | 60 | 61 | 6. 查看NFS共享情况 62 | 使用showmount –e 可查看当前NFS服务器的加载情况。 63 | ```bash 64 | showmount -e 65 | 66 | ``` 67 | --------- 68 | 69 | ## 客户端配置 70 | 71 | 以下操作均在`客户端(开发板)的终端`上进行,默认用户为root。 72 | 以下操作均在`客户端(开发板)的终端`上进行,默认用户为root。 73 | 以下操作均在`客户端(开发板)的终端`上进行,默认用户为root。 74 | 75 | 1. 创建挂载点 76 | 挂载时需要本地存在该目录,本例子把开发板挂载在/home/root/mountnfs目录下,首先需要创建该目录: 77 | ```bash 78 | #以下命令在开发板上运行 79 | mkdir /home/root/mountnfs 80 | ``` 81 | 82 | 2. 临时挂载NFS文件系统 83 | 84 | 接下来使用mount命令进行挂载: 85 | ```bash 86 | #以下命令在开发板上运行 87 | #需要把下面的dev设置为前面自己的主机名 88 | mount -o vers=4 dev:/home/embedfire/workdir /home/root/mountnfs 89 | ``` 90 | 91 | 以上命令使用的各个参数如下: 92 | * -o vers=4:表示使用NFS文件系统第4版本,若不注明版本可能会提示参数错误。 93 | * dev:目标主机的名字,此处也可以直接使用目标主机的IP地址,如本例子的目标机器IP为192.168.0.219。 94 | * /home/embedfire/workdir:远端的主机共享目录。 95 | * /home/root/mountnfs:本地挂载点,即要把远端共享的目录映射到本地的哪个目录。 96 | 若挂载成功,终端不会有输出,Linux下执行命令后若没有输出通常就是表示执行成功。 97 | 使用这种方式挂载目录只是临时的,开发板在重启后需要重新挂载该NFS目录才能访问。 98 | 99 | 3. 使用脚本进行测试 100 | 挂载成功后,可以在开发机上把前面编写的hello world脚本复制至共享目录,然后在开发板上的终端直接访问该脚本文件并执行。在后面我们都会采用这样的形式进行开发,即在开发主机编写代码,复制至共享目录,然后在开发板上测试。 101 | 102 | 4. 取消挂载 103 | 当客户机在网络上无法找到NFS共享的目录时,如开发主机关机时,在NFS的客户机的终端常常会输出一些提示,或在使用ls命令查看共享目录会导致长时间等待,这时可以对目录使用umount命令取消挂载,示例如下: 104 | ```bash 105 | #以下命令在开发板上运行 106 | umount /home/root/mountnfs 107 | ``` 108 | 使用该命令时以要取消挂载的目录作为参数即可,没有输出表示执行正常。如果在当前挂载的目录进行umount操作,会提示“device is busy”。建议取消挂载时,先切换到家目录”~”,在进行umount操作。 109 | 110 | -------------------------------------------------------------------------------- /APP/nfs_config/exports: -------------------------------------------------------------------------------- 1 | # /etc/exports: the access control list for filesystems which may be exported 2 | # to NFS clients. See exports(5). 3 | # 4 | # Example for NFSv2 and NFSv3: 5 | # /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check) 6 | # 7 | # Example for NFSv4: 8 | # /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check) 9 | # /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check) 10 | # 11 | 12 | #把998改成自己的用户id号 13 | /home/embedfire/workdir 192.168.0.0/24(rw,sync,anonuid=998,anongid=998,no_subtree_check) 14 | -------------------------------------------------------------------------------- /APP/uart/c/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "stdio.h": "c", 4 | "fcntl.h": "c", 5 | "stat.h": "c", 6 | "errno.h": "c", 7 | "bsp_uart.h": "c", 8 | "stdlib.h": "c" 9 | } 10 | } -------------------------------------------------------------------------------- /APP/uart/c/Makefile: -------------------------------------------------------------------------------- 1 | #生成可执行文件的名称 2 | Target = uart_demo 3 | ARCH = ARM 4 | #编译器CC 5 | #根据传入的参数ARCH,确定使用的编译器 6 | #默认使用arm-gcc编译器 7 | ifeq ($(ARCH), ARM) 8 | CC = arm-linux-gnueabi-gcc 9 | else 10 | CC = gcc 11 | endif 12 | #存放中间文件的路径 13 | build_dir = objs 14 | #存放源文件的文件夹 15 | src_dir = src user 16 | #存放头文件的文件夹 17 | inc_dir = inc 18 | #存放可执行文件的文件夹 19 | exe_dir = bin 20 | #源文件 21 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 22 | #目标文件(*.o) 23 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 24 | #头文件 25 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 26 | #编译参数 27 | #指定头文件的路径 28 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 29 | #链接过程 30 | #开发板上无法使用动态库,因此使用静态链接的方式 31 | $(exe_dir)/$(Target) : $(objects) 32 | $(CC) $^ -o $@ --static 33 | #编译工程 34 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 35 | $(build_dir)/%.o : src/%.c | Build_DIR 36 | $(CC) -c $(CFLAGS) $^ -o $@ 37 | #编译user文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : user/%.c | Build_DIR 39 | $(CC) -c $(CFLAGS) $^ -o $@ 40 | #以下为伪目标,调用方式:make 伪目标 41 | #clean:用于Clean Project 42 | #check:用于检查某个变量的值 43 | .PHONY:clean check 44 | #命令前带“-”,表示出错之后,继续执行后面的命令 45 | clean: 46 | -rm -rf objs 47 | -rm -rf bin 48 | 49 | #命令前带“@”,表示不在终端上输出执行的命令 50 | check: 51 | @echo $(CFLAGS) 52 | #创建一个新目录objs,用于存放过程文件 53 | Build_DIR: 54 | @mkdir -p $(build_dir) 55 | @mkdir -p $(exe_dir) 56 | -------------------------------------------------------------------------------- /APP/uart/c/bin/uart_demo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/APP/uart/c/bin/uart_demo -------------------------------------------------------------------------------- /APP/uart/c/inc/bsp_uart.h: -------------------------------------------------------------------------------- 1 | #ifndef _BSP_UART_H_ 2 | #define _BSP_UART_H_ 3 | 4 | #include //standard input & output,标准输入输出,经常使用的printf函数,scanf函数 5 | #include //standard library,标准输入输出库,包含malloc函数、free函数 6 | #include //POSIX系统接口头文件 7 | #include //文件接口头文件 8 | #include //系统基础数据类型 9 | #include //定义文件的状态 10 | #include //Linux串口头文件 11 | #include //错误码头文件,定义了一些错误宏定义 12 | 13 | #define UART_DEVICE "/dev/ttymxc2" 14 | #define UART_BAUDRATE B115200 15 | 16 | #define TRUE 1 17 | #define FALSE 0 18 | 19 | typedef enum UART_StopBits_n 20 | { 21 | UART_StopBits_1 = 1, 22 | UART_StopBits_2 = 2, 23 | }UART_StopBits_Type; 24 | 25 | typedef enum UART_WordLength_n 26 | { 27 | UART_WordLength_5 = 5, 28 | UART_WordLength_6, 29 | UART_WordLength_7, 30 | UART_WordLength_8, 31 | }UART_WordLength_Type; 32 | 33 | typedef enum UART_Parity_x 34 | { 35 | UART_Parity_No = 0, 36 | UART_Parity_Even, 37 | UART_Parity_Odd, 38 | }UART_Parity_Type; 39 | 40 | struct uart_dev 41 | { 42 | int fd; 43 | }; 44 | void UART_Init(void); 45 | void UART_DeInit(void); 46 | ssize_t UART_Send_Date(char *buf, int len); 47 | ssize_t UART_Rece_Date(char *buf, int len); 48 | //设置串口波特率 49 | void UART_Set_Baudrate(int fd, speed_t speed); 50 | 51 | int UART_Set_WordLength(int fd, UART_WordLength_Type databits); 52 | 53 | int UART_Set_StopBits(int fd, UART_StopBits_Type stopbits); 54 | 55 | int UART_Set_Parity(int fd, UART_Parity_Type parity); 56 | #endif /* _BSP_UART_H_ */ -------------------------------------------------------------------------------- /APP/uart/c/src/bsp_uart.c: -------------------------------------------------------------------------------- 1 | #include "bsp_uart.h" 2 | 3 | struct uart_dev uart_d; 4 | 5 | speed_t speed_arr[] = 6 | { 7 | B115200, B38400, B19200, B9600, B4800, B2400, B1200, B300, 8 | }; 9 | 10 | 11 | static void UART_Config(void) 12 | { 13 | uart_d.fd = open(UART_DEVICE, O_RDWR); 14 | if(uart_d.fd < 0) 15 | { 16 | printf("failt to open %s\n", UART_DEVICE); 17 | exit (1); 18 | } 19 | } 20 | 21 | /** 22 | *@brief 设置串口通信的数据位长度 23 | *@param fd 类型 int 打开串口的文件句柄 24 | *@param databits 类型 UART_WordLength_Type 串口数据位长度 25 | *@return int 26 | */ 27 | int UART_Set_WordLength(int fd, UART_WordLength_Type databits) 28 | { 29 | struct termios opt; 30 | int res = 0; 31 | tcgetattr(fd, &opt); 32 | //清空标志位 33 | opt.c_cflag &= ~CSIZE; 34 | 35 | switch (databits) 36 | { 37 | case UART_WordLength_5: 38 | opt.c_cflag |= CS5; 39 | break; 40 | case UART_WordLength_6: 41 | opt.c_cflag |= CS6; 42 | break; 43 | case UART_WordLength_7: 44 | opt.c_cflag |= CS7; 45 | break; 46 | case UART_WordLength_8: 47 | opt.c_cflag |= CS8; 48 | break; 49 | default: 50 | printf("Unsupported data size: %d\n", databits); 51 | return FALSE; 52 | } 53 | tcflush (fd, TCIFLUSH); 54 | res = tcsetattr(fd, TCSANOW, &opt); 55 | if(res < 0) 56 | { 57 | printf("failed to set wordlength\n"); 58 | return FALSE ; 59 | } 60 | return TRUE; 61 | } 62 | /** 63 | *@brief 设置串口通信的停止位 64 | *@param fd 类型 int 打开串口的文件句柄 65 | *@param databits 类型UART_StopBits_Type 串口停止位长度 66 | *@return int 67 | */ 68 | int UART_Set_StopBits(int fd, UART_StopBits_Type stopbits) 69 | { 70 | struct termios opt; 71 | int res = 0; 72 | tcgetattr(fd, &opt); 73 | 74 | switch (stopbits) 75 | { 76 | case UART_StopBits_1: 77 | opt.c_cflag &= ~CSTOPB; 78 | break; 79 | case UART_StopBits_2: 80 | opt.c_cflag |= CSTOPB; 81 | default: 82 | printf("Unsupported stopbits: %d\n", stopbits); 83 | break; 84 | } 85 | 86 | tcflush (fd, TCIFLUSH); 87 | res = tcsetattr(fd, TCSANOW, &opt); 88 | if(res < 0) 89 | { 90 | printf("failed to set wordlength\n"); 91 | return FALSE ; 92 | } 93 | return TRUE; 94 | } 95 | /** 96 | *@brief 设置串口通信的校验位 97 | *@param fd 类型 int 打开串口的文件句柄 98 | *@param databits 类型UART_Parity_Type 串口校验位方式 99 | *@return int 100 | */ 101 | int UART_Set_Parity(int fd, UART_Parity_Type parity) 102 | { 103 | struct termios opt; 104 | int res = 0; 105 | tcgetattr(fd, &opt); 106 | 107 | switch (parity) 108 | { 109 | case UART_Parity_No: 110 | opt.c_cflag &= ~PARENB; 111 | opt.c_iflag &= ~INPCK; 112 | break; 113 | case UART_Parity_Odd: 114 | opt.c_cflag |= PARENB; 115 | opt.c_cflag |= PARODD; 116 | opt.c_iflag |= INPCK; 117 | case UART_Parity_Even: 118 | opt.c_cflag |= PARENB; 119 | opt.c_cflag &= ~PARODD; 120 | opt.c_iflag |= INPCK; 121 | default: 122 | break; 123 | } 124 | tcflush(fd, TCIOFLUSH); 125 | res = tcsetattr(fd, TCSANOW, &opt); 126 | if(res < 0) 127 | { 128 | printf("failed to set parity\n"); 129 | return FALSE; 130 | } 131 | return TRUE; 132 | } 133 | 134 | /** 135 | *@brief 设置串口通信速率 136 | *@param fd 类型 int 打开串口的文件句柄 137 | *@param speed 类型 int 串口速度 138 | *@return void 139 | */ 140 | void UART_Set_Baudrate(int fd, speed_t speed) 141 | { 142 | struct termios opt; 143 | int res = 0; 144 | //清空接收发送缓冲区 145 | tcflush(fd, TCIOFLUSH); 146 | //读取当前串口的参数 147 | tcgetattr(fd, &opt); 148 | for(int i = 0; i < sizeof(speed_arr)/sizeof(speed_arr[0]); i++) 149 | { 150 | if(speed == speed_arr[i]) 151 | { 152 | //设置输入波特率 153 | cfsetispeed(&opt, speed_arr[i]); 154 | //设置输出波特率 155 | cfsetospeed(&opt, speed_arr[i]); 156 | //更新配置 157 | res = tcsetattr(fd, TCSANOW, &opt); 158 | if(res < 0) 159 | { 160 | printf("failed to set baudrate\n"); 161 | return ; 162 | } 163 | 164 | } 165 | } 166 | tcflush(fd, TCIOFLUSH); 167 | } 168 | 169 | 170 | 171 | void UART_Init(void) 172 | { 173 | UART_Config(); 174 | UART_Set_Baudrate(uart_d.fd, UART_BAUDRATE); 175 | UART_Set_WordLength(uart_d.fd, UART_WordLength_8); 176 | UART_Set_StopBits(uart_d.fd, UART_StopBits_1); 177 | UART_Set_Parity(uart_d.fd, UART_Parity_No); 178 | } 179 | 180 | ssize_t UART_Send_Date(char *buf, int len) 181 | { 182 | return write(uart_d.fd, buf, len); 183 | } 184 | 185 | ssize_t UART_Rece_Date(char *buf, int len) 186 | { 187 | ssize_t res = 0; 188 | res = read(uart_d.fd, buf, len); 189 | return res; 190 | } 191 | 192 | void UART_DeInit(void) 193 | { 194 | close(uart_d.fd); 195 | } 196 | -------------------------------------------------------------------------------- /APP/uart/c/user/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "bsp_uart.h" 3 | 4 | #define MAX_NUMS 256 5 | 6 | char w_buf[] = "Embedfire i.mx6ull uart demo\n"; 7 | char r_buf[MAX_NUMS]; 8 | 9 | int main(int argc, char *argv[]) 10 | { 11 | printf("This is UART demo\n"); 12 | UART_Init(); 13 | //不发送字符串数组的结束符 14 | UART_Send_Date(w_buf, sizeof(w_buf)/sizeof(w_buf[0])-1); 15 | 16 | UART_Rece_Date(r_buf, MAX_NUMS); 17 | 18 | printf("%s", r_buf); 19 | 20 | UART_DeInit(); 21 | 22 | return 0; 23 | } -------------------------------------------------------------------------------- /APP/uart/c_simple/Makefile: -------------------------------------------------------------------------------- 1 | #生成可执行文件的名称 2 | Target = uart_demo 3 | ARCH = ARM 4 | #编译器CC 5 | #根据传入的参数ARCH,确定使用的编译器 6 | #默认使用arm-gcc编译器 7 | ifeq ($(ARCH), ARM) 8 | CC = arm-linux-gnueabi-gcc 9 | else 10 | CC = gcc 11 | endif 12 | #存放中间文件的路径 13 | build_dir = objs 14 | #存放源文件的文件夹 15 | src_dir = src user 16 | #存放头文件的文件夹 17 | inc_dir = inc 18 | #存放可执行文件的文件夹 19 | exe_dir = bin 20 | #源文件 21 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 22 | #目标文件(*.o) 23 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 24 | #头文件 25 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 26 | #编译参数 27 | #指定头文件的路径 28 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 29 | #链接过程 30 | #开发板上无法使用动态库,因此使用静态链接的方式 31 | $(exe_dir)/$(Target) : $(objects) 32 | $(CC) $^ -o $@ --static 33 | #编译工程 34 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 35 | $(build_dir)/%.o : src/%.c | Build_DIR 36 | $(CC) -c $(CFLAGS) $^ -o $@ 37 | #编译user文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : user/%.c | Build_DIR 39 | $(CC) -c $(CFLAGS) $^ -o $@ 40 | #以下为伪目标,调用方式:make 伪目标 41 | #clean:用于Clean Project 42 | #check:用于检查某个变量的值 43 | .PHONY:clean check 44 | #命令前带“-”,表示出错之后,继续执行后面的命令 45 | clean: 46 | -rm -rf objs 47 | -rm -rf bin 48 | 49 | #命令前带“@”,表示不在终端上输出执行的命令 50 | check: 51 | @echo $(CFLAGS) 52 | #创建一个新目录objs,用于存放过程文件 53 | Build_DIR: 54 | @mkdir -p $(build_dir) 55 | @mkdir -p $(exe_dir) 56 | -------------------------------------------------------------------------------- /APP/uart/c_simple/user/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define UART_DEV_PATH "/dev/ttymxc2" 11 | #define SEND_STRING "Embedfire i.mx6ull uart demo\n" 12 | 13 | char r_buf[128]; 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | int fd; 18 | struct termios opt; 19 | //获取串口设备描述符 20 | printf("This is UART demo\n"); 21 | fd = open(UART_DEV_PATH, O_RDWR); 22 | if(fd < 0) 23 | { 24 | printf("Fail to Open %s device\n", UART_DEV_PATH); 25 | exit(1); 26 | } 27 | //清空缓冲区 28 | tcflush(fd, TCIOFLUSH); 29 | //获取串口参数opt 30 | tcgetattr(fd, &opt); 31 | //设置串口输出波特率 32 | cfsetospeed(&opt, B115200); 33 | //设置串口输入波特率 34 | cfsetispeed(&opt, B115200); 35 | //设置8位数据位 36 | opt.c_cflag &= ~CSIZE; 37 | opt.c_cflag |= CS8; 38 | //设置1位停止位 39 | opt.c_cflag &= ~CSTOPB; 40 | //无校验位 41 | opt.c_cflag &= ~PARENB; 42 | opt.c_iflag &= ~INPCK; 43 | //更新配置 44 | tcsetattr(fd, TCSANOW, &opt); 45 | //串口发送字符串 46 | write(fd, SEND_STRING, strlen(SEND_STRING)); 47 | //接收字符串 48 | read(fd, r_buf, 128); 49 | 50 | printf("receive : %s", r_buf); 51 | 52 | close(fd); 53 | return 0; 54 | } -------------------------------------------------------------------------------- /APP/uart/shell/uart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 串口(uart3)发送接受实验 3 | # echo用于向串口发送数据 4 | # cat用于接收数据 5 | # 按“Ctrl+C”可退出 6 | # 注意:用户往UART3发送数据时,需要在发送内容后加上换行符 7 | echo "embedfire imx6ull uart demo" > /dev/ttymxc2 8 | cat /dev/ttymxc2 9 | -------------------------------------------------------------------------------- /APP/video/c/Makefile: -------------------------------------------------------------------------------- 1 | #生成可执行文件的名称 2 | Target = video_demo 3 | ARCH = ARM 4 | #编译器CC 5 | #根据传入的参数ARCH,确定使用的编译器 6 | #默认使用arm-gcc编译器 7 | ifeq ($(ARCH), ARM) 8 | CC = arm-linux-gnueabi-gcc 9 | else 10 | CC = gcc 11 | endif 12 | #存放中间文件的路径 13 | build_dir = objs 14 | #存放源文件的文件夹 15 | src_dir = src user 16 | #存放头文件的文件夹 17 | inc_dir = inc 18 | #存放可执行文件的文件夹 19 | exe_dir = bin 20 | #源文件 21 | sources = $(foreach dir,$(src_dir),$(wildcard $(dir)/*.c)) 22 | #目标文件(*.o) 23 | objects = $(patsubst %.c,$(build_dir)/%.o,$(notdir $(sources))) 24 | #头文件 25 | includes = $(foreach dir,$(inc_dir),$(wildcard $(dir)/*.h)) 26 | #编译参数 27 | #指定头文件的路径 28 | CFLAGS = $(patsubst %, -I%, $(inc_dir)) 29 | #链接过程 30 | #开发板上无法使用动态库,因此使用静态链接的方式 31 | $(exe_dir)/$(Target) : $(objects) 32 | $(CC) $^ -o $@ --static 33 | #编译工程 34 | #编译src文件夹中的源文件,并将生成的目标文件放在objs文件夹中 35 | $(build_dir)/%.o : src/%.c | Build_DIR 36 | $(CC) -c $(CFLAGS) $^ -o $@ 37 | #编译user文件夹中的源文件,并将生成的目标文件放在objs文件夹中 38 | $(build_dir)/%.o : user/%.c | Build_DIR 39 | $(CC) -c $(CFLAGS) $^ -o $@ 40 | #以下为伪目标,调用方式:make 伪目标 41 | #clean:用于Clean Project 42 | #check:用于检查某个变量的值 43 | .PHONY:clean check 44 | #命令前带“-”,表示出错之后,继续执行后面的命令 45 | clean: 46 | -rm -rf objs 47 | -rm -rf bin 48 | 49 | #命令前带“@”,表示不在终端上输出执行的命令 50 | check: 51 | @echo $(CFLAGS) 52 | #创建一个新目录objs,用于存放过程文件 53 | Build_DIR: 54 | @mkdir -p $(build_dir) 55 | @mkdir -p $(exe_dir) 56 | -------------------------------------------------------------------------------- /APP/video/c/user/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | //音乐文件列表,大小需要根据SD卡的内容调整 6 | char video_ls[1000]; 7 | //命令 8 | char cmdstr[100]; 9 | 10 | int main(void) 11 | { 12 | //文件指针,用于接收管道数据 13 | FILE *fp; 14 | printf("This is the video demo\n"); 15 | //挂载SD卡 16 | //system("mount /dev/mmcblk0p1 /media"); 17 | //使用popen函数接收find的执行结果, 18 | //第二个参数‘r’表示从标准输出读取数据 19 | //xargs用于删除执行结果的换行符 20 | fp = popen("find /run -name '*.mp4' -o -name '*.mkv' -o -name '*.avi' | xargs", "r"); 21 | if(fp == NULL) 22 | printf("fail to open\n"); 23 | //读取文件内容,这里能够读取到命令的执行结果 24 | fgets(video_ls, 1000, fp); 25 | //关闭文件 26 | pclose(fp); 27 | //执行播放命令 28 | sprintf(cmdstr,"gplay-1.0 %s", video_ls); 29 | system(cmdstr); 30 | //取消SD卡的挂载 31 | system("umount /media"); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /APP/video/shell/Angry_Birds.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/APP/video/shell/Angry_Birds.avi -------------------------------------------------------------------------------- /APP/video/shell/video_player.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export GSTL=gst-launch-1.0 4 | export PLAYBIN=playbin 5 | export GPLAY=gplay-1.0 6 | export GSTINSPECT=gst-inspect-1.0 7 | 8 | 9 | 10 | $GPLAY --repeat Angry_Birds.avi 11 | 12 | -------------------------------------------------------------------------------- /APP/video/shell/将该视频文件放在家目录下.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/APP/video/shell/将该视频文件放在家目录下.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 野火IMX6UL开发板SDK 2 | 3 | * 协议:GPLV2 4 | * 版本说明: 5 | * SDK_Release_Data:2019-12-30 6 | * SDK_VERSION:0.1 7 | * SDK_Author:jackeyt 8 | * SDK_site:https://jackeyt.cn 9 | * 运行环境:Ubuntu 18.04 LTS(WSL、VM、真机均可) 10 | * 开发板:野火IMX6UL Pro开发板 11 | * soc:NXP IMX6UL,ARM Cortex A7 12 | ---------- 13 | 14 | > 功能说明 15 | * 支持一键运行检查开发编译环境开发 16 | * 支持一键配置、编译UBOOT 17 | * 支持一键配置、编译Linux Kernel 18 | * 支持一键配置、制作文件系统:野火官方的各种文件系统、以及Ubuntu16.04、18.04、Debian9、10 19 | * 支持一键配置QT开发环境(NXP官方环境)[未完成] 20 | * 支持一键第三方开源包[未完成] 21 | * 支持一键编译野火官方APP[未完成] 22 | * 支持一键打包SD可烧录的IMG固件包,并支持Linux、windows(etcher等)工具进进行一键烧录 23 | 24 | ---------- 25 | SDK目录详情: 26 | ``` 27 | APP 28 | build.sh 29 | configs 30 | docs 31 | filesystems 32 | kernel 33 | output 34 | packages 35 | QT 36 | reamde.md 37 | scripts 38 | uboot 39 | VERSION 40 | ``` 41 | > 目录说明 42 | * APP =>野火官方的测试APP、脚本等,详情见文件夹下的readme 43 | * build.sh =>SDK的主要执行文件 44 | * configs =>配置文件夹,其中deconf.mk用于配置各个 45 | * docs =>说明、使用文档,原理图等存放 46 | * filesystems =>文件系统:野火官方的各种文件系统、以及Ubuntu、Debian等 47 | * kernel =>clone来自野火官方的kernel 48 | * output =>SDK输出文件夹,用于存放编译生成的各种文件等 49 | * packages =>第三方的开源APP,用于移植至开发板 50 | * QT =>野火官方的测试APP、脚本等,详情见文件夹下的readme 51 | * reamde.md =>说明文档readme,本文档 52 | * scripts =>SDK的各种脚本集合 53 | * uboot =>clone来自野火官方的uboot 54 | * VERSION =>本SDK的版本号 55 | 56 | 57 | 58 | ---------- 59 | 如何安装? 60 | 61 | ``` 62 | git clone https://gitee.com/jackeyt/ebf_IMX6_SDK.git 63 | ``` 64 | 或者: 65 | ``` 66 | git clone https://github.com/jackeyt/ebf_IMX6_SDK.git 67 | ``` 68 | ---------- 69 | 70 | 如何运行? 71 | ``` 72 | ./build.sh 73 | ``` 74 | 75 | ---------- 76 | 77 | > 主菜单效果: 78 | ``` 79 | __________ ______ ______ ____ _______ _____ ____ __ __ 80 | / ____/ __ )/ ____/ / _/ |/ / |/ / ___/ / ___// __ \/ //_/ 81 | / __/ / __ / /_ / // /|_/ /| / __ \ \__ \/ / / / ,< 82 | / /___/ /_/ / __/ _/ // / / // / /_/ / ___/ / /_/ / /| | 83 | /_____/_____/_/ _____/___/_/ /_//_/|_\____/____/____/_____/_/ |_| 84 | /_____/ /_____/ 85 | SDK_Release_Data:2019-11-30 86 | 87 | SDK_VERSION:0.1 88 | 89 | SDK_Author:jackeyt 90 | 91 | SDK_site:https://jackeyt.cn 92 | 93 | [0] Building Env check 94 | [1] Building uboot for ebf_imx6ul 95 | [2] Building linux kernel for ebf_imx6ul 96 | [3] Building filesystems for ebf_imx6ul 97 | [4] Building QT for ebf_imx6ul 98 | [5] Building 3th packages for ebf_imx6ul 99 | [6] Building APPs for ebf_imx6ul 100 | [7] Building QT APPs for ebf_imx6ul 101 | [8] Building and Burning image to sdcard 102 | [9] Exiting SDK Building Guide! 103 | please select: 104 | 105 | ``` 106 | ---------- 107 | > 功能说明 108 | 109 | * ### 0.检查编译环境 110 | 111 | 运行`build.sh`之后,在主菜单上选择`[0] Building Env check`即可开始检查系统编译环境,效果如下: 112 | 113 | ``` 114 | please select: 0 115 | your select is: 0 116 | Building Env check starting... 117 | 118 | 119 | checking packages... 120 | ``` 121 | 122 | * 注意需要`root`权限,按提示输入密码! 123 | 124 | ---------- 125 | 运行成功结果如下: 126 | ``` 127 | checking CROSS_COMPILE:arm-linux-gnueabihf-gcc 128 | arm-linux-gnueabihf-gcc is /opt/arm-gcc/bin/arm-linux-gnueabihf-gcc 129 | checking packages success! 130 | ``` 131 | 132 | ### 1.UBOOT选项 133 | 运行`build.sh`之后,在主菜单上选择`[1] Building uboot for ebf_imx6u`即可开始检查系统编译环境,效果如下: 134 | ``` 135 | your select is: 1 136 | Building uboot for ebf_imx6ul starting... 137 | [0] uboot_configure 138 | [1] uboot_build 139 | [2] uboot_clean 140 | [3] uboot_distclean 141 | [4] uboot_menuconfig 142 | ``` 143 | 可以看到uboot选项的支持功能有: 144 | * 0.配置 145 | * 1.编译 146 | * 2.clean清除 147 | * 3.distclean清除 148 | * 4.menuconfig菜单选择 149 | 150 | #### 1.0 UBOOT选项—配置 151 | 支持三种Flash的配置:NAND、EMMC、SD Card 152 | 输入`0`回车进入配置选项菜单: 153 | ``` 154 | your select is: 0 155 | Configuring Uboot... 156 | Select uboot configs: 157 | 158 | 1:configs for nand 159 | 2:configs for emmc 160 | 3:configs for SD Card 161 | ``` 162 | 163 | 下面以NAND Flash为例: 164 | 输入`1`回车即可: 165 | ``` 166 | please select configs for uboot: 1 167 | configs for nand 168 | .... 169 | make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mx6ull_14x14_evk_nand_defconfig 170 | HOSTCC scripts/basic/fixdep 171 | HOSTCC scripts/kconfig/conf.o 172 | SHIPPED scripts/kconfig/zconf.tab.c 173 | SHIPPED scripts/kconfig/zconf.lex.c 174 | SHIPPED scripts/kconfig/zconf.hash.c 175 | HOSTCC scripts/kconfig/zconf.tab.o 176 | HOSTLD scripts/kconfig/conf 177 | # 178 | # configuration written to .config 179 | # 180 | Configured mx6ull_14x14_evk_nand_defconfig to uboot success! 181 | ``` 182 | 183 | #### 1.1 UBOOT选项—编译 184 | 输入`1`回车即可: 185 | ``` 186 | Building uboot for ebf_imx6ul starting... 187 | [0] uboot_configure 188 | [1] uboot_build 189 | [2] uboot_clean 190 | [3] uboot_distclean 191 | please select: 1 192 | your select is: 1 193 | 194 | Using Confiugre file:mx6ull_14x14_evk_nand_defconfig 195 | make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8 196 | scripts/kconfig/conf --silentoldconfig Kconfig 197 | CHK include/config.h 198 | UPD include/config.h 199 | GEN include/autoconf.mk 200 | GEN include/autoconf.mk.dep 201 | CHK include/config/uboot.release 202 | ............ 203 | ............ 204 | LD u-boot 205 | OBJCOPY u-boot-nodtb.bin 206 | OBJCOPY u-boot.srec 207 | SYM u-boot.sym 208 | COPY u-boot.bin 209 | CFGS board/freescale/mx6ullevk/imximage.cfg.cfgtmp 210 | MKIMAGE u-boot.imx 211 | ====Build uboot ok!==== 212 | ``` 213 | 214 | #### 1.2 UBOOT选项—clean 215 | 输入`2`回车即可: 216 | ``` 217 | Building uboot for ebf_imx6ul starting... 218 | [0] uboot_configure 219 | [1] uboot_build 220 | [2] uboot_clean 221 | [3] uboot_distclean 222 | please select: 2 223 | your select is: 2 224 | Cleaning Uboot... 225 | 226 | make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- clean 227 | 228 | ====Clean uboot ok!==== 229 | ``` 230 | 231 | 232 | #### 1.3 UBOOT选项—distclean 233 | 输入`3`回车即可: 234 | ``` 235 | Building uboot for ebf_imx6ul starting... 236 | [0] uboot_configure 237 | [1] uboot_build 238 | [2] uboot_clean 239 | [3] uboot_distclean 240 | please select: 3 241 | your select is: 3 242 | Distleaning Uboot... 243 | make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean 244 | CLEAN scripts/basic 245 | CLEAN scripts/kconfig 246 | CLEAN include/config include/generated 247 | CLEAN .config .config.old include/autoconf.mk include/autoconf.mk.dep include/config.h 248 | ====distclean uboot ok!==== 249 | ``` 250 | 251 | #### 1.4 UBOOT选项—menuconfig 252 | 253 | 进入`menuconfig`菜单配置模式 254 | 255 | 256 | ### 2.Linux Kernel选项 257 | ``` 258 | please select again: 2 259 | Building kernel for ebf_imx6ul starting... 260 | [0] linux_configure 261 | [1] linux_distclean 262 | [2] linux_clean 263 | [3] linux_build_dts_only 264 | [4] linux_build_modules_only 265 | [5] linux_build_kernel 266 | [6] linux_build_all 267 | [7] linux_kernel_menuconfig 268 | ``` 269 | #### 2.0 kernel选项—配置 270 | ``` 271 | your select is: 0 272 | Configuring kernel... 273 | Select kernel configs: 274 | 275 | 1:configs for LCD 4.3 inch 276 | 2:configs for LCD 5.0 inch 277 | 3:configs for LCD 7.0 inch 278 | ``` 279 | 支持三种尺寸LCD的配置:4.3、5.0、7.0 280 | 281 | #### 2.1 kernel选项—1~7 282 | > 这里不再赘述,看选项即知道 283 | 284 | ### 3.filesystems选项 285 | 286 | > 在主菜单选择`[3] Building filesystems for ebf_imx6ul`即可进行文件系统编译选项: 287 | ``` 288 | your select is: 3 289 | Building filesystems for ebf_imx6ul starting... 290 | Select which type fs you want to build: 291 | 292 | 0:readme 293 | 1:base_fs 294 | 2:debian 9 Stretch 295 | 3:debian 10 Buster 296 | 4:ebf_rootfs 297 | 5:ebf sato 298 | 6:qt5 fs 299 | 7:ubuntu 16.04 core 300 | 8:ubuntu 18.04 core 301 | please select configs for filesystem: 302 | ``` 303 | > 说明 304 | ---------- 305 | * 0:针对文件系统编译说明 306 | * 1:野火官方的最简文件系统 307 | * 2:debian9文件系统 308 | * 3:debian10文件系统 309 | * 4:野火官方的文件系统 310 | * 5:野火官方的文件系统 311 | * 6:野火官方的文件系统带qt5 312 | * 7:ubuntu16.04文件系统 313 | * 8:ubuntu18.04文件系统 314 | 315 | 关于野火官方的文件系统说明,可见:`filesystems/readme.md` 316 | 317 | >下面以编译debian9系统为例[1]: 318 | 319 | ``` 320 | .... 321 | I: Extracting libsmartcols1... 322 | I: Extracting libuuid1... 323 | I: Extracting mount... 324 | I: Extracting util-linux... 325 | I: Extracting liblzma5... 326 | I: Extracting zlib1g... 327 | download buster success! 328 | 329 | ``` 330 | 331 | ``` 332 | ..... 333 | I: Configuring libc-bin... 334 | I: Configuring systemd... 335 | I: Base system installed successfully. 336 | ``` 337 | 338 | 339 | > 下面以编译ubuntu16.04系统为例[1]: 340 | ``` 341 | ...... 342 | Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1 343 | Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected. 344 | HTTP request sent, awaiting response... 200 OK 345 | Length: 37806000 (36M) [application/octet-stream] 346 | Saving to: ‘ubuntu-base-16.04.6-base-armhf.tar.gz’ 347 | 348 | ubuntu-base-16.04.6-base-armh 100%[=================================================>] 36.05M 260KB/s in 83s 349 | 350 | 2019-12-08 02:16:34 (443 KB/s) - ‘ubuntu-base-16.04.6-base-armhf.tar.gz’ saved [37806000/37806000] 351 | 352 | download ubuntu-base-16.04.6-base-armhf.tar.gz success! 353 | ``` 354 | * ### 4.QT选项[to be done] 355 | * ### 5.配置编译第三方包[to be done] 356 | * ### 6.官方出厂APP编译[to be done] 357 | * ### 7.QT APPs选项[to be done] 358 | * ### 8.SD卡镜像制作&烧写选项 359 | 根据配置编译好的uboot、zImage、filesystem等,打包生成一个可用于烧录到SD卡、EMMC、NAND的固件包,目前只支持生成SD卡固件,可以直接使用linux下的dd命令,或者windows下的烧录工具一键烧录到SD卡,并放至开发板上一键启动。 360 | 生成目录:SDK/output/images/sd/ -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.1 2 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PWD=$(pwd) 4 | 5 | #Config Info 6 | Config_file=${PWD}/configs/defconfig.mk 7 | source ${Config_file} 2>/dev/null 8 | 9 | #calls functions for files 10 | . ${PWD}/scripts/building_env_check.sh 11 | . ${PWD}/scripts/building_uboot_func.sh 12 | . ${PWD}/scripts/building_kernel_func.sh 13 | . ${PWD}/scripts/building_fs_func.sh 14 | . ${PWD}/scripts/building_sdcard_img.sh 15 | 16 | # version Info 17 | SDK_NAME=EBF_IMX6_SDK 18 | SDK_Release_Data=2019-11-30 19 | SDK_VERSION=0.1 20 | SDK_Author=jackeyt 21 | SDK_site=https://jackeyt.cn 22 | 23 | 24 | 25 | function VerInfo_print() 26 | { 27 | figlet -f slant ${SDK_NAME} 28 | echo_green_n SDK_Release_Data:${SDK_Release_Data} 29 | echo_green_n SDK_VERSION:${SDK_VERSION} 30 | echo_green_n SDK_Author:${SDK_Author} 31 | echo_green_n SDK_site:${SDK_site} 32 | } 33 | 34 | function uboot_menu_print() 35 | { 36 | echo_white [0] uboot_configure 37 | echo_white [1] uboot_build 38 | echo_white [2] uboot_clean 39 | echo_white [3] uboot_distclean 40 | echo_white [4] uboot_menuconfig 41 | } 42 | 43 | function uboot_menu_select() 44 | { 45 | case $1 in 46 | 0) 47 | echo_red_n Configuring Uboot... 48 | uboot_config 49 | uboot_main 50 | ;; 51 | 1) 52 | echo_red_n Building uboot for ebf_imx6ul starting... 53 | uboot_build 54 | ;; 55 | 2) 56 | echo_red_n Cleaning Uboot... 57 | uboot_clean 58 | ;; 59 | 3) 60 | echo_red_n Distleaning Uboot... 61 | uboot_distclean 62 | ;; 63 | 4) 64 | echo_red_n menuconfig Uboot... 65 | uboot_menuconfig 66 | uboot_main 67 | ;; 68 | *) 69 | echo_red_n "Please chose again!" 70 | uboot_main 71 | ;; 72 | esac 73 | } 74 | 75 | function uboot_main() 76 | { 77 | uboot_menu_print 78 | read -p "please select: " para1 79 | echo_red_n "your select is: " $para1 80 | uboot_menu_select $para1 81 | } 82 | 83 | function kernel_menu_print() 84 | { 85 | echo_white [0] linux_configure 86 | echo_white [1] linux_distclean 87 | echo_white [2] linux_clean 88 | echo_white [3] linux_build_dts_only 89 | echo_white [4] linux_build_modules_only 90 | echo_white [5] linux_build_kernel 91 | echo_white [6] linux_build_all 92 | echo_white [7] linux_kernel_menuconfig 93 | } 94 | 95 | function kernel_menu_select() 96 | { 97 | case $1 in 98 | 0) 99 | echo_red_n Configuring kernel... 100 | kernel_config 101 | kernel_menu_print 102 | read -p "configured finish!please select to build: " para1 103 | echo_red_n "your select is: " $para1 104 | kernel_menu_select $para1 105 | ;; 106 | 1) 107 | echo_red_n "kernel distclean..." 108 | kernel_distclean 109 | ;; 110 | 2) 111 | echo_red_n "Cleaning kernel..." 112 | kernel_clean 113 | ;; 114 | 3) 115 | echo_red_n "Building dts only..." 116 | kernel_build_dtbs 117 | ;; 118 | 4) 119 | echo_red_n "Building modules only ..." 120 | kernel_build_modules 121 | ;; 122 | 5) 123 | echo_red_n "Building kenrnel all types..." 124 | kernel_build 125 | kernel_build_dtbs 126 | kernel_build_modules 127 | ;; 128 | 6) 129 | echo_red_n "Building dts only..." 130 | kernel_build 131 | ;; 132 | 7) 133 | echo_red_n "menuconfig starting..." 134 | kernel_menuconfig 135 | kernel_menu_print 136 | read -p "menuconfig finish!please select to build: " para1 137 | echo_red_n "your select is: " $para1 138 | kernel_menu_select $para1 139 | ;; 140 | *) 141 | echo_red_n "Please chose again!" 142 | kernel_main 143 | ;; 144 | esac 145 | } 146 | 147 | function kernel_main() 148 | { 149 | kernel_menu_print 150 | read -p "please select: " para1 151 | echo_red_n "your select is: " $para1 152 | kernel_menu_select $para1 153 | } 154 | 155 | function fs_main() 156 | { 157 | fs_config 158 | fs_build 159 | } 160 | 161 | function sd_main() 162 | { 163 | FlashALL2Image 164 | } 165 | 166 | #main 167 | function main_menu_print() 168 | { 169 | echo_white_n [0] Building Env check 170 | echo_white_n [1] Building uboot for ebf_imx6ul 171 | echo_white_n [2] Building linux kernel for ebf_imx6ul 172 | echo_white_n [3] Building filesystems for ebf_imx6ul 173 | echo_white_n [4] Building QT for ebf_imx6ul 174 | echo_white_n [5] Building 3th packages for ebf_imx6ul 175 | echo_white_n [6] Building APPs for ebf_imx6ul 176 | echo_white_n [7] Building QT APPs for ebf_imx6ul 177 | echo_white_n [8] Building and Burning image to sdcard 178 | echo_white_n [9] Exiting SDK Building Guide! 179 | } 180 | 181 | function main_menu_select() 182 | { 183 | case $1 in 184 | 0) 185 | echo_red_n Building Env check starting... 186 | BuildingEnvCheck 187 | ;; 188 | 1) 189 | echo_red_n Building uboot for ebf_imx6ul starting... 190 | uboot_main 191 | ;; 192 | 2) 193 | echo_red_n Building kernel for ebf_imx6ul starting... 194 | kernel_main 195 | ;; 196 | 3) 197 | echo_red_n Building filesystems for ebf_imx6ul starting... 198 | fs_main 199 | ;; 200 | 4) 201 | echo_red_n Building QT for ebf_imx6ul starting... 202 | ;; 203 | 5) 204 | echo_red_n Building 3th packages for ebf_imx6ul... 205 | ;; 206 | 6) 207 | echo_red_n Building APPs for ebf_imx6ul starting... 208 | ;; 209 | 7) 210 | echo_red_n Building QT APPs for ebf_imx6ul starting... 211 | ;; 212 | 8) 213 | echo_red_n Building and Burning image to sdcard starting... 214 | sd_main 215 | ;; 216 | 9) 217 | echo_red_n Exiting SDK Building Guide! 218 | exit 1 219 | ;; 220 | *) 221 | echo_red_n "Please select the right option's num:0~9" 222 | main_menu_print 223 | read -p "please select again: " para 224 | main_menu_select $para 225 | ;; 226 | esac 227 | } 228 | 229 | function main() 230 | { 231 | VerInfo_print 232 | main_menu_print 233 | read -p "please select: " para 234 | echo_red_n "your select is: " $para 235 | main_menu_select $para 236 | } 237 | 238 | main -------------------------------------------------------------------------------- /configs/boot.scripts/emmc_boot.txt: -------------------------------------------------------------------------------- 1 | setenv mmcargs 'setenv bootargs console=${console},${baudrate} root=/dev/ram0 rw initrd=0x83800000,16M fstype=ext4 quiet mem=256m update_emmc' 2 | run mmcargs 3 | fatload mmc 0 0x80800000 zlmage 4 | fatload mmc 0 0x83000000 zlmage-imx6ull-14x14-evk-emmc-update.dtb 5 | fatload mmc 0 0x83800000 6 | rootfs.cpio.gz 7 | bootz 0x80800000-0x83000000 -------------------------------------------------------------------------------- /configs/boot.scripts/nand_boot.txt: -------------------------------------------------------------------------------- 1 | setenv mmcargs 'setenv bootargs console=${console},${baudrate} root=/dev/ram0 rw initrd= 0x83800000,16M fstype=ext4 quiet mtdparts=gpmi-nand:64m(boot),16m(kernel),16m(dtb),-(rootfs) mem=256m update_nand' 2 | run mmcargs 3 | fatload mmc 0 0x80800000 zlmage 4 | fatload mmc 0 0x83000000 zlmage-imx6ull-14x14-evk-gpmi-weim-update.dtb 5 | fatload mmc 0 0x83800000 6 | rootfs.cpio.gz 7 | bootz 0x80800000-0x83000000 -------------------------------------------------------------------------------- /configs/boot.scripts/sd_boot.txt: -------------------------------------------------------------------------------- 1 | setenv mmcargs 'setenv bootargs console=${console},${baudrate} root=${mmcroot}' 2 | run mmcargs 3 | run loadimage 4 | run loadfdt 5 | bootz ${loadaddr}-${fdt_addr} -------------------------------------------------------------------------------- /configs/defconfig.mk: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #path config 4 | export SDK_PATH=$(pwd) 5 | UBOOT_DIR=$SDK_PATH/uboot/ebf_6ull_uboot 6 | KERNEL_DIR=$SDK_PATH/kernel/ebf_6ull_linux/ 7 | KERNEL_MODULES_DIR=$KERNEL_DIR/modules 8 | OUT_DIR=$SDK_PATH/output 9 | 10 | DTB_OUTPATH=$OUT_DIR/dtbs 11 | MOD_OUTPATH=$OUT_DIR/modules 12 | PKG_OUTPATH=$OUT_DIR/packages 13 | APP_OUTPATH=$OUT_DIR/APPs 14 | IMAGE_PATH=$OUT_DIR/images 15 | KERNEL_OUTPATH=$OUT_DIR/kernel 16 | UBOOT_OUTPATH=$OUT_DIR/uboot 17 | ROOTFS_OUTPATH=$OUT_DIR/rootfs 18 | 19 | #out kernel dtbs uboot files 20 | OUT_UBOOT=$UBOOT_OUTPATH/u-boot.imx 21 | OUT_KERNEL=$KERNEL_OUTPATH/zImage 22 | OUT_DTB=$DTB_OUTPATH/imx6ull-14x14-evk.dtb 23 | 24 | FS_DIR=$SDK_PATH/filesystems 25 | FS_MOUNT_DIR=$SDK_PATH/temp_rootfs 26 | BASE_FS_DIR=$FS_DIR/base_fs 27 | DEBIAN9_FS_DIR=$FS_DIR/debian9 28 | DEBIAN10_FS_DIR=$FS_DIR/debian10 29 | EBF_FS_DIR=$FS_DIR/ebf_rootfs 30 | EBF-SATO_FS_DIR=$FS_DIR/ebf_sato 31 | QT5_FS_DIR=$FS_DIR/qt5_fs 32 | UBUNTU16_FS_DIR=$FS_DIR/ubuntu_core/ubuntu16.04 33 | UBUNTU18_FS_DIR=$FS_DIR/ubuntu_core/ubuntu18.04 34 | TEMP_ROOTFS_DIR=$FS_DIR/temp_rootfs 35 | 36 | #build config 37 | export ARCH=arm 38 | export CROSS_COMPILE=arm-linux-gnueabihf- 39 | JOBS=8 40 | 41 | #uboot build config 42 | uboot_deconfig=mx6ull_14x14_evk_nand_defconfig 43 | uboot_verbose=2 44 | boot_script=${UBOOT_DIR}/../boot.script.SDCARD 45 | boot_scr=${UBOOT_DIR}/../boot.scr 46 | 47 | #kernel build config 48 | kernel_deconfig=imx6_v7_ebf_defconfig 49 | kernel_verbose=2 50 | 51 | #fs build config 52 | #1:base_fs 53 | #2:debian 9 Stretch 54 | #3:debian 10 Buster 55 | #4:ebf_rootfs 56 | #5:ebf sato 57 | #6:qt5 fs 58 | #7:ubuntu 16.04 core 59 | #8:ubuntu 18.04 core 60 | fs_deconfig=1 61 | 62 | #output image 63 | SD_IMG_NAME=EBF_SDCard_Image_forIMX6 64 | EMMC_IMG_NAME=EBF_EMMC_Image_forIMX6 65 | NAND_IMG_NAME=EBF_NAND_Image_forIMX6 66 | 67 | SD_IMG_PATH=$IMAGE_PATH/sd 68 | EMMC_IMG_PATH=$IMAGE_PATH/emmc 69 | NAND_IMG_PATH=$IMAGE_PATH/nand 70 | 71 | #config parti 72 | SD_IMG_STARTSIZE=10 #M 73 | SD_IMG_FATSIZE=64 #M 74 | SD_IMG_EXTSIZE=400 #M 75 | -------------------------------------------------------------------------------- /docs/野火_EBF6ULL S1 Pro 底板_V1.0_原理图.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/docs/野火_EBF6ULL S1 Pro 底板_V1.0_原理图.pdf -------------------------------------------------------------------------------- /docs/野火_EBF6ULL S1 核心板V1.0_原理图.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/docs/野火_EBF6ULL S1 核心板V1.0_原理图.pdf -------------------------------------------------------------------------------- /filesystems/base_fs/core-image-base-imx6ull14x14evk.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/filesystems/base_fs/core-image-base-imx6ull14x14evk.tar.bz2 -------------------------------------------------------------------------------- /filesystems/debian10/sources.list: -------------------------------------------------------------------------------- 1 | deb http://ftp2.cn.debian.org/debian buster main -------------------------------------------------------------------------------- /filesystems/debian9/sources.list: -------------------------------------------------------------------------------- 1 | deb http://ftp2.cn.debian.org/debian stretch main -------------------------------------------------------------------------------- /filesystems/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # 文件系统说明: 4 | 5 | ## qt5文件系统 6 | NXP 官方提供的qt5测试文件系统 7 | 8 | ## ebf-sato 文件系统 9 | 野火在NXP官方sato文件系统上添加qt支持,包含python等内容 10 | 11 | 如: 12 | core-image-sato-imx6ull14x14evk.ext4 13 | core-image-sato-imx6ull14x14evk.manifest 14 | core-image-sato-imx6ull14x14evk.tar.bz2 15 | 16 | ## ebf_rootfs 17 | 野火在ebf-sato文件系统基础上裁剪得到的文件系统,支持qt,野火出厂GUI界面,主要是为了适配NAND FLASH的小容量而裁剪的。 18 | 19 | ## debian文件系统 20 | debian文件系统 21 | - ebf_debian_fs_nand_emmc.bz2:支持烧录至nand和emmc 22 | - ebf_debian_rootfs.tar.bz2:支持烧录至sd卡 23 | 24 | ## base 文件系统 25 | sato 文件系统只包含终端,无法运行qt等图形界面 26 | 27 | 如: 28 | core-image-base-imx6ull14x14evk.ext4 29 | core-image-base-imx6ull14x14evk.manifest 30 | core-image-base-imx6ull14x14evk.tar.bz2 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /filesystems/ubuntu_core/ubuntu16.04/resolv.conf: -------------------------------------------------------------------------------- 1 | nameserver 127.0.0.53 2 | -------------------------------------------------------------------------------- /filesystems/ubuntu_core/ubuntu16.04/sources.list: -------------------------------------------------------------------------------- 1 | deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe 2 | deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe 3 | deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe 4 | deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe 5 | deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe 6 | deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe 7 | deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe 8 | deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe 9 | deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe 10 | deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe -------------------------------------------------------------------------------- /filesystems/ubuntu_core/ubuntu18.04/resolv.conf: -------------------------------------------------------------------------------- 1 | nameserver 127.0.0.53 2 | -------------------------------------------------------------------------------- /filesystems/ubuntu_core/ubuntu18.04/sources.list: -------------------------------------------------------------------------------- 1 | deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe 2 | deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe 3 | deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-proposed main multiverse restricted universe 4 | deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe 5 | deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe 6 | deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe 7 | deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe 8 | deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-proposed main multiverse restricted universe 9 | deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe 10 | deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe -------------------------------------------------------------------------------- /output/dtbs/imx6ull-14x14-evk-btwifi.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/output/dtbs/imx6ull-14x14-evk-btwifi.dtb -------------------------------------------------------------------------------- /output/dtbs/imx6ull-14x14-evk-emmc-43.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/output/dtbs/imx6ull-14x14-evk-emmc-43.dtb -------------------------------------------------------------------------------- /output/dtbs/imx6ull-14x14-evk-emmc-cam-dht11.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/output/dtbs/imx6ull-14x14-evk-emmc-cam-dht11.dtb -------------------------------------------------------------------------------- /output/dtbs/imx6ull-14x14-evk-emmc-hdmi.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/output/dtbs/imx6ull-14x14-evk-emmc-hdmi.dtb -------------------------------------------------------------------------------- /output/dtbs/imx6ull-14x14-evk-emmc-wifi.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/output/dtbs/imx6ull-14x14-evk-emmc-wifi.dtb -------------------------------------------------------------------------------- /output/dtbs/imx6ull-14x14-evk-emmc.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/output/dtbs/imx6ull-14x14-evk-emmc.dtb -------------------------------------------------------------------------------- /output/dtbs/imx6ull-14x14-evk-gpmi-weim-43.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/output/dtbs/imx6ull-14x14-evk-gpmi-weim-43.dtb -------------------------------------------------------------------------------- /output/dtbs/imx6ull-14x14-evk-gpmi-weim-cam-dht11.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/output/dtbs/imx6ull-14x14-evk-gpmi-weim-cam-dht11.dtb -------------------------------------------------------------------------------- /output/dtbs/imx6ull-14x14-evk-gpmi-weim-hdmi.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/output/dtbs/imx6ull-14x14-evk-gpmi-weim-hdmi.dtb -------------------------------------------------------------------------------- /output/dtbs/imx6ull-14x14-evk-gpmi-weim-wifi.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/output/dtbs/imx6ull-14x14-evk-gpmi-weim-wifi.dtb -------------------------------------------------------------------------------- /output/dtbs/imx6ull-14x14-evk.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/output/dtbs/imx6ull-14x14-evk.dtb -------------------------------------------------------------------------------- /output/kernel/zImage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/output/kernel/zImage -------------------------------------------------------------------------------- /output/uboot/boot.scr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/output/uboot/boot.scr -------------------------------------------------------------------------------- /output/uboot/u-boot.imx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/output/uboot/u-boot.imx -------------------------------------------------------------------------------- /packages/x11vnc/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/packages/x11vnc/readme.txt -------------------------------------------------------------------------------- /packages/x11vnc/x11vnc-0.9.13.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackeyt/ebf_IMX6_SDK/88a75c1c62215e4bf96fb01fcc67bae08820e648/packages/x11vnc/x11vnc-0.9.13.tar.gz -------------------------------------------------------------------------------- /scripts/building_env_check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #calls functions for files 4 | . ${SDK_PATH}/scripts/func_echo.sh 5 | 6 | function hasCommandByType(){ 7 | if type $1 2>/dev/null; 8 | then 9 | return 1 10 | else 11 | return 0 12 | fi 13 | } 14 | 15 | #sudo apt-get install figlet build-essential libncurses5 libncurses5-dev lzop u-boot-tools fakeroot gawk 16 | #sudo apt-get install lib32ncurses5 lib32tinfo5 libc6-i386 qemu-user-static debootstrap binfmt-support 17 | function BuildingEnvCheck() 18 | { 19 | echo_green_n 20 | echo_green "checking packages..." 21 | sudo apt-get update 22 | sudo apt install -y figlet build-essential libncurses5 libncurses5-dev lzop u-boot-tools fakeroot gawk 23 | sudo apt install -y lib32ncurses5 lib32tinfo5 libc6-i386 qemu-user-static debootstrap binfmt-support 24 | sudo apt install -y figlet android-tools-fsutils 25 | echo_green "checking CROSS_COMPILE:${CROSS_COMPILE}gcc" 26 | hasCommandByType ${CROSS_COMPILE}gcc 27 | returnVue=$? 28 | if [ $returnVue == 0 ];then 29 | echo_red_n "尚未安装${CROSS_COMPILE}gcc" 30 | sudo apt install -y gcc-arm-linux-gnueabihf 31 | fi 32 | if [ $? -eq 0 ]; 33 | then 34 | echo_green_n "checking packages success!" 35 | else 36 | echo_red_n "checking packages failed!" 37 | exit 1 38 | fi 39 | } -------------------------------------------------------------------------------- /scripts/building_fs_func.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | #calls functions for files 5 | . ${SDK_PATH}/scripts/func_echo.sh 6 | 7 | function fs_mount() 8 | { 9 | sudo mount --bind /dev $TEMP_ROOTFS_DIR/dev/ 10 | sudo mount --bind /sys $TEMP_ROOTFS_DIR/sys/ 11 | sudo mount --bind /proc $TEMP_ROOTFS_DIR/proc/ 12 | sudo mount --bind /dev/pts $TEMP_ROOTFS_DIR/dev/pts/ 13 | } 14 | 15 | function fs_unmount() 16 | { 17 | sudo umount $TEMP_ROOTFS_DIR/sys/ 18 | sudo umount $TEMP_ROOTFS_DIR/proc/ 19 | sudo umount $TEMP_ROOTFS_DIR/dev/pts/ 20 | sudo umount $TEMP_ROOTFS_DIR/dev/ 21 | } 22 | 23 | #fs readme 24 | function fs_readme() 25 | { 26 | echo_green "readme:" 27 | echo_green "1:base_fs:" 28 | echo_green "2:debian 9 Stretch:" 29 | echo_green "3:debian 10 Buster:" 30 | echo_green "4:ebf_rootfs:" 31 | echo_green "5:ebf_sato:" 32 | echo_green "6:qt5 fs:" 33 | echo_green "7:ubuntu 16.04 core:" 34 | echo_green "8:ubuntu 18.04 core:" 35 | fs_config 36 | } 37 | 38 | #fs config 39 | function fs_config() 40 | { 41 | echo_green_n Select which type fs you want to build: 42 | echo_green "0:readme" 43 | echo_green "1:base_fs" 44 | echo_green "2:debian 9 Stretch" 45 | echo_green "3:debian 10 Buster" 46 | echo_green "4:ebf_rootfs" 47 | echo_green "5:ebf sato" 48 | echo_green "6:qt5 fs" 49 | echo_green "7:ubuntu 16.04 core" 50 | echo_green "8:ubuntu 18.04 core" 51 | 52 | read -p "please select configs for filesystem: " para 53 | echo_green $FS_DIR 54 | case $para in 55 | 0) 56 | echo_red_n "readme for filesystems" 57 | fs_readme 58 | ;; 59 | 1) 60 | echo_red_n "configs base_fs" 61 | fs_deconfig=1 62 | ;; 63 | 2) 64 | echo_red_n "configs debian 9 Stretch" 65 | fs_deconfig=2 66 | ;; 67 | 3) 68 | echo_red_n "configs debian 10 Buster" 69 | fs_deconfig=3 70 | ;; 71 | 4) 72 | echo_red_n "configs ebf_rootfs" 73 | fs_deconfig=4 74 | ;; 75 | 5) 76 | echo_red_n "configs ebf sato" 77 | fs_deconfig=5 78 | ;; 79 | 6) 80 | echo_red_n "configs qt5 fs" 81 | fs_deconfig=6 82 | ;; 83 | 7) 84 | echo_red_n "configs ubuntu 16.04" 85 | fs_deconfig=7 86 | ;; 87 | 8) 88 | echo_red_n "configs ubuntu 18.04" 89 | fs_deconfig=8 90 | ;; 91 | 92 | *) 93 | echo_red_n "Please select again!" 94 | fs_config 95 | ;; 96 | esac 97 | if [ -z "$fs_deconfig" ]; then 98 | echo_red_n "Please configure again!" 99 | fs_config 100 | fi 101 | } 102 | 103 | #base_fs build 104 | function base_fs_build() 105 | { 106 | echo_green_n "base_fs build start!" 107 | } 108 | 109 | #sourcelist & install pkgs 110 | function update_deb() 111 | { 112 | #chroot 113 | sudo LC_ALL=C LANGUAGE=C LANG=C chroot $TEMP_ROOTFS_DIR <> /etc/fstab 115 | echo "nameserver 127.0.0.53" > /etc/resolv.conf 116 | mknod /dev/console c 5 1 117 | ln -s /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttymxc0.service 118 | mkdir -p /run/sshd 119 | echo auto eth0 > /etc/network/interfaces.d/eth0 120 | echo iface eth0 inet dhcp >> /etc/network/interfaces.d/eth0 121 | echo "ebf_imx6ull" > /etc/hostname 122 | echo "127.0.0.1 localhost" >> /etc/hosts 123 | echo "127.0.1.1 ebf_imx6ull" >> /etc/hosts 124 | apt update 125 | apt install -y sudo net-tools vim net-tools ethtool ifupdown iputils-ping openssh-server 126 | apt-get clean 127 | useradd -s '/bin/bash' -m -G adm,sudo fire 128 | echo "fire:fire" |chpasswd 129 | echo "root:fire" |chpasswd 130 | exit 131 | EOF 132 | } 133 | 134 | #debian build 135 | debian_build() 136 | { 137 | ISSUE=buster 138 | 139 | case $1 in 140 | 9) 141 | echo_green_n "debian9 build start!" 142 | ISSUE=stretch 143 | ;; 144 | 10) 145 | echo_green_n "debian10 build start!" 146 | ISSUE=buster 147 | ;; 148 | *) 149 | echo_green_n "debian10 build start!" 150 | ISSUE=buster 151 | ;; 152 | esac 153 | 154 | if [ "`ls -A $TEMP_ROOTFS_DIR`" = "" ]; then 155 | echo_green_n "$TEMP_ROOTFS_DIR is empty!" 156 | else 157 | echo_red_n "$TEMP_ROOTFS_DIR is not empty" 158 | sudo rm -Rf $TEMP_ROOTFS_DIR/* 159 | fi 160 | 161 | sudo debootstrap --foreign --verbose --arch=armhf $ISSUE $TEMP_ROOTFS_DIR http://ftp2.cn.debian.org/debian 162 | if [ $? -eq 0 ]; then 163 | echo_green_n "download $ISSUE success!" 164 | else 165 | echo_red_n "download $ISSUE failed!" 166 | exit 1 167 | fi 168 | #change 169 | fs_mount 170 | sudo mkdir -p $TEMP_ROOTFS_DIR/usr/share/man/man1/ 171 | sudo cp -f /usr/bin/qemu-arm-static $TEMP_ROOTFS_DIR/usr/bin 172 | if [ $TEMP_ROOTFS_DIR -eq 'stretch' ]; then 173 | echo_exec "sudo cp -f $DEBIAN9_FS_DIR/sources.list $TEMP_ROOTFS_DIR/etc/apt/" 174 | else 175 | echo_exec "sudo cp -f $DEBIAN10_FS_DIR/sources.list $TEMP_ROOTFS_DIR/etc/apt/" 176 | fi 177 | #first chroot 178 | sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot $TEMP_ROOTFS_DIR debootstrap/debootstrap --second-stage 179 | #update 180 | update_deb 181 | fs_unmount 182 | } 183 | 184 | #ebf_rootfs build 185 | function ebf_rootfs_build() 186 | { 187 | echo_green_n "ebf_rootfs build start!" 188 | } 189 | 190 | #ebf_sato build 191 | function ebf_sato_build() 192 | { 193 | echo_green_n "ebf_sato build start!" 194 | } 195 | 196 | #qt5 fs build 197 | function qt5_fs_build() 198 | { 199 | echo_green_n "qt5 fs build start!" 200 | } 201 | 202 | #ubuntu build 203 | function ubuntu_build() 204 | { 205 | ISSUE=bionic 206 | echo_green_n "building ubuntu start!" 207 | if [ "`ls -A $TEMP_ROOTFS_DIR`" = "" ]; then 208 | echo_green_n "$TEMP_ROOTFS_DIR is empty!" 209 | else 210 | echo_red_n "$TEMP_ROOTFS_DIR is not empty" 211 | sudo rm -Rf $TEMP_ROOTFS_DIR/* 212 | fi 213 | 214 | case $1 in 215 | xenial) 216 | echo_green_n "ubuntu16 build start!" 217 | ISSUE=xenial 218 | pushd ${UBUNTU16_FS_DIR} 219 | if [ ! -f ubuntu-base-16.04.6-base-armhf.tar.gz ];then 220 | wget https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cdimage/ubuntu-base/releases/16.04/release/ubuntu-base-16.04.6-base-armhf.tar.gz 221 | if [ $? -eq 0 ]; then 222 | echo_green_n "download ubuntu-base-16.04.6-base-armhf.tar.gz success!" 223 | else 224 | echo_red_n "download ubuntu-base-16.04.6-base-armhf.tar.gz failed!" 225 | exit 1 226 | fi 227 | fi 228 | echo_exec "sudo tar xzf ubuntu-base-16.04.6-base-armhf.tar.gz -C $TEMP_ROOTFS_DIR" 229 | if [ $? -eq 0 ]; then 230 | echo_green_n "unpacked ubuntu-base-16.04 success!" 231 | else 232 | echo_red_n "unpacked ubuntu-base-16.04 failed!" 233 | exit 1 234 | fi 235 | popd 236 | echo_exec "sudo cp -f $UBUNTU16_FS_DIR/sources.list $TEMP_ROOTFS_DIR/etc/apt/" 237 | echo_exec "sudo cp -f $UBUNTU16_FS_DIR/resolv.conf $TEMP_ROOTFS_DIR/etc/apt/" 238 | ;; 239 | bionic) 240 | echo_green_n "ubuntu18 build start!" 241 | ISSUE=bionic 242 | pushd ${UBUNTU18_FS_DIR} 243 | if [ ! -f ubuntu-base-18.04-base-armhf.tar.gz ];then 244 | wget https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cdimage/ubuntu-base/releases/18.04/release/ubuntu-base-18.04-base-armhf.tar.gz 245 | if [ $? -eq 0 ]; then 246 | echo_green_n "download ubuntu-base-18.04-base-armhf.tar.gz success!" 247 | else 248 | echo_red_n "download ubuntu-base-18.04-base-armhf.tar.gz failed!" 249 | exit 1 250 | fi 251 | fi 252 | echo_exec "sudo tar xzf ubuntu-base-18.04-base-armhf.tar.gz -C $TEMP_ROOTFS_DIR" 253 | if [ $? -eq 0 ]; then 254 | echo_green_n "unpacked ubuntu-base-18.04 success!" 255 | else 256 | echo_red_n "unpacked ubuntu-base-18.04 failed!" 257 | exit 1 258 | fi 259 | popd 260 | echo_exec "sudo cp -f $UBUNTU18_FS_DIR/sources.list $TEMP_ROOTFS_DIR/etc/apt/" 261 | echo_exec "sudo cp -f $UBUNTU18_FS_DIR/resolv.conf $TEMP_ROOTFS_DIR/etc/apt/" 262 | ;; 263 | *) 264 | echo_green_n "debian10 build start!" 265 | ISSUE=bionic 266 | ;; 267 | esac 268 | 269 | fs_mount 270 | sudo mkdir -p $TEMP_ROOTFS_DIR/usr/share/man/man1/ 271 | sudo cp -f /usr/bin/qemu-arm-static $TEMP_ROOTFS_DIR/usr/bin 272 | update_deb 273 | fs_unmount 274 | } 275 | 276 | function packing_fs() 277 | { 278 | TIMESTAMP=`date +%Y%m%d%H%m%S` 279 | 280 | pushd $FS_DIR 281 | sudo tar cjf $1-${TIMESTAMP}.tar.gz temp_rootfs/ 282 | sudo mv -f $1-${TIMESTAMP}.tar.gz $ROOTFS_OUTPATH 283 | pushd 284 | } 285 | function fs_build() 286 | { 287 | case $fs_deconfig in 288 | 1) 289 | base_fs_build 290 | ;; 291 | 2) 292 | debian_build 9 293 | packing_fs debian9 294 | echo_green_n "build and packed debian9 finish!" 295 | ;; 296 | 3) 297 | debian_build 10 298 | packing_fs debian10 299 | echo_green_n "build and packed debian10 finish!" 300 | ;; 301 | 4) 302 | ebf_rootfs_build 303 | ;; 304 | 5) 305 | ebf_sato_build 306 | ;; 307 | 6) 308 | qt5_fs_build 309 | ;; 310 | 7) 311 | ubuntu_build xenial 312 | packing_fs ubuntu16 313 | echo_green_n "build and packed ubuntu16 finish!" 314 | ;; 315 | 8) 316 | ubuntu_build bionic 317 | packing_fs ubuntu18 318 | echo_green_n "build and packed ubuntu18 finish!" 319 | ;; 320 | *) 321 | echo_red_n "Please select again!" 322 | fs_config 323 | ;; 324 | esac 325 | } 326 | -------------------------------------------------------------------------------- /scripts/building_kernel_func.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | #calls functions for files 5 | . ${SDK_PATH}/scripts/func_echo.sh 6 | 7 | 8 | #kernel config 9 | function kernel_config() 10 | { 11 | echo_green_n Select kernel configs: 12 | echo_green "1:configs for LCD 4.3 inch" 13 | echo_green "2:configs for LCD 5.0 inch" 14 | echo_green "3:configs for LCD 7.0 inch" 15 | 16 | read -p "please select configs for kernel: " para 17 | echo_green $KERNEL_DIR 18 | case $para in 19 | 1) 20 | echo_red_n "configs for LCD 4.3 inch" 21 | cp -fv $KERNEL_DIR/drivers/video/logo/logo_linux_clut224_4.3.ppm $KERNEL_DIR/drivers/video/logo/logo_linux_clut224.ppm 22 | ;; 23 | 2) 24 | echo_red_n "configs for LCD 5.0 inch" 25 | cp -fv $KERNEL_DIR/drivers/video/logo/logo_linux_clut224_5.0.ppm $KERNEL_DIR/drivers/video/logo/logo_linux_clut224.ppm 26 | ;; 27 | 3) 28 | echo_red_n "configs for SD LCD 7.0 inch" 29 | cp -fv $KERNEL_DIR/drivers/video/logo/logo_linux_clut224_5.0.ppm $KERNEL_DIR/drivers/video/logo/logo_linux_clut224.ppm 30 | ;; 31 | *) 32 | echo_red_n "Please select again!" 33 | kernel_config 34 | ;; 35 | esac 36 | if [ -z "$kernel_deconfig" ]; then 37 | echo_red_n "Please configure again!" 38 | kernel_config 39 | else 40 | pushd $KERNEL_DIR 41 | echo_exec "make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} ${kernel_deconfig}" 42 | if [ $? -eq 0 ]; then 43 | echo_green_n "Configured $kernel_deconfig to kernel success!" 44 | popd 45 | else 46 | echo_red_n "Configured $kernel_deconfig to kernel failed!" 47 | popd 48 | exit 1 49 | 50 | fi 51 | fi 52 | } 53 | 54 | #kernel clean 55 | function kernel_clean() 56 | { 57 | pushd ${KERNEL_DIR} 58 | echo_exec "make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} clean" 59 | if [ $? -eq 0 ]; then 60 | echo_green_n "====Clean kernel ok!====" 61 | else 62 | echo_red_n "====Clean kernel failed!====" 63 | exit 1 64 | fi 65 | popd 66 | } 67 | 68 | #kernel distclean 69 | function kernel_distclean() 70 | { 71 | pushd ${KERNEL_DIR} 72 | echo_exec "make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} distclean" 73 | if [ $? -eq 0 ]; then 74 | echo_green_n "====distclean kernel ok!====" 75 | else 76 | echo_red_n "====distclean kernel failed!====" 77 | exit 1 78 | fi 79 | popd 80 | } 81 | 82 | #kernel build 83 | function kernel_build() 84 | { 85 | pushd ${KERNEL_DIR} 86 | echo_red_n "Using Confiugre file:$kernel_deconfig" 87 | echo_exec "make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -j${JOBS}" 88 | if [ $? -eq 0 ]; then 89 | echo_green_n "====Build kernel ok!====" 90 | cp -rafv arch/arm/boot/zImage $KERNEL_OUTPATH 91 | else 92 | echo_red_n "====Build kernel failed!====" 93 | exit 1 94 | fi 95 | popd 96 | } 97 | 98 | #kernel build dtbs 99 | function kernel_build_dtbs() 100 | { 101 | pushd ${KERNEL_DIR} 102 | echo_red_n "Using Confiugre file:$kernel_deconfig" 103 | echo_exec "make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -j${JOBS} dtbs" 104 | if [ $? -eq 0 ]; then 105 | echo_green_n "====Build dtbs ok!====" 106 | cp -rafv arch/arm/boot/dts/imx6ull-14x14-ev*.dtb $DTB_OUTPATH 107 | else 108 | echo_red_n "====Build dtbs failed!====" 109 | exit 1 110 | fi 111 | popd 112 | } 113 | 114 | #kernel build modules 115 | function kernel_build_modules() 116 | { 117 | pushd ${KERNEL_DIR} 118 | echo_red_n "Using Confiugre file:$kernel_deconfig" 119 | echo_exec "make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -j${JOBS} modules_install INSTALL_MOD_PATH=$MOD_OUTPATH" 120 | if [ $? -eq 0 ]; then 121 | echo_green_n "====Build modules finished in $MOD_OUTPATH!====" 122 | else 123 | echo_red_n "====Build modules failed!====" 124 | exit 1 125 | fi 126 | popd 127 | } 128 | 129 | #kernel menuconfig 130 | function kernel_menuconfig() 131 | { 132 | pushd ${KERNEL_DIR} 133 | echo_red_n "Using Confiugre file:$kernel_deconfig" 134 | echo_exec "make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} menuconfig" 135 | if [ $? -eq 0 ]; then 136 | echo_green_n "====kernel_menuconfig finished !====" 137 | else 138 | echo_red_n "====kernel_menuconfig failed!====" 139 | exit 1 140 | fi 141 | popd 142 | } -------------------------------------------------------------------------------- /scripts/building_sdcard_img.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #calls functions for files 4 | . ${SDK_PATH}/scripts/func_echo.sh 5 | TIMESTAMP=`date +%Y%m%d%H%m%S` 6 | BOOT_IMG=${SD_IMG_PATH}/boot.img 7 | ROOTFS_IMG=${SD_IMG_PATH}/rootfs.img 8 | OUTPUT_IMG=$SD_IMG_PATH/ebf-imx6ull-${TIMESTAMP}.img 9 | 10 | 11 | function BurnSdcardImg() 12 | { 13 | echo_green "Prepare to Burn SDcard Image!" 14 | read -p "please enter your sd partition,such as:/dev/sda " para1 15 | 16 | 17 | } 18 | 19 | function Build_Burn_toSdcard() 20 | { 21 | echo_green_n "packing $fs_deconfig" 22 | 23 | } 24 | 25 | function BurnUboot2img() 26 | { 27 | dd if=$1 of=$2 bs=1024 seek=1 conv=fsync,notrunc 28 | } 29 | 30 | function BuildRootfs_img() 31 | { 32 | rm -f ${ROOTFS_IMG} 33 | rm -rf tmpfs 34 | #echo_exec "sudo make_ext4fs -s -l ${SD_IMG_EXTSIZE}M -a root -L rootfs $ROOTFS_IMG $TEMP_ROOTFS_DIR" 35 | sudo mkdir -p tmpfs 36 | dd if=/dev/zero of=${ROOTFS_IMG} bs=1M count=$SD_IMG_EXTSIZE conv=fsync,notrunc 37 | mkfs.ext4 ${ROOTFS_IMG} 38 | echo_exec "sudo mount -t ext4 ${ROOTFS_IMG} tmpfs -o loop" 39 | echo_exec "sudo cp -rafp $TEMP_ROOTFS_DIR/* tmpfs" 40 | echo_exec "sudo sync" 41 | echo_exec "sudo umount tmpfs" 42 | echo_exec "sudo rm -rf tmpfs" 43 | } 44 | 45 | function MakeImg_Partition() 46 | { 47 | sfdisk --force $1 << EOF 48 | ${SD_IMG_STARTSIZE}M,${SD_IMG_FATSIZE}M,c 49 | $(expr ${SD_IMG_STARTSIZE} + ${SD_IMG_FATSIZE})M,,83 50 | write 51 | EOF 52 | } 53 | 54 | 55 | # Generate the boot image with the boot scripts and required Device Tree 56 | function generate_boot_image() 57 | { 58 | FATSIZE="-F 32" 59 | BOOTDD_VOLUME_ID=BOOT 60 | 61 | rm -f ${BOOT_IMG} 62 | echo_exec "mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 ${FATSIZE} -C ${BOOT_IMG} $(expr ${SD_IMG_FATSIZE} \* 1024)" 63 | 64 | echo "mtools_skip_check=1" > ~/.mtoolsrc 65 | 66 | # Copy boot scripts 67 | echo_exec "mcopy -i ${BOOT_IMG} -s ${UBOOT_OUTPATH}/boot.scr ::/boot.scr" 68 | 69 | # Copy zImage 70 | echo_exec "mcopy -i ${BOOT_IMG} -s ${OUT_KERNEL} ::/zImage" 71 | 72 | # Copy dtb 73 | echo_exec "mcopy -i ${BOOT_IMG} -s ${OUT_DTB} ::/imx6ull-14x14-evk.dtb" 74 | } 75 | 76 | 77 | function generate_total_image () 78 | { 79 | # Initialize a sparse file 80 | dd if=/dev/zero of=${OUTPUT_IMG} bs=1M count=$(expr ${SD_IMG_STARTSIZE} \+ ${SD_IMG_FATSIZE} \+ ${SD_IMG_EXTSIZE}) 81 | } 82 | 83 | # 10MiB 64MiB SD_IMG_EXTSIZE 84 | # <--------------------> <-------------> <----------------------> 85 | # ------------------------ ------------ ------------------------ 86 | # | SD_IMG_STARTSIZE | SD_IMG_FATSIZE | SD_IMG_EXTSIZE | 87 | # ------------------------ ------------ ------------------------ 88 | # ^ ^ ^ ^ 89 | # | | | | 90 | # 0 10MB 74MB 74MB + SD_IMG_EXTSIZE 91 | function FlashALL2Image () 92 | { 93 | #1.generate boot image file 94 | echo_green_n "building boot Image:$BOOT_IMG" 95 | generate_boot_image 96 | #2.generate total image file 97 | generate_total_image 98 | #3.Build Partition 99 | echo_green_n "Partiting SD Image:$OUTPUT_IMG" 100 | MakeImg_Partition $OUTPUT_IMG 101 | #4.0 Burn uboot 102 | echo_green_n "burning uboot to $OUTPUT_IMG" 103 | BurnUboot2img ${OUT_UBOOT} ${OUTPUT_IMG} 104 | #4.1 Burn Partition fat32 105 | echo_green_n "burning $BOOT_IMG to $OUTPUT_IMG" 106 | dd if=${BOOT_IMG} of=${OUTPUT_IMG} conv=notrunc,fsync bs=1M seek=${SD_IMG_STARTSIZE} 107 | #4.2 Burn Partition ext4 108 | BuildRootfs_img 109 | echo_green_n "burning $ROOTFS_IMG to $OUTPUT_IMG" 110 | echo_exec "dd if=${ROOTFS_IMG} of=${OUTPUT_IMG} conv=notrunc,fsync bs=1M seek=$(expr ${SD_IMG_STARTSIZE} \+ ${SD_IMG_FATSIZE})" 111 | rm -f ${ROOTFS_IMG} #save disk space 112 | if [ $? -eq 0 ]; 113 | then 114 | echo_green_n "package SD Image:$OUTPUT_IMG success!" 115 | else 116 | echo_red_n "package SD Image:$OUTPUT_IMG failed!" 117 | exit 1 118 | fi 119 | } 120 | 121 | function BuildSdcardImg() 122 | { 123 | echo_green_n "building SDcard Image!" 124 | 125 | } -------------------------------------------------------------------------------- /scripts/building_uboot_func.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | #calls functions for files 5 | . ${SDK_PATH}/scripts/func_echo.sh 6 | 7 | # boot.src build 8 | function boot_src_buuild() 9 | { 10 | ${uboot_dir}/tools/mkimage -A arm -T script -O linux -d ${boot_script} ${boot_scr} 11 | } 12 | 13 | 14 | #uboot config 15 | function uboot_config() 16 | { 17 | echo_green_n Select uboot configs: 18 | echo_green "1:configs for nand" 19 | echo_green "2:configs for emmc" 20 | echo_green "3:configs for SD Card" 21 | 22 | read -p "please select configs for uboot: " para 23 | 24 | case $para in 25 | 1) 26 | echo_red_n "configs for nand" 27 | uboot_deconfig=mx6ull_14x14_evk_nand_defconfig 28 | ;; 29 | 2) 30 | echo_red_n "configs for emmc" 31 | uboot_deconfig=mx6ull_14x14_evk_emmc_defconfig 32 | ;; 33 | 3) 34 | echo_red_n "configs for SD Card" 35 | uboot_deconfig=mx6ull_14x14_evk_defconfig 36 | ;; 37 | *) 38 | echo "Please select again!" 39 | uboot_config 40 | ;; 41 | esac 42 | if [ -z "$uboot_deconfig" ]; then 43 | echo_red_n "Please configure again!" 44 | uboot_config 45 | else 46 | pushd $UBOOT_DIR 47 | echo_exec "make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} ${uboot_deconfig}" 48 | if [ $? -eq 0 ]; then 49 | echo_green_n "Configured $uboot_deconfig to uboot success!" 50 | popd 51 | else 52 | echo_red_n "Configured $uboot_deconfig to uboot failed!" 53 | popd 54 | exit 1 55 | 56 | fi 57 | fi 58 | } 59 | 60 | #uboot clean 61 | function uboot_clean() 62 | { 63 | pushd ${UBOOT_DIR} 64 | echo_exec "make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} clean" 65 | if [ $? -eq 0 ]; then 66 | echo_green_n "====Clean uboot ok!====" 67 | else 68 | echo_red_n "====Clean uboot failed!====" 69 | exit 1 70 | fi 71 | popd 72 | } 73 | 74 | #uboot distclean 75 | function uboot_distclean() 76 | { 77 | pushd ${UBOOT_DIR} 78 | echo_exec "make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} distclean" 79 | if [ $? -eq 0 ]; then 80 | echo_green_n "====distclean uboot ok!====" 81 | else 82 | echo_red_n "====distclean uboot failed!====" 83 | exit 1 84 | fi 85 | popd 86 | } 87 | 88 | #uboot build 89 | function uboot_build() 90 | { 91 | pushd ${UBOOT_DIR} 92 | echo_red_n "Using Confiugre file:$uboot_deconfig" 93 | echo_exec "make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -j${JOBS}" 94 | if [ $? -eq 0 ]; then 95 | echo_green_n "====Build uboot ok!====" 96 | cp -vf ./u-boot.imx ${OUT_UBOOT} 97 | else 98 | echo_red_n "====Build uboot failed!====" 99 | exit 1 100 | fi 101 | popd 102 | } 103 | 104 | #uboot build 105 | function uboot_menuconfig() 106 | { 107 | pushd ${UBOOT_DIR} 108 | echo_red_n "Using Confiugre file:$uboot_deconfig" 109 | echo_exec "make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} menuconfig" 110 | if [ $? -eq 0 ]; then 111 | echo_green_n "====menuconfig uboot ok!====" 112 | else 113 | echo_red_n "====menuconfig uboot failed!====" 114 | exit 1 115 | fi 116 | popd 117 | } 118 | 119 | 120 | -------------------------------------------------------------------------------- /scripts/func_echo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #echo funs 3 | function echo_green() 4 | { 5 | echo -ne "\e[32m" 6 | echo -n $* 7 | echo -e "\e[0m" 8 | } 9 | 10 | function echo_red() 11 | { 12 | echo -ne "\e[31m" 13 | echo -n $* 14 | echo -e "\e[0m" 15 | } 16 | 17 | function echo_white() 18 | { 19 | echo -ne "\e[0m" 20 | echo -n $* 21 | echo -e "\e[0m" 22 | } 23 | 24 | function echo_green_n() 25 | { 26 | echo -ne "\e[32m" 27 | echo -n $* 28 | echo -e "\r" 29 | echo -ne "\e[0m" 30 | echo 31 | } 32 | 33 | function echo_red_n() 34 | { 35 | echo -ne "\e[31m" 36 | echo -n $* 37 | echo -e "\r" 38 | echo -ne "\e[0m" 39 | } 40 | 41 | function echo_white_n() 42 | { 43 | echo -ne "\e[0m" 44 | echo -n $* 45 | echo -e "\r" 46 | echo -ne "\e[0m" 47 | } 48 | 49 | function notice_pause_g() 50 | { 51 | echo_green_n $* 52 | echo_green_n " press ENTER to continue!" 53 | read 54 | } 55 | 56 | function notice_pause_r() 57 | { 58 | echo_red_n $* 59 | echo_red_n " press ENTER to continue!" 60 | read 61 | } 62 | 63 | function notice_pause_w() 64 | { 65 | echo_white_n $* 66 | echo_white_n " press ENTER to continue!" 67 | read 68 | } 69 | 70 | function echo_exec() 71 | { 72 | echo_white_n $* 73 | $* 74 | } --------------------------------------------------------------------------------