Bare Medal on BCM2835 and BCM2836

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.

转载于:https://www.cnblogs.com/darryo/p/Bare-Medal-on-BCM2835-and-BCM2836.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值