A few days ago, I have tried to write bare medal program but failed. Now I find that the main mistake is that I have mistake the address of GPIO of BCM 2835(Raspberry Pi 1 for which the sample code is desined ) and BCM2836(Raspberry Pi 2 which I am using).

Refrence: dwelch67


Firstly, the base address of GPIO is changed.

Address of RPi BCM2835: 0x20000000

Address of RPi BCM2836: 0x3f000000

Let us make it more easier

Create two file BCM2835.h and BCM2836.h to recode the macro define.

BCM2835.h

#define PBASE 0x20000000

BCM2836.h

#define PBASE 0x3f000000

Then in the code which control your used to control the peripheral, like periph.c, add the following code:

#ifdef RPI2
#include "BCM2836.h" //Raspberry Pi 2
#else
#include "BCM2835.h" //Raspberry Pi 1
#endif //Ther other macro looks like this:
#define ARM_TIMER_CTL (PBASE + 0x0000B408)

At last, we could modify our Makefile to generate two kernel image:

  1. kernel.img : for Raspberry Pi 1, BCM2835
  2. Kernel7.img : for Raspberry Pi 2, BCM2836

To do this, you could add -DRpi2 in your compile cmd to add the macro define

$(ARMGNU)-gcc $(COPS) -c periph.c -o periph7.o -DRPI2

And this is why your /boot/ directory has both kernel.img and kernel7.img.

The official has already consider the two situations.

Bare Medal on BCM2835 and BCM2836的更多相关文章

  1. Device trees, Overlays and Parameters of Raspberry Pi

    Raspberry Pi's latest kernels and firmware, including Raspbian and NOOBS releases, now by default us ...

  2. git init和git init -bare区别

    1 Git init  和 git init –bare 的区别 用"git init"初始化的版本库用户也可以在该目录下执行所有git方面的操作.但别的用户在将更新push上来的 ...

  3. [译]bare repository

    git init --bare 使用--bare创建的repository没有工作目录, 在这个repository中不能修改文件和commit. 中心repository必须是bare reposi ...

  4. git init 与 git init --bare 的区别

    git init  和 git init –bare 的区别 使用命令"git init --bare"(bare汉语意思是:裸,裸的)初始化的版本库(暂且称为bare repos ...

  5. 把普通的git库变成bare库

    $ cd your_repo $ mv .git .. && rm -fr * $ mv ../.git . $ mv .git/* . $ rmdir .git $ git conf ...

  6. git config and options core.bare hard

    In Lynda course Building a Web Interface with React.js 003 Using the exercises > git clone --bare ...

  7. Why provision Bare Metal

    Here are a few use-cases for bare metal (physical server) provisioning in cloud; there are doubtless ...

  8. Bare metal APIs with ASP.NET Core MVC(转)

    ASP.NET Core MVC now provides a true "one asp.net" framework that can be used for building ...

  9. git init 与 git init --bare 区别

    git init 与 git init --bare 区别 发现问题 最早是在公司的wiki上发现了这个命令,google后发现值得记录下来 实践中发现的区别 网上找了很多资料,但说的很乱,干脆在自己 ...

随机推荐

  1. requerjs 合并 优化配置

    /* * This is an example build file that demonstrates how to use the build system for * require.js. * ...

  2. Jmeter性能测试 入门

    Jmeter是一款优秀的开源测试工具, 是每个资深测试工程师,必须掌握的测试工具,熟练使用Jmeter能大大提高工作效率. 熟练使用Jmeter后, 能用Jmeter搞定的事情,你就不会使用LoadR ...

  3. Python之路第一课Day2--随堂笔记

    入门知识拾遗 一.bytes类型 bytes转二进制然后转回来 msg="张杨" print(msg) print(msg.encode("utf-8")) p ...

  4. 【转】 Camera模仿3D效果的小例子(图片无限旋转)

    import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactor ...

  5. 安装phonegap3.2

    安装phonegap3.2,要用node.js,还要安装git  

  6. Android Studio插件美化Android Studio,文艺清新范

    一:重新定义你工作区的颜色 1:原生的工作区文字的颜色反人类,来这个网站下载自己喜欢的主题:http://www.riaway.com/  轻松定义:下载后是个jar包. 2:导入jar包 file ...

  7. Grandle全局变量定义及引用

    在Project的build.gradle脚本中定义一些全局变量 ext { compileSdkVersion = 21 buildToolsVersion = "24.0.1" ...

  8. 关于thinkphp开发的几种规范(仅限个人)

    一.只要设计到where查询语句,无论是增删改查 $cn['username'] = session('member.username'); $cn['itemid'] = $itemid; $ite ...

  9. svn中第一次check out working copy项目下来出现 ld: library not found for -lcrypto clang: error: linker command failed with exit code 1 (use -v to see invocation)

    这个问题主要是.a文件的忽略删除,需要更改设置,并且把文件重新添加

  10. Flink – window operator

      参考, http://wuchong.me/blog/2016/05/25/flink-internals-window-mechanism/ http://wuchong.me/blog/201 ...