-
Notifications
You must be signed in to change notification settings - Fork 271
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
Fully tested for aarch64 OS without a bus error #289
base: master
Are you sure you want to change the base?
Conversation
aarch64 architecture is for 64bit OS. It doesn't allow the 32bit compiler option like -marm -mabi=aapcs-linux -mhard-float -mfloat-abi=hard If only the architecture is not aarch64, it follows the existing compiler option, otherwise drop unacceptable options.
spi.cpp tick.h
display.h spi.cpp spi.h
volatile uint64_t *systemTimerRegister = 0; | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if instead of the above, it would work to do
#if __aarch64__
typedef uint64_t __attribute__((aligned(4))) timer_uint64_t;
#else
typedef uint64_t timer_uint64_t;
#endif
volatile timer_uint64_t *systemTimerRegister = 0;
This will tell the compiler that systemTimerRegister
points to something that is only 32-bit aligned, and it should then automatically generate the appropriate 32-bit load and stores on its own.
After that, the other #ifdef __aarch64__
s would not be necessary below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've applied your patch on the following 64bit OS.
"Linux raspberrypi 5.15.84-v8+ #1613 SMP PREEMPT Thu Jan 5 12:03:08 GMT 2023 aarch64 GNU/Linux"
But it makes same bus error.
bcm_host_get_peripheral_address: 0x3f000000, bcm_host_get_peripheral_size: 16777216, bcm_host_get_sdram_address: 0xc0000000
BCM core speed: current: 400000000hz, max turbo: 400000000hz. SPI CDIV: 6, SPI max frequency: 66666667hz
Initializing display
bcm2835 library version: 10071 (0x00002757)
Creating SPI task thread
InitSPI done
Bus error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, bummer. That would have been sweet if that had worked.
Looks like some unrelated commit slipped into the PR tree? |
systemTimerRegister = (volatile uint64_t*)((uintptr_t)bcm2835 + BCM2835_TIMER_BASE + 0x04); // Generates an unaligned 64-bit pointer, but seems to be fine. | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
// On 32-bit Pi, we can perform an unaligned 64-bit pointer access to read the timer for a micro-optimization, but on 64-bit Pi reading in 32-bit parts is needed.
#if __aarch64__
systemTimerRegister = (volatile uint32_t*)
#else
systemTimerRegister = (volatile uint64_t*)
#endif
systemTimerRegister = (volatile uint32_t*)((uintptr_t)bcm2835 + BCM2835_TIMER_BASE + 0x04);
?
@@ -5,11 +5,14 @@ | |||
#include <unistd.h> | |||
|
|||
// Initialized in spi.cpp along with the rest of the BCM2835 peripheral: | |||
#if __aarch64__ | |||
extern volatile uint32_t *systemTimerRegister; | |||
#define tick() (*systemTimerRegister+((uint64_t)(*(systemTimerRegister+1))<<32)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
#define tick() (systemTimerRegister[0] | ((uint64_t)systemTimerRegister[1] << 32))
?
Does a 64bit Version of rcp-ili9341 will come? |
@meesokim would you please seperate out the kedei_trash stuff out into a seperate PR, so that we users can test this more easily? |
I cloned it and built, but it still caused a bus error: bcm_host_get_peripheral_address: 0x3f000000, bcm_host_get_peripheral_size: 16777216, bcm_host_get_sdram_address: 0xc0000000 I'm sure there wasn't any compile error and this was the only question |
I cloned it and built as well, but also get a bus error:
This is off of the newest Raspbian Lite install. |
aarch64 architecture is for 64bit OS.
It doesn't allow the 32bit compiler option like -marm -mabi=aapcs-linux -mhard-float -mfloat-abi=hard
So I've replaced them to 64bit compiler option.
Unfortunately BCM2835_TIMER_BASE is not an aligned 64bit address. Therefore we can use 64bit address directly.
It's fixed by calculating upper 32bit and lower 32bit value respectively.
There is no more any bus error after applying this patches.