public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: rickou at rickou.net <rickou@rickou.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] Question about bootp structure pack
Date: Tue, 21 Feb 2017 20:38:38 +0100	[thread overview]
Message-ID: <58ac9741.cf0d1c0a.74142.3477@mx.google.com> (raw)

Hi everyone, 

I?m using u-boot-2015.07 in one of my project based on vpac270 soc module.
u-boot is well configured and build is fine without error.
Gcc is v3.4.5 and glibc v2.3.6 built by crosstool 0.43 for arm-softfloat-linux-gnu

My problem is when i use DHCP command to retrieve a file from my TFTP server, i can?t get any IP from the DHCP server.
After analysing ethernet frames on server side i found that frame do not arrive at all on server.
After checking debug d?tails on U-boot, it seem bootp frame is not good because of some 0x00 paddings Inside the frame. (at end of header for example)

If i add the attribute packed to the bootp header struct and ethernet header, now all is working fine?!

In net/bootp.h?:
struct bootp_hdr {
	u8		bp_op;		/* Operation			*/
# define OP_BOOTREQUEST	1
# define OP_BOOTREPLY	2
	u8		bp_htype;	/* Hardware type		*/
# define HWT_ETHER	1
	u8		bp_hlen;	/* Hardware address length	*/
# define HWL_ETHER	6
	u8		bp_hops;	/* Hop count (gateway thing)	*/
	u32		bp_id;		/* Transaction ID		*/
	u16		bp_secs;	/* Seconds since boot		*/
	u16		bp_spare1;	/* Alignment			*/
	struct in_addr	bp_ciaddr;	/* Client IP address		*/
	struct in_addr	bp_yiaddr;	/* Your (client) IP address	*/
	struct in_addr	bp_siaddr;	/* Server IP address		*/
	struct in_addr	bp_giaddr;	/* Gateway IP address		*/
	u8		bp_chaddr[16];	/* Client hardware address	*/
	char		bp_sname[64];	/* Server host name		*/
	char		bp_file[128];	/* Boot file name		*/
	char		bp_vend[OPT_FIELD_SIZE]; /* Vendor information	*/
} __attribute__((packed));

#define BOOTP_HDR_SIZE	sizeof(struct bootp_hdr)

And in include/net.h
struct ethernet_hdr {
	u8		et_dest[6];	/* Destination node		*/
	u8		et_src[6];	/* Source node			*/
	u16		et_protlen;	/* Protocol or length		*/
} __attribute__((packed));

I think the uboot src should work as is, because I have checked uboot source modification since 2015.07, but no changes on the struct definition and header_size still made with sizeof(struct).
So i think, the problem come from my side and perhaps from gcc itself.

But?i don?t understand why gcc should pack these structs.. i think normal use is to not pack.. except if makefile include some build option to do that, my gcc toolchain do not understand..

Someone can help me to understand what i made wrong?? and help me to resolve this problem without patching ??




Provenance?: Courrier pour Windows 10

             reply	other threads:[~2017-02-21 19:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-21 19:38 rickou at rickou.net [this message]
2017-02-26  6:27 ` [U-Boot] [U-boot] Question about bootp structure pack Eric BOUXIROT
2017-02-27  9:07   ` Lukasz Majewski
2017-03-03  6:45     ` Eric BOUXIROT
2017-03-07  8:59     ` Eric BOUXIROT

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58ac9741.cf0d1c0a.74142.3477@mx.google.com \
    --to=rickou@rickou.net \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox