Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C Raspberry Pi的错误感知引导加载程序_C_Linux_Assembly_Raspberry Pi_Bare Metal - Fatal编程技术网

C Raspberry Pi的错误感知引导加载程序

C Raspberry Pi的错误感知引导加载程序,c,linux,assembly,raspberry-pi,bare-metal,C,Linux,Assembly,Raspberry Pi,Bare Metal,我想为Raspberry Pi编写一个简单的引导程序。此引导加载程序的主要目的是在远程位置启用Raspberry Pi,以便从内核更新中恢复,因为内核死机导致设备无法启动。更新内核的过程应如下所示: 默认的Linux内核是/boot/rpi kernel.img,字符串“rpi kernel.img”写在/boot/default kernel.txt中。内核参数“panic=10”已添加到/boot/config.txt中的“cmdline=”中 通过SSH连接到Raspberry Pi 将/

我想为Raspberry Pi编写一个简单的引导程序。此引导加载程序的主要目的是在远程位置启用Raspberry Pi,以便从内核更新中恢复,因为内核死机导致设备无法启动。更新内核的过程应如下所示:

默认的Linux内核是
/boot/rpi kernel.img
,字符串“rpi kernel.img”写在
/boot/default kernel.txt
中。内核参数“panic=10”已添加到
/boot/config.txt
中的“cmdline=”中

  • 通过SSH连接到Raspberry Pi
  • /boot/rpi kernel.img
    复制到
    /boot/rpi kernel fallback.img
  • 创建空文件
    /boot/kernel\u update
  • 下载内核更新并将其移动到
    /boot/rpi kernel.img
  • 重新启动
  • 这是我在伪代码中想到的引导加载程序的设计:

    作为启动过程的最后一步,shell脚本将在删除
    /boot/kernel\u update
    之前检查
    /boot/kernel\u update
    是否存在,然后检查网络是否正常,环境是否正常

    我想使引导加载程序尽可能干净和简单,不支持HDMI、USB、以太网、串行等。问题是我不知道如何开始使用它

    主要的挑战是读取和写入SD卡上的FAT32文件系统,以及引导Linux内核。一切都必须从覆盆子圆周率的裸机开始。


    任何代码示例、资源、建议等。这样做会很有帮助。

    你可能会得到更多的帮助。我已经在那个网站上问了一个类似的问题,但没有答案。我认为raspberrypi.stackexchange.com更适合于回答Raspberry Pi的一般问题。我认为您应该提出一些实际的代码,而不仅仅是伪代码。看看uboot源代码,它应该为您提供一个可能的fork的起点,而不是从头开始编写。
    read kernel parameters passed from start.elf
    
    if empty file '/boot/kernel_update' does not exists
    
        boot kernel defined in '/boot/default-kernel.txt' with kernel parameters passed from start.elf
    
    else
    
        if empty file '/boot/boot_kernel_update' exists
    
            write string 'rpi-kernel-fallback.img' to file '/boot/default-kernel.txt'
            delete file '/boot/kernel_update'
            delete file '/boot/boot_kernel_update'
            create empty file '/boot/kernel_update_failed'
            boot kernel 'rpi-kernel-fallback.img' with kernel parameters passed from start.elf
    
        else
    
            create empty file '/boot/boot_kernel_update'
            boot kernel '/boot/rpi-kernel.img' with kernel parameters passed from start.elf