|
参考: https://blog.csdn.net/qq_37858281/article/details/120584993 https://www.xjx100.cn/news/633142.html?action=onClick http://www.ichengxu.cc/show-22-14963-1.html
1. 下载编译DNW 1.1 下载 https://github.com/changbindu/dnw-linux
1.2 将dnw-linux-master放到 /home/guo/work/linux/tool文件夹, 并进入. $ cd work/linux/tool/dnw-linux-master/ ~/work/linux/tool/dnw-linux-master$
屏蔽掉dnw-linux-master/src/driver/Makefile中的secbulk-m := secbulk.o行. 否则会报错. 屏蔽即行前加 #.
1.3 编译 $ make
报错: make -C /lib/modules/`uname -r`/build M=`pwd`/src/driver modules make[1]: *** /lib/modules/5.10.0-22-amd64/build: No such file or directory. Stop. make: *** [Makefile:9: driver] Error 2
原因: 没安装内核安装包
/lib/modules/5.10.0-22-amd64$ ls kernel modules.builtin.bin modules.order modules.alias modules.builtin.modinfo modules.softdep modules.alias.bin modules.dep modules.symbols modules.builtin modules.dep.bin modules.symbols.bin modules.builtin.alias.bin modules.devname 文件夹下根本就没有build文件夹.
解决: 参考: https://www.codenong.com/cs106743244/ 安装linux-headers sudo apt-get install linux-headers-$(uname -r)
/lib/modules/5.10.0-22-amd64$ ls -al
total 4976 drwxr-xr-x 3 root root 4096 Aug 16 09:52 . drwxr-xr-x 5 root root 4096 May 12 11:11 .. lrwxrwxrwx 1 root root 38 Apr 22 20:24 build -> /usr/src/linux-headers-5.10.0-22-amd64 drwxr-xr-x 12 root root 4096 May 12 11:11 kernel -rw-r--r-- 1 root root 1242687 May 12 11:12 modules.alias -rw-r--r-- 1 root root 1189253 May 12 11:12 modules.alias.bin -rw-r--r-- 1 root root 5541 Apr 22 20:24 modules.builtin -rw-r--r-- 1 root root 0 May 12 11:12 modules.builtin.alias.bin -rw-r--r-- 1 root root 6754 May 12 11:12 modules.builtin.bin -rw-r--r-- 1 root root 38430 Apr 22 20:24 modules.builtin.modinfo -rw-r--r-- 1 root root 497964 May 12 11:12 modules.dep -rw-r--r-- 1 root root 671637 May 12 11:12 modules.dep.bin -rw-r--r-- 1 root root 476 May 12 11:12 modules.devname -rw-r--r-- 1 root root 153966 Apr 22 20:24 modules.order -rw-r--r-- 1 root root 1116 May 12 11:12 modules.softdep -rw-r--r-- 1 root root 563210 May 12 11:12 modules.symbols -rw-r--r-- 1 root root 685934 May 12 11:12 modules.symbols.bin lrwxrwxrwx 1 root root 39 Apr 22 20:24 source -> /usr/src/linux-headers-5.10.0-22-common
可以看到已经有build文件夹了, 并且是指向/usr/src/linux-headers-5.10.0-22-amd64的.
$ ls /usr/src/ linux-headers-5.10.0-22-amd64 linux-kbuild-5.10 linux-headers-5.10.0-22-common
1.4 再次编译: 成功.
2. 查看开发板USB ID 1)选择USB启动模式. (S5PV210设为SD卡启动模式, 但是不插卡, 会转到USB启动模式) 2)连接OTG到电脑. 3)开机. 将设备(开发板)连接到虚拟机. 将设备按USB设备对待. 连接到虚拟机, 可参考: https://www.cnblogs.com/seifguo/p/17647825.html 4)查看系统日志. $ sudo dmesg
[ 26.955455] 01:20:29.320890 IpcCLT-1427 VBoxDRMClient: IPC client connection started [ 26.971168] 01:20:29.336609 main VBoxClient VMSVGA: Creating worker thread ... [ 27.007092] 01:20:29.372628 main VBoxClient VMSVGA: Service started [ 262.412724] usb 1-2: new high-speed USB device number 3 using xhci_hcd [ 262.755274] usb 1-2: New USB device found, idVendor=04e8, idProduct=1234, bcdDevice= 1.00 [ 262.755276] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 262.755277] usb 1-2: Product: SEC S5PC110 Test B/D [ 262.755277] usb 1-2: Manufacturer: System MCU guo@debian:~$ 可以看到厂商ID是idVendor=04e8, 产品ID是idProduct=1234.
3. 编译安装DNW 3.1 修改驱动. 打开dnw-linux-master/src/driver/secbulk.c, 查看secbulk_table[]变量: static struct usb_device_id secbulk_table[]= { { USB_DEVICE(0x5345, 0x1234) }, /* FS2410 */ { USB_DEVICE(0x04e8, 0x1234) }, /* EZ6410 */ { } }; 可以看到已定义了{ USB_DEVICE(0x04e8, 0x1234) }, 就不需要改动了.
3.2 修改dnw.c文件 unsigned load_addr = 0x57e00000; 改为 unsigned load_addr = 0xd0020000;
printf("Default load address: 0x57e00000\n"); 改为 printf("Default load address: 0xd0020000\n");
0xd0020000是S5PV210的默认启动位置.
3.3 编译 安装 在dnw-linux-master源码顶层目录下编译安装. guo@debian:~/work/linux/tool/dnw-linux-master$ make guo@debian:~/work/linux/tool/dnw-linux-master$ sudo make install
4. 验证. 采用usb启动方式, 使用dnw下载裸机程序到开发板的内存中运行. 裸机程序需要加16字节的文件头. 如果不加文件头, 需要在3.2步骤中, 将0xd0020000改为0xd0020010. 并且开发板需要用usb启动方式(usb启动不校验文件头). 注意: 要将将设备连接到虚拟机!!
$ sudo dnw ~/work/linux/sin210/01noos/00test/210.bin
load address: 0xD0020000 Writing data... 100% 0x00000076 bytes (0 K) speed: infM/S
成功. 可以看到led在闪烁(210.bin是一个led灯闪烁的裸机程序).
来源:https://www.cnblogs.com/seifguo/p/17649003.html |