Coder Social home page Coder Social logo

raspi-kernel's People

Contributors

hexagonale avatar jsandler18 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raspi-kernel's Issues

Raspberry Pi 3 atomic locks

Thank you for your amazing tutorial series. It has been so informative and I have learnt loads!

I'm just having one problem with lesson 09. I'm compiling for my 64-bit Pi 3 (I am not following the tutorial series, only this specific section), and I can not compile the code (I changed the registers to work with 64-bit):
try_lock: mov x1, #0 swp x2, x1, [r0] // stores the value in x1 into the address in x0, and stores the value at the address in x0 into x2 mov x0, x2 blx lr

My error message is "Error: selected processor does not support `swp x2,x1,[x0]'!". Apparently the "swp" instruction was deprecated and removed, and does not exist on later Pi models. Is there a newer, better instruction to accomplish an atomic lock? Or is it my toolchain at fault? I have tried building with -mcpu=cortex-a7 but it tells me it's not a valid CPU, instead suggesting I try cortex-a53, but even then, I get the same error about the instruction not being supported.

Makefile fails to compile with error "collect2: error: ld returned 1 exit status make: *** [Makefile:39: build] Error 1"

When I run the command 'make', I get this error:

/mnt/c/users/andre/desktop/custom_rpi_os/gcc-arm-10.2-2020.11-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -T linker.ld -o kernel.elf -ffreestanding -O2 -nostdlib objects/mailbox.o objects/mem.o objects/interrupts.o objects/atag.o objects/kerio.o objects/uart.o objects/gpu.o objects/process.o objects/timer.o objects/kernel.o objects/model2/framebuffer.o objects/stdlib.o objects/process_asm.o objects/interrupt_vector.o objects/boot.o objects/lock_asm.o
/mnt/c/users/andre/desktop/custom_rpi_os/gcc-arm-10.2-2020.11-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: objects/model2/framebuffer.o:/mnt/c/Users/andre/desktop/custom_rpi_os/raspi-kernel-master/build/../include/kernel/framebuffer.h:20: multiple definition of `fbinfo'; objects/gpu.o:/mnt/c/Users/andre/desktop/custom_rpi_os/raspi-kernel-master/build/../include/kernel/framebuffer.h:20: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:39: build] Error 1

How can I fix this issue?

(I am on Ubuntu WSL)

Running on Rasberry Pi 4B

I'm trying to get this code running on my RPi4B and I can't seem to get it working. I've changed PERIPHERAL_BASE to 0xFE000000 as documented here, but my Raspberry Pi gets stuck on the rainbow screen when booting. Does anyone have advice for further debugging this issue?

I've installed Raspbian on my SD card, and have deleted the other kernel images and replaced kernel7.img with the image built from the Makefile. On QEMU I'm able to run it fine (as long as I switch the PERIPHERAL_BASE back to the 2/3 address)

problem with multi-core disable code on raspberry pi 3

Your code to disable three of the four processors does not work properly for me.
I have tested with my own C code, that just switches a few gpios on and off on a raspberry pi 3, and with your current boot.S code, my code is not launched.

However, if i replace the line cmp r1, #2 by cmp r1, #0, it works.
If i understand correctly, the effect of that change is that my code runs on the core 0, instead of the core 2. No idea why it makes a difference, maybe core 0 is special, somehow?
Is there any reason why you choose to use core 2?

Missing code in detailed explanation of interrupt_vector.S

The code at the top of the page is fine, but the line-by-line explanation missed out the extra push/pop of r1 that you have to wrap around the line

bl      irq_handler

Of course, it's pretty clear why it's necessary -- but it probably needs a mention, at least so that people who are typing in the code as its explained rather than copy/pasting from the top of the page don't get confused.

typo

raspi-kernel/src/kernel/interrupt_vector.S file has a minor typo in line 35, just so you know

The kfree function in mem.c is not setting the prev and next pointers correctly

Combining the heap segments to the left does not update the seg->next->prev pointer to point to the previous heap segment.

Similar problem when combining on the right where the seg->next->next->prev pointer is not updated to the current heap segment.

Freeing pointers in the same order they were allocated is causing the segment_size field to become larger than the amount in the initial heap segment. I haven't tested any other scenarios but correctly setting the pointers as outlined above along with null checks solved the issue.

Is it just me?

When I run the latest commit in the qemu emulator and connect to the VNC server with vncviewer, the screen stays black and nothing that I type in the terminal get's echo'ed back. I can't see any boot text either.
Where do I start with debugging?

The code doesn't run on real hardware raspi 2 B

I downloaded and built the "master" branch code, or part 06 branch code.
It runs smoothly on qemu-system-arm simulator,

but when I renamed the kernel.img to kernel7.img and copied to the raspbian SD card of the real raspi 2 hardware, it doesn't run at all, just blank black screen (I disabled the raspi colour splash test). I also tried to change the gpu.c BLACK colour to BLUE, it worked in simulator, but doesn't work on real hardware.

To double check, when I switch back the raspbian kernel7.img, the raspberry pi runs without issue. The hardware is raspberry pi 2 B model.

Cannot compile qemu from provided link

As the title suggests, trying to build qemu from the source provided throws a number of errors, its better to just clone the current github repo and compile build that or just download qemu-system-arm from your package manager if it is included

Problems with ENABLE / DISABLE INTERRUPTS

You need to define these functions as extern inline in header and implement the logic in interrupts.c.
Else the build process will fail, with an undefined reference error.

qemu emulation shows black screen on macos

Hi
Many thanks for this tutorial.
I stuck on the 2nd step on booting the myos.elf on qemu.
The emulation gives a black screen.
I'm using a macbook pro (macos mojave)

Thanks

Possible issues with mem.c

A couple possible issues with mem.c, in alloc_page:
-The address of the start of the page is calculated by page_mem = (void *)((page - all_pages_array) * PAGE_SIZE);, however page_t has size 4 bytes, so page_mem is 4x too big as each entry in all_pages_array is 4 bytes.
-In allocating a page, you do not check if the page is part of the MMIO region, so a program could start writing data here erroneously.
Sorry if these aren't issues or I'm wrong about indexing into all_pages_array, I'm fairly new to this.

c99 & assembly errors

First of all, I am getting errors around line 64 in gpu.c complaining about how declaring 'i' and 'j' in the for loop requires c99. Defining the variables outside the for loop does the trick, though.

Secondly, I am having issues compiling process_asm.s, due to a bad expression.

arm-none-eabi-gcc -mcpu=cortex-a7 -fpic -ffreestanding  -g -I../src/kernel -c ../src/kernel/process_asm.S -o objects/process_asm.o
../src/kernel/process_asm.S: Assembler messages:
../src/kernel/process_asm.S:17: Error: bad expression -- `ldr r0,=#(10000)'

I cloned your repo of section 9, corrected some of the paths in the Makefile, and compiled.

If I play with the syntax of =#(10000), sometimes I can get it to compile. However, I just get a wall of errors:

/Users/gmisail/Downloads/raspi-kernel-93d44a737728aa5fe366ad8ca62563e78987b023 2/build/../include/kernel/interrupts.h:17: multiple definition of `ENABLE_INTERRUPTS'
objects/interrupts.o:/Users/gmisail/Downloads/raspi-kernel-93d44a737728aa5fe366ad8ca62563e78987b023 2/build/../include/kernel/interrupts.h:17: first defined here
objects/process.o: In function `INTERRUPTS_ENABLED':
/Users/gmisail/Downloads/raspi-kernel-93d44a737728aa5fe366ad8ca62563e78987b023 2/build/../include/kernel/interrupts.h:17: multiple definition of `DISABLE_INTERRUPTS'
objects/interrupts.o:/Users/gmisail/Downloads/raspi-kernel-93d44a737728aa5fe366ad8ca62563e78987b023 2/build/../include/kernel/interrupts.h:17: first defined here
objects/timer.o: In function `INTERRUPTS_ENABLED':
/Users/gmisail/Downloads/raspi-kernel-93d44a737728aa5fe366ad8ca62563e78987b023 2/build/../include/kernel/interrupts.h:17: multiple definition of `INTERRUPTS_ENABLED'
objects/interrupts.o:/Users/gmisail/Downloads/raspi-kernel-93d44a737728aa5fe366ad8ca62563e78987b023 2/build/../include/kernel/interrupts.h:17: first defined here
objects/timer.o: In function `INTERRUPTS_ENABLED':
/Users/gmisail/Downloads/raspi-kernel-93d44a737728aa5fe366ad8ca62563e78987b023 2/build/../include/kernel/interrupts.h:17: multiple definition of `ENABLE_INTERRUPTS'
objects/interrupts.o:/Users/gmisail/Downloads/raspi-kernel-93d44a737728aa5fe366ad8ca62563e78987b023 2/build/../include/kernel/interrupts.h:17: first defined here
objects/timer.o: In function `INTERRUPTS_ENABLED':
/Users/gmisail/Downloads/raspi-kernel-93d44a737728aa5fe366ad8ca62563e78987b023 2/build/../include/kernel/interrupts.h:17: multiple definition of `DISABLE_INTERRUPTS'
objects/interrupts.o:/Users/gmisail/Downloads/raspi-kernel-93d44a737728aa5fe366ad8ca62563e78987b023 2/build/../include/kernel/interrupts.h:17: first defined here
collect2: error: ld returned 1 exit status

Thank you

Stuck in: print on a real Screen

I am trying to show ur OS on a real Screen.(Part 6). But my screen keeps black.

My raspys 1 + 2 work fine-> i checked it with other OS.

I followed ur tutorial until part 6. I got my Images and loaded them on my Card. After copieing them into my old OS installation of Rasphian i get stuck in the rainbow screen. If i tun the Rainbow Screen off, the Raspie get suck in blackscreen. Same on both(1+2). After 42 tries it surrendered.:(

Could someone assure me, that this tutorial still works in 2021? And inform me about , how u got it on the rean screen.

installing qemu

I am using windows subsystem for linux (WSL) on windows 10 - ubuntu app.
When I run the line "./configure --target-list=arm-softmmu,arm-linux-user" from the qemu folder I get:
ERROR: Python not found. Use --python=/path/to/python

So I run: " ./configure --target-list=arm-softmmu,arm-linux-user --python=/mnt/c/Python27"
And I get:

./configure: 1576: ./configure: /mnt/c/Python27: Permission denied
ERROR: Cannot use '/mnt/c/Python27', Python 2.6 or later is required.
Note that Python 3 or later is not yet supported.
Use --python=/path/to/python to specify a supported Python.

My Python version on /mnt/c/Python27 is 2.7.16

I'm very new to linux and I would very much appreciate any help
Thank you

Part 2 - kernel runs on all four CPUs?

I've copied the code from part two and compiled it. When I run it in qemu-system-arm I get something like this:

HHeello, kernel World!
llHo, ello, kernel World!
kernel World!
Hello, kernel World!

Further, when I try to type I get the letter followed by a varying number of newlines. I tried looking at it with GDB and as near as I can determine there are four different instances of the kernel running (presumably on the four cores), which means all four of them race each other to initialize the UART and run uart_getc().

Is there a step I've missed to get the kernel to only start on one core?

process_asm.S issue with pushing sp

In the file process_asm.S there might be an issue (I have been testing on a raspberry pi 2)

According to the arm specification, you should never push the sp ("reglist must not include the SP." from here). I tried out your code on my pi and that line seemed to be crashing it. So I think line 11 of process_asm.S should be changed to push {lr} as we usually just want garbage there.

Undefined reference to mmio_read

When I try to link kernel.o, I get this error:


~/Downloads/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-gcc -T linker.ld -o myos.elf -ffreestanding -O2 -nostdlib boot.o kernel.o
kernel.o: In function `uart_putc':
kernel.c:(.text+0x88): undefined reference to `mmio_read'
kernel.o: In function `uart_getc':
kernel.c:(.text+0xb4): undefined reference to `mmio_read'
kernel.c:(.text+0xc8): undefined reference to `mmio_read'
collect2: error: ld returned 1 exit status

Surprisingly, I get nothing relevant when I try to search the web for this problem. I think I'm missing some library specific to the rpi, which needs to be passed to the linker.

Timer doesn't work

I am trying to get the timer to work on the Raspberry Pi 2B v1.1 but it is not working. I use the UART for debugging and every time the timer interrupt should be called, the reset handler is called.

I have changed the "kerio.c" to output via the UART. In the timer interrupt in "timers.c" a text should be output. In "kernel.c" additionally the UART is initialized and the timer is set to 5 seconds. After 5 seconds the reset handler is called instead of the timer interrupt.

MakeFile not working

when i run the command "arm-none-eabi-gcc build/Makefile" after completing step 3 it gives me this error:

build/Makefile: file not recognized: file format not recognized
collect2.exe: error: ld returned 1 exit status

Issues with QEMU

Hello hope you read this! Forked this after reading your guide, I cannot get QEMU to work as of now, what is the new qemu command that we can use as of the most recent commit you have? Currently I just run it and it hangs saying man0 and doesn't appear to echo or do anything. Any thoughts?

Reaping of last kernel thread leads to invalid memory access

Running processes indefinitely works as a charm. But as soon as a process finishes, the context switch does not work any longer.

I found out, that all values inside the reap method are correct during execution. Also, when reaping the last process other than the init process, the run_queue size is 0 after popping it, but in the very next call to schedule, the run_queue's size is back to 1 again. As there is in reality nothing in there, the following pop fetches illegal content, where it starts doing weird stuff.

Verifying the pid field of new_thread and the current_process also shows, that even the current_process is an illegal access (as pid is a high number and proc_name is scrambled).

So I would take a wild guess, that something in the switch_to_thread assembly may be problematic.

I would guess the reaped thread must be called to a context switch, that disregards everything from the old thread, as the memory has already been freed.

Could you please verify it or maybe you have an idea to solve that?

Deadlock in mem.c

In mem.c at

while(seg->next != NULL && !seg->next->is_allocated) {
        seg->next->next->prev = seg;
        seg->next = seg->next->next;
        seg->segment_size += seg->next->segment_size;
}

a seg = seg->next; is needed at the end. Otherwise the loop iterates over the same segment over and over.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.