13

I wrote a very simple kernel years ago, and ran it on a 386. I haven't done bare metal programming in years, but in broad terms you need to write some assembler code that will: disable interrupts during the boot process if the Pi has a memory controller, you'll need to set that up set up a timer tick configure the interrupt controller set up a stack so ...


12

I haven't looked at your code in depth, but it seems to me you're on the right track. Make sure that: The _start symbol is indeed the one used when compiling & linking your assembly file and your C file (and that main() isn't used instead) When calling main(), you need to use the C calling convention: push on the stack the address of the instruction ...


10

Assembly is a programming language, and, like other programming languages, you have plain text source codes that can be edited by all text editors out there. The confusion comes from the fact that, as it is the lowest level programming language just above machine language, other programming language's compilers will generate assembly source-code from their ...


8

The root problem is that the activity LED moved from being attached to gpio 16 to being attached to gpio 47 on the B+. You need to update the code to reflect that change. There are a number of changes you need to make. It is more than just changing 16 to 47. Gpio 47 is controlled by different registers. See this thread on raspberrypi.org which covers ...


4

I have not tried it, but there is a binutils-multiarch package "used to manipulate binary and object files that may have been created on other architectures". It includes an objdump which from the looks of things will replace the existing one. The other files are listed here. So, worth trying: apt-get install binutils-multiarch And seeing if the new ...


3

I would recommend taking a look at this site http://www.makeuseof.com/tag/emulate-raspberry-pi-pc/ which describes how to emulate the original raspberry pi on a pc. You then should be able to debug and run assembly code on the emulated raspberry pi that you created.


3

This and the other resources in the Bare metal, Assembly forum are a great start.


3

You need to tell gcc the architecture when just assembling like this. So gcc -march=native -o test test.s tells it to assemble for your native architecture (arm on a RPi). This will yield link errors about multiple definitions of _start and crt1.o. Gcc expects to link in the C runtime which actually provides _start normally and that then calls main. You can ...


3

Unfortunately things are not as easy as you described. All the applications you gave as an example (a compiler, an editor, an interpreter, etc) are quite complicated and they are not only doing computation but also interact quite heavily with the OS. They need a way to use files, interact with user (like keyboard input, screen output), expect a concept of "...


2

Try this instead: http://www.valvers.com/open-software/raspberry-pi/step01-bare-metal-programming-in-cpt1/ Also, the x86 experience is a bit different. It may be applicable to general ARM bare metal OS programming. But for Pi, sorry it is the gpu start first and set up quite a bit before your OS (?) code.


2

The main problem you might encounter is the C libraries and prologue code. It's started before your own code starts executing and sets up the stack, the heap and does plenty of other helpful things. However, when you're trying to program for bare metal you don't have any OS running below you and you'd better to avoid calling these functions. In order to do ...


2

Do you add Microsoft IoT Extension SDK ?


2

Okay, I figured it out myself... The first ldr actually loads the address of the variable. And so to have the value of pattern in the register (rather than the address), I still have to load the value at the address into the register. Also check here


2

I'm not surprised you couldn't find any information. The BCM2836 is a SoC not a CPU. As far as you are concerned the BCM2836 is identical to the BCM2835 except for the different ARM CPU. The main user CPU used on the Pi 2 is an ARM Cortex A7 with four cores. If you search for BCM2835 and the ARM CPU you'll find all the information you could need.


2

On the Pis with the 40 pin expansion header (except Pi3) the power LED (red) is connected to GPIO 35 (not present on the Pi Zero) the activity LED (green) is connected to GPIO 47 Pi3 uses a GPIO expander to drive the LEDs which can only be accessed from the VPU.


2

You may be able to do what you want with the debugger gdb. Compile and link a small test program. q.c #include <stdio.h> int main(int argc, char *argv[]) { int i; for (i=0; i<10; i++) printf("%d\n", i*i); return 0; } gcc -o q q.c gdb q Enter the commands layout asm layout reg start and then si to single step ┌──Register group: ...


1

You need to check your country's laws regarding wireless transmission systems. You need to make sure that you're not exceeding any limits in terms of, for example, power transmission, and that you are not operating in a band for which you have not been granted permission. The bottom line is: before you start building anything, research and make sure that ...


1

Ok found the solution. There were some coding issues. This code is working now: .section .init .globl _start _start: @ Base adress for gpio controller ldr r0, =0x20200000 @ Set GPIO 24 as output mov r2, #0x01 lsl r2, #0x0C str r2, [r0, #0x08] @ Set GPIO 13 as input mov r1, #0x00 str r1, [r0, #0x04] @ I/O masks mov r2, #0x01 lsl r2, #0x0D mov r3, #...


1

The solution lies in the config.txt. After reading many forums and the RPi site, there is a config option called disable_commandline_tags. If it is not set or is set to 0 in config.txt, ATAGS is loaded by start.elf starting at 0x100. My kernel was also using kernel_old=1, which starts loading at 0x0. The ATAGs entry was overwriting a piece of the kernel....


1

You are running this under userland Linux. Userland address spaces are virtual address spaces which bear no relationship to physical (hardware address spaces). The Memory Management Unit (MMU) maps virtual addresses to physical addresses. You need to tell your program to allow access to physical address 0x3F000000. In C you would use mmap. I have no ...


1

I expect your terminology is incorrect. If you want to control interrupts you will either have to go bare metal or write a Linux kernel driver. If you use Raspbian from userland you can not "control" interrupts. However you can request a callback when an interrupt happens. Do you want to use interrupts to control peripherals? To do what?


1

While there is a full schematics of the B, rev2 on Raspberrypi.org only some "Reduced Schematics" for the B+ are available. This is stripped down to the absolute minimum, but it is at least possible to figure out the pin numbering on the GPIO expansion header. Another nice spot to visit is elinux which is updated with information of the different pin ...


1

With Linux you could try the framebuffer interface. It can be memory mapped as a buffer where you write your data.


1

What is your C compiler? If it's GCC, adding parameters -S -save-temps makes it leave all intermediate files - preprocessed, assembly, objects.


1

s-matyukevich/raspberry-pi-os https://github.com/s-matyukevich/raspberry-pi-os This awesome repo does both the C bootstraping, and goes into pretty complex topics. Furthermore, it looks into how the Linux kernel does things, and annotates Linux kernel code. Have a look at the first tutorial for a minimalistic setup: https://github.com/s-matyukevich/...


1

your program cannot just end, it's supposed to make a system call, that returns the control to the operating system. also, this is totally off topic here.


Only top voted, non community-wiki answers of a minimum length are eligible