如安在STM32上移植Linux?超具体的实操履历分享
这四种给rootfs提供内容的方法都有一个配合点:在kernel启动时,一系列的文件被解压到rootfs,假如kernel能在个中找到可执行的文件“/init”,kernel就会运行它;这意味着,kernel不会再去分析“root=”是指向那边的。 另外,一旦initramfs内里的init 历程运行起来,kernel就会以为启动已经完成。接下来,init将掌控整个宇宙!它拥有轰隆无敌的专门为它预留的Process ID #1,整个体系接下来的全部都将由它来缔造!尚有,它的职位将是不行剥夺的,嗯哼,PID 1 退出的话,体系会panic的。 接下来我会先容其他一些,在rootfs中,init措施可以做的事。 Footnote 1: The kernel doesn’t allow rootfs to be unmounted for the same reason the same reason it won’t let the first process (PID 1, generally running init) be killed. The fact the lists of mounts and processes are never empty simplifies the kernel’s implementation. Footnote 2: The cpio format is another way of combining files together, like tar and zip. It’s an older and simpler storage format that dates back to the original unix, and it’s the storage format used inside RPM packages. It’s not as widely used as tar or zip because the command line syntax of the cpio command is unnecessarily complicated (type “man 1 cpio” at a Linux or Cygwin command line if you have a strong stomach). Luckily, we don’t need to use this command. Footnote 3: The kernel will always panic if PID 1 exits; this is unrelated to initramfs. All of the signals that might kill init are blocked, even “kill -9” which will reliably kill any other process. But init can still call the exit() syscall itself, and the kernel panics if this happens in PID 1. Avoiding it here is mostly a cosmetic issue: we don’t want the panic scrolling our “Hello World!” message off the top of the screen. Footnote 4: Statically linking programs against glibc produces enormous, bloated binaries. Yes, this is expected to be over 400k for a hello world proram. You can try using the “strip” command on the resulting binary, but it won’t help much. This sort of bloat is why uClibc exists. Footnote 5: Older 2.6 kernels had a bug where they would append to duplicate files rather than overwriting. Test your kernel version before depending on this behavior. Footnote 6:User Mode Linux or QEMU can be very helpful testing out initramfs, but are beyond the scope of this article. Footnote 7: Well, sort of. The default one is probably meant to be empty, but due to a small bug (gen_initramfs_list.sh spits out an example file when run with no arguments) the version in the 2.6.16 kernel actually contains a “/dev/console” node and a “/root” directory, which aren’t used for anything. It gzips down to about 135 bytes, and might as well actually be empty. On Intel you can run “readelf -S vmlinux” and look for section “.init.ramfs” to see the cpio.gz archive linked into a 2.6 kernel. Elf section names might vary a bit on other platforms. 显然stm32f103行使的是第三种要领,内里那些指令无非是配置文件权限、配置软毗连等等操纵,时代还学了一点bash shell,又有点收成,大白了原理之后就好办了,直接照猫画虎,我回收的是第二种要领: 1、先建设rootfs这个文件夹,再在这个文件夹下面别离建设bin、dev、etc、proc、sys等目次 2、编译busybox,把天生的bin文件复制到rootfs/bin下 3、新建linuxrc文件,配置权限chmod 777,然后在u-boot传给内核参数中必然要加上init=/linuxrc 4、在dev目次下,加装备节点,否则会没有输出信息哦! · 1 mknod -m 666 console c 5 1 · 2 mknod -m 666 null c 1 3 5、在内核make menuconfig上CONFIG_INITRAMFS_SOURCE=“你方才构建的文件夹的绝对路径” 编译内核,initramfs直接和内核编译在一路,不消其它分出一个bin文件拷,这较量利便,启动,在串口调试助手中可看到相干表现信息: 最后说一下本身的感触,用initramfs根文件体系固然利便适用,可是有破绽就是它只读不行写,这对开拓很倒霉,率领说会加个spi flash再在内里挂载个根文件体系(spi flash能挂jfss2吗?),那是往后的事了往后再说,今朝这种环境以我的技能程度只能做到这个份上了,加了根文件之后,stm32内部flash尚有200多k的存储空间,应该可以添加些驱动和应用措施,那下面我的使命是编写简朴的驱动与应用措施,好吧,又得继承进修,全力事变了。。。(本文摘自:http://blog.csdn.net/jccg89104) (编辑:湖南网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |