To fix compiler warnings of the following type:
warning: format '%x' expects argument of type 'unsigned int', but argument has type 'long unsigned int' [-Wformat=]
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
litex/soc/software/liblitesdcard/sdcard.c: In function 'sdcard_read':
litex/soc/software/liblitesdcard/sdcard.c:476:29: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
sdblock2mem_dma_base_write((uint64_t) buf);
^
litex/soc/software/liblitesdcard/sdcard.c: In function 'sdcard_write':
litex/soc/software/liblitesdcard/sdcard.c:507:30: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
sdmem2block_dma_base_write((uint64_t) buf);
^
When casting a pointer (32-bit or 64-bit, depending on the platform) to
a 64-bit integer, an intermediate cast to "uintptr_t" should be used to
avoid warnings like the above.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
There is no need to use "unsigned long" for small numbers related to the
number of characters in a line. Use "unsigned int" instead.
This allows us to drop the casts when calling putnstr(), and fixes compiler
warnings on 64-bit for callsites where the casts were missing:
warning: field precision specifier '.*' expects argument of type 'int', but argument 2 has type 'long unsigned int'
Reported-by: Gabriel Somlo <gsomlo@gmail.com>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
The sizeof operator returns "size_t", which is defined to be "unsigned
int" on 32-bit, and "unsigned long" on 64-bit.
Format it using "%zu", to fix compiler warnings of the following type on
64-bit:
warning: format '%d' expects argument of type 'int', but argument has type 'long unsigned int' [-Wformat=]
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
On 64-bit:
litex/soc/software/bios/cmds/cmd_bios.c: In function 'crc_handler':
litex/soc/software/bios/cmds/cmd_bios.c:110:30: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
printf("CRC32: %08x", crc32((unsigned char *)addr, length));
^
Fix this by using the appropriate types (uintptr_t and size_t) for
memory addresses and sizes, which are defined to 32-bit or 64-bit,
depending on the platform.
Note that the specified length must still be smaller than 4 GiB on
64-bit, or it will be truncated, as the crc32() function is currently
limited to a 32-bit size anyway.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
On 64-bit:
litex/soc/software/bios/boot.c: In function 'serialboot':
litex/soc/software/bios/boot.c:216:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
writepointer = (char *) get_uint32(&frame.payload[0]);
^
When casting from a 32-bit integer to a pointer (32-bit or 64-bit,
depending on the platform), an intermediate cast to "uintptr_t" should
be used to avoid warnings like the above.
Note that using a 32-bit integer is OK, even on 64-bit, as this is
specified by the boot protocol.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
To fix compiler warnings of the following type:
warning: format '%lu' expects argument of type 'long unsigned int', but argument has type 'unsigned int' [-Wformat=]
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
To fix compiler warnings of the following type:
warning: zero-length gnu_printf format string [-Wformat-zero-length]
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Set the PRINTF_SPECIAL flag when printing pointers, so they are prefixed
by "0x", to match glibc behavior.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
As per convention, the types of size_t, ptrdiff_t, intptr_t, and
uintptr_t should be based on "long" or "int" depending on the platform
(32-bit or 64-bit).
This fixes compiler warnings of the following type:
litex/soc/software/liblitesdcard/sdcard.c: In function 'sdcard_read':
litex/soc/software/liblitesdcard/sdcard.c:476:39: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
sdblock2mem_dma_base_write((uint64_t)(uintptr_t) buf);
^
Reported-by: Gabriel Somlo <gsomlo@gmail.com>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
The value of ULONG_MAX should depend on the size of "long".
While at it:
- Add missing "UL" and "U" suffixes to large unsigned values,
- Make INT_MIN and SHRT_MIN explicitly negative,
- Use decimal instead of hexadecimal values, for easier comparison
with /usr/include/limits.h.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
__WORDSIZE is defined by glibc, not by the compiler. Hence it is never
defined for us, and checking __WORDSIZE to determine the size of "long"
thus causes subtle misbehavings.
Fix this by checking for the presence of __LP64__ instead.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
It's probably better not mixing uploading/flashing utilities. Flashing should be
done with the proper bootloader (as we are doing on Fomu/OrangeCrab for example).
Keeping board definition files directly in LiteX is no longer useful since we are already relying on board
definitions files from LiteX-Boards (https://github.com/litex-hub/litex-boards) in various benches/projects
and having definitions files directly in LiteX creates confusion/additional work.
For projects using board definition files from LiteX, the litex.boards import can just be replaced with litex_boards:
from litex.boards.platforms import kc705
from litex_boards.platforms import kc705