TImada / raspi4_freertos

FreeRTOS UART sample porting to Raspberry Pi 4B.
MIT License
54 stars 20 forks source link

Cant Launch FreeRTOS by u-boot #1

Closed LabNelson closed 2 years ago

LabNelson commented 2 years ago

Thank you for the nice project Takayuki! I use: a Virtual Machine Ubuntu 18.04 (like Tlmada) aarch64-none-elf Cross Compiler RaspOS Lite (64-bit) on the Pi 4 (8GB RAM) What I did so far: I managed to come to step 4/5 (without changing memory region) I disabled the mmu, but dont change the page table configuration (step3)

Yet, I dont have a USB to UART Converter, so Im writing in the u-boot command line on the RPi4. I copied the uart.elf file on the SD-card and get into the u-boot prompt.

Step 4: I loaded the uart.elf file with fatload (boot-partition is in fat): fatload mmc 0:1 0x28000000 uart.elf 28512 bytes read in 40ms. Everything is fine. Afterwards I flushed the dcache. But after bootelf 0x28000000 nothing happens. I thought maybe without UART-connections there is no output, so i continued. Step 5: I didnt remove the PL011 and didnt add the memory region 0x20000000 - 0x209FFFFF to the reserved-memory. I used the modified device tree file from ubuntu 20.04 (as mentioned), compiled it to dtb file an copied it on the SD-card. After changing the CFLAGS and extendind the cmdline.txt with maxcpus=3, I got to the u-boot prompt to lanch FreeRTOS.

Problem: Like in step 4 I also couldnt launch FreeRtos in step 5. No output in u-boot.

What I did to solve the problem: Im dealing with https://elinux.org/RPi_U-Boot#Test_U-Boot to start Freertos (uart.elf with BCM2711-rpi-4-b-rtos.dtb), or RaspOS (start.elf/start4.elf with BCM2711-rpr-4-b.dtb)

Can somebody help me to launch freertos/RaspOS from u-boot? Thank you in advance Nelson

TImada commented 2 years ago

This sample is designed to use both UART1 (for u-boot) and UART2 (for FreeRTOS) independently. Therefore, any FreeRTOS output does not appear on UART1.

Did you connect UART2 on the Pi4 board with your PC?

LabNelson commented 2 years ago

Thank you for your explanation which UART-port is for what! It wasnt that clear to me, that you used 2 UART-ports. Yet, I dont have a converter from USB to UART, so I couldnt connect neither UART1 nor UART2 with my PC. I ordered a converter, so I guess this is solved after delivery.

LabNelson commented 2 years ago

Now, I got an converter and connected the PC (UART-Pins) with the Pins 6 (GND), 8 (Rx), 10 (Tx) of the Pi. Baud Rate ist 115200. In Step 4 I got the u-boot screen on my uart-terminal. But after bootelf 0x28000000 (Step 4.3), I didnt get a response, neither on HDMI Screen of the pi nor the uart-terminal on PC. I can continue to write commands.

Afterwards I connect UART-Converter on Pins 6 (GND), 27 (Rx), 28 (Tx). Neither in step 4.3 nor 5, i get response on uart2-terminal.

Can anybody help me?

TImada commented 2 years ago

Correct pin assignment is pin 27(Tx)/28(Rx).

LabNelson commented 2 years ago

Hmm. Maybe its an adress issue? Ive got the 8GB RAM version. Where did you get the adress 0x28000000 from?

TImada commented 2 years ago

That address is located in one of DDR SDRAM regions. (See Figure 1 in https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf)

LabNelson commented 2 years ago

Now, I installed Ubuntu 20.04 for RPi on the RPi4. I followed the instructions till 4.3: The dcache commands are not known. BUT after bootelf 0x28000000, i see `## Starting application at 0x20001788 ...

Application terminated, rc = 0x0` on my uart1 terminal. When i connect my usb-ttl converter to the uart2, i cant type in the u-boot-commands (Although i have hdmi an keyboard connected to RPi4).

Do you have 2 USB-TTL Converters either connected to uart1 and uart2 at the same time?

LabNelson commented 2 years ago

It is working! dcache commands are further unknown, but on one kernel ther ist linux and on the other, there is FreeRTOS Demo program. So i will continue to write own examples...

Can you mention to install Linux on the RPi4. It wasnt clear to me and it was the problem since the first hour. But I have to thank you another time for this project. Compared to do it on my own, it saved a lot of time :)

TImada commented 2 years ago

Do you have 2 USB-TTL Converters either connected to uart1 and uart2 at the same time?

Yes, I have a converter board which is capable of handling dual UART channels like [1].

dcache commands are further unknown

I guess you have overwritten the recompiled u-boot by installing Ubuntu 20.04.

Can you mention to install Linux on the RPi4.

Linux installation is not so complicated except for u-boot recompiling. You can find and simply follow one of many articles on Raspi4 Linux installation on the Web.

[1] https://www.digikey.com/catalog/en/partgroup/ft2232d-evaluation-board-dlp-2232ml-g/35721

LabNelson commented 2 years ago

Yes, I have a converter board which is capable of handling dual UART channels like [1]. Ahh, interesting. Its not available anymore, but I found another Open-source dual-channel converter here http://thingsoc.github.io/projects/TSOC-USBUART1.html

dcache commands are further unknown

I guess you have overwritten the recompiled u-boot by installing Ubuntu 20.04. I started with a blank SD-card, then installed Ubuntu, and after that compiled u-boot. So u-boot was written last.

Can you mention to install Linux on the RPi4.

Linux installation is not so complicated except for u-boot recompiling. You can find and simply follow one of many articles on Raspi4 Linux installation on the Web. The installation itself is easy. But i was not aware of installing Linux on the Rpi4. In your instruction i thought you are using Linux only on the host-PC. My working configuration is: Host-PC: Ubuntu 18.04 RPi: Ubuntu 20.04 (64-bit) (+FreeRTOS)