树莓派(2代)内核定制及调试准备

1、内核编译


zcat /proc/config.gz > /tmp/zf.confg (raspberry)
scp pi@xxx.xxx.xxx.xxx:/tmp/zf.confg ./ (ubuntu)

(编译器最好使用树莓派提供的,有硬件浮点支持。)
如果开发机器为64位,需要安装32位编译器系统支持文件(我得系统为ubuntu):sudo apt-get installlib32z1

make ARCH=arm CROSS_COMPILE=${CCPREFIX} oldconfig


make ARCH=arm CROSS_COMPILE=${CCPREFIX} -k -j 4  [4核处理器]

/proc/config.gz 找不到 sudo modprobe configs

记住:在二代板子(别的没验证),要拷贝Image,而不是按照一些说明使用工具解压缩zImage文件。

sudo scp user@ip:/[dir]/raspberrypi2/linux-rpi-[version]/arch/arm/boot/Image ./kernel_new.img

启用内核调试:

2、固件升级


三个启动文件,另外有VC库

Firstly, update the required boot files in the Raspberry Pi boot directory with those you've downloaded. These are:

  • bootcode.bin
  • fixup.dat
  • start.elf

Next, you need to copy the VC libraries over. There are two copies of this: one for hard float and one for soft float. To find the correct one, run the following command:

${CCPREFIX}gcc -v 2>&1 | grep hard

If something prints out, and you can see --with-float=hard, you need the hard float ones. NOTE: The current version of Raspbian uses hard float.

Remove the /opt/vc directory from the Raspberry Pi root, then:

  • For hard float, copy vc from the hardfp/opt directory into /opt in the Raspberry Pi root directory(硬件浮点)
  • Otherwise copy vc from the top-level opt directory into /opt in the Raspberry Pi root directory.(软件模拟)
Note: The hard float vs soft float here refers only to the kernel itself, not the functionality it provides. Your applications will still be able to use hard floats. The kernel doesn't use floats anyway, so it is not something to worry about as long as you select the correct  vc directory to copy.

3、内核的基础库


make ARCH=arm CROSS_COMPILE=${CCPREFIX} modules [-k -j 4]

INSTALL_MOD_PATH=../xxx/  modules_install

4、SD卡扩容:


启动过程:

From this Raspberry Pi forum post:

  1. When the Raspberry Pi is first turned on, the ARM core is off, and the GPU core is on. At this point the SDRAM is disabled.
  2. The GPU starts executing the first stage bootloader, which is stored in ROM on the SoC. The first stage bootloader reads the SD card, and loads the second stage bootloader (bootcode.bin) into the L2 cache, and runs it.
  3. bootcode.bin enables SDRAM, and reads the third stage bootloader (loader.bin) from the SD card into RAM, and runs it.
  4. loader.bin reads the GPU firmware (start.elf).
  5. start.elf reads config.txtcmdline.txt and kernel.img

loader.bin doesn't do much. It can handle .elf files, and so is needed to load start.elf at the top of memory (ARM uses SDRAM from address zero). There is a plan to add elf loading support to bootcode.bin, which would make loader.bin unnecessary, but it's a low priority (I guess it might save you 100ms on boot).

Here are some resources that could be helpful:

5、内核调试

树莓派的官方系统支持串口调试,但是,现在的机器上一般没有串口,更没有分开的连接线。需要搞个usb转TTL模块,在某宝上7~8块就能搞定(这次感冒没吃药好了,省钱搞了个20.8的^^)。搞软件的,一看到连接线就发怵。不要不耐烦,一共就需要动手连接3根线:地线、发送、接收(前提是我们使用miniUSB口给树莓派供电)。先来看看树莓派的GPIO管脚定义:

也就是说,跟usb的TTL模块对应的管脚连接6、8、10管脚就可以了。下面的问题就是我们搞清楚编号是从哪里开始的:

连接上这3根线(没用到串口供电,这模块挺高级的,支持5v、3.3v供电):


编辑树莓派的启动参数,通常如下面所示:

# cat /boot/cmdline.txt 
dwc_otg.lpm_enable=0 dwc_otg.speed=1 debug console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 kgdbwait 
console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait 
是的,就比原来的参数多了【 kgdboc=ttyAMA0,115200 kgdbwait】
如果需要跟控制台共享此端口,需要在kgdboc前面加上:kgdbcon(空格)
请参考:
http://sysprogs.com/VisualKernel/tutorials/raspberry/jtagsetup/



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值