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. Jmeter性能测试 入门

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

  2. Web用户的身份验证及WebApi权限验证流程的设计和实现

    5. WebApi 服务端代码示例 5.1 控制器基类ApiControllerBase [csharp] view plaincopy   /// /// Controller的基类,用于实现适合业 ...

  3. bzoj1057: [ZJOI2007]棋盘制作--最大子矩阵

    既然要求最大01子矩阵,那么把应该为0的位置上的数取反,这样就变成求最大子矩阵 最大子矩阵可以用单调栈 #include<stdio.h> #include<string.h> ...

  4. hive 使用where条件报错 java.lang.NoSuchMethodError: org.apache.hadoop.hive.ql.ppd.ExprWalkerInfo.getConvertedNode

    hadoop 版本 2.6.0 hive版本 1.1.1 错误: java.lang.NoSuchMethodError: org.apache.hadoop.hive.ql.ppd.ExprWalk ...

  5. web项目存数据到数据库,中文乱码,解决过程

    first: 排查原因: 打断点,查看到底是在执行存数据库操作之前就已经乱码了,还是存数据库操作后乱码的. 前者解决方案: 在web.xml里面加上: <filter> <filte ...

  6. 《UML大战需求分析》阅读笔记06

    对<UML>撒站需求分析的阅读现在已到达尾声,虽然读这本书是应老师的要求,但是在后期的阅读中也逐渐喜欢上这本书,在阅读的过程中不断领会需求分析与UML之间的联系,让在软件需求分析阶段有了更 ...

  7. BZOJ 3365 Distance Statistics 点分治

    这道题是一道点分治的题目,难度不大,可以拿来练手. 关键是对于找出来的重心的删除操作需要删掉这条边,这很重要. 还有每次找重心的时候,不但要考虑他的子节点的siz,还要考虑父节点的siz. 然后就A了 ...

  8. require.js工作原理(初始)

    详情:请见阮一峰老师的日志:http://www.ruanyifeng.com/blog/2012/11/require_js.html: 导入:<script data-main=" ...

  9. ansible 简单使用

    前面讲完安装,现在说说怎么用 1.创建目录 mkdir -p /etc/ansible 2. 编辑(或创建)/etc/ansible/hosts 并在其中加入一个或多个远程系统:echo '192.1 ...

  10. 改善你的jQuery的25个步骤 千倍级效率提升

    1. 从Google Code加载jQueryGoogle Code上已经托管了多种JavaScript类库,从Google Code上加载jQuery比直接从你的服务器加载更有优势.它节省了你服务器 ...