Skip to content
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

Fix endianness #176

Merged
merged 2 commits into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions firmware/uip/contiki-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ typedef unsigned int uip_stats_t;
#endif

/* uIP configuration */
#if defined(__lm32__) || defined(__or1k__)
#define UIP_CONF_BYTE_ORDER UIP_BIG_ENDIAN
#else
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
#endif

#define UIP_CONF_LLH_LEN 14
#define UIP_CONF_BROADCAST 1
#define UIP_CONF_LOGGING 1
Expand Down
2 changes: 1 addition & 1 deletion targets/arty/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, platform, *args, **kwargs):
platform.request("eth_clocks"),
platform.request("eth"))
self.submodules.ethmac = LiteEthMAC(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand why LiteEthMAC needs to understand the cpu endianness? However it looks like that is something from upstream, not something you invented?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MAC converts 32-bit writes/reads to/from 8-bit streams so needs to know the endiannness to know in which order reading/storing the streams.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have detected the problems when testing the firmware on HW. Without setting the proper endianess, data read from liteeth buffers had each 4-byte chunk reverted, causing the software to fail to detect the proper type of packet and drop it in a process.

After realising what was going on, I tested the pure LiteX platform and it worked fine. Diffing them pointed to the endianness property (not set in LiteX-BuildEnv).

phy=self.ethphy, dw=32, interface="wishbone")
phy=self.ethphy, dw=32, interface="wishbone", endianness=self.cpu.endianness)
self.add_wb_slave(mem_decoder(self.mem_map["ethmac"]), self.ethmac.bus)
self.add_memory_region("ethmac",
self.mem_map["ethmac"] | self.shadow_base, 0x2000)
Expand Down
2 changes: 1 addition & 1 deletion targets/atlys/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, platform, *args, **kwargs):
self.clk_freq)

self.submodules.ethmac = LiteEthMAC(
phy=self.ethphy, dw=32, interface="wishbone")
phy=self.ethphy, dw=32, interface="wishbone", endianness=self.cpu.endianness)
self.add_wb_slave(mem_decoder(self.mem_map["ethmac"]), self.ethmac.bus)
self.add_memory_region("ethmac",
self.mem_map["ethmac"] | self.shadow_base, 0x2000)
Expand Down
2 changes: 1 addition & 1 deletion targets/mimas_a7/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, platform, *args, **kwargs):
platform.request("eth_clocks"),
platform.request("eth"))
self.submodules.ethmac = LiteEthMAC(
phy=self.ethphy, dw=32, interface="wishbone")
phy=self.ethphy, dw=32, interface="wishbone", endianness=self.cpu.endianness)
self.add_wb_slave(mem_decoder(self.mem_map["ethmac"]), self.ethmac.bus)
self.add_memory_region("ethmac",
self.mem_map["ethmac"] | self.shadow_base, 0x2000)
Expand Down
2 changes: 1 addition & 1 deletion targets/nexys_video/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, platform, *args, **kwargs):
platform.request("eth_clocks"),
platform.request("eth"))
self.submodules.ethmac = LiteEthMAC(
phy=self.ethphy, dw=32, interface="wishbone")
phy=self.ethphy, dw=32, interface="wishbone", endianness=self.cpu.endianness)
self.add_wb_slave(mem_decoder(self.mem_map["ethmac"]), self.ethmac.bus)
self.add_memory_region("ethmac",
self.mem_map["ethmac"] | self.shadow_base, 0x2000)
Expand Down
2 changes: 1 addition & 1 deletion targets/opsis/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, platform, *args, **kwargs):
platform.request("eth"))
self.platform.add_source("gateware/rgmii_if.vhd")
self.submodules.ethmac = LiteEthMAC(
phy=self.ethphy, dw=32, interface="wishbone")
phy=self.ethphy, dw=32, interface="wishbone", endianness=self.cpu.endianness)
self.add_wb_slave(mem_decoder(self.mem_map["ethmac"]), self.ethmac.bus)
self.add_memory_region("ethmac",
self.mem_map["ethmac"] | self.shadow_base, 0x2000)
Expand Down
2 changes: 1 addition & 1 deletion targets/sim/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, *args, **kwargs):
BaseSoC.__init__(self, *args, **kwargs)

self.submodules.ethphy = LiteEthPHYModel(self.platform.request("eth"))
self.submodules.ethmac = LiteEthMAC(phy=self.ethphy, dw=32, interface="wishbone")
self.submodules.ethmac = LiteEthMAC(phy=self.ethphy, dw=32, interface="wishbone", endianness=self.cpu.endianness)
self.add_wb_slave(mem_decoder(self.mem_map["ethmac"]), self.ethmac.bus)
self.add_memory_region("ethmac", self.mem_map["ethmac"] | self.shadow_base, 0x2000)

Expand Down