f32c / arduino

FPGArduino source
http://www.nxlab.fer.hr/fpgarduino
68 stars 44 forks source link

MIPS gcc won't compile u8g, RISC-V compiles it #9

Closed emard closed 8 years ago

emard commented 8 years ago

u8glib will not compile for MIPS gcc actually compiles but mips-elf-objcopy fails

RISC-V compiles the same and works tested on SSD1306 SPI (software) in u8g.h section SW SPI, Arduino after teensy add this

elif defined( F32C ) /* FPGArduino */

#define U8G_COM_SW_SPI u8g_com_arduino_std_sw_spi_fn
#define U8G_COM_ST7920_SW_SPI u8g_com_arduino_st7920_spi_fn

https://bintray.com/olikraus/u8glib/Arduino/view

u8glib_arduino_v1.18.1.zip sha1: f90c3c338244ff872c9c94777d7d76be381788a6

In the Arduino IDE, import the ZIP library from the "Add Library" Menu. compile any example .e.g. U8gLogo

.arduino15/packages/FPGArduino/tools/f32c-compiler/1.0.0/bin/mips-elf-objcopy -O binary /tmp/build5698330625315358907.tmp/U8gLogo.cpp.elf /tmp/build5698330625315358907.tmp/U8gLogo.cpp.bin BFD: Warning: Writing section .init' to huge (ie negative) file offset 0xffffffff7fc00000. BFD: Warning: Writing section.text' to huge (ie negative) file offset 0xffffffff7fc0005c. BFD: Warning: Writing section .rodata' to huge (ie negative) file offset 0xffffffff7fc0222c. BFD: Warning: Writing section.ctors' to huge (ie negative) file offset 0xffffffff7fc0228c. BFD: Warning: Writing section `.sdata' to huge (ie negative) file offset 0xffffffff7fc02290.

emard commented 8 years ago

Here is a simple file that manifests this error I have seen it on gcc 4.8 on linux 64-bit and it looks like linker has some bug of wrong combination of 32 and 64 bit integer arithmetic.

in f32c bitstream RAM can be remapped to address below 0x80000000 e.g. 0x10000000 using C_sdram_base = x"1"

In this case, the code can be compiled without above warnings but still it will not work. Remapping: in boards.txt locate entries related to your board and change something like fpga_esa11_7a35i_bram.menu.ramsize.32M.compiler.ld.extra_flags=--section-start=.init=0x80000000 to fpga_esa11_7a35i_bram.menu.ramsize.32M.compiler.ld.extra_flags=--section-start=.init=0x10000000 error_manifest.txt

Something has to be done with compiler or linker to fix this

gornjas commented 8 years ago

This should mask the ld bug: https://github.com/f32c/f32c/commit/52d0fc0eb1c5afed666a24502b977d6fb7afdd21

emard commented 8 years ago

Marko found mips linker bug, this workaround fixes it objcopy -R .rel.dyn u8g and error_manifest now compile properly haven't tested the u8g display myself but it should work now as well as for RISC-V