diff --git a/litex/soc/software/bios/boot.c b/litex/soc/software/bios/boot.c index af05c3c1d..f1b22966d 100644 --- a/litex/soc/software/bios/boot.c +++ b/litex/soc/software/bios/boot.c @@ -8,6 +8,7 @@ // License: BSD #include +#include #include #include #include @@ -23,6 +24,10 @@ #include #endif +#ifdef CSR_SPIFLASH_BASE +#include +#endif + #include "sfl.h" #include "boot.h" @@ -95,6 +100,14 @@ static int check_ack(void) return ACK_TIMEOUT; } +static uint32_t get_uint32(unsigned char* data) +{ + return ((uint32_t) data[0] << 24) | + ((uint32_t) data[1] << 16) | + ((uint32_t) data[2] << 8) | + (uint32_t) data[3]; +} + #define MAX_FAILED 5 /* Returns 1 if other boot methods should be tried */ @@ -165,11 +178,7 @@ int serialboot(void) char *writepointer; failed = 0; - writepointer = (char *)( - ((unsigned long)frame.payload[0] << 24) - |((unsigned long)frame.payload[1] << 16) - |((unsigned long)frame.payload[2] << 8) - |((unsigned long)frame.payload[3] << 0)); + writepointer = (char *) get_uint32(&frame.payload[0]); for(i=4;i