Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will this tutorial work on Raspberry Pi 4? #127

Closed
ZzzGin opened this issue Jul 3, 2019 · 13 comments
Closed

Will this tutorial work on Raspberry Pi 4? #127

ZzzGin opened this issue Jul 3, 2019 · 13 comments

Comments

@ZzzGin
Copy link

ZzzGin commented Jul 3, 2019

I've read the introduction of this tutorial and I really think this is what I want to start my journey of Linux kernel. Thank you for this material.
For now, the 4th gen of raspberry pi is out so I am not sure if this repo works on the new Pi (whose SoC is Broadcom BCM2711B0 quad-core A72 (ARMv8-A) 64-bit @ 1.5GHz).
If it won't work, I decide to buy the one mentioned in the Introduction.

@s-matyukevich
Copy link
Owner

Short answer: No, we have to update the code to make it work on the RPi 4b.

Long answer:
Looks like BCM2711B0 has different peripheral Base address (0xFE000000) link this means that at least this line has to be updated. Based on what I saw in the bcm2711-rpi-4-b.dts looks like mini UART, interrupt controller and timer should work. MMU should also work fine as well. So hopefully base address should be the only change we have to make.

@ZzzGin
Copy link
Author

ZzzGin commented Jul 4, 2019

@s-matyukevich thanks for replying.
I will use a 3 gen for this tutorial. And I will try it on the new pi when I get a 4th gen, since it is out of stock on its official website.

@ZzzGin ZzzGin closed this as completed Jul 4, 2019
@vikash876
Copy link

vikash876 commented Aug 14, 2019

Pheww... Working now!! :) So here are all the modifications you would need for this:

PBASE has to be modified to 0xFE000000 : #define PBASE 0xFE000000
config.txt needs to have just one line: arm_64bit=1

Thanks to s-matyukevich and following thread https://www.raspberrypi.org/forums/viewtopic.php?t=244479&p=1491494

PS: I just bought RPI4 to follow this entire tutorial and overcome the hurdles faced on the way. Earlier I have explored the linux kernel books which emphasize more on the X86 architecture and was looking for some books on the Arm Linux since in coming days Arm is going to be a next Desktop platform and also since I work in embedded field where Linux on Arm rules :). Kudos to s-matyukevich to make this nice tutorial and this is the one stop Linux on Arm material I need. My hunt for a book has stoped :))

@rockytriton
Copy link

Hey, so you were able to get the UART working? I tried the same things with my pi 4 and no luck. Can you post the contents of your config.txt? Also did you have to download the 2711 dtb file and fixup4.dat and start4.elf?

@vikash876
Copy link

vikash876 commented Aug 18, 2019

Hi rockytriton,

Here is my forked version which works with rapsberry pi-4 : [email protected]:vikash876/raspberry-pi-os.git

Steps to build:

  1. git clone [email protected]:vikash876/raspberry-pi-os.git
  2. build the lesson01
  3. copy config.txt from lesson01/src/ and overwrite on your sd card
  4. delete kernel7.img from your sd and copy kernel8.img to your sd card.

Also I have your answers here:
rockytriton: so you were able to get the UART working?
ans: Yes, I am using USB to TTL cable made by adafriut(https://www.adafruit.com/product/954).Any similar cable should work. I can see the print "Hello, world!"
rockytriton: Can you post the contents of your config.txt?
ans: please check https://github.com/vikash876/raspberry-pi-os/blob/master/src/lesson01/src/config.txt
rockytriton: Also did you have to download the 2711 dtb file and fixup4.dat and start4.elf?
ans: I did following:

  1. Flash the sd card with raspbian (either lite or full)
  2. delete the kernel7.img
  3. copy and replace the config.txt from my forked version lesson1/src/config.txt (as above link)
  4. copy the kernel8.img
  5. Boot the raspberry pi-4 with modified sd card and and set serial baud rate to 115200 in console.
  6. Observe "Hello, world!" on screen :))

Changes from s-matyukevich version

  1. Changed config.txt
  2. Changed Base address (to: 0xFE000000)
  3. Set the new baudrate (to: 541. since new GPU clock rate is 500MHZ, replaced this value in the formula)

hope this helps.

@rockytriton
Copy link

Thanks for all the details. I was pretty much doing the exact same things, except the 541 change. However I figured out what my issue really was... With the pi3 I would always use the serial cable's red cable to power the pi, so I didn't have to have its power source plugged in too. It seems that with the pi4 maybe that's not enough power to boot it. I put a usb cable into the pi4 to boot it and it's now working finally.

@vikash876
Copy link

Glad to hear. Yes I always tried with usb c powered. A 3amp power input is must I suppose.

@AlexGatz
Copy link

AlexGatz commented Feb 2, 2020

Thank you! Somehow I looked over this. I had just realized I was looking at the datasheet from the bcm2835 instead of the bcm2711.

@AlexGatz
Copy link

AlexGatz commented Feb 2, 2020

Hello, wo0>���p>0 is my output lol

and an odd error from dmesg:
[drm:intel_pipe_update_end [i915]] *ERROR* Atomic update failure on pipe A (start=467527 end=467528) time 1289 us, min 1062, max 1079, scanline start 896, end 1122

@danieltomch17
Copy link

danieltomch17 commented Jun 6, 2020

Changes from s-matyukevich version

  1. Changed config.txt
  2. Changed Base address (to: 0xFE000000)
  3. Set the new baudrate (to: 541. since new GPU clock rate is 500MHZ, replaced this value in the formula)

I have done all the above. The “Hello World” is printed just as expected, but the the kernel_main gets into a loop where it reads from the uart and prints back whatever is read - but in my case it prints gibberish. Any ideas on how to fix that problem?

image

@bcoppens
Copy link

bcoppens commented Jul 7, 2020

I have done all the above. The “Hello World” is printed just as expected, but the the kernel_main gets into a loop where it reads from the uart and prints back whatever is read - but in my case it prints gibberish. Any ideas on how to fix that problem?

You can fix this by adding enable_uart=1 to your config.txt. I presume that otherwise the VPU dynamically scales down the core frequency after booting, so that the clock is only correct while printing the first couple of characters before it scales itself down; and that the enable_uart=1 prevents this. (This is not 100% clear from the documentation that this would be so on the Pi 4B; I've submitted an issue on the Raspberry Documentation page about this: raspberrypi/documentation#1614).

It's also not clear why some people (such as myself) need the enable_uart=1 to get things working, and others don't... (Maybe a different firmware version?)

@AbramQuerashi
Copy link

Hi All,

From all the above comments it looks like I can purchase a RPi4 4GB memory board and this project is build able and can run on RPi4 ?

-abram

@jyotimahapatra
Copy link

vikash876@b430423 was pretty much everything i needed to make it work. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants