Bare metal clock and timers tutorial for banana pi

Programming, for all ages and all languages.
Post Reply
inaciose
Posts: 6
Joined: Mon Jul 17, 2017 10:07 pm

Bare metal clock and timers tutorial for banana pi

Post by inaciose »

Hello

Im trying to learn as hobby how to make baremetal programing on banana pi.

To begin I take this tutorial and made it in banana pi
http://wiki.osdev.org/ARM_RaspberryPi_Tutorial_C

Then I add the getc and made an echo shell (just show what you type in serial port);
After that i blink a led using a loop delay function;

Then i try to blink the led with interrups. I got stuck here. Im not smart enought to figure if for my self.
There is no simple information or simple code sample about clok control and timers on banana pi, and allwinner A20.
Then i try to see if i cant get the code from else here. U-boot code was my first try. But it is not simple enough get how to do it.

So.. i need some help to get this done.
Any one knows where to get a simple code sample or tutorial about clock control, timers and interrupts on banana pi / A20

Thanks
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Bare metal clock and timers tutorial for banana pi

Post by Octacone »

Banana Pi is a "clone" of Raspberry Pi (sort of). None of them feature a battery powered real time clock (RTC) (low cost intended).
You can buy a separate RTC module that uses on-board GPIOs for communication and can be programmed.
If you are talking about other timers it is most likely they are using some sort of a crystal, meaning fixed frequency.
They are both acquiring their data/time information from an online server.
See if you can use PWM signaling for internal tick keeping. (most likely can be programmed, desired frequency).
Also take a look at your CPU, see if you can find any manuals online. There is a chance that there might be some timer related info.

Here is some Cortex A53 documentation (you didn't mention your processor at all):
https://developer.arm.com/products/proc ... x-a53/docs
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
inaciose
Posts: 6
Joined: Mon Jul 17, 2017 10:07 pm

Re: Bare metal clock and timers tutorial for banana pi

Post by inaciose »

Octacone wrote: See if you can use PWM signaling for internal tick keeping. (most likely can be programmed, desired frequency).
Also take a look at your CPU, see if you can find any manuals online. There is a chance that there might be some timer related info.
Hello. Tks.
The PWM and the manual are the path, unfortunately the manual its only a description of bytes and bits, without a single sample code.
Need to get smarter to do it.
User avatar
zaval
Member
Member
Posts: 656
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

Re: Bare metal clock and timers tutorial for banana pi

Post by zaval »

There is no simple information or simple code sample about clok control and timers on banana pi, and allwinner A20.

Then i try to see if i cant get the code from else here. U-boot code was my first try. But it is not simple enough get how to do it.

Any one knows where to get a simple code sample or tutorial about clock control, timers and interrupts on banana pi / A20
I fear, there is no such things as code samples on "clock control, timers and interrupts on banana pi / A20". Or it's so rare, that noone knows about its existence. Try searching for it, maybe you will be lucky to find some blog with the content which you exactly are searching for. It's just not as a common "hobby" as eg "learning to blink leds on RPi with python". You need to learn buffing your banana by yourself. :mrgreen:

But what I want to say - is don't give up on uboot inspecting. It's not as "hard" as it seems (messy but readable yet). Just have a bit of persistence. It's the ultimate source on the "bare metal programming" of such devices - all they use it as a "firmware", so nowhere else you'll find what you need.
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).
inaciose
Posts: 6
Joined: Mon Jul 17, 2017 10:07 pm

Re: Bare metal clock and timers tutorial for banana pi

Post by inaciose »

After a lot of time reading arm manuals I manage to code a simple sample on interrupts and timers for allwinner A20 banana pi.

https://github.com/inaciose/noos/tree/master/bpi/gic02

zaval wrote:
There is no simple information or simple code sample about clok control and timers on banana pi, and allwinner A20.

Then i try to see if i cant get the code from else here. U-boot code was my first try. But it is not simple enough get how to do it.

Any one knows where to get a simple code sample or tutorial about clock control, timers and interrupts on banana pi / A20
I fear, there is no such things as code samples on "clock control, timers and interrupts on banana pi / A20". Or it's so rare, that noone knows about its existence. Try searching for it, maybe you will be lucky to find some blog with the content which you exactly are searching for. It's just not as a common "hobby" as eg "learning to blink leds on RPi with python". You need to learn buffing your banana by yourself. :mrgreen:

But what I want to say - is don't give up on uboot inspecting. It's not as "hard" as it seems (messy but readable yet). Just have a bit of persistence. It's the ultimate source on the "bare metal programming" of such devices - all they use it as a "firmware", so nowhere else you'll find what you need.
Post Reply