首先,你需要下载一份Uboot的.bin文件。
方法一:编程烧录
然后再在偏移512个字节后烧录,以下是我在Linux环境下简易写的烧录程序:
/*
本程序是为烧录TF的Uboot使用,其功能为偏移512个字节写入一个.bin文件
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#define BUFFER_SIZE 512
int main()
{
int src_fd,dest_fd;
char buffer[BUFFER_SIZE];
ssize_t bytes_read,bytes_written;
off_t offset = 512;//512个字节的偏移量
//1-打开文件:TF文件和目标文件
src_fd = open("ubootpak.bin",O_RDONLY);//.bin源文件只读
if(src_fd == -1)
{
perror("1打开文件都错了,多少有点废物");
return -1;
}
dest_fd = open("/dev/sdb",O_WRONLY);//TF可读可写
if(dest_fd == -1)
{
perror("2打开文件都错了,多少有点废物");
return -2;
}
//2-定位偏移量
if(lseek(dest_fd,offset,SEEK_SET) == -1)
{
perror("定位出错");
return -3;
}
//3-读取并写入数据
while((bytes_read = read(src_fd,buffer,BUFFER_SIZE)) > 0)
{
bytes_written = write(dest_fd,buffer,bytes_read);
if(bytes_written != bytes_read)
{
perror("写入错误");
return -4;
}
}
//4-关闭文件
close(src_fd);
close(dest_fd);
printf("烧录成功\n");
return 0;
}
直接gcc编译即可
PS:运行时记得加sudo,不然权限不够会报错
方法二:命令行烧录
sudo dd if=./ubootpa.bin of=/dev/sda seek=1
if 输入文件
of 输出文件
seek=blocks从输出文件开头跳过blocks个块后开始复制
执行sync同步一下读写操作
把SD卡查到开发板中(插入到SD0)