TImada / raspi4_freertos

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

UART2 Address #2

Closed pauloasherring closed 2 years ago

pauloasherring commented 2 years ago

Hey there! First of all, thanks for this port, this is enabling some real learning processes here :)

Secondly, this is not an issue perse. But, because it didn't work out of the box for me, I started code browsing to understand what is going on. And I found that here you define the base address of the UART2.

However, checking the RPi4's Periherals Document, p147, I noticed that the UART2 address is offset by 0x80000000 on the code.

So, what would be the rationale here? Is it supposed to be 0xFE201400 or 0x7E201400? I know that somehow this is correct, otherwise, people would complain that it is not working =)

Again, thank you so very much for the port. Kind regards, Paulo.

TImada commented 2 years ago

Hi Paulo,

The UART2 address (0x7e201400) on P.147 is a memory address for Legacy Master view. Check the section 1.2.4. "Legacy master addresses" on P.6. You can find a sentence describing "The peripheral addresses specified in this document are legacy master addresses".

On the other hand, Ubuntu Linux utilizes ARM view with Low Peripheral mode by default rather than Legacy Master view. In that case, the UART2 address starts at 0xfe201400.

You can find memory mapping between Legacy Master view and ARM view with Low Peripheral mode in Figure 1 on P.5.

pauloasherring commented 2 years ago

Hello Takayuki, Thanks for the prompt answer! That completely makes sense. After adding arm_64bit=1 to the config.txt file, it worked! Thanks a lot, for sharing here and for the support =D