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. ZooKeeper学习总结 第二篇:ZooKeeper深入探讨(转载)

    其实zookeeper系列的学习总结很早就写完了,这段时间在准备找工作的事情,就一直没有更新了.下边给大家送上,文中如有不恰当的地方,欢迎给予指证,不胜感谢!. 1. 数据模型 1.1. 只适合存储小 ...

  2. 对Ajax连接的认识~为毛不能上传文件!!!

    最近做毕设的时候需要用到上传图片的功能,但是我的毕设全部的传输都是基于ajax的请求,百度了一圈发现TMD居然说ajax不能上传文件!!当时我就不乐意了啊,那难道其他人都用的是黑科技吗?!又来网上的大 ...

  3. java单例模式的几种写法比较

    概念: Java中单例模式是一种常见的设计模式,单例模式的写法有好几种,这里主要介绍三种:懒汉式单例.饿汉式单例.登记式单例. 单例模式有以下特点: 1.单例类只能有一个实例. 2.单例类必须自己创建 ...

  4. python函数

    一.函数: 创建函数:使用def语句 举例:定义一个返回斐波那楔数列列表的函数 def fibs(num): result = [0,1] for i in range(num-2): result. ...

  5. iOS编程中遇到的问题

    1.应用在iPhone6plus 系统iOS9.1安装时没遇到问题,在iPhone4s 系统iOS 7时bulid success 但是安装失败提示 There was an internal API ...

  6. linux系统中批量查找文件与文件内容的方法

    在linux中查看与修改文件权限我们都必须使用命令来操作,不能像windows一样点几下就好了,下面我们简单的介绍一下linux中的相关命令 比如查找当前目录下面所有的php文件里面某个关键字 fin ...

  7. 关于Java异常

    此处讲运行时异常和非运行时异常地区别,并分别举例 运行时异常一般为程序逻辑错误引起的,可选择捕获处理或不处理,如:IndexOutOfBoundException, NullPointerExcept ...

  8. bzoj1745: [Usaco2005 oct]Flying Right 飞行航班(贪心+map)

    之前做过一道基本一样的题目,抽象出来就是有个容量为c的载体,一些线段上某个点到另一个点要运输w个东西,求从头到尾最多能运多少东西. 这种模型可以用贪心做,用map,map[r]表示r的那个点,我们准备 ...

  9. oracle数据导入/导出

    Oracle数据导入导出imp/exp 功能:Oracle数据导入导出imp/exp就相当与oracle数据还原与备份.   大多情况都可以用Oracle数据导入导出完成数据的备份和还原(不会造成数据 ...

  10. Servlet异步上传文件

    这里需要用到插件ajaxfileupload.js,jar包:commons-fileupload-1.3.2.jar,commons-io-2.5.jar 注意红色部分的字!!!! 1.创建一个we ...