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

Sending ethernet frames using software #68

Open
BD00ley opened this issue May 25, 2021 · 1 comment
Open

Sending ethernet frames using software #68

BD00ley opened this issue May 25, 2021 · 1 comment
Labels

Comments

@BD00ley
Copy link

BD00ley commented May 25, 2021

Hello,

Suppose I already have an ethernet core integrated into my design and wanted to send out a simple ethernet frame using a bare metal program flashed onto it. What might the program look like?
I already tried the following and can see the the preamble and SFD, but the rest of the frame is not I expect and I'm lost on modifying the payload. I appreciate any help that can be offered.

int main(void) {

#ifdef CONFIG_CPU_HAS_INTERRUPT
irq_setmask(0);
irq_setie(1);
#endif

// Random values for parts of the ethernet frame.
const unsigned char macaddr = 0x35;
unsigned int ip = 10;
unsigned short src_port = 0x66;
unsigned short dst_port = 0x77;
unsigned int length = 80;
int status = 0;

uart_init(); 
puts("\nTesting ethernet...\n");
eth_init();
//eth_mode();

// Pointer to payload. Is this correct?
char *payload = (char *)udp_get_tx_buffer;
*payload = 0x00;
printf("Data in payload: %d\n", *payload);
*payload = 0xee;
printf("After writing 0xEE to payload: %x\n", *(char*)udp_get_tx_buffer);

udp_start(&macaddr, ip);
udp_service();
status = udp_send(src_port, dst_port, length);
if(status == 0) 
	printf("Failed to send.\n");
else
	printf("Successfully sent from core.\n");

while(1) {
}

return 0;
}
@enjoy-digital
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants